private void ApplyToIconPanel(UIPanel groupPanel, IconPanelModifier modifier, bool verticalScroll)
 {
     if (groupPanel == null)
     {
         return;
     }
     if (modifier == null)
     {
         return;
     }
     try{                                                      //seperator panels do not have UIScrollablePanels nor UIScrollbars
         UITabContainer tabContainer = groupPanel.GetComponentInChildren <UITabContainer>();
         foreach (UIComponent comp in tabContainer.components) //for each displayable panel of icons
         {
             if (comp is UIPanel)
             {
                 UIPanel           panel = comp as UIPanel;
                 UIScrollablePanel sp    = panel.GetComponentInChildren <UIScrollablePanel>();
                 UIScrollbar       sb    = panel.GetComponentInChildren <UIScrollbar>();
                 modifier.Invoke(panel, sp, sb, verticalScroll);
                 panel.Invalidate();
                 sp.Invalidate();
                 sb.Invalidate();
             }
         }
         tabContainer.Invalidate();
     }catch (Exception e) {
         //Debug.Print(groupPanel,e);
     }
 }
예제 #2
0
        public override void Start()
        {
            base.Start();

            _instance        = this;
            isVisible        = true;
            canFocus         = true;
            isInteractive    = true;
            backgroundSprite = "UnlockingPanel";
            //padding = new RectOffset(5, 5, 5, 0);
            autoLayout                        = true;
            autoLayoutDirection               = LayoutDirection.Vertical;
            autoLayoutPadding.top             = 5;
            autoLayoutPadding.left            = 5;
            autoLayoutPadding.right           = 5;
            builtinKeyNavigation              = true;
            clipChildren                      = true;
            freeScroll                        = false;
            scrollWheelDirection              = UIOrientation.Vertical;
            verticalScrollbar                 = new UIScrollbar();
            scrollWheelAmount                 = 10;
            verticalScrollbar.stepSize        = 1f;
            verticalScrollbar.incrementAmount = 10f;
            SetupControls();
        }
예제 #3
0
        //private UITextPanel<string> buttonOMF;

        public override void OnInitialize()
        {
            uIElement = new UIElement();
            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

            uIPanel = new UIPanel();
            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = UICommon.MainPanelBackground;
            uIPanel.PaddingTop      = 0f;
            uIElement.Append(uIPanel);

            modList = new UIList();
            modList.Width.Set(-25f, 1f);
            modList.Height.Set(-50f, 1f);
            modList.Top.Set(50f, 0f);
            modList.ListPadding = 5f;
            uIPanel.Append(modList);

            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(-50f, 1f);
            uIScrollbar.Top.Set(50f, 0f);
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);

            modList.SetScrollbar(uIScrollbar);

            UITextPanel <string> uIHeaderTexTPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModsModsList"), 0.8f, true);

            uIHeaderTexTPanel.HAlign = 0.5f;
            uIHeaderTexTPanel.Top.Set(-35f, 0f);
            uIHeaderTexTPanel.SetPadding(15f);
            uIHeaderTexTPanel.BackgroundColor = UICommon.DefaultUIBlue;
            uIElement.Append(uIHeaderTexTPanel);

            buttonB = new UITextPanel <string>(Language.GetTextValue("UI.Back"), 1f, false);
            buttonB.Width.Set(-10f, 1f / 3f);
            buttonB.Height.Set(25f, 0f);
            buttonB.VAlign = 1f;
            buttonB.Top.Set(-20f, 0f);
            buttonB.WithFadedMouseOver();
            buttonB.OnClick += BackClick;
            uIElement.Append(buttonB);

            //buttonOMF = new UITextPanel<string>(Language.GetTextValue("tModLoader.ModsOpenModsFolder"), 1f, false);
            //buttonOMF.CopyStyle(buttonB);
            //buttonOMF.HAlign = 0.5f;
            //buttonOMF.OnMouseOver += UICommon.FadedMouseOver;
            //buttonOMF.OnMouseOut += UICommon.FadedMouseOut;
            //buttonOMF.OnClick += OpenModsFolder;
            //uIElement.Append(buttonOMF);

            Append(uIElement);
        }
        private static void AdjustVerticalScrollbar(UIScrollbar verticalScrollbar, UIComponent tabPanel, UIScrollablePanel scrollablePanel)
        {
            verticalScrollbar.width       = 20f;
            verticalScrollbar.height      = tabPanel.height;
            verticalScrollbar.orientation = UIOrientation.Vertical;
            verticalScrollbar.pivot       = UIPivotPoint.BottomLeft;
            verticalScrollbar.AlignTo(tabPanel, UIAlignAnchor.TopRight);
            verticalScrollbar.minValue        = 0;
            verticalScrollbar.value           = 0;
            verticalScrollbar.incrementAmount = 104;
            verticalScrollbar.autoHide        = true;

            UISlicedSprite trackSprite = (UISlicedSprite)verticalScrollbar.Find("trackSprite");

            trackSprite.relativePosition = Vector2.zero;
            trackSprite.autoSize         = true;
            trackSprite.size             = trackSprite.parent.size;
            trackSprite.fillDirection    = UIFillDirection.Vertical;
            trackSprite.spriteName       = ""; // "ScrollbarTrack";

            UISlicedSprite thumbSprite = (UISlicedSprite)verticalScrollbar.Find("thumbSprite");

            thumbSprite.relativePosition = Vector2.zero;
            thumbSprite.fillDirection    = UIFillDirection.Vertical;
            thumbSprite.autoSize         = true;
            thumbSprite.width            = thumbSprite.parent.width - 8;
            thumbSprite.spriteName       = "ScrollbarThumb";

            verticalScrollbar.thumbObject     = thumbSprite;
            scrollablePanel.verticalScrollbar = verticalScrollbar;
        }
예제 #5
0
        public override void OnInitialize()
        {
            allEvilAvailable = new UIList();
            List <ModBiome> allEvil = BiomeLibs.Biomes.Values.Where(i => i.BiomeAlt == BiomeAlternative.evilAlt).ToList();

            scrollbar = new UIScrollbar();
            scrollbar.Top.Set(-5, 0f);
            scrollbar.HAlign = 1f;

            Add(GenerateButton("Corruption"));
            Add(GenerateButton("Crimson"));
            foreach (var biome in allEvil)
            {
                Add(GenerateButton(biome));
            }

            Add(GenerateButton("Random"));
            allEvilAvailable.Width.Set(800, 0f);
            allEvilAvailable.Height.Set(400, 0f);
            allEvilAvailable.Left.Set(Main.screenWidth / 2 - 400, 0f);
            allEvilAvailable.Top.Set(Main.screenHeight / 2 - 200, 0f);
            allEvilAvailable.SetScrollbar(scrollbar);
            Width.Set(Main.screenWidth, 0f);
            Height.Set(Main.screenHeight, 0f);
            Left.Set(0, 0f);
            Top.Set(0, 0f);
            Append(allEvilAvailable);
            Append(scrollbar);
        }
예제 #6
0
        public void InitializePage()
        {
            this.RemoveAllChildren();
            UIElement element = new UIElement();

            element.Width.Set(590f, 0.0f);
            element.Top.Set(220f, 0.0f);
            element.Height.Set(-220f, 1f);
            element.HAlign       = 0.5f;
            this._outerContainer = element;
            this.Append(element);
            UIPanel uiPanel = new UIPanel();

            uiPanel.Width.Set(0.0f, 1f);
            uiPanel.Height.Set(-110f, 1f);
            uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uiPanel.PaddingTop      = 0.0f;
            element.Append((UIElement)uiPanel);
            this._container = (UIElement)uiPanel;
            UIList uiList = new UIList();

            uiList.Width.Set(-25f, 1f);
            uiList.Height.Set(-50f, 1f);
            uiList.Top.Set(50f, 0.0f);
            uiList.HAlign      = 0.5f;
            uiList.ListPadding = 14f;
            uiPanel.Append((UIElement)uiList);
            this._list = uiList;
            UIScrollbar scrollbar = new UIScrollbar();

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(-20f, 1f);
            scrollbar.HAlign = 1f;
            scrollbar.VAlign = 1f;
            scrollbar.Top    = StyleDimension.FromPixels(-5f);
            uiList.SetScrollbar(scrollbar);
            this._scrollBar = scrollbar;
            UITextPanel <LocalizedText> uiTextPanel = new UITextPanel <LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);

            uiTextPanel.Width.Set(-10f, 0.5f);
            uiTextPanel.Height.Set(50f, 0.0f);
            uiTextPanel.VAlign = 1f;
            uiTextPanel.HAlign = 0.5f;
            uiTextPanel.Top.Set(-45f, 0.0f);
            uiTextPanel.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
            uiTextPanel.OnMouseOut  += new UIElement.MouseEvent(this.FadedMouseOut);
            uiTextPanel.OnClick     += new UIElement.MouseEvent(this.GoBackClick);
            uiTextPanel.SetSnapPoint("Back", 0, new Vector2?(), new Vector2?());
            element.Append((UIElement)uiTextPanel);
            this._backPanel = (UIElement)uiTextPanel;
            int currentGroupIndex = 0;

            this.TryAddingList(Language.GetText("UI.EmoteCategoryGeneral"), ref currentGroupIndex, 10, this.GetEmotesGeneral());
            this.TryAddingList(Language.GetText("UI.EmoteCategoryRPS"), ref currentGroupIndex, 10, this.GetEmotesRPS());
            this.TryAddingList(Language.GetText("UI.EmoteCategoryItems"), ref currentGroupIndex, 11, this.GetEmotesItems());
            this.TryAddingList(Language.GetText("UI.EmoteCategoryBiomesAndEvents"), ref currentGroupIndex, 8, this.GetEmotesBiomesAndEvents());
            this.TryAddingList(Language.GetText("UI.EmoteCategoryTownNPCs"), ref currentGroupIndex, 9, this.GetEmotesTownNPCs());
            this.TryAddingList(Language.GetText("UI.EmoteCategoryCritters"), ref currentGroupIndex, 7, this.GetEmotesCritters());
            this.TryAddingList(Language.GetText("UI.EmoteCategoryBosses"), ref currentGroupIndex, 8, this.GetEmotesBosses());
        }
예제 #7
0
        private static void PrintMessage(string msg)
        {
            try
            {
                SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(() =>
                {
                    UILabel messageBox = UIView.GetAView().FindUIComponent <UILabel>("ChatLogPanelMessageBox");
                    if (messageBox != null)
                    {
                        // Check if the thumb is at the bottom of the scrollbar for autoscrolling
                        UIScrollbar scrollBar = UIView.GetAView().FindUIComponent <UIScrollbar>("ChatLogPanelScrollBar");
                        UISlicedSprite thumb  = UIView.GetAView().FindUIComponent <UISlicedSprite>("ChatLogPanelThumb");
                        float size            = (thumb.relativePosition.y + thumb.size.y);
                        bool autoScroll       = Math.Abs(size - scrollBar.height) < 0.2f;

                        messageBox.text += ($"{msg}\n");

                        if (autoScroll)
                        {
                            scrollBar.minValue = scrollBar.maxValue;
                        }
                    }
                });
            }
            catch (Exception)
            {
                // IGNORE
            }
        }
예제 #8
0
        public override void OnInitialize()
        {
            messageBox = new UIMessageBox("")
            {
                Width  = { Pixels = -25, Precent = 1f },
                Height = { Pixels = -40, Precent = 1f },
                Top    = { Pixels = 40 },
            };
            Append(messageBox);

            var messageBoxScrollbar = new UIScrollbar
            {
                Height = { Pixels = -30, Precent = 1f },
                Top    = { Pixels = 30 },
                //VAlign = 0.5f,
                HAlign = 1f
            };

            messageBoxScrollbar.SetView(100f, 1000f);
            Append(messageBoxScrollbar);

            messageBox.SetScrollbar(messageBoxScrollbar);

            base.OnInitialize();
        }
예제 #9
0
        public override void OnInitialize()
        {
            uIElement = new UIElement();
            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

            UIPanel uIPanel = new UIPanel();

            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIElement.Append(uIPanel);

            modInfo = new UIMessageBox("This is a test of mod info here.");
            modInfo.Width.Set(-25f, 1f);
            modInfo.Height.Set(0f, 1f);
            uIPanel.Append(modInfo);

            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(-20, 1f);
            uIScrollbar.VAlign = 0.5f;
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);

            modInfo.SetScrollbar(uIScrollbar);
            uITextPanel        = new UITextPanel <string>("Mod Info", 0.8f, true);
            uITextPanel.HAlign = 0.5f;
            uITextPanel.Top.Set(-35f, 0f);
            uITextPanel.SetPadding(15f);
            uITextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uITextPanel);

            modHomepageButton = new UITextPanel <string>("Visit the Mod's Homepage for even more info", 1f, false);
            modHomepageButton.Width.Set(-10f, 1f);
            modHomepageButton.Height.Set(25f, 0f);
            modHomepageButton.VAlign = 1f;
            modHomepageButton.Top.Set(-65f, 0f);
            modHomepageButton.OnMouseOver += UICommon.FadedMouseOver;
            modHomepageButton.OnMouseOut  += UICommon.FadedMouseOut;
            modHomepageButton.OnClick     += VisitModHomePage;
            uIElement.Append(modHomepageButton);

            UITextPanel <string> backButton = new UITextPanel <string>("Back", 1f, false);

            backButton.Width.Set(-10f, 0.5f);
            backButton.Height.Set(25f, 0f);
            backButton.VAlign = 1f;
            backButton.Top.Set(-20f, 0f);
            backButton.OnMouseOver += UICommon.FadedMouseOver;
            backButton.OnMouseOut  += UICommon.FadedMouseOut;
            backButton.OnClick     += BackClick;
            uIElement.Append(backButton);

            Append(uIElement);
        }
예제 #10
0
        public override void OnInitialize()
        {
            var element = new UIElement();

            element.Width.Set(0.0f, 0.8f);
            element.MaxWidth.Set(650f, 0.0f);
            element.Top.Set(220f, 0.0f);
            element.Height.Set(-220f, 1f);
            element.HAlign = 0.5f;
            var uiPanel = new UIPanel();

            uiPanel.Width.Set(0.0f, 1f);
            uiPanel.Height.Set(-110f, 1f);
            uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            element.Append((UIElement)uiPanel);
            this._containerPanel = uiPanel;
            this._worldList      = new UIList();
            this._worldList.Width.Set(-25f, 1f);
            this._worldList.Height.Set(0.0f, 1f);
            this._worldList.ListPadding = 5f;
            uiPanel.Append((UIElement)this._worldList);
            var scrollbar = new UIScrollbar();

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0.0f, 1f);
            scrollbar.HAlign = 1f;
            uiPanel.Append((UIElement)scrollbar);
            this._worldList.SetScrollbar(scrollbar);
            var uiTextPanel1 =
                new UITextPanel <LocalizedText>(Language.GetText("UI.SelectWorld"), 0.8f, true);

            uiTextPanel1.HAlign = 0.5f;
            uiTextPanel1.Top.Set(-35f, 0.0f);
            uiTextPanel1.SetPadding(15f);
            uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
            element.Append((UIElement)uiTextPanel1);
            var uiTextPanel2 =
                new UITextPanel <LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);

            uiTextPanel2.Width.Set(-10f, 0.5f);
            uiTextPanel2.Height.Set(50f, 0.0f);
            uiTextPanel2.VAlign = 1f;
            uiTextPanel2.Top.Set(-45f, 0.0f);
            uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
            uiTextPanel2.OnMouseOut  += new UIElement.MouseEvent(this.FadedMouseOut);
            uiTextPanel2.OnClick     += new UIElement.MouseEvent(this.GoBackClick);
            element.Append((UIElement)uiTextPanel2);
            this._backPanel = uiTextPanel2;
            var uiTextPanel3 =
                new UITextPanel <LocalizedText>(Language.GetText("UI.New"), 0.7f, true);

            uiTextPanel3.CopyStyle((UIElement)uiTextPanel2);
            uiTextPanel3.HAlign       = 1f;
            uiTextPanel3.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
            uiTextPanel3.OnMouseOut  += new UIElement.MouseEvent(this.FadedMouseOut);
            uiTextPanel3.OnClick     += new UIElement.MouseEvent(this.NewWorldClick);
            element.Append((UIElement)uiTextPanel3);
            this._newPanel = uiTextPanel3;
            this.Append(element);
        }
예제 #11
0
        public void InitializePage()
        {
            RemoveAllChildren();
            UIElement uIElement = new UIElement();

            uIElement.Width.Set(590f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;
            _outerContainer  = uIElement;
            Append(uIElement);
            UIPanel uIPanel = new UIPanel();

            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIPanel.PaddingTop      = 0f;
            uIElement.Append(uIPanel);
            _container = uIPanel;
            UIList uIList = new UIList();

            uIList.Width.Set(-25f, 1f);
            uIList.Height.Set(-50f, 1f);
            uIList.Top.Set(50f, 0f);
            uIList.HAlign      = 0.5f;
            uIList.ListPadding = 14f;
            uIPanel.Append(uIList);
            _list = uIList;
            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(-20f, 1f);
            uIScrollbar.HAlign = 1f;
            uIScrollbar.VAlign = 1f;
            uIScrollbar.Top    = StyleDimension.FromPixels(-5f);
            uIList.SetScrollbar(uIScrollbar);
            _scrollBar = uIScrollbar;
            UITextPanel <LocalizedText> uITextPanel = new UITextPanel <LocalizedText>(Language.GetText("UI.Back"), 0.7f, large: true);

            uITextPanel.Width.Set(-10f, 0.5f);
            uITextPanel.Height.Set(50f, 0f);
            uITextPanel.VAlign = 1f;
            uITextPanel.HAlign = 0.5f;
            uITextPanel.Top.Set(-45f, 0f);
            uITextPanel.OnMouseOver += FadedMouseOver;
            uITextPanel.OnMouseOut  += FadedMouseOut;
            uITextPanel.OnClick     += GoBackClick;
            uITextPanel.SetSnapPoint("Back", 0);
            uIElement.Append(uITextPanel);
            _backPanel = uITextPanel;
            int currentGroupIndex = 0;

            TryAddingList(Language.GetText("UI.EmoteCategoryGeneral"), ref currentGroupIndex, 10, GetEmotesGeneral());
            TryAddingList(Language.GetText("UI.EmoteCategoryRPS"), ref currentGroupIndex, 10, GetEmotesRPS());
            TryAddingList(Language.GetText("UI.EmoteCategoryItems"), ref currentGroupIndex, 11, GetEmotesItems());
            TryAddingList(Language.GetText("UI.EmoteCategoryBiomesAndEvents"), ref currentGroupIndex, 8, GetEmotesBiomesAndEvents());
            TryAddingList(Language.GetText("UI.EmoteCategoryTownNPCs"), ref currentGroupIndex, 9, GetEmotesTownNPCs());
            TryAddingList(Language.GetText("UI.EmoteCategoryCritters"), ref currentGroupIndex, 7, GetEmotesCritters());
            TryAddingList(Language.GetText("UI.EmoteCategoryBosses"), ref currentGroupIndex, 8, GetEmotesBosses());
        }
예제 #12
0
        public override void OnInitialize()
        {
            var area = new UIElement {
                Width  = { Percent = 0.8f },
                Top    = { Pixels = 200 },
                Height = { Pixels = -240, Percent = 1f },
                HAlign = 0.5f
            };

            var uIPanel = new UIPanel {
                Width           = { Percent = 1f },
                Height          = { Pixels = -110, Percent = 1f },
                BackgroundColor = UICommon.mainPanelBackground
            };

            area.Append(uIPanel);

            messageBox = new UIMessageBox("")
            {
                Width  = { Pixels = -25, Percent = 1f },
                Height = { Percent = 1f }
            };
            uIPanel.Append(messageBox);

            var uIScrollbar = new UIScrollbar {
                Height = { Pixels = -20, Percent = 1f },
                VAlign = 0.5f,
                HAlign = 1f
            }.WithView(100f, 1000f);

            uIPanel.Append(uIScrollbar);

            messageBox.SetScrollbar(uIScrollbar);

            var buttonOk = new UITextPanel <string>(Language.GetTextValue("tModLoader.OK"), 0.7f, true)
            {
                Width  = { Pixels = -10, Percent = 0.5f },
                Height = { Pixels = 50 },
                Left   = { Percent = 0f },
                VAlign = 1f,
                Top    = { Pixels = -30 }
            }.WithFadedMouseOver();

            buttonOk.OnClick += OKClick;
            area.Append(buttonOk);

            buttonAlt = new UITextPanel <string>("???", 0.7f, true)
            {
                Width  = { Pixels = -10, Percent = 0.5f },
                Height = { Pixels = 50 },
                Left   = { Percent = .5f },
                VAlign = 1f,
                Top    = { Pixels = -30 }
            }.WithFadedMouseOver();
            buttonAlt.OnClick += AltClick;
            area.Append(buttonAlt);

            Append(area);
        }
예제 #13
0
        public override void OnInitialize()
        {
            UIElement element = new UIElement();

            element.Width.Set(0.0f, 0.8f);
            element.MaxWidth.Set(650f, 0.0f);
            element.Top.Set(220f, 0.0f);
            element.Height.Set(-220f, 1f);
            element.HAlign = 0.5f;
            UIPanel uiPanel = new UIPanel();

            uiPanel.Width.Set(0.0f, 1f);
            uiPanel.Height.Set(-110f, 1f);
            uiPanel.BackgroundColor = Color.op_Multiply(new Color(33, 43, 79), 0.8f);
            this._containerPanel    = uiPanel;
            element.Append((UIElement)uiPanel);
            this._playerList = new UIList();
            this._playerList.Width.Set(-25f, 1f);
            this._playerList.Height.Set(0.0f, 1f);
            this._playerList.ListPadding = 5f;
            uiPanel.Append((UIElement)this._playerList);
            UIScrollbar scrollbar = new UIScrollbar();

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0.0f, 1f);
            scrollbar.HAlign = 1f;
            uiPanel.Append((UIElement)scrollbar);
            this._playerList.SetScrollbar(scrollbar);
            UITextPanel <LocalizedText> uiTextPanel1 = new UITextPanel <LocalizedText>(Language.GetText("UI.SelectPlayer"), 0.8f, true);

            uiTextPanel1.HAlign = 0.5f;
            uiTextPanel1.Top.Set(-35f, 0.0f);
            uiTextPanel1.SetPadding(15f);
            uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
            element.Append((UIElement)uiTextPanel1);
            UITextPanel <LocalizedText> uiTextPanel2 = new UITextPanel <LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);

            uiTextPanel2.Width.Set(-10f, 0.5f);
            uiTextPanel2.Height.Set(50f, 0.0f);
            uiTextPanel2.VAlign = 1f;
            uiTextPanel2.Top.Set(-45f, 0.0f);
            uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
            uiTextPanel2.OnMouseOut  += new UIElement.MouseEvent(this.FadedMouseOut);
            uiTextPanel2.OnClick     += new UIElement.MouseEvent(this.GoBackClick);
            uiTextPanel2.SetSnapPoint("Back", 0, new Vector2?(), new Vector2?());
            element.Append((UIElement)uiTextPanel2);
            this._backPanel = uiTextPanel2;
            UITextPanel <LocalizedText> uiTextPanel3 = new UITextPanel <LocalizedText>(Language.GetText("UI.New"), 0.7f, true);

            uiTextPanel3.CopyStyle((UIElement)uiTextPanel2);
            uiTextPanel3.HAlign       = 1f;
            uiTextPanel3.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
            uiTextPanel3.OnMouseOut  += new UIElement.MouseEvent(this.FadedMouseOut);
            uiTextPanel3.OnClick     += new UIElement.MouseEvent(this.NewCharacterClick);
            element.Append((UIElement)uiTextPanel3);
            uiTextPanel2.SetSnapPoint("New", 0, new Vector2?(), new Vector2?());
            this._newPanel = uiTextPanel3;
            this.Append(element);
        }
예제 #14
0
        public override void OnInitialize()
        {
            //const float width = 400f;
            //const float height = 600f;

            uiPanel = new UIPanel();
            uiPanel.Width.Set(300f, 0f);
            uiPanel.Height.Set(400f, 0f);
            uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            //uiPanel.SetPadding(0);
            uiPanel.HAlign = 0.5f;
            uiPanel.VAlign = 0.5f;

            playerList = new UIList();
            playerList.Width.Set(-10f, 1f);
            playerList.Height.Set(-50f, 1f);
            playerList.Top.Set(50f, 0f);
            playerList.ListPadding = 5f;
            uiPanel.Append(playerList);

            var uiScrollbar = new UIScrollbar();

            uiScrollbar.SetView(100f, 1000f);
            uiScrollbar.Height.Set(-50f, 1f);
            uiScrollbar.Top.Set(50f, 0f);
            uiScrollbar.HAlign = 1f;
            uiPanel.Append(uiScrollbar);
            playerList.SetScrollbar(uiScrollbar);

            homeButton = new UITextPanel <string>(Language.GetTextValue("Mods.GoldensMisc.HomeButton"));
            homeButton.Width.Set(0, 0.4f);
            homeButton.OnMouseOver += MiscUtils.UI.FadedMouseOver;
            homeButton.OnMouseOut  += MiscUtils.UI.FadedMouseOut;
            homeButton.OnClick     += HomeButtonClicked;
            uiPanel.Append(homeButton);

            //var teleportButton = new UITextPanel<string>(Language.GetTextValue("Mods.GoldensMisc.TeleportButton"));
            //teleportButton.Width.Set(0f, 0.7f);
            ////teleportButton.Height.Set(20f, 0f);
            ////teleportButton.SetPadding(0);
            //teleportButton.OnMouseOver += MiscUtils.UI.FadedMouseOver;
            //teleportButton.OnMouseOut += MiscUtils.UI.FadedMouseOut;
            //teleportButton.OnClick += TeleportButtonClick;
            //uiPanel.Append(teleportButton);

            //var buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete");
            //var closeButton = new UIImageButton(buttonDeleteTexture);
            var closeButton = new UITextPanel <string>(Language.GetTextValue("Mods.GoldensMisc.CloseButton"));

            closeButton.Left.Set(0, 0.6f);
            closeButton.Width.Set(0, 0.4f);
            //closeButton.SetPadding(0);
            closeButton.OnMouseOver += MiscUtils.UI.FadedMouseOver;
            closeButton.OnMouseOut  += MiscUtils.UI.FadedMouseOut;
            closeButton.OnClick     += new MouseEvent(CloseButtonClicked);
            uiPanel.Append(closeButton);

            base.Append(uiPanel);
        }
예제 #15
0
        public static UIScrollbar CreateScrollbar(UIComponent parent, string name)
        {
            UIScrollbar scrollbar = parent.AddUIComponent <UIScrollbar>();

            scrollbar.name = name;

            return(scrollbar);
        }
예제 #16
0
        public void SetScrollbar(UIScrollbar scrollbar)
        {
            this.scrollbar = scrollbar;

            scrollbar.Top.Set(this.Top.Pixels + padding, this.Top.Percent);
            scrollbar.Left.Set(Width.Pixels + scrollbar.Left.Pixels, 0);
            scrollbar.Height = this.Height;
        }
예제 #17
0
        public override void OnInitialize()
        {
            UIElement uIElement = new UIElement();

            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

            UIPanel scrollPanel = new UIPanel();

            scrollPanel.Width.Set(0f, 1f);
            scrollPanel.Height.Set(-65f, 1f);
            scrollPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIElement.Append(scrollPanel);

            settingsItemList = new UIList();
            settingsItemList.Width.Set(-25f, 1f);
            settingsItemList.Height.Set(0f, 1f);
            settingsItemList.ListPadding = 5f;
            scrollPanel.Append(settingsItemList);

            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(0f, 1f);
            uIScrollbar.HAlign = 1f;
            scrollPanel.Append(uIScrollbar);
            settingsItemList.SetScrollbar(uIScrollbar);

            UITextPanel <string> titleTextPanel = new UITextPanel <string>(TerraCustomUtils.TCText("SavedSetings"), 0.8f, true);

            titleTextPanel.HAlign = 0.5f;
            titleTextPanel.Top.Set(-35f, 0f);
            titleTextPanel.SetPadding(15f);
            titleTextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(titleTextPanel);

            UITextPanel <string> backButton = new UITextPanel <string>(Localization.Language.GetTextValue("UI.Back"), 1f, false).WithFadedMouseOver();

            backButton.Width.Set(-10f, 1f / 2f);
            backButton.Height.Set(25f, 0f);
            backButton.VAlign = 1f;
            backButton.Top.Set(-20f, 0f);
            backButton.OnClick += new UIElement.MouseEvent(BackClick);
            uIElement.Append(backButton);

            UITextPanel <string> saveNewButton = new UITextPanel <string>(TerraCustomUtils.TCText("SaveCurrentSettingsAsNew"), 1f, false).WithFadedMouseOver(Color.Green, Color.Green * 0.7f);;

            saveNewButton.CopyStyle(backButton);
            saveNewButton.BackgroundColor = Color.Green * 0.7f;
            saveNewButton.HAlign          = 1f;
            saveNewButton.OnClick        += new UIElement.MouseEvent(SaveNewSettings);
            uIElement.Append(saveNewButton);

            base.Append(uIElement);
        }
예제 #18
0
 public override void ScrollWheel(UIScrollWheelEvent evt)
 {
     base.ScrollWheel(evt);
     if (this._scrollbar != null)
     {
         UIScrollbar viewPosition = this._scrollbar;
         viewPosition.ViewPosition = viewPosition.ViewPosition - (float)evt.ScrollWheelValue;
     }
 }
        private void CreatePartInfoPanel()
        {
            _partInfoPanel = new UIPanel
            {
                Left   = new StyleDimension(_tabPanel.Width.Pixels - 150 - 20, 0),
                Top    = new StyleDimension(40, 0),
                Width  = new StyleDimension(150, 0),
                Height = new StyleDimension(190, 0)
            };
            _partInfoPanel.SetPadding(0);
            _tabPanel.Append(_partInfoPanel);

            // Create an image for the info with a default empty image
            var texture = new Texture2D(Main.instance.GraphicsDevice, 1, 1);

            _partInfoImage = new UIImage(texture)
            {
                HAlign     = .5f,
                ImageScale = 20f / (texture.Width > texture.Height ? texture.Width : texture.Height),
            };
            _partInfoImage.SetImage(texture);
            _partInfoImage.Width  = new StyleDimension(20, 0);
            _partInfoImage.Height = new StyleDimension(20, 0);
            _partInfoImage.Left   = new StyleDimension(-10, 0);
            _partInfoPanel.Append(_partInfoImage);

            // Add a UIText for the name of the part
            _partInfoName = new UIText("")
            {
                Top    = new StyleDimension(35, 0),
                HAlign = 0.5f,
                Left   = new StyleDimension(-5, 0)
            };
            _partInfoPanel.Append(_partInfoName);

            // Add a UIList for the description of the part, each line is a new element in the list
            _partInfoDescription = new UnsortedList
            {
                Top    = new StyleDimension(60, 0),
                Left   = new StyleDimension(8, 0),
                Width  = new StyleDimension(_partInfoPanel.Width.Pixels - 20, 0),
                Height = new StyleDimension(125, 0)
            };
            _partInfoPanel.Append(_partInfoDescription);

            UIScrollbar descriptionScrollbar = new UIScrollbar
            {
                Height = new StyleDimension(_partInfoPanel.Height.Pixels - 10, 0),
                Top    = new StyleDimension(5, 0),
                Width  = new StyleDimension(20, 0),
                Left   = new StyleDimension(_partInfoPanel.Width.Pixels - 20, 0)
                         //HAlign = 1f
            }.WithView(20, 130);

            _partInfoPanel.Append(descriptionScrollbar);
            _partInfoDescription.SetScrollbar(descriptionScrollbar);
        }
예제 #20
0
        private void UpdateScrollbar()
        {
            UIScrollbar scrollbar = Scrollbar;

            if (scrollbar != null)
            {
                scrollbar.SetView(GetInnerDimensions().Height, _height);
            }
        }
예제 #21
0
        public override void OnInitialize()
        {
            UIElement uIElement = new UIElement();

            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(650f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;
            UIPanel uIPanel = new UIPanel();

            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            _containerPanel         = uIPanel;
            uIElement.Append(uIPanel);
            _playerList = new UIList();
            _playerList.Width.Set(0f, 1f);
            _playerList.Height.Set(0f, 1f);
            _playerList.ListPadding = 5f;
            uIPanel.Append(_playerList);
            _scrollbar = new UIScrollbar();
            _scrollbar.SetView(100f, 1000f);
            _scrollbar.Height.Set(0f, 1f);
            _scrollbar.HAlign = 1f;
            _playerList.SetScrollbar(_scrollbar);
            UITextPanel <LocalizedText> uITextPanel = new UITextPanel <LocalizedText>(Language.GetText("UI.SelectPlayer"), 0.8f, large: true);

            uITextPanel.HAlign = 0.5f;
            uITextPanel.Top.Set(-40f, 0f);
            uITextPanel.SetPadding(15f);
            uITextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uITextPanel);
            UITextPanel <LocalizedText> uITextPanel2 = new UITextPanel <LocalizedText>(Language.GetText("UI.Back"), 0.7f, large: true);

            uITextPanel2.Width.Set(-10f, 0.5f);
            uITextPanel2.Height.Set(50f, 0f);
            uITextPanel2.VAlign = 1f;
            uITextPanel2.Top.Set(-45f, 0f);
            uITextPanel2.OnMouseOver += FadedMouseOver;
            uITextPanel2.OnMouseOut  += FadedMouseOut;
            uITextPanel2.OnClick     += GoBackClick;
            uITextPanel2.SetSnapPoint("Back", 0);
            uIElement.Append(uITextPanel2);
            _backPanel = uITextPanel2;
            UITextPanel <LocalizedText> uITextPanel3 = new UITextPanel <LocalizedText>(Language.GetText("UI.New"), 0.7f, large: true);

            uITextPanel3.CopyStyle(uITextPanel2);
            uITextPanel3.HAlign       = 1f;
            uITextPanel3.OnMouseOver += FadedMouseOver;
            uITextPanel3.OnMouseOut  += FadedMouseOut;
            uITextPanel3.OnClick     += NewCharacterClick;
            uIElement.Append(uITextPanel3);
            uITextPanel2.SetSnapPoint("New", 0);
            _newPanel = uITextPanel3;
            Append(uIElement);
        }
예제 #22
0
        public override void OnInitialize()
        {
            _tabPanel = new TabPanel(500, 250,
                                     new Tab("Material Info", this),
                                     new Tab("Part Assembler", new PartAssemblerState()),
                                     new Tab("Tool Assembler", new ToolAssemblerState()));

            _tabPanel.Left.Set(DraggableUIPanel.lastPos.X, 0);
            _tabPanel.Top.Set(DraggableUIPanel.lastPos.Y, 0);
            _tabPanel.OnCloseBtnClicked += () => TerrarianWeaponry.Instance.UpdateState(null);

            _materialSlot = new ItemSlotWrapper
            {
                VAlign = 0.5f,
                Left   = new StyleDimension(90, 0)
            };
            _materialSlot.OnItemChanged += OnItemChanged;
            _tabPanel.Append(_materialSlot);

            #region Create Material Info Panel

            _infoPanel = new UIPanel
            {
                Left   = new StyleDimension(230, 0),
                Width  = new StyleDimension(255, 0),
                Top    = new StyleDimension(40, 0),
                Height = new StyleDimension(195, 0)
            };
            _infoPanel.SetPadding(0);
            _tabPanel.Append(_infoPanel);

            // Create a list
            _infoList = new UIList
            {
                Width  = new StyleDimension(235, 0),
                Height = new StyleDimension(0, 1),
                Left   = new StyleDimension(5, 0),
                Top    = new StyleDimension(5, 0)
            };
            _infoPanel.Append(_infoList);

            // And add a scrollbar
            UIScrollbar infoScrollbar = new UIScrollbar
            {
                Height = new StyleDimension(185, 0),
                Top    = new StyleDimension(5, 0),
                Width  = new StyleDimension(20, 0),
                Left   = new StyleDimension(235, 0)
            }.WithView(50, 250);
            _infoPanel.Append(infoScrollbar);
            _infoList.SetScrollbar(infoScrollbar);

            #endregion

            Append(_tabPanel);
        }
예제 #23
0
        // runs only once, do internal init here
        public override void Awake()
        {
            base.Awake();

            // Note - parent may not be set yet
            ScrollPanel = AddUIComponent <UIScrollablePanel>();
            ScrollBar   = AddUIComponent <UIScrollbar>();
            TrackSprite = ScrollBar.AddUIComponent <UISlicedSprite>();
            ThumbSprite = TrackSprite.AddUIComponent <UISlicedSprite>();
        }
예제 #24
0
        public override void OnInitialize()
        {
            UIElement area = new UIElement();

            area.Width.Set(0f, 0.8f);
            area.Top.Set(200f, 0f);
            area.Height.Set(-240f, 1f);
            area.HAlign = 0.5f;

            UIPanel uIPanel = new UIPanel();

            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            area.Append(uIPanel);

            message.Width.Set(-25f, 1f);
            message.Height.Set(0f, 1f);
            uIPanel.Append(message);

            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(-20, 1f);
            uIScrollbar.VAlign = 0.5f;
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);

            message.SetScrollbar(uIScrollbar);

            UITextPanel <string> button1 = new UITextPanel <string>("OK", 0.7f, true);

            button1.Width.Set(-10f, 0.5f);
            button1.Height.Set(50f, 0f);
            button1.Left.Set(0, 0f);
            button1.VAlign = 1f;
            button1.Top.Set(-30f, 0f);
            button1.OnMouseOver += UICommon.FadedMouseOver;
            button1.OnMouseOut  += UICommon.FadedMouseOut;
            button1.OnClick     += OKClick;
            area.Append(button1);

            button2 = new UITextPanel <string>("???", 0.7f, true);
            button2.Width.Set(-10f, 0.5f);
            button2.Height.Set(50f, 0f);
            button2.Left.Set(0, .5f);
            button2.VAlign = 1f;
            button2.Top.Set(-30f, 0f);
            button2.OnMouseOver += UICommon.FadedMouseOver;
            button2.OnMouseOut  += UICommon.FadedMouseOut;
            button2.OnClick     += AltClick;
            area.Append(button2);

            Append(area);
        }
예제 #25
0
        public override void Start()
        {
            base.Start();
            this.autoLayoutDirection     = LayoutDirection.Horizontal;
            this.autoLayoutStart         = LayoutStart.TopLeft;
            this.autoLayoutPadding       = new RectOffset(0, 0, 0, 0);
            this.autoLayout              = true;
            this._scrollablePanel        = this.AddUIComponent <UIScrollablePanel>();
            this._scrollablePanel.width  = this.width - 10f;
            this._scrollablePanel.height = this.height;
            this._scrollablePanel.autoLayoutDirection = LayoutDirection.Vertical;
            this._scrollablePanel.autoLayoutStart     = LayoutStart.TopLeft;
            this._scrollablePanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 0);
            this._scrollablePanel.autoLayout          = true;
            this._scrollablePanel.clipChildren        = true;
            this._scrollablePanel.backgroundSprite    = "UnlockingPanel";
            this._scrollablePanel.color = (Color32)Color.black;
            UIPanel uiPanel = this.AddUIComponent <UIPanel>();

            uiPanel.width  = 10f;
            uiPanel.height = this.height;
            uiPanel.autoLayoutDirection = LayoutDirection.Horizontal;
            uiPanel.autoLayoutStart     = LayoutStart.TopLeft;
            uiPanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 0);
            uiPanel.autoLayout          = true;
            UIScrollbar scrollbar = uiPanel.AddUIComponent <UIScrollbar>();

            scrollbar.width       = 10f;
            scrollbar.height      = scrollbar.parent.height;
            scrollbar.orientation = UIOrientation.Vertical;
            scrollbar.pivot       = UIPivotPoint.BottomLeft;
            scrollbar.AlignTo((UIComponent)uiPanel, UIAlignAnchor.TopRight);
            scrollbar.minValue        = 0.0f;
            scrollbar.value           = 0.0f;
            scrollbar.incrementAmount = 27f;
            this._scrollbar           = scrollbar;
            UISlicedSprite uiSlicedSprite1 = scrollbar.AddUIComponent <UISlicedSprite>();

            uiSlicedSprite1.relativePosition = (Vector3)Vector2.zero;
            uiSlicedSprite1.autoSize         = true;
            uiSlicedSprite1.size             = uiSlicedSprite1.parent.size;
            uiSlicedSprite1.fillDirection    = UIFillDirection.Vertical;
            uiSlicedSprite1.spriteName       = "ScrollbarTrack";
            scrollbar.trackObject            = (UIComponent)uiSlicedSprite1;
            UISlicedSprite uiSlicedSprite2 = uiSlicedSprite1.AddUIComponent <UISlicedSprite>();

            uiSlicedSprite2.relativePosition        = (Vector3)Vector2.zero;
            uiSlicedSprite2.fillDirection           = UIFillDirection.Vertical;
            uiSlicedSprite2.autoSize                = true;
            uiSlicedSprite2.width                   = uiSlicedSprite2.parent.width - 4f;
            uiSlicedSprite2.spriteName              = "ScrollbarThumb";
            scrollbar.thumbObject                   = (UIComponent)uiSlicedSprite2;
            this._scrollablePanel.verticalScrollbar = scrollbar;
            this._scrollablePanel.eventMouseWheel  += (MouseEventHandler)((component, param) => this._scrollablePanel.scrollPosition += new Vector2(0.0f, Mathf.Sign(param.wheelDelta) * -1f * scrollbar.incrementAmount));
        }
예제 #26
0
        public override void OnInitialize()
        {
            var area = new UIElement {
                Width    = { Percent = 0.8f },
                MaxWidth = UICommon.MaxPanelWidth,
                Top      = { Pixels = 220 },
                Height   = { Pixels = -220, Percent = 1f },
                HAlign   = 0.5f
            };

            var uIPanel = new UIPanel {
                Width           = { Percent = 1f },
                Height          = { Pixels = -110, Percent = 1f },
                BackgroundColor = UICommon.MainPanelBackground
            };

            area.Append(uIPanel);

            _myPublishedMods = new UIList {
                Width       = { Pixels = -25, Percent = 1f },
                Height      = { Percent = 1f },
                ListPadding = 5f
            };
            uIPanel.Append(_myPublishedMods);

            var uIScrollbar = new UIScrollbar {
                Height = { Percent = 1f },
                HAlign = 1f
            }.WithView(100f, 1000f);

            uIPanel.Append(uIScrollbar);
            _myPublishedMods.SetScrollbar(uIScrollbar);

            TextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBMyPublishedMods"), 0.8f, true)
            {
                HAlign          = 0.5f,
                Top             = { Pixels = -35 },
                BackgroundColor = UICommon.DefaultUIBlue
            }.WithPadding(15);
            area.Append(TextPanel);

            var backButton = new UITextPanel <string>(Language.GetTextValue("UI.Back"))
            {
                VAlign = 1f,
                Height = { Pixels = 25 },
                Width  = new StyleDimension(-10f, 1f / 2f),
                Top    = { Pixels = -20 }
            }.WithFadedMouseOver();

            backButton.OnClick += BackClick;
            area.Append(backButton);

            Append(area);
        }
예제 #27
0
        private static void PrintMessage(string sender, string msg)
        {
            try
            {
                SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(() =>
                {
                    if (UseChirper)
                    {
                        // Write message to Chirper panel
                        ChirperMessage.ChirpPanel.AddMessage(new ChirperMessage(sender, msg), true);
                    }
                    else
                    {
                        msg = $"<{sender}> {msg}";
                        ChatLogPanel chatPanel = UIView.GetAView().FindUIComponent <ChatLogPanel>("ChatLogPanel");
                        if (chatPanel != null)
                        {
                            // Reset the timeout counter when a new message is received
                            chatPanel._timeoutCounter = 0;

                            // If the panel is closed, make sure it gets shown
                            if (!chatPanel.isVisible)
                            {
                                chatPanel.isVisible = true;
                                chatPanel.Update();
                            }
                        }

                        UILabel messageBox = UIView.GetAView().FindUIComponent <UILabel>("ChatLogPanelMessageBox");
                        if (messageBox != null)
                        {
                            // Check if the thumb is at the bottom of the scrollbar for autoscrolling
                            UIScrollbar scrollBar =
                                UIView.GetAView().FindUIComponent <UIScrollbar>("ChatLogPanelScrollBar");
                            UISlicedSprite thumb =
                                UIView.GetAView().FindUIComponent <UISlicedSprite>("ChatLogPanelThumb");
                            float size      = (thumb.relativePosition.y + thumb.size.y);
                            bool autoScroll = Math.Abs(size - scrollBar.height) < 0.2f;

                            messageBox.text += ($"{msg}\n");

                            if (autoScroll)
                            {
                                scrollBar.minValue = scrollBar.maxValue;
                            }
                        }
                    }
                });
            }
            catch (Exception)
            {
                // IGNORE
            }
        }
        public override void OnInitialize()
        {
            UIElement uIElement = new UIElement();

            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;
            UIPanel uIPanel = new UIPanel();

            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIElement.Append(uIPanel);
            _playerList = new UIList();
            _playerList.Width.Set(-25f, 1f);
            _playerList.Height.Set(0f, 1f);
            _playerList.ListPadding = 5f;
            uIPanel.Append(_playerList);
            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(0f, 1f);
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);
            _playerList.SetScrollbar(uIScrollbar);
            UITextPanel uITextPanel = new UITextPanel("Select Player", 0.8f, true);

            uITextPanel.HAlign = 0.5f;
            uITextPanel.Top.Set(-35f, 0f);
            uITextPanel.SetPadding(15f);
            uITextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uITextPanel);
            UITextPanel uITextPanel2 = new UITextPanel("Back", 0.7f, true);

            uITextPanel2.Width.Set(-10f, 0.5f);
            uITextPanel2.Height.Set(50f, 0f);
            uITextPanel2.VAlign = 1f;
            uITextPanel2.Top.Set(-45f, 0f);
            uITextPanel2.OnMouseOver += FadedMouseOver;
            uITextPanel2.OnMouseOut  += FadedMouseOut;
            uITextPanel2.OnClick     += GoBackClick;
            uIElement.Append(uITextPanel2);
            UITextPanel uITextPanel3 = new UITextPanel("New", 0.7f, true);

            uITextPanel3.CopyStyle(uITextPanel2);
            uITextPanel3.HAlign       = 1f;
            uITextPanel3.OnMouseOver += FadedMouseOver;
            uITextPanel3.OnMouseOut  += FadedMouseOut;
            uITextPanel3.OnClick     += NewCharacterClick;
            uIElement.Append(uITextPanel3);
            Append(uIElement);
        }
예제 #29
0
        private void CheckItems()
        {
            if (m_itemWidth <= 0 || m_itemHeight <= 0 || template == null)
            {
                return;
            }

            int nbRow = /*Mathf.CeilToInt*/ (int)(height / m_itemHeight);
            int nbCol = /*Mathf.CeilToInt*/ (int)(width / m_itemWidth);

            UIScrollbar scrollbar = parent.parent.GetComponentInChildren <UIScrollbar>();

            if (scrollbar != null)
            {
                scrollbar.isVisible = nbRow > 1;
            }

            int nbItems = nbCol * nbRow;

            if (m_items == null)
            {
                m_items = new FastList <I>();
                m_items.SetCapacity(nbItems);
            }

            if (m_items.m_size < nbItems)
            {
                // Adding missing items
                for (int i = m_items.m_size; i < nbItems; i++)
                {
                    m_items.Add(new I());

                    /*m_items.Add(new I()
                     *  {
                     *      item = CreateItem()
                     *  });
                     *
                     * m_items.m_buffer[i].Init();*/
                }
            }
            else if (m_items.m_size > nbItems)
            {
                // Remove excess items
                for (int i = nbItems; i < m_items.m_size; i++)
                {
                    if (m_items.m_buffer[i].component != null)
                    {
                        Destroy(m_items.m_buffer[i].component.gameObject);
                    }
                }

                m_items.SetCapacity(nbItems);
            }
        }
예제 #30
0
        public override void OnInitialize()
        {
            UIElement element = new UIElement();

            element.Width.Set(0.0f, 0.8f);
            element.MaxWidth.Set(600f, 0.0f);
            element.Top.Set(220f, 0.0f);
            element.Height.Set(-220f, 1f);
            element.HAlign = 0.5f;
            UIPanel uiPanel = new UIPanel();

            uiPanel.Width.Set(0.0f, 1f);
            uiPanel.Height.Set(-110f, 1f);
            uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            element.Append(uiPanel);
            _worldList = new UIList();
            _worldList.Width.Set(-25f, 1f);
            _worldList.Height.Set(0.0f, 1f);
            _worldList.ListPadding = 5f;
            uiPanel.Append(_worldList);
            UIScrollbar scrollbar = new UIScrollbar();

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0.0f, 1f);
            scrollbar.HAlign = 1f;
            uiPanel.Append(scrollbar);
            _worldList.SetScrollbar(scrollbar);
            UITextPanel uiTextPanel1 = new UITextPanel("Select World", 0.8f, true);

            uiTextPanel1.HAlign = 0.5f;
            uiTextPanel1.Top.Set(-35f, 0.0f);
            uiTextPanel1.SetPadding(15f);
            uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
            element.Append(uiTextPanel1);
            UITextPanel uiTextPanel2 = new UITextPanel("Back", 0.7f, true);

            uiTextPanel2.Width.Set(-10f, 0.5f);
            uiTextPanel2.Height.Set(50f, 0.0f);
            uiTextPanel2.VAlign = 1f;
            uiTextPanel2.Top.Set(-45f, 0.0f);
            uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver);
            uiTextPanel2.OnMouseOut  += new UIElement.MouseEvent(FadedMouseOut);
            uiTextPanel2.OnClick     += new UIElement.MouseEvent(GoBackClick);
            element.Append(uiTextPanel2);
            UITextPanel uiTextPanel3 = new UITextPanel("New", 0.7f, true);

            uiTextPanel3.CopyStyle(uiTextPanel2);
            uiTextPanel3.HAlign       = 1f;
            uiTextPanel3.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver);
            uiTextPanel3.OnMouseOut  += new UIElement.MouseEvent(FadedMouseOut);
            uiTextPanel3.OnClick     += new UIElement.MouseEvent(NewWorldClick);
            element.Append(uiTextPanel3);
            Append(element);
        }
예제 #31
0
        public virtual bool InitPanel()
        {
            try
            {
                // Get Title
                _title = transform.Find("Caption").GetComponent<UILabel>();

                // Get Description
                _description = transform.Find("Scrollable Panel/Message").GetComponent<UILabel>();

                // Remove Close Button
                GameObject.Destroy(transform.Find("Caption/Close").gameObject);

                // Hide scrollbar
                _scrollbar = transform.Find("Scrollbar").GetComponent<UIScrollbar>();
                _scrollbar.opacity = 0;

                // Change Dont show text
                _dontShowAgainCheckbox = transform.Find("DontShow").GetComponent<UICheckBox>();
                transform.Find("DontShow/OnOff").GetComponent<UILabel>().text = "Don't show on future updates";

                // Change ok to Options
                _okButton = transform.Find("Ok").GetComponent<UIButton>();
                GameObject.Destroy(_okButton.GetComponent<BindEvent>());

                // Change cancel to Later
                _cancelButton = transform.Find("Cancel").GetComponent<UIButton>();
                GameObject.Destroy(_cancelButton.GetComponent<BindEvent>());

                // Get fireworks
                ParadoxUnlockPanel paradoxPanel = UIView.GetAView().GetComponentInChildren<ParadoxUnlockPanel>();
                if (paradoxPanel != null)
                {
                    m_fireworks = paradoxPanel.m_Fireworks;
                    if (m_fireworks != null)
                    {
                        Renderer[] componentsInChildren = this.m_fireworks.GetComponentsInChildren<Renderer>();
                        m_fireworkMaterials = new Material[componentsInChildren.Length];
                        for (int i = 0; i < componentsInChildren.Length; ++i)
                        {
                            m_fireworkMaterials[i] = componentsInChildren[i].material;
                        }
                    }
                }

                // Add panel to dynamic panels library
                this.name = this.GetType().Name;
                UIDynamicPanels.DynamicPanelInfo panelInfo = new UIDynamicPanels.DynamicPanelInfo();
                typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_Name").SetValue(panelInfo, this.name);
                typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_PanelRoot").SetValue(panelInfo, this.GetComponent<UIPanel>());
                typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_IsModal").SetValue(panelInfo, true);
                panelInfo.viewOwner = UIView.GetAView();
                panelInfo.AddInstance(this.GetComponent<UIPanel>());

                Dictionary<string, UIDynamicPanels.DynamicPanelInfo> cachedPanels = typeof(UIDynamicPanels).GetFieldByName("m_CachedPanels").GetValue(UIView.library) as Dictionary<string, UIDynamicPanels.DynamicPanelInfo>;
                if (!cachedPanels.ContainsKey(panelInfo.name))
                    cachedPanels.Add(panelInfo.name, panelInfo);

                return true;
            }
            catch (Exception)
            {
                // TODO: log error
                return false;
            }
        }
        private void CollapseIconPanel(UIPanel panel, UIScrollablePanel scrollablePanel, UIScrollbar horizontalScrollbar, bool verticalScroll)
        {
            panel.height = defaultSize.y;
            panel.width = defaultSize.x;

            try{
                m_verticalScrollbars[panel].Hide();
            }catch{}

            //adjust layout of UIScollablePanel
            scrollablePanel.autoLayout = true;
            scrollablePanel.autoLayoutStart = LayoutStart.BottomLeft;
            scrollablePanel.wrapLayout = false;
            scrollablePanel.autoLayoutDirection = LayoutDirection.Horizontal;
            scrollablePanel.width = 763.0f;
            //adjust position of Scollbar buttons
            horizontalScrollbar.decrementButton.relativePosition = defaultPositionDecrementButton;
            horizontalScrollbar.incrementButton.relativePosition = defaultPositionIncrementButton;
        }
        private void ExpandIconPanel(UIPanel panel, UIScrollablePanel scrollablePanel, UIScrollbar horizontalScrollbar, bool verticalScroll)
        {
            panel.height *= defaultSize.y * rows;
            horizontalScrollbar.value = 0;

            //adjust layout of UIScollablePanel
            scrollablePanel.autoLayout = true;
            scrollablePanel.autoLayoutStart = LayoutStart.TopLeft;
            scrollablePanel.wrapLayout = true;
            scrollablePanel.width++;

            UIScrollbar verticalScrollbar;
            try{
                verticalScrollbar = m_verticalScrollbars[panel];
            }catch{
                verticalScrollbar = CreateVerticalScrollbar(panel,scrollablePanel);
                m_verticalScrollbars[panel] = verticalScrollbar;
            }

            if(verticalScroll){
                scrollablePanel.autoLayoutDirection = LayoutDirection.Horizontal;
                verticalScrollbar.Show();
            } else{
                verticalScrollbar.Hide();
                scrollablePanel.autoLayoutDirection = LayoutDirection.Vertical;
                horizontalScrollbar.decrementButton.relativePosition = new Vector3(defaultPositionDecrementButton.x, panel.height / 2.0f - 21.5f);
                horizontalScrollbar.incrementButton.relativePosition = new Vector3(defaultPositionIncrementButton.x, panel.height / 2.0f - 21.5f);
            }
        }