public override void OnInitialize()
        {
            Visible       = false;
            DragablePanel = new DragableUIPanel();
            DragablePanel.SetPadding(0);
            DragablePanel.Left.Set(Main.screenWidth - 300, 0f);
            DragablePanel.Top.Set(Main.screenHeight - 100, 0f);
            DragablePanel.Width.Set(50, 0);
            DragablePanel.Height.Set(50, 0f);
            DragablePanel.BackgroundColor = new Color(0, 0, 0, 0);
            DragablePanel.BorderColor     = new Color(0, 0, 0, 0);

            _cookbookButton = new CookbookButton(ModContent.GetTexture("ExtraExplosives/Items/Accessories/AnarchistCookbook/AnarchistCookbook"), "CookbookButton");
            Texture2D          button1        = ModContent.GetTexture("ExtraExplosives/Items/Accessories/AnarchistCookbook/AnarchistCookbook");
            UIHoverImageButton CookbookButton = new UIHoverImageButton(button1, "Anarchist Cookbook");

            CookbookButton.Left.Set(22, 0f);
            CookbookButton.Top.Set(22, 0f);
            CookbookButton.Width.Set(22, 0);
            CookbookButton.Height.Set(22, 0f);
            CookbookButton.OnClick += new MouseEvent(OpenCookbook);
            DragablePanel.Append(CookbookButton);


            Append(DragablePanel);
        }
        private void TogHover(UIMouseEvent evt, UIElement listeningElement)
        {
            UIHoverImageButton button = (evt.Target as UIHoverImageButton);

            WheresMyItemsPlayer.hover = !WheresMyItemsPlayer.hover;
            button.hoverText          = "Click to switch peek modes: Show " + (WheresMyItemsPlayer.hover ? "Hovered" : "All");
        }
        public override void OnInitialize()
        {
            checklistPanel = new UIPanel();
            checklistPanel.SetPadding(10);
            checklistPanel.Left.Pixels = 0;
            checklistPanel.HAlign      = 1f;
            checklistPanel.Top.Set(50f, 0f);
            checklistPanel.Width.Set(250f, 0f);
            checklistPanel.Height.Set(-100, 1f);
            checklistPanel.BackgroundColor = new Color(73, 94, 171);

            toggleCompletedButton             = new UIHoverImageButton(Main.magicPixel, "Toggle Completed");
            toggleCompletedButton.OnClick    += ToggleCompletedButtonClicked;
            toggleCompletedButton.Left.Pixels = spacing;
            toggleCompletedButton.Top.Pixels  = 0;
            checklistPanel.Append(toggleCompletedButton);

            toggleMiniBossButton             = new UIHoverImageButton(Main.magicPixel, "Toggle Mini Bosses");
            toggleMiniBossButton.OnClick    += ToggleMiniBossButtonClicked;
            toggleMiniBossButton.Left.Pixels = spacing + 32;
            toggleMiniBossButton.Top.Pixels  = 0;
            checklistPanel.Append(toggleMiniBossButton);

            toggleEventButton             = new UIHoverImageButton(Main.magicPixel, "Toggle Events");
            toggleEventButton.OnClick    += ToggleEventButtonClicked;
            toggleEventButton.Left.Pixels = spacing + 64;
            toggleEventButton.Top.Pixels  = 0;
            checklistPanel.Append(toggleEventButton);

            toggleHiddenButton             = new UIHoverImageButton(Main.magicPixel, "Toggle Show Hidden Bosses\n(Alt-Click to clear Hidden bosses)\n(Alt-Click on boss to hide)");
            toggleHiddenButton.OnClick    += ToggleHiddenButtonClicked;
            toggleHiddenButton.Left.Pixels = spacing + 96;
            toggleHiddenButton.Top.Pixels  = 0;
            checklistPanel.Append(toggleHiddenButton);

            checklistList            = new UIList();
            checklistList.Top.Pixels = 32f + spacing;
            checklistList.Width.Set(-25f, 1f);
            checklistList.Height.Set(-32f, 1f);
            checklistList.ListPadding    = 12f;
            checklistList.OnScrollWheel += OnScrollWheel_FixHotbarScroll;
            checklistPanel.Append(checklistList);

            FixedUIScrollbar checklistListScrollbar = new FixedUIScrollbar();

            checklistListScrollbar.SetView(100f, 1000f);
            //checklistListScrollbar.Height.Set(0f, 1f);
            checklistListScrollbar.Top.Pixels = 32f + spacing;
            checklistListScrollbar.Height.Set(-32f - spacing, 1f);
            checklistListScrollbar.HAlign = 1f;
            checklistPanel.Append(checklistListScrollbar);
            checklistList.SetScrollbar(checklistListScrollbar);

            // Checklistlist populated when the panel is shown: UpdateCheckboxes()

            Append(checklistPanel);

            // TODO, game window resize issue
        }
Beispiel #4
0
        private void OnUITabClick(UIMouseEvent evt, UIElement listeningelement)
        {
            UIHoverImageButton button = listeningelement as UIHoverImageButton;

            LastActiveTransformationTab = _tabsForTransformations[_tabButtons[button]];

            InfoPanelOpened = false;
        }
Beispiel #5
0
        public override void OnInitialize()
        {
            UIHoverImageButton Menu_button = new UIHoverImageButton("Creativetools/UI Assets/MenuButton", "Open Menu");

            Menu_button.MarginTop  = 260;
            Menu_button.MarginLeft = 20;
            Menu_button.OnClick   += new MouseEvent(Menu_buttonClicked);
            Append(Menu_button);
        }
Beispiel #6
0
        protected UIHoverImageButton InitializeHoverTextButton(Texture2D texture, string hoverText, MouseEvent onClick, float offsetX, float offsetY, UIElement parent = null)
        {
            UIHoverImageButton button = new UIHoverImageButton(texture, hoverText);

            button.OnClick += onClick;

            InitializeUIElement <UIHoverImageButton>(ref button, texture, offsetX, offsetY, parent);
            return(button);
        }
Beispiel #7
0
        /// <summary>
        /// Creates a UIHoverImageButton with a click event
        /// </summary>
        /// <param name="element">The UIHoverImageButton which should be created</param>
        /// <param name="AppendTo">What UIElement it should append to</param>
        /// <param name="action">The Click Event</param>
        /// <param name="MarginLeft">X Position relative to "AppendTo"</param>
        /// <param name="MarginTop">Y Position relative to "AppendTo"</param>
        /// <param name="HAllign">Percentage X Position relative to "AppendTo"</param>
        /// <param name="VAllign">Percentage Y Position relative to "AppendTo"</param>
        /// <returns></returns>
        public static UIElement ImageButtons(UIHoverImageButton element, UIElement AppendTo, Action <UIElement> action, float MarginLeft = 0, float MarginTop = 0, float HAllign = 0, float VAllign = 0)
        {
            action(element);
            AppendTo.Append(element);
            element.MarginLeft = MarginLeft;
            element.MarginTop  = MarginTop;
            element.HAlign     = HAllign;
            element.VAlign     = VAllign;

            return(element);
        }
        public override void OnInitialize()
        {
            searchBarPanel = new UIPanel();
            searchBarPanel.SetPadding(0);
            //searchBarPanel.Left.Set(0, .5f);
            //searchBarPanel.Top.Set(0, .5f);
            searchBarPanel.Top.Set(50, 0f);
            searchBarPanel.HAlign = 0.5f;
            searchBarPanel.VAlign = 0.5f;
            searchBarPanel.Width.Set(170f, 0f);
            searchBarPanel.Height.Set(30f, 0f);
            searchBarPanel.BackgroundColor = new Color(73, 94, 171);
            searchBarPanel.OnMouseDown    += DragStart;
            searchBarPanel.OnMouseUp      += DragEnd;

            Texture2D          buttonPlayTexture = ModLoader.GetTexture("Terraria/UI/Cursor_2");
            UIHoverImageButton playButton        = new UIHoverImageButton(buttonPlayTexture, "Click to switch peek modes: Show All");

            playButton.Left.Set(5, 0f);
            playButton.Top.Set(5, 0f);
            playButton.OnClick += TogHover;
            searchBarPanel.Append(playButton);

            box = new NewUITextBox("Type here to search", 0.78f);
            box.OnTabPressed += () =>
            {
                if (!string.IsNullOrEmpty(history))
                {
                    box.SetText(history);
                }
            };
            box.BackgroundColor = Color.Transparent;
            box.BorderColor     = Color.Transparent;
            box.Left.Pixels     = 15;
            box.Top.Pixels      = -5;
            box.MinWidth.Pixels = 120;
            box.OnUnfocus      += () =>
            {
                if (!string.IsNullOrEmpty(box.Text))
                {
                    history = box.Text;
                }
                visible = false;
            };
            searchBarPanel.Append(box);

            Append(searchBarPanel);
        }
        public override void OnInitialize()
        {
            Texture2D bpTex = GetTexture("Erilipah/UI/Notes/BackPage");

            backPage = new UIHoverImageButton(bpTex, "Back a page")
            {
                HAlign = 0.0f,
                VAlign = 1.0f
            };
            backPage.Width.Set(32, 0);
            backPage.Height.Set(24, 0);
            backPage.OnClick += BackPage;
            Append(backPage);

            Texture2D tpTex = GetTexture("Erilipah/UI/Notes/TurnPage");

            turnPage = new UIHoverImageButton(tpTex, "Turn page")
            {
                HAlign = 1.0f,
                VAlign = 1.0f
            };
            turnPage.Width.Set(32, 0);
            turnPage.Height.Set(24, 0);
            turnPage.OnClick += TurnPage;
            Append(turnPage);

            Texture2D iuTex = GetTexture("Erilipah/UI/Notes/Index");
            Texture2D ilTex = GetTexture("Erilipah/UI/Notes/IndexLocked");

            indeces = new UIHoverImageButton[pageCount];
            for (int i = 0; i < pageCount; i++)
            {
                float hAlign = i % 6 / 5f;
                float top    = i / 6 * 28;
                indeces[i] = new UIHoverImageButton(CollectedNotes[i] ? iuTex : ilTex, $"{i + 1}")
                {
                    HAlign = hAlign,
                    VAlign = 0
                };
                indeces[i].Top.Set(top, 0);
                indeces[i].Width.Set(24, 0);
                indeces[i].Height.Set(24, 0);
                indeces[i].OnClick += IndexClick;
                Append(indeces[i]);
            }
        }
Beispiel #10
0
        public override void OnInitialize()
        {
            checklistPanel = new UIPanel();
            checklistPanel.SetPadding(10);
            checklistPanel.Left.Pixels = 0;
            checklistPanel.HAlign      = 1f;
            checklistPanel.Top.Set(50f, 0f);
            checklistPanel.Width.Set(250f, 0f);
            checklistPanel.Height.Set(-100, 1f);
            checklistPanel.BackgroundColor = new Color(73, 94, 171);

            toggleButton             = new UIHoverImageButton(Main.itemTexture[ItemID.SuspiciousLookingEye], "Toggle Completed");
            toggleButton.OnClick    += ToggleButtonClicked;
            toggleButton.Left.Pixels = spacing;
            toggleButton.Top.Pixels  = spacing;
            checklistPanel.Append(toggleButton);

            checklistList            = new UIList();
            checklistList.Top.Pixels = 32f + spacing;
            checklistList.Width.Set(0f, 1f);
            checklistList.Height.Set(-32f, 1f);
            checklistList.ListPadding = 12f;
            checklistPanel.Append(checklistList);

            UIScrollbar checklistListScrollbar = new UIScrollbar();

            checklistListScrollbar.SetView(100f, 1000f);
            checklistListScrollbar.Height.Set(0f, 1f);
            checklistListScrollbar.HAlign = 1f;
            checklistPanel.Append(checklistListScrollbar);
            checklistList.SetScrollbar(checklistListScrollbar);

            // Checklistlist populated when the panel is shown: UpdateCheckboxes()

            Append(checklistPanel);

            // TODO, game window resize issue
        }
Beispiel #11
0
        public override void OnInitialize()
        {
            bool      autotrash = Terraria.ModLoader.ModLoader.GetMod("AutoTrash") != null;
            Texture2D showTex   = GetTexture("Erilipah/UI/Notes/ShowNotes");

            showButton = new UIHoverImageButton(showTex, "Show notes");
            showButton.Left.Set(autotrash ? 350 : 410, 0);
            showButton.Top.Set(260, 0);
            showButton.Width.Set(26, 0);
            showButton.Height.Set(28, 0);
            showButton.OnClick += ShowButtonClicked;
            Append(showButton);

            pages = new NoteUIPages {
                HAlign = 0.5f, VAlign = 0.5f
            };
            pages.SetPadding(0);
            pages.Left.Set(0, 0);
            pages.Top.Set(0, 0);
            pages.Width.Set(140 + 20, 0);  // Page size + index width + turn/back page
            pages.Height.Set(162 + 58, 0); // Page size + index height + turn/back page
            Append(pages);
        }
Beispiel #12
0
        // The reason all of this is called in OnPlayerEnterWorld is because the icons themselves don't make it to the UI if the player cannot possibly access them. We need to reset the back panel every time.
        internal void OnPlayerEnterWorld(DBTPlayer dbtPlayer)
        {
            _tabs.Clear();
            _tabButtons.Clear();
            _tabsForTransformations.Clear();

            BackPanel.RemoveAllChildren();
            BackPanel.Append(BackPanelImage);

            List <Node <TransformationDefinition> > rootNodes = TransformationDefinitionManager.Instance.Tree.Nodes
                                                                .Where(t => t.Value.CheckPrePlayerConditions() && t.Value.BaseConditions(dbtPlayer) && t.Value.DoesDisplayInCharacterMenu(dbtPlayer))
                                                                .Where(t => t.Parents.Count == 0).ToList();

            List <Node <TransformationDefinition> > others = new List <Node <TransformationDefinition> >();

            int lastXOffset = 0;

            foreach (Node <TransformationDefinition> rootNode in rootNodes)
            {
                if (rootNode.Value.TransformationIcon.Height > _panelsYOffset)
                {
                    _panelsYOffset = rootNode.Value.TransformationIcon.Height;
                }
            }

            _panelsYOffset += PADDING_Y;

            foreach (Node <TransformationDefinition> rootNode in rootNodes)
            {
                if (rootNode.Children.Count == 0)
                {
                    others.Add(rootNode);
                    continue;
                }

                lastXOffset += PADDING_X * 2;// Prior code: (_tabs.Count + 1); changed due to the spacing growing exponentially with each tab.

                UIHoverImageButton tabButton = InitializeHoverTextButton(rootNode.Value.TransformationIcon, rootNode.Value.TabHoverText, OnUITabClick, lastXOffset, PADDING_Y, BackPanelImage);

                UIPanel tabPanel = new UIPanel()
                {
                    Width  = new StyleDimension(BackPanelTexture.Width - 20, 0),
                    Height = new StyleDimension(BackPanelTexture.Height - (_panelsYOffset + 10 + PADDING_Y), 0),

                    Left = new StyleDimension(0, 0),
                    Top  = new StyleDimension(0, 0),

                    BackgroundColor = Color.Transparent,
                    BorderColor     = rootNode.Value.Appearance.GeneralColor.HasValue ? rootNode.Value.Appearance.GeneralColor.Value : Color.White
                };

                BackPanelImage.Append(tabPanel);

                Tab tab = new Tab(tabButton, tabPanel);
                tab.Panel.Deactivate();

                _tabs.Add(tab);
                _tabButtons.Add(tabButton, tab);
                _tabsForTransformations.Add(tab, rootNode.Value);

                int yOffset = 0;

                RecursiveInitializeTransformation(tab.Panel, rootNode, ref yOffset);

                lastXOffset += rootNode.Value.TransformationIcon.Width;
            }
        }
        public override void OnInitialize()
        {
            base.OnInitialize();
            width     = 500;
            mainPanel = new UIPanel();
            mainPanel.SetPadding(6);
            mainPanel.MinWidth.Set(width, 0);
            mainPanel.BackgroundColor = new Color(173, 94, 171);

            //height = 300;
            //mainPanel.Left.Set(-40f - width, 1f);
            //mainPanel.Top.Set(-110f - height, 1f);
            //mainPanel.Width.Set(width, 0f);
            //mainPanel.Height.Set(height, 0f);

            UIText text = new UIText("Quick Tweak:", 0.85f);

            mainPanel.Append(text);

            UICheckbox privateFieldsCheckbox = new UICheckbox("Private", "Show Private fields");

            privateFieldsCheckbox.Selected = QuickTweakTool.showPrivateFields;
            privateFieldsCheckbox.Left.Set(100, 0);
            privateFieldsCheckbox.OnSelectedChanged += () => {
                QuickTweakTool.showPrivateFields = privateFieldsCheckbox.Selected;
                updateNeeded = true;
            };
            mainPanel.Append(privateFieldsCheckbox);

            UIImageButton resetButton = new UIHoverImageButton(ModContent.GetTexture("Terraria/UI/ButtonDelete"), "Clear Tweaks");

            resetButton.OnClick += (a, b) => {
                QuickTweakTool.tweaks.Clear();
                updateNeeded = true;
            };
            resetButton.Top.Set(height, 0f);
            resetButton.Left.Set(-26, 1f);
            mainPanel.Append(resetButton);

            // Separate page for common things? Save load?
            UIImageButton mountButton = new UIHoverImageButton(ModContent.GetTexture("Terraria/UI/ButtonDelete"), "Edit current mount");

            mountButton.OnClick += (a, b) => {
                if (Main.LocalPlayer.mount._active)
                {
                    //foreach (var field in typeof(Mount.MountData).GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic)) {
                    QuickTweak.QuickTweakTool.AddTweak(Main.LocalPlayer.mount._data, "");
                    //}
                }
                updateNeeded = true;
            };
            mountButton.Top.Set(height, 0f);
            mountButton.Left.Set(-52, 1f);
            mainPanel.Append(mountButton);

            UIImageButton modPlayersButton = new UIHoverImageButton(ModContent.GetTexture("Terraria/UI/ButtonDelete"), "Edit ModPlayers");

            modPlayersButton.OnClick += (a, b) => {
                FieldInfo   modPlayersField = typeof(Player).GetField("modPlayers", BindingFlags.Instance | BindingFlags.NonPublic);
                ModPlayer[] modPlayers      = (ModPlayer[])modPlayersField.GetValue(Main.LocalPlayer);
                foreach (var modPlayer in modPlayers)
                {
                    QuickTweak.QuickTweakTool.AddTweak(modPlayer, "");
                }
                updateNeeded = true;
            };
            modPlayersButton.Top.Set(height, 0f);
            modPlayersButton.Left.Set(-78, 1f);
            mainPanel.Append(modPlayersButton);

            UIImageButton nearestNPCButton = new UIHoverImageButton(ModContent.GetTexture("Terraria/UI/ButtonDelete"), "Nearest NPC");

            nearestNPCButton.OnClick += (a, b) => {
                NPC   closest     = null;
                float minDistance = float.MaxValue;
                for (int k = 0; k < 200; k++)
                {
                    if (Main.npc[k].active)
                    {
                        float distance = Vector2.DistanceSquared(Main.LocalPlayer.Center, Main.npc[k].Center);
                        if (distance < minDistance)
                        {
                            closest     = Main.npc[k];
                            minDistance = distance;
                        }
                    }
                }
                if (closest != null)
                {
                    QuickTweak.QuickTweakTool.AddTweak(closest, closest.GivenOrTypeName);
                    if (closest.modNPC != null)
                    {
                        QuickTweak.QuickTweakTool.AddTweak(closest.modNPC, closest.GivenOrTypeName + " modNPC");
                    }
                }
                FieldInfo   globalNPCsField = typeof(NPC).GetField("globalNPCs", BindingFlags.Instance | BindingFlags.NonPublic);
                GlobalNPC[] globalNPCs      = (GlobalNPC[])globalNPCsField.GetValue(closest);
                foreach (var globalNPC in globalNPCs)
                {
                    QuickTweak.QuickTweakTool.AddTweak(globalNPC, "");
                }
                updateNeeded = true;
            };
            nearestNPCButton.Top.Set(height, 0f);
            nearestNPCButton.Left.Set(-104, 1f);
            mainPanel.Append(nearestNPCButton);

            AppendToAndAdjustWidthHeight(mainPanel, text, ref height, ref width);
            height += 14;

            tweakList = new UIList();
            tweakList.MinHeight.Set(500, 0f);
            tweakList.Width.Set(-25, 1f);
            tweakList.ListPadding = 6f;

            updateNeeded = true;

            var tweakListScrollbar = new UIElements.FixedUIScrollbar(userInterface);

            tweakListScrollbar.SetView(100f, 1000f);
            tweakListScrollbar.Top.Pixels = height;            // + spacing;
            tweakListScrollbar.Height.Set(-height /*- spacing*/, 1f);
            tweakListScrollbar.HAlign = 1f;
            mainPanel.Append(tweakListScrollbar);
            tweakList.SetScrollbar(tweakListScrollbar);
            // minheight and minwidth have to be set for this to work.
            // If adjusting dynamically, mainpanel size not determined yet.
            AppendToAndAdjustWidthHeight(mainPanel, tweakList, ref height, ref width);

            AdjustMainPanelDimensions(mainPanel);
            Append(mainPanel);
        }
Beispiel #14
0
        public override void OnInitialize()
        {
            mainPanel = new NonDragableUIPanel();
            mainPanel.SetPadding(0);
            mainPanel.Left.Set(0f, 0f);
            mainPanel.Top.Set(0f, 0f);
            mainPanel.Width.Set(0f, 1f);
            mainPanel.Height.Set(0f, 1f);


            Texture2D starterselect     = ModContent.GetTexture("Terramon/UI/PossibleAssets/StarterMenuNew");
            UIImagez  starterselectmenu = new UIImagez(starterselect);

            starterselectmenu.Left.Set(0, 0);
            starterselectmenu.Top.Set(0, 0);
            starterselectmenu.Width.Set(1, 0);
            starterselectmenu.Height.Set(1, 0);
            mainPanel.Append(starterselectmenu);

            Texture2D bottomleftcornertexture = ModContent.GetTexture("Terramon/UI/Starter/BottomLeftCorner");
            UIImagez  bottomleftcorner        = new UIImagez(bottomleftcornertexture);

            bottomleftcorner.HAlign = 0f;
            bottomleftcorner.VAlign = 1f;
            bottomleftcorner.Top.Set(0, 0);
            bottomleftcorner.Width.Set(64, 0);
            bottomleftcorner.Height.Set(64, 0);
            mainPanel.Append(bottomleftcorner);

            Texture2D topleftcornertexture = ModContent.GetTexture("Terramon/UI/Starter/TopLeftCorner");
            UIImagez  topleftcorner        = new UIImagez(topleftcornertexture);

            topleftcorner.HAlign = 0f;
            topleftcorner.VAlign = 0f;
            topleftcorner.Top.Set(0, 0);
            topleftcorner.Width.Set(64, 0);
            topleftcorner.Height.Set(64, 0);
            mainPanel.Append(topleftcorner);

            Texture2D bottomrightcornertexture = ModContent.GetTexture("Terramon/UI/Starter/BottomRightCorner");
            UIImagez  bottomrightcorner        = new UIImagez(bottomrightcornertexture);

            bottomrightcorner.HAlign = 1f;
            bottomrightcorner.VAlign = 1f;
            bottomrightcorner.Top.Set(0, 0);
            bottomrightcorner.Width.Set(64, 0);
            bottomrightcorner.Height.Set(64, 0);
            mainPanel.Append(bottomrightcorner);

            Texture2D toprightcornertexture = ModContent.GetTexture("Terramon/UI/Starter/TopRightCorner");
            UIImagez  toprightcorner        = new UIImagez(toprightcornertexture);

            toprightcorner.HAlign = 1f;
            toprightcorner.VAlign = 0f;
            toprightcorner.Top.Set(0, 0);
            toprightcorner.Width.Set(64, 0);
            toprightcorner.Height.Set(64, 0);
            mainPanel.Append(toprightcorner);

            Texture2D test     = ModContent.GetTexture("Terramon/UI/PossibleAssets/Text");
            UIImagez  testmenu = new UIImagez(test);

            testmenu.HAlign = 0.5f;
            testmenu.VAlign = 0.3f;
            testmenu.Width.Set(391, 0);
            testmenu.Height.Set(99, 0);
            mainPanel.Append(testmenu);

            Texture2D          bulbasaurTexture       = ModContent.GetTexture("Terramon/UI/PossibleAssets/Bulbasaur");
            UIHoverImageButton bulbasaurTextureButton = new UIHoverImageButton(bulbasaurTexture, "Bulbasaur");

            bulbasaurTextureButton.HAlign = 0.35f;
            bulbasaurTextureButton.VAlign = 0.5f;
            bulbasaurTextureButton.Width.Set(100, 0f);
            bulbasaurTextureButton.Height.Set(92, 0f);
            bulbasaurTextureButton.OnClick += bulbasaurTextureButtonClicked;
            mainPanel.Append(bulbasaurTextureButton);

            Texture2D          charmanderTexture       = ModContent.GetTexture("Terramon/UI/PossibleAssets/Charmander");
            UIHoverImageButton charmanderTextureButton = new UIHoverImageButton(charmanderTexture, "Charmander");

            charmanderTextureButton.HAlign = 0.5f;
            charmanderTextureButton.VAlign = 0.5f;
            charmanderTextureButton.Width.Set(100, 0f);
            charmanderTextureButton.Height.Set(92, 0f);
            charmanderTextureButton.OnClick += charmanderTextureButtonClicked;
            mainPanel.Append(charmanderTextureButton);

            Texture2D squirtleTexture       = ModContent.GetTexture("Terramon/UI/PossibleAssets/Squirtle");
            UIImagez  squirtleTextureButton = new UIImagez(squirtleTexture);

            squirtleTextureButton.HAlign = 0.65f;
            squirtleTextureButton.VAlign = 0.5f;
            squirtleTextureButton.Width.Set(100, 0f);
            squirtleTextureButton.Height.Set(92, 0f);
            mainPanel.Append(squirtleTextureButton);

            Texture2D charmanderTextTexture = ModContent.GetTexture("Terramon/UI/PossibleAssets/SquirtleText");
            UIImagez  charmanderText        = new UIImagez(charmanderTextTexture);

            charmanderText.HAlign = 0.5f;
            charmanderText.VAlign = 0.7f;
            charmanderText.Width.Set(351, 0);
            charmanderText.Height.Set(65, 0);
            mainPanel.Append(charmanderText);

            Texture2D          chooseTexture = ModContent.GetTexture("Terramon/UI/PossibleAssets/Choose");
            UIHoverImageButton choose        = new UIHoverImageButton(chooseTexture, "Choose Squirtle!");

            choose.HAlign = 0.5f;
            choose.VAlign = 0.8f;
            choose.Width.Set(153, 0);
            choose.Height.Set(43, 0);
            choose.OnClick += Chosen;
            mainPanel.Append(choose);


            Append(mainPanel);
        }
Beispiel #15
0
        public override void OnInitialize()
        {
            playerBackGroundTexture = TextureManager.Load("Images/UI/PlayerBackground");

            teamDPSPanel = new UIDragablePanel();
            teamDPSPanel.SetPadding(6);
            teamDPSPanel.Left.Set(-310f, 0f);
            teamDPSPanel.HAlign = 1f;
            teamDPSPanel.Top.Set(90f, 0f);
            teamDPSPanel.Width.Set(415f, 0f);
            teamDPSPanel.MinWidth.Set(50f, 0f);
            teamDPSPanel.MaxWidth.Set(500f, 0f);
            teamDPSPanel.Height.Set(350, 0f);
            teamDPSPanel.MinHeight.Set(50, 0f);
            teamDPSPanel.MaxHeight.Set(300, 0f);
            teamDPSPanel.BackgroundColor = new Color(73, 94, 171);
            //Append(favoritePanel);

            label          = new UIText("DPS");
            label.OnClick += Label_OnClick;
            teamDPSPanel.Append(label);
            teamDPSPanel.AddDragTarget(label);

            //var togglePercentButton = new UIHoverImageButton(Main.itemTexture[ItemID.SuspiciousLookingEye], "Toggle %");
            var togglePercentButton = new UIHoverImageButton(DPSExtreme.instance.GetTexture("PercentButton"), "Toggle %");

            togglePercentButton.OnClick    += (a, b) => showPercent = !showPercent;
            togglePercentButton.Left.Pixels = 174;
            togglePercentButton.Top.Pixels  = -4;
            //toggleCompletedButton.Top.Pixels = spacing;
            teamDPSPanel.Append(togglePercentButton);

            var labelDimensions = label.GetInnerDimensions();
            int top             = (int)labelDimensions.Height + 4;

            dpsList = new UIGrid();
            dpsList.Width.Set(0, 1f);
            dpsList.Height.Set(-top, 1f);
            dpsList.Top.Set(top, 0f);
            dpsList.ListPadding = 0f;
            teamDPSPanel.Append(dpsList);
            teamDPSPanel.AddDragTarget(dpsList);

            var       type          = Assembly.GetAssembly(typeof(Mod)).GetType("Terraria.ModLoader.UI.Elements.UIGrid");
            FieldInfo loadModsField = type.GetField("_innerList", BindingFlags.Instance | BindingFlags.NonPublic);

            teamDPSPanel.AddDragTarget((UIElement)loadModsField.GetValue(dpsList));             // list._innerList

            bossList = new UIGrid();
            bossList.Width.Set(0, 1f);
            bossList.Height.Set(-top, 1f);
            bossList.Top.Set(top, 0f);
            bossList.ListPadding = 0f;
            //teamDPSPanel.Append(bossList);
            teamDPSPanel.AddDragTarget(bossList);
            teamDPSPanel.AddDragTarget((UIElement)loadModsField.GetValue(bossList));

            var scrollbar = new InvisibleFixedUIScrollbar(userInterface);

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0, 1f);
            scrollbar.Left.Set(-20, 1f);
            teamDPSPanel.Append(scrollbar);
            dpsList.SetScrollbar(scrollbar);

            scrollbar = new InvisibleFixedUIScrollbar(userInterface);
            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0, 1f);
            scrollbar.Left.Set(-20, 1f);
            teamDPSPanel.Append(scrollbar);
            bossList.SetScrollbar(scrollbar);

            //updateNeeded = true;
        }
Beispiel #16
0
        public void InitializeUI()
        {
            RemoveAllChildren();

            linePropertyTarget = LinePropertyTarget.Shapes;

            panelMain = new UIDragablePanel(true, false, false);
            panelMain.SetPadding(6);
            panelMain.Left.Set(438f, 0f);
            panelMain.Top.Set(400f, 0f);
            panelMain.Width.Set(200f, 0f);
            panelMain.MinWidth.Set(200f, 0f);
            panelMain.MaxWidth.Set(Main.screenWidth, 0f);
            panelMain.Height.Set(300, 0f);
            panelMain.MinHeight.Set(300, 0f);
            panelMain.MaxHeight.Set(Main.screenHeight, 0f);
            panelMain.OnClick += (a, b) =>
            {
                inputDistance.InputEnd();
                inputCount.InputEnd();
            };

            Texture2D texture = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/closeButton");

            closeButton          = new UIHoverImageButton(texture, "Close");
            closeButton.OnClick += (a, b) => Show = false;
            closeButton.Left.Set(-20f, 1f);
            closeButton.Top.Set(6f, 0f);
            panelMain.Append(closeButton);

            float   topPos  = 0;
            float   leftPos = menuMargin;
            Vector2 textSize;

            //キャプション
            labelCaption = new UIText("Parallel Copy Setting");
            labelCaption.Left.Set(leftPos, 0f);
            labelCaption.Top.Set(topPos, 0f);
            panelMain.Append(labelCaption);
            panelMain.AddDragTarget(labelCaption);
            textSize = Main.fontMouseText.MeasureString(labelCaption.Text);
            topPos  += textSize.Y * 2;

            //距離:ラベル
            var label = new UIText("Distance (block):");

            label.Left.Set(leftPos, 0f);
            label.Top.Set(topPos, 0f);
            panelMain.Append(label);
            panelMain.AddDragTarget(label);
            textSize = Main.fontMouseText.MeasureString(label.Text);
            topPos  += textSize.Y;
            //距離:インプット
            inputDistance      = new UIInputTextBox((int)Main.fontMouseText.MeasureString("9999").X, 4, true);
            inputDistance.Text = "8";
            inputDistance.Left.Set(leftPos, 0f);
            inputDistance.Top.Set(topPos, 0f);
            inputDistance.OnClick += (a, b) => inputCount.InputEnd();
            panelMain.Append(inputDistance);
            topPos += inputDistance.Height.Pixels + textSize.Y;

            //カウント:ラベル
            label = new UIText("Copy count:");
            label.Left.Set(leftPos, 0f);
            label.Top.Set(topPos, 0f);
            panelMain.Append(label);
            panelMain.AddDragTarget(label);
            textSize = Main.fontMouseText.MeasureString(label.Text);
            topPos  += textSize.Y;
            //カウント:インプット
            inputCount      = new UIInputTextBox((int)Main.fontMouseText.MeasureString("99").X, 2, true);
            inputCount.Text = "10";
            inputCount.Left.Set(leftPos, 0f);
            inputCount.Top.Set(topPos, 0f);
            inputCount.OnClick += (a, b) => inputDistance.InputEnd();
            panelMain.Append(inputCount);
            topPos += inputCount.Height.Pixels + textSize.Y;

            panelMain.MinHeight.Set(topPos, 0f);
            panelMain.Height.Set(topPos, 0f);

            updateNeeded = true;
        }
        // In OnInitialize, we place various UIElements onto our UIState (this class).
        // UIState classes have width and height equal to the full screen, because of this, usually we first define a UIElement that will act as the container for our UI.
        // We then place various other UIElement onto that container UIElement positioned relative to the container UIElement.
        public override void OnInitialize()
        {
            // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features.
            mainPanel = new NonDragableUIPanel();
            mainPanel.SetPadding(0);
            // We need to place this UIElement in relation to its Parent. Later we will be calling `base.Append(mainPanel);`.
            // This means that this class, ExampleUI, will be our Parent. Since ExampleUI is a UIState, the Left and Top are relative to the top left of the screen.
            mainPanel.Left.Set(0f, 0f);
            mainPanel.Top.Set(0f, 0f);
            mainPanel.Width.Set(0f, 1f);
            mainPanel.Height.Set(0f, 1f);

            //pokemon icons



            // Next, we create another UIElement that we will place. Since we will be calling `mainPanel.Append(playButton);`, Left and Top are relative to the top left of the mainPanel UIElement.
            // By properly nesting UIElements, we can position things relatively to each other easily.



            Texture2D starterselect     = ModContent.GetTexture("Terramon/UI/PossibleAssets/StarterMenuNew");
            UIImagez  starterselectmenu = new UIImagez(starterselect);

            starterselectmenu.Left.Set(0, 0);
            starterselectmenu.Top.Set(0, 0);
            starterselectmenu.Width.Set(1, 0);
            starterselectmenu.Height.Set(1, 0);
            mainPanel.Append(starterselectmenu);

            Texture2D bottomleftcornertexture = ModContent.GetTexture("Terramon/UI/Starter/BottomLeftCorner");
            UIImagez  bottomleftcorner        = new UIImagez(bottomleftcornertexture);

            bottomleftcorner.HAlign = 0f;
            bottomleftcorner.VAlign = 1f;
            bottomleftcorner.Top.Set(0, 0);
            bottomleftcorner.Width.Set(64, 0);
            bottomleftcorner.Height.Set(64, 0);
            mainPanel.Append(bottomleftcorner);

            Texture2D topleftcornertexture = ModContent.GetTexture("Terramon/UI/Starter/TopLeftCorner");
            UIImagez  topleftcorner        = new UIImagez(topleftcornertexture);

            topleftcorner.HAlign = 0f;
            topleftcorner.VAlign = 0f;
            topleftcorner.Top.Set(0, 0);
            topleftcorner.Width.Set(64, 0);
            topleftcorner.Height.Set(64, 0);
            mainPanel.Append(topleftcorner);

            Texture2D bottomrightcornertexture = ModContent.GetTexture("Terramon/UI/Starter/BottomRightCorner");
            UIImagez  bottomrightcorner        = new UIImagez(bottomrightcornertexture);

            bottomrightcorner.HAlign = 1f;
            bottomrightcorner.VAlign = 1f;
            bottomrightcorner.Top.Set(0, 0);
            bottomrightcorner.Width.Set(64, 0);
            bottomrightcorner.Height.Set(64, 0);
            mainPanel.Append(bottomrightcorner);

            Texture2D toprightcornertexture = ModContent.GetTexture("Terramon/UI/Starter/TopRightCorner");
            UIImagez  toprightcorner        = new UIImagez(toprightcornertexture);

            toprightcorner.HAlign = 1f;
            toprightcorner.VAlign = 0f;
            toprightcorner.Top.Set(0, 0);
            toprightcorner.Width.Set(64, 0);
            toprightcorner.Height.Set(64, 0);
            mainPanel.Append(toprightcorner);

            Texture2D test     = ModContent.GetTexture("Terramon/UI/PossibleAssets/Text");
            UIImagez  testmenu = new UIImagez(test);

            testmenu.HAlign = 0.5f;  // 1
            testmenu.VAlign = 0.3f;  // 1
            testmenu.Width.Set(391, 0);
            testmenu.Height.Set(99, 0);
            mainPanel.Append(testmenu);

            Texture2D bulbasaurTexture       = ModContent.GetTexture("Terramon/UI/PossibleAssets/Bulbasaur");
            UIImagez  bulbasaurTextureButton = new UIImagez(bulbasaurTexture); // Localized text for "Close"

            bulbasaurTextureButton.HAlign = 0.35f;                             // 1
            bulbasaurTextureButton.VAlign = 0.5f;                              // 1bulbasaurTextureButton.Left.Set(63, 0f);
            bulbasaurTextureButton.Width.Set(100, 0f);
            bulbasaurTextureButton.Height.Set(92, 0f);
            mainPanel.Append(bulbasaurTextureButton);

            Texture2D          charmanderTexture       = ModContent.GetTexture("Terramon/UI/PossibleAssets/Charmander");
            UIHoverImageButton charmanderTextureButton = new UIHoverImageButton(charmanderTexture, "Charmander"); // Localized text for "Close"

            charmanderTextureButton.HAlign = 0.5f;                                                                // 1
            charmanderTextureButton.VAlign = 0.5f;                                                                // 1bulbasaurTextureButton.Left.Set(63, 0f);
            charmanderTextureButton.Width.Set(100, 0f);
            charmanderTextureButton.Height.Set(92, 0f);
            charmanderTextureButton.OnClick += new MouseEvent(charmanderTextureButtonClicked);
            mainPanel.Append(charmanderTextureButton);

            Texture2D          squirtleTexture       = ModContent.GetTexture("Terramon/UI/PossibleAssets/Squirtle");
            UIHoverImageButton squirtleTextureButton = new UIHoverImageButton(squirtleTexture, "Squirtle"); // Localized text for "Close"

            squirtleTextureButton.HAlign = 0.65f;                                                           // 1
            squirtleTextureButton.VAlign = 0.5f;                                                            // 1bulbasaurTextureButton.Left.Set(63, 0f);
            squirtleTextureButton.Width.Set(100, 0f);
            squirtleTextureButton.Height.Set(92, 0f);
            squirtleTextureButton.OnClick += new MouseEvent(squirtleTextureButtonClicked);
            mainPanel.Append(squirtleTextureButton);

            Texture2D bulbasaurTextTexture = ModContent.GetTexture("Terramon/UI/PossibleAssets/BulbasaurText");
            UIImagez  bulbasaurText        = new UIImagez(bulbasaurTextTexture);

            bulbasaurText.HAlign = 0.5f;  // 1
            bulbasaurText.VAlign = 0.69f; // 1
            bulbasaurText.Width.Set(307, 0);
            bulbasaurText.Height.Set(57, 0);
            mainPanel.Append(bulbasaurText);

            Texture2D          chooseTexture = ModContent.GetTexture("Terramon/UI/PossibleAssets/Choose");
            UIHoverImageButton choose        = new UIHoverImageButton(chooseTexture, "Choose Bulbasaur!");

            choose.HAlign = 0.5f; // 1
            choose.VAlign = 0.8f; // 1
            choose.Width.Set(153, 0);
            choose.Height.Set(43, 0);
            choose.OnClick += new MouseEvent(Chosen);
            mainPanel.Append(choose);



            Append(mainPanel);

            // As a recap, ExampleUI is a UIState, meaning it covers the whole screen. We attach mainPanel to ExampleUI some distance from the top left corner.
            // We then place playButton, closeButton, and moneyDiplay onto mainPanel so we can easily place these UIElements relative to mainPanel.
            // Since mainPanel will move, this proper organization will move playButton, closeButton, and moneyDiplay properly when mainPanel moves.
        }
        // In OnInitialize, we place various UIElements onto our UIState (this class).
        // UIState classes have width and height equal to the full screen, because of this, usually we first define a UIElement that will act as the container for our UI.
        // We then place various other UIElement onto that container UIElement positioned relative to the container UIElement.
        public override void OnInitialize()
        {
            // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features.
            // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features.


            //pokemon icons



            // Next, we create another UIElement that we will place. Since we will be calling `mainPanel.Append(playButton);`, Left and Top are relative to the top left of the mainPanel UIElement.
            // By properly nesting UIElements, we can position things relatively to each other easily.
            mainPanel = new DragableUIPanel();
            mainPanel.SetPadding(0);
            // We need to place this UIElement in relation to its Parent. Later we will be calling `base.Append(mainPanel);`.
            // This means that this class, ExampleUI, will be our Parent. Since ExampleUI is a UIState, the Left and Top are relative to the top left of the screen.
            mainPanel.HAlign = 0.4f;
            mainPanel.VAlign = 0.65f;
            mainPanel.Width.Set(180, 0f);
            mainPanel.Height.Set(70f, 0f);

            partyslot1 = new VanillaItemSlotWrapper(ItemSlot.Context.BankItem, 1f);
            partyslot1.SetPadding(0);
            // We need to place this UIElement in relation to its Parent. Later we will be calling `base.Append(mainPanel);`.
            // This means that this class, ExampleUI, will be our Parent. Since ExampleUI is a UIState, the Left and Top are relative to the top left of the screen.
            partyslot1.HAlign        = 0.15f;
            partyslot1.VAlign        = 0.5f;
            partyslot1.ValidItemFunc = item => item.IsAir || TerramonMod.PokeballFactory.GetEnum(item.modItem) != TerramonMod.PokeballFactory.Pokebals.Nothing;
            mainPanel.Append(partyslot1);

            partyslot2 = new VanillaItemSlotWrapper(ItemSlot.Context.BankItem, 1f);
            partyslot2.SetPadding(0);
            // We need to place this UIElement in relation to its Parent. Later we will be calling `base.Append(mainPanel);`.
            // This means that this class, ExampleUI, will be our Parent. Since ExampleUI is a UIState, the Left and Top are relative to the top left of the screen.
            partyslot2.HAlign        = 0.65f;
            partyslot2.VAlign        = 0.5f;
            partyslot2.ValidItemFunc = item => item.IsAir || item.modItem is RareCandy;
            mainPanel.Append(partyslot2);

            PokemonGoesHere        = new UIText("0/0");
            PokemonGoesHere.HAlign = 0.5f;
            PokemonGoesHere.VAlign = 1.5f;
            PokemonGoesHere.SetText("Place a Pokémon in the first slot.");
            mainPanel.Append(PokemonGoesHere);

            RareCandiesGoHere        = new UIText("0/0");
            RareCandiesGoHere.HAlign = 0.5f;
            RareCandiesGoHere.VAlign = 1.7f;
            RareCandiesGoHere.SetText("");
            mainPanel.Append(RareCandiesGoHere);

            Texture2D buttonSaveTexture = ModContent.GetTexture("Terraria/UI/ButtonPlay");

            SaveButton        = new UIHoverImageButton(buttonSaveTexture, "Evolve!"); // Localized text for "Close"
            SaveButton.HAlign = 0.95f;
            SaveButton.VAlign = 0.53f;
            SaveButton.Width.Set(30, 0f);
            SaveButton.Height.Set(30, 0f);
            SaveButton.OnClick += new MouseEvent(EvolveButtonClicked);

            //Texture2D buttonSaveTexture = ModContent.GetTexture("Terraria/UI/ButtonPlay");
            //UIHoverImageButton SaveButton = new UIHoverImageButton(buttonSaveTexture, "Evolve"); // Localized text for "Close"
            //SaveButton.Left.Set(33, 0f);
            //SaveButton.Top.Set(7, 0f);
            //SaveButton.Width.Set(30, 0f);
            //SaveButton.Height.Set(30, 0f);
            //SaveButton.OnClick += new MouseEvent();
            //mainPanel.Append(SaveButton);

            Append(mainPanel);



            // As a recap, ExampleUI is a UIState, meaning it covers the whole screen. We attach mainPanel to ExampleUI some distance from the top left corner.
            // We then place playButton, closeButton, and moneyDiplay onto mainPanel so we can easily place these UIElements relative to mainPanel.
            // Since mainPanel will move, this proper organization will move playButton, closeButton, and moneyDiplay properly when mainPanel moves.
        }
Beispiel #19
0
        public override void OnInitialize()
        {
            base.OnInitialize();
            mainPanel = new UIPanel();
            width     = 310;
            height    = 610;
            mainPanel.SetPadding(6);
            mainPanel.BackgroundColor = Color.Orange * 0.7f;

            int    top  = 0;
            UIText text = new UIText("Projectiles:", 0.85f);

            text.Top.Set(top, 0f);
            mainPanel.Append(text);

            UITextPanel <string> clearProjectilesButton = new UITextPanel <string>("Clear Projectiles");

            clearProjectilesButton.OnClick += (a, b) => {
                for (int i = 0; i < Main.maxProjectiles; i++)
                {
                    if (Main.projectile[i].active)
                    {
                        Main.projectile[i].Kill();
                        if (Main.netMode == 1)
                        {
                            NetMessage.SendData(27, -1, -1, null, i, 0f, 0f, 0f, 0);
                        }
                    }
                }
            };
            clearProjectilesButton.Top.Set(top, 0f);
            clearProjectilesButton.Width.Set(-10, 0.5f);
            clearProjectilesButton.HAlign = 1;
            clearProjectilesButton.SetPadding(4);
            mainPanel.Append(clearProjectilesButton);

            top += 20;

            UIText text2 = new UIText("Filter:", 0.85f);

            text2.Top.Set(top, 0f);
            mainPanel.Append(text2);

            searchFilter = new NewUITextBox("Search", 0.85f);
            searchFilter.SetPadding(0);
            searchFilter.OnTextChanged += () => { ValidateInput(); updateNeeded = true; };
            searchFilter.Top.Set(top, 0f);
            searchFilter.Left.Set(text2.GetInnerDimensions().Width, 0f);
            searchFilter.Width.Set(-text2.GetInnerDimensions().Width, 1f);
            searchFilter.Height.Set(20, 0f);
            //searchFilter.VAlign = 0.5f;
            mainPanel.Append(searchFilter);
            top += 20;

            speedXDataProperty = new UIFloatRangedDataValue("SpeedX:", 0, -10, 10);
            speedYDataProperty = new UIFloatRangedDataValue("SpeedY:", 0, -10, 10);
            var ui2DRange = new UI2DRange <float>(speedXDataProperty, speedYDataProperty);

            ui2DRange.Top.Set(top, 0f);
            mainPanel.Append(ui2DRange);
            top += 30;

            ai0DataProperty = new UIFloatRangedDataValue("ai0:", 0, -10, 10);
            var uiRange = new UIRange <float>(ai0DataProperty);

            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            ai1DataProperty = new UIFloatRangedDataValue("ai1:", 0, -10, 10);
            uiRange         = new UIRange <float>(ai1DataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            knockbackDataProperty = new UIFloatRangedDataValue("Knockback:", 0, 0, 20);
            uiRange = new UIRange <float>(knockbackDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            damageDataProperty = new UIIntRangedDataValue("Damage:", 20, 0, 200);
            var uiRangeI = new UIRange <int>(damageDataProperty);

            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            aiStyleDataProperty = new UIIntRangedDataValue("AIStyle:", -1, -1, 145);
            uiRangeI            = new UIRange <int>(aiStyleDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            drawOffsetXDataProperty = new UIIntRangedDataValue("drawOffsetX:", 0, -30, 30);
            uiRangeI = new UIRange <int>(drawOffsetXDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            drawOriginOffsetXDataProperty = new UIIntRangedDataValue("drawOriginOffsetX:", 0, -30, 30);
            uiRangeI = new UIRange <int>(drawOriginOffsetXDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            drawOriginOffsetYDataProperty = new UIIntRangedDataValue("drawOriginOffsetY:", 0, -30, 30);
            uiRangeI = new UIRange <int>(drawOriginOffsetYDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            hostile = new UIBoolNDataValue("Hostile");
            var hostileCheckbox = new UITriStateCheckbox(hostile);

            hostileCheckbox.Top.Set(top, 0f);
            mainPanel.Append(hostileCheckbox);
            top += 30;

            friendly = new UIBoolNDataValue("Friendly");
            var friendlyCheckbox = new UITriStateCheckbox(friendly);

            friendlyCheckbox.Top.Set(top, 0f);
            mainPanel.Append(friendlyCheckbox);
            top += 25;

            pause = new UICheckbox("Pause", "Pauses All Projectiles (Prevent AI from running)");
            pause.Top.Set(top, 0f);
            mainPanel.Append(pause);

            UIHoverImageButton stepButton = new UIHoverImageButton(ModdersToolkit.Instance.GetTexture("UIElements/next"), "Step");

            stepButton.OnClick += (s, e) => step = true;
            stepButton.Top.Set(top - 6, 0f);
            stepButton.Left.Set(80, 0f);
            mainPanel.Append(stepButton);

            top += 25;

            freeze = new UICheckbox("Freeze", "Zero out velocity during PreAI for All Projectiles");
            freeze.Top.Set(top, 0f);
            mainPanel.Append(freeze);
            top += 25;

            projectileGrid            = new UIGrid(7);
            projectileGrid.Top.Pixels = top;
            //autoTrashGrid.Left.Pixels = spacing;
            projectileGrid.Width.Set(-25f, 1f);             // leave space for scroll?
            projectileGrid.Height.Set(-top, 1f);
            projectileGrid.ListPadding = 6f;
            mainPanel.Append(projectileGrid);

            // this will initialize grid
            updateNeeded = true;

            var projectileGridScrollbar = new UIElements.FixedUIScrollbar(_userInterface);

            projectileGridScrollbar.SetView(100f, 1000f);
            projectileGridScrollbar.Top.Pixels = top;            // + spacing;
            projectileGridScrollbar.Height.Set(-top /*- spacing*/, 1f);
            projectileGridScrollbar.HAlign = 1f;
            mainPanel.Append(projectileGridScrollbar);
            projectileGrid.SetScrollbar(projectileGridScrollbar);

            AdjustMainPanelDimensions(mainPanel);
            Append(mainPanel);
        }
Beispiel #20
0
        public void InitializeUI()
        {
            RemoveAllChildren();

            panelMain                     = new UIDragablePanel(true, true, true);
            panelMain.caption             = caption;
            panelMain.drawCaptionPosition = 1;
            panelMain.SetPadding(6);
            panelMain.Left.Set(438f, 0f);
            panelMain.Top.Set(400f, 0f);
            panelMain.Width.Set(300f, 0f);
            panelMain.MinWidth.Set(300f, 0f);
            panelMain.MaxWidth.Set(Main.screenWidth, 0f);
            panelMain.Height.Set(210, 0f);
            panelMain.MinHeight.Set(210, 0f);
            panelMain.MaxHeight.Set(Main.screenHeight, 0f);

            Texture2D texture = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/closeButton");

            closeButton          = new UIHoverImageButton(texture, "Close");
            closeButton.OnClick += (a, b) => Show = false;
            closeButton.Left.Set(-20f, 1f);
            closeButton.Top.Set(6f, 0f);
            panelMain.Append(closeButton);

            float topPos  = 0;
            float leftPos = menuMargin;

            //ボタン:ロード
            btnLoad = new UIImageListButton(
                new List <Texture2D>()
            {
                Main.itemTexture[ItemID.AlphabetStatueL].Resize(menuIconSize)
            },
                new List <object>()
            {
                0
            },
                new List <string>()
            {
                "Load image"
            },
                0);
            var btn = btnLoad;

            btn.OnClick += (a, b) => LoadImage();
            leftPos     += menuMargin;
            btn.Left.Set(leftPos, 0f);
            btn.Top.Set(topPos, 0f);
            panelMain.Append(btn);

            //ボタン:配置モード
            btnPositionMode = new UIImageListButton(
                new List <Texture2D>()
            {
                Main.itemTexture[ItemID.AlphabetStatueW].Resize(menuIconSize),
                Main.itemTexture[ItemID.AlphabetStatueS].Resize(menuIconSize)
            },
                new List <object>()
            {
                ImagePositionMode.World, ImagePositionMode.Screen
            },
                new List <string>()
            {
                "Image position: World", "Image position: Screen"
            },
                0);
            btn          = btnPositionMode;
            btn.OnClick += (a, b) => btn.NextIamge();
            leftPos     += menuIconSize + menuMargin;
            btn.Left.Set(leftPos, 0f);
            btn.Top.Set(topPos, 0f);
            panelMain.Append(btn);

            //ツールボックス
            panelGrid = new UIPanel();
            var panel = panelGrid;

            panel.SetPadding(6);
            panel.Top.Set(32, 0f);
            panel.Width.Set(0, 1f);
            panel.Height.Set(-40, 1f);
            panelMain.Append(panel);

            grid = new UIGrid();
            grid.Width.Set(-20f, 1f);
            grid.Height.Set(0, 1f);
            grid.ListPadding = 2f;
            panel.Append(grid);

            var scrollbar = new FixedUIScrollbar(userInterface);

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0, 1f);
            scrollbar.Left.Set(-20, 1f);
            panel.Append(scrollbar);
            grid.SetScrollbar(scrollbar);

            slider       = new UISlider();
            slider.Value = 0.8f;
            leftPos     += menuIconSize + menuMargin;
            slider.Left.Set(leftPos, 0f);
            slider.Top.Set(topPos, 0f);
            panelMain.Append(slider);

            updateNeeded = true;
        }
Beispiel #21
0
        public void InitializeUI()
        {
            RemoveAllChildren();

            linePropertyTarget = LinePropertyTarget.Shapes;

            panelMain = new UIDragablePanel(true, false, false);
            panelMain.SetPadding(6);
            panelMain.Left.Set(438f, 0f);
            panelMain.Top.Set(400f, 0f);
            panelMain.Width.Set(200f, 0f);
            panelMain.MinWidth.Set(200f, 0f);
            panelMain.MaxWidth.Set(Main.screenWidth, 0f);
            panelMain.Height.Set(300, 0f);
            panelMain.MinHeight.Set(300, 0f);
            panelMain.MaxHeight.Set(Main.screenHeight, 0f);

            Texture2D texture = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/closeButton");

            closeButton          = new UIHoverImageButton(texture, "Close");
            closeButton.OnClick += (a, b) => Show = false;
            closeButton.Left.Set(-20f, 1f);
            closeButton.Top.Set(6f, 0f);
            panelMain.Append(closeButton);

            float topPos  = 0;
            float leftPos = menuMargin;

            //キャプション
            var label = new UIText("Line Property");

            label.Left.Set(leftPos, 0f);
            label.Top.Set(topPos, 0f);
            panelMain.Append(label);
            panelMain.AddDragTarget(label);
            topPos += Main.fontMouseText.MeasureString("Line Property").Y;

            labelConfig = new UIText[3];
            //設定対象:図形
            labelConfig[0]           = new UIText("Shapes");
            labelConfig[0].TextColor = labelColorSelected;
            labelConfig[0].Left.Set(leftPos, 0f);
            labelConfig[0].Top.Set(topPos, 0f);
            labelConfig[0].OnMouseOver += Label_OnMouseOver;
            labelConfig[0].OnMouseOut  += Label_OnMouseOut;
            labelConfig[0].OnClick     += (a, b) => ChangeConfig(LinePropertyTarget.Shapes);
            panelMain.Append(labelConfig[0]);
            leftPos += Main.fontMouseText.MeasureString("Shapes").X + menuMargin;

            //設定対象:カーソル
            labelConfig[1]           = new UIText("Cursor");
            labelConfig[1].TextColor = labelColorInactive;
            labelConfig[1].Left.Set(leftPos, 0f);
            labelConfig[1].Top.Set(topPos, 0f);
            labelConfig[1].OnMouseOver += Label_OnMouseOver;
            labelConfig[1].OnMouseOut  += Label_OnMouseOut;
            labelConfig[1].OnClick     += (a, b) => ChangeConfig(LinePropertyTarget.Cursor);
            panelMain.Append(labelConfig[1]);
            leftPos += Main.fontMouseText.MeasureString("Cursor").X + menuMargin;

            //設定対象:カーソルスナップ
            labelConfig[2]           = new UIText("Snap");
            labelConfig[2].TextColor = labelColorInactive;
            labelConfig[2].Left.Set(leftPos, 0f);
            labelConfig[2].Top.Set(topPos, 0f);
            labelConfig[2].OnMouseOver += Label_OnMouseOver;
            labelConfig[2].OnMouseOut  += Label_OnMouseOut;
            labelConfig[2].OnClick     += (a, b) => ChangeConfig(LinePropertyTarget.CursorSnap);
            panelMain.Append(labelConfig[2]);
            leftPos += Main.fontMouseText.MeasureString("Snap").X + menuMargin;

            leftPos = menuMargin;
            topPos += Main.fontMouseText.MeasureString("Shapes").Y * 2;

            //線幅
            label = new UIText("Line width:");
            label.Left.Set(leftPos, 0f);
            label.Top.Set(topPos, 0f);
            panelMain.Append(label);
            panelMain.AddDragTarget(label);
            topPos += Main.fontMouseText.MeasureString("Line width:").Y;

            sliderWidth = new UISlider(1, 16);
            sliderWidth.Left.Set(leftPos, 0f);
            sliderWidth.Top.Set(topPos, 0f);
            sliderWidth.OnChanged += SliderWidth_OnChanged;
            panelMain.Append(sliderWidth);
            topPos += sliderWidth.Height.Pixels;

            //線色
            label = new UIText("Line color:");
            label.Left.Set(leftPos, 0f);
            label.Top.Set(topPos, 0f);
            panelMain.Append(label);
            panelMain.AddDragTarget(label);
            topPos += Main.fontMouseText.MeasureString("Line color:").Y;

            sliderColor = new UISliderColor();
            sliderColor.Left.Set(leftPos, 0f);
            sliderColor.Top.Set(topPos, 0f);
            sliderColor.OnChanged += SliderColor_OnChanged;
            panelMain.Append(sliderColor);
            topPos += sliderColor.Height.Pixels;

            //透過率
            label = new UIText("Color transmittance:");
            label.Left.Set(leftPos, 0f);
            label.Top.Set(topPos, 0f);
            panelMain.Append(label);
            panelMain.AddDragTarget(label);
            topPos += Main.fontMouseText.MeasureString("Color transmittance:").Y;

            sliderTransmittance = new UISlider();
            sliderTransmittance.Left.Set(leftPos, 0f);
            sliderTransmittance.Top.Set(topPos, 0f);
            sliderTransmittance.OnChanged += SliderTransmittance_OnChanged;
            panelMain.Append(sliderTransmittance);
            topPos += sliderTransmittance.Height.Pixels * 2;

            panelMain.MinHeight.Set(topPos, 0f);
            panelMain.Height.Set(topPos, 0f);

            updateNeeded = true;
        }
Beispiel #22
0
        public override void OnInitialize()
        {
            Camera.fixedscreen = Main.LocalPlayer.position - new Vector2(Main.screenWidth / 2, Main.screenHeight / 2);

            TabPanel Menu = new TabPanel(400, 350,
                                         new Tab("Better Zoom", new BZUI()),
                                         new Tab(" Camera Control", this)
                                         );

            Menu.Left.Set(DragableUIPanel.lastPos.X, 0f);
            Menu.Top.Set(DragableUIPanel.lastPos.Y, 0f);
            Menu.OnCloseBtnClicked += () => ModContent.GetInstance <BetterZoom>().userInterface.SetState(null);
            Append(Menu);

            speed = new UIFloatRangedDataValue("Tracking Speed", 1, 0.1f, 100);
            var speedSldr = new UIRange <float>(speed);

            speedSldr.Width.Set(0, 1);
            speedSldr.MarginTop  = 50;
            speedSldr.MarginLeft = -20;
            Menu.Append(speedSldr);

            Menu.Append(new UIText("Control Trackers: ")
            {
                MarginTop = 130, MarginLeft = 210
            });

            UIHoverImageButton PathTrackerBtn = new UIHoverImageButton("BetterZoom/Assets/PathTrackerButton", "Place Path tracker");

            PathTrackerBtn.OnClick   += (evt, elm) => placing = TrackerID.PathTracker;
            PathTrackerBtn.MarginLeft = 245;
            PathTrackerBtn.MarginTop  = 155;
            Menu.Append(PathTrackerBtn);

            UIHoverImageButton EraseTrackerBtn = new UIHoverImageButton("BetterZoom/Assets/EraserButton", "Erase Trackers");

            EraseTrackerBtn.OnClick   += (evt, elm) => erasing = !erasing;
            EraseTrackerBtn.MarginLeft = 245;
            EraseTrackerBtn.MarginTop  = 190;
            Menu.Append(EraseTrackerBtn);

            UIHoverImageButton DelBtn = new UIHoverImageButton("BetterZoom/Assets/DelButton", "Delete all Trackers");

            DelBtn.OnClick   += DeleteAll;
            DelBtn.MarginLeft = 285;
            DelBtn.MarginTop  = 190;
            Menu.Append(DelBtn);

            UIHoverImageButton EntityBtn = new UIHoverImageButton("BetterZoom/Assets/EntityTrackerButton", "Place Entity Tracker");

            EntityBtn.OnClick   += ToggleEnityTracker;
            EntityBtn.MarginLeft = 285;
            EntityBtn.MarginTop  = 155;
            Menu.Append(EntityBtn);

            UIHoverImageButton MoveBtn = new UIHoverImageButton("BetterZoom/Assets/MoveButton", "Move Path Tracker");

            MoveBtn.OnClick   += (evt, elm) => moving = !moving;
            MoveBtn.MarginLeft = 325;
            MoveBtn.MarginTop  = 190;
            Menu.Append(MoveBtn);

            lockScreenBtn            = new UIToggleImage(TextureManager.Load("Images/UI/Settings_Toggle"), 13, 13, new Point(17, 1), new Point(1, 1));
            lockScreenBtn.MarginTop  = 100;
            lockScreenBtn.MarginLeft = 250;
            lockScreenBtn.OnClick   += (evt, elm) => Camera.ToggleLock();
            lockScreenBtn.Append(new UIText("Lock Screen", 0.9f)
            {
                MarginLeft = -230
            });
            Menu.Append(lockScreenBtn);

            Menu.Append(new UIText("Control Screen: ")
            {
                MarginTop = 130, MarginLeft = 20
            });

            // Dpad
            var Dpad = UIHelper.Dpad(60, 155);

            for (int i = 0; i < Dpad.Length; i++)
            {
                Menu.Append(Dpad[i]);
            }

            Dpad[0].OnMouseDown += (evt, elm) => Camera.MoveRelativeTo(new Vector2(0, -5f));
            Dpad[1].OnMouseDown += (evt, elm) => Camera.MoveRelativeTo(new Vector2(0, 5f));
            Dpad[2].OnMouseDown += (evt, elm) => Camera.MoveRelativeTo(new Vector2(-5f, 0));
            Dpad[3].OnMouseDown += (evt, elm) => Camera.MoveRelativeTo(new Vector2(5f, 0));

            var hideTrackersBtn = new UIToggleImage(TextureManager.Load("Images/UI/Settings_Toggle"), 13, 13, new Point(17, 1), new Point(1, 1));

            hideTrackersBtn.MarginTop  = 250;
            hideTrackersBtn.MarginLeft = 250;
            hideTrackersBtn.OnClick   += (evt, elm) => TrackerUI.hide = !TrackerUI.hide;
            hideTrackersBtn.Append(new UIText("Hide Trackers", 0.9f)
            {
                MarginLeft = -230
            });
            Menu.Append(hideTrackersBtn);

            // Control Buttons
            playButton          = new UITextPanel <string>("Play");
            playButton.VAlign   = 0.9f;
            playButton.HAlign   = 0.1f;
            playButton.OnClick += (evt, elm) => Camera.PlayStopTracking();
            Menu.Append(playButton);

            UITextPanel <string> pauseButton = new UITextPanel <string>("Pause");

            pauseButton.VAlign   = 0.9f;
            pauseButton.HAlign   = 0.5f;
            pauseButton.OnClick += (evt, elm) =>
            {
                Camera.PauseTracking();
                pauseButton.SetText(text: Camera.Playing ? "Pause" : "Resume");
            };
            Menu.Append(pauseButton);

            var repeatBtn = new UITextPanel <string>("Repeat");

            repeatBtn.VAlign   = 0.9f;
            repeatBtn.HAlign   = 0.9f;
            repeatBtn.OnClick += (evt, elm) =>
            {
                Camera.repeat = !Camera.repeat;
                repeatBtn.SetText(text: Camera.repeat ? "End" : "Repeat");
            };
            Menu.Append(repeatBtn);
        }
Beispiel #23
0
        // Color slider
        // customdata?
        // random jitter on all floats?

        // TODO, browser and Eyedropper, and Intents-Open other tool to select from it.
        public override void OnInitialize()
        {
            mainPanel = new UIPanel();
            //mainPanel.SetPadding(0);
            mainPanel.Left.Set(-290f, 1f);
            mainPanel.Top.Set(-620f, 1f);
            mainPanel.Width.Set(240f, 0f);
            mainPanel.Height.Set(520f, 0f);
            mainPanel.SetPadding(12);
            mainPanel.BackgroundColor = new Color(173, 194, 171);

            int top = 0;

            UIText text = new UIText("Dust:", 0.85f);

            text.Top.Set(top, 0f);
            //text.Left.Set(12f, 0f);
            mainPanel.Append(text);

            UITextPanel <string> resetButton = new UITextPanel <string>("Reset Tool");

            resetButton.SetPadding(4);
            resetButton.Width.Set(-10, 0.5f);
            resetButton.Left.Set(0, 0.5f);
            resetButton.Top.Set(top, 0f);
            resetButton.OnClick += ResetButton_OnClick;
            mainPanel.Append(resetButton);

            top += 20;
            noGravityCheckbox = new UICheckbox("No Gravity", "");
            noGravityCheckbox.Top.Set(top, 0f);
            //gravityCheckbox.Left.Set(12f, 0f);
            mainPanel.Append(noGravityCheckbox);

            top            += 20;
            noLightCheckbox = new UICheckbox("No Light", "");
            noLightCheckbox.Top.Set(top, 0f);
            mainPanel.Append(noLightCheckbox);

            top += 20;
            showSpawnRectangleCheckbox = new UICheckbox("Show Spawn Rectangle", "");
            showSpawnRectangleCheckbox.Top.Set(top, 0f);
            mainPanel.Append(showSpawnRectangleCheckbox);

            top += 30;
            scaleDataProperty = new UIFloatRangedDataValue("Scale:", 1f, 0, 5f);
            UIElement uiRange = new UIRange <float>(scaleDataProperty);

            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);

            top += 30;
            widthDataProperty = new UIIntRangedDataValue("Width:", 30, 0, 400);
            uiRange           = new UIRange <int>(widthDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);

            top += 30;
            heightDataProperty = new UIIntRangedDataValue("Height:", 30, 0, 400);
            uiRange            = new UIRange <int>(heightDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);

            top += 30;
            UIImageButton b = new UIImageButton(ModdersToolkit.instance.GetTexture("UIElements/searchIcon"));

            b.OnClick += (s, e) => { ShowDustChooser = !ShowDustChooser; Recalculate(); };
            b.Top.Set(top, 0f);
            mainPanel.Append(b);

            typeDataProperty = new IntDataRangeProperty("Type:", 1, DustTool.dustCount, true);             //TODO fix.
            typeDataProperty.range.Top.Set(top, 0f);
            typeDataProperty.range.Left.Set(20, 0f);
            typeDataProperty.range.Width.Set(-20, 1f);
            mainPanel.Append(typeDataProperty.range);

            //top += 30;
            //UIImageButton b = new UIImageButton(ModdersToolkit.instance.GetTexture("UIElements/eyedropper"));

            dustChooserUI = new DustChooserUI(userInterface);

            top += 30;
            useCustomColorCheckbox = new UICheckbox("Use Custom Color", "");
            useCustomColorCheckbox.Top.Set(top, 0f);
            mainPanel.Append(useCustomColorCheckbox);

            top += 20;
            colorDataProperty = new ColorDataRangeProperty("Color:");
            colorDataProperty.range.Top.Set(top, 0f);
            mainPanel.Append(colorDataProperty.range);

            top += 30;
            alphaDataProperty = new UIIntRangedDataValue("Alpha:", 0, 0, 255);
            uiRange           = new UIRange <int>(alphaDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);

            top += 30;
            shaderDataProperty = new UIIntRangedDataValue("Shader:", 0, 0, DustTool.shaderCount);
            uiRange            = new UIRange <int>(shaderDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);

            top += 30;
            speedXDataProperty = new UIFloatRangedDataValue("SpeedX:", 0, -10, 10);
            uiRange            = new UIRange <float>(speedXDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);

            top += 30;
            speedYDataProperty = new UIFloatRangedDataValue("SpeedY:", 0, -10, 10);
            uiRange            = new UIRange <float>(speedYDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);

            //todo, position this better? displays as well?
            //		top += 30;
            //		var ui2DRange = new UI2DRange<float>(speedXDataProperty, speedYDataProperty);
            //		ui2DRange.Top.Set(top, 0f);
            //		//ui2DRange.Width.Set(0, 1f);
            //		mainPanel.Append(ui2DRange);

            top += 30;
            fadeInDataProperty = new UIFloatRangedDataValue("FadeIn:", 0, 0, 3);
            uiRange            = new UIRange <float>(fadeInDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);

            top += 30;
            spawnChanceDataProperty = new UIFloatRangedDataValue("Spawn%:", 1f, 0, 1, true, true);
            uiRange = new UIRange <float>(spawnChanceDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);

            top += 24;
            UIRadioButtonGroup g = new UIRadioButtonGroup();

            NewDustRadioButton        = new UIRadioButton("NewDust", "Dust.NewDust method");
            NewDustPerfectRadioButton = new UIRadioButton("NewDustPerfect", "Dust.NewDust method");
            NewDustDirectRadioButton  = new UIRadioButton("NewDustDirect", "Dust.NewDust method");
            g.Add(NewDustRadioButton);
            g.Add(NewDustPerfectRadioButton);
            g.Add(NewDustDirectRadioButton);
            g.Top.Pixels = top;
            g.Width.Set(0, .75f);
            mainPanel.Append(g);
            NewDustRadioButton.Selected = true;

            UIHoverImageButton copyCodeButton = new UIHoverImageButton(ModdersToolkit.instance.GetTexture("UIElements/CopyCodeButton"), "Copy code to clipboard");

            copyCodeButton.OnClick += CopyCodeButton_OnClick;
            copyCodeButton.Top.Set(-20, 1f);
            copyCodeButton.Left.Set(-20, 1f);
            mainPanel.Append(copyCodeButton);

            Append(mainPanel);
        }
        internal void UpdateList()
        {
            if (!updateNeeded)
            {
                return;
            }
            updateNeeded = false;

            BindingFlags bindingFlags = QuickTweakTool.showPrivateFields ? BindingFlags.Public | BindingFlags.NonPublic : BindingFlags.Public;

            tweakList.Clear();
            foreach (var tweakEntry in QuickTweakTool.tweaks)
            {
                object tweakItem = tweakEntry.item;
                string label     = tweakEntry.label;

                List <(object, FieldInfo)> FieldsToDisplay = new List <(object, FieldInfo)>();
                if (tweakItem is Type type)
                {
                    foreach (var field in type.GetFields(bindingFlags | BindingFlags.Static))
                    {
                        FieldsToDisplay.Add((null, field));
                    }
                }
                else if (tweakItem is FieldInfo FieldInfo)
                {
                    FieldsToDisplay.Add((null, FieldInfo));
                }
                else if (tweakItem is ValueTuple <object, FieldInfo> tuple)
                {
                    FieldsToDisplay.Add(((object, FieldInfo))tweakItem);
                    //instance = tuple.Item1;
                    //item = tuple.Item2;
                }
                else if (tweakItem is ValueTuple <object, string> stringtuple)
                {
                    FieldInfo fieldInfo = stringtuple.Item1.GetType().GetField(stringtuple.Item2, bindingFlags | BindingFlags.Instance);
                    if (fieldInfo != null)
                    {
                        FieldsToDisplay.Add(((object, FieldInfo))(stringtuple.Item1, fieldInfo));
                    }
                    else
                    {
                        Main.NewText($"Field not found: {stringtuple.Item2} in {stringtuple.Item1.GetType().Name}");
                    }
                }
                else if (tweakItem is object)
                {
                    foreach (FieldInfo field in tweakItem.GetType().GetFields(bindingFlags | BindingFlags.Instance))
                    {
                        FieldsToDisplay.Add((tweakItem, field));
                    }
                }

                // Pass in "additionalOnChanged" probably, to handle UI updates?
                // CreateUIElementFromObjectAndField(instance, item);
                // -> object will do recursion.
                // place element on Panel or in List.

                // Need dictionary of expected/known ranges for various field names?

                var panel = new UIPanel();
                panel.SetPadding(6);
                panel.BackgroundColor = Color.LightCoral * 0.7f;
                int top = 0;

                var header = new UIText(label != "" ? label : tweakItem.ToString());
                panel.Append(header);

                UIImageButton removeButton = new UIHoverImageButton(ModContent.GetTexture("Terraria/UI/ButtonDelete"), "Remove");
                removeButton.OnClick += (a, b) => {
                    QuickTweakTool.tweaks.Remove(tweakEntry);
                    updateNeeded = true;
                };
                removeButton.Top.Set(top, 0f);
                removeButton.Left.Set(-22, 1f);
                panel.Append(removeButton);

                top += 20;

                foreach (var fieldToDisplay in FieldsToDisplay)
                {
                    object    instance  = fieldToDisplay.Item1;
                    FieldInfo fieldInfo = fieldToDisplay.Item2;

                    if (fieldInfo.FieldType == typeof(bool))
                    {
                        var dataElement = new UIBoolDataValue(fieldInfo.Name);
                        dataElement.DataGetter = () => (bool)fieldInfo.GetValue(instance);
                        dataElement.DataSetter = (value) => fieldInfo.SetValue(instance, value);
                        AppendToAndIncrement(panel, new UICheckbox2(dataElement), ref top);
                    }
                    else if (fieldInfo.FieldType == typeof(int))
                    {
                        RangeAttribute rangeAttribute = (RangeAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(RangeAttribute));
                        int            min            = 0;
                        int            max            = 100;
                        if (rangeAttribute != null && rangeAttribute.min is int && rangeAttribute.max is int)
                        {
                            min = (int)rangeAttribute.min;
                            max = (int)rangeAttribute.max;
                        }
                        var dataElement = new UIIntRangedDataValue(fieldInfo.Name, min: min, max: max);
                        dataElement.DataGetter = () => (int)fieldInfo.GetValue(instance);
                        dataElement.DataSetter = (value) => fieldInfo.SetValue(instance, value);
                        AppendToAndIncrement(panel, new UIRange <int>(dataElement), ref top);
                    }
                    else if (fieldInfo.FieldType == typeof(float))
                    {
                        RangeAttribute rangeAttribute = (RangeAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(RangeAttribute));
                        float          min            = -1f;
                        float          max            = 1f;
                        if (rangeAttribute != null && rangeAttribute.min is float && rangeAttribute.max is float)
                        {
                            max = (float)rangeAttribute.max;
                            min = (float)rangeAttribute.min;
                        }
                        if (rangeAttribute != null && rangeAttribute.min is int && rangeAttribute.max is int)
                        {
                            min = (int)rangeAttribute.min;
                            max = (int)rangeAttribute.max;
                        }
                        var dataElement = new UIFloatRangedDataValue(fieldInfo.Name, .4f, min, max);
                        dataElement.DataGetter = () => (float)fieldInfo.GetValue(instance);
                        dataElement.DataSetter = (value) => fieldInfo.SetValue(instance, value);
                        AppendToAndIncrement(panel, new UIRange <float>(dataElement), ref top);
                    }
                }
                panel.Height.Set(top + panel.PaddingBottom + PaddingTop, 0f);
                panel.Width.Set(0, 1f);
                tweakList.Add(panel);
            }
        }
Beispiel #25
0
        public void InitializeUI()
        {
            RemoveAllChildren();

            panelMain                     = new UIDragablePanel(true, true, true);
            panelMain.caption             = caption;
            panelMain.drawCaptionPosition = 0;
            panelMain.SetPadding(6);
            panelMain.Left.Set(240f, 0f);
            panelMain.Top.Set(400f, 0f);
            panelMain.Width.Set(196f, 0f);
            panelMain.MinWidth.Set(196f, 0f);
            panelMain.MaxWidth.Set(Main.screenWidth, 0f);
            panelMain.Height.Set(142, 0f);
            panelMain.MinHeight.Set(110, 0f);
            panelMain.MaxHeight.Set(Main.screenHeight, 0f);

            Texture2D texture = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/closeButton");

            closeButton          = new UIHoverImageButton(texture, "Close");
            closeButton.OnClick += (a, b) => Show = false;
            closeButton.Left.Set(-20f, 1f);
            //closeButton.Top.Set(6f, 0f);
            closeButton.Top.Set(0f, 0f);
            panelMain.Append(closeButton);

            //float topPos = menuMargin + Main.fontMouseText.MeasureString(caption).Y;
            float topPos  = 0;
            float leftPos = 0;

            //ボタン:レンジ矩形
            texture      = ModLoader.GetMod("TeraCAD").GetTexture("UIElements/rangeRectangle");
            btnRangeRect = new UIImageListButton(
                new List <Texture2D>()
            {
                texture, texture
            },
                new List <object>()
            {
                true, false
            },
                new List <string>()
            {
                "Display range rectangle: On", "Display range rectangle: Off"
            },
                1);
            btnRangeRect.OnClick += (a, b) =>
            {
                btnRangeRect.NextIamge();
                btnRangeRect.visibilityActive = btnRangeRect.visibilityInactive = btnRangeRect.GetValue <bool>() ? 1.0f : 0.4f;
            };
            leftPos += menuMargin;
            btnRangeRect.Left.Set(leftPos, 0f);
            btnRangeRect.Top.Set(topPos, 0f);
            panelMain.Append(btnRangeRect);

            //ボタン:フライカメラ
            btnFlyCam = new UIImageListButton(
                new List <Texture2D>()
            {
                Main.itemTexture[ItemID.AngelWings].Resize(menuIconSize),
                Main.itemTexture[ItemID.AngelWings].Resize(menuIconSize),
            },
                new List <object>()
            {
                true, false
            },
                new List <string>()
            {
                "Fly cam: On", "Fly cam: Off"
            },
                1);
            btnFlyCam.OnClick += (a, b) =>
            {
                btnFlyCam.NextIamge();
                FlyCam.Enabled             = btnFlyCam.GetValue <bool>();
                btnFlyCam.visibilityActive = btnFlyCam.visibilityInactive = btnFlyCam.GetValue <bool>() ? 1.0f : 0.4f;
            };
            leftPos += menuMargin + menuIconSize;
            btnFlyCam.Left.Set(leftPos, 0f);
            btnFlyCam.Top.Set(topPos, 0f);
            panelMain.Append(btnFlyCam);

            //ボタン:レンジ
            btnRange = new UIImageListButton(
                new List <Texture2D>()
            {
                Main.itemTexture[ItemID.Toolbelt].Resize(menuIconSize),
                Main.itemTexture[ItemID.Toolbelt].Resize(menuIconSize),
            },
                new List <object>()
            {
                true, false
            },
                new List <string>()
            {
                "Infinity range: On", "Infinity range: Off"
            },
                1);
            btnRange.OnClick += (a, b) =>
            {
                btnRange.NextIamge();
                btnRange.visibilityActive = btnRange.visibilityInactive = btnRange.GetValue <bool>() ? 1.0f : 0.4f;
            };
            leftPos += menuMargin + menuIconSize;
            btnRange.Left.Set(leftPos, 0f);
            btnRange.Top.Set(topPos, 0f);
            panelMain.Append(btnRange);

            //ボタン:スナップ
            btnSnap = new UIImageListButton(
                (new ImageList(ModLoader.GetMod("TeraCAD").GetTexture("ToolUI/Snap"), 28, 28)).listTexture,
                new List <object>()
            {
                SnapType.TopLeft,
                SnapType.TopCenter,
                SnapType.TopRight,
                SnapType.LeftCenter,
                SnapType.Center,
                SnapType.RightCenter,
                SnapType.BottomLeft,
                SnapType.BottomCenter,
                SnapType.BottomRight,
            },
                new List <string>()
            {
                "Snap: TopLeft",
                "Snap: TopCenter",
                "Snap: TopRight",
                "Snap: LeftCenter",
                "Snap: Center",
                "Snap: RightCenter",
                "Snap: BottomLeft",
                "Snap: BottomCenter",
                "Snap: BottomRight",
            },
                0);
            btnSnap.OnClick += (a, b) =>
            {
                btnSnap.NextIamge();
                ToolBox.snapType = btnSnap.GetValue <SnapType>();
            };
            btnSnap.OnRightClick += (a, b) =>
            {
                btnSnap.PrevIamge();
                ToolBox.snapType = btnSnap.GetValue <SnapType>();
            };
            leftPos += menuMargin + menuIconSize;
            btnSnap.Left.Set(leftPos, 0f);
            btnSnap.Top.Set(topPos, 0f);
            panelMain.Append(btnSnap);

            //ボタン:コンフィグ
            var btnConfig = new UIImageListButton(
                new List <Texture2D>()
            {
                Main.itemTexture[ItemID.Cog].Resize(menuIconSize),
            },
                new List <object>()
            {
                0
            },
                new List <string>()
            {
                "Show Line Property"
            },
                0);

            btnConfig.OnClick += (a, b) => LinePropertyUI.instance.Show = !LinePropertyUI.instance.Show;
            leftPos           += menuMargin + menuIconSize;
            btnConfig.Left.Set(leftPos, 0f);
            btnConfig.Top.Set(topPos, 0f);
            panelMain.Append(btnConfig);

            topPos += menuIconSize + menuMargin;

            //ツールボックス
            panelTool = new UIPanel();
            panelTool.SetPadding(6);
            panelTool.Top.Set(topPos, 0f);
            panelTool.Width.Set(0, 1f);
            panelTool.Height.Set(-52, 1f);
            panelMain.Append(panelTool);

            gridTool = new UIGrid();
            gridTool.Width.Set(-20f, 1f);
            gridTool.Height.Set(0, 1f);
            gridTool.ListPadding = 2f;
            panelTool.Append(gridTool);

            var scrollbar = new FixedUIScrollbar(userInterface);

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0, 1f);
            scrollbar.Left.Set(-20, 1f);
            panelTool.Append(scrollbar);
            gridTool.SetScrollbar(scrollbar);

            //シェイプツール
            var imageList = new ImageList(ModLoader.GetMod("TeraCAD").GetTexture("ToolUI/ShapeTools"), 28, 28);

            //選択ツール
            var btnSelect = new UISlotTool(imageList[0], ToolType.Select, gridTool.Count, "Selecct");

            btnSelect.OnClick += (a, b) => ToolBox.Select(btnSelect);
            gridTool.Add(btnSelect);
            //直線ツール
            var btnLine = new UISlotTool(imageList[1], ToolType.Line, gridTool.Count, "Line");

            btnLine.OnClick += (a, b) => ToolBox.Select(btnLine);
            gridTool.Add(btnLine);
            //矩形ツール
            var btnRect = new UISlotTool(imageList[2], ToolType.Rect, gridTool.Count, "Recangle");

            btnRect.OnClick += (a, b) => ToolBox.Select(btnRect);
            gridTool.Add(btnRect);
            //円ツール
            var btnCircle = new UISlotTool(imageList[3], ToolType.Circle, gridTool.Count, "Circle");

            btnCircle.OnClick += (a, b) => ToolBox.Select(btnCircle);
            gridTool.Add(btnCircle);
            //楕円ツール
            //var btnEllipse = new UISlotTool(imageList[4], ToolType.Ellipse, gridTool.Count, "Ellipse");
            //btnEllipse.OnClick += (a, b) => ToolBox.Select(btnEllipse);
            //gridTool.Add(btnEllipse);
            //イメージツール
            var btnImage = new UISlotTool(Main.itemTexture[ItemID.TheCursedMan], ToolType.Image, gridTool.Count, "Image");

            btnImage.OnClick += (a, b) =>
            {
                ToolBox.Select(btnImage);
                ImageUI.instance.Show = btnImage.isSelect;
            };
            gridTool.Add(btnImage);
            //削除ツール
            var btnEraser = new UISlotTool(imageList[5], ToolType.Eraser, gridTool.Count, "Eraser");

            btnEraser.OnClick += (a, b) => ToolBox.Select(btnEraser);
            gridTool.Add(btnEraser);
            //全削除ツール
            var btnAllClear = new UISlotTool(Main.trashTexture.Resize(menuIconSize), ToolType.AllClear, gridTool.Count, "All Clear");

            btnAllClear.OnClick += (a, b) => ToolBox.Select(btnAllClear);
            gridTool.Add(btnAllClear);
            //平行コピー
            var btnParallelCopy = new UISlotTool(imageList[6], ToolType.ParallelCopy, gridTool.Count, "Parallel Copy");

            btnParallelCopy.OnClick += (a, b) => ToolBox.Select(btnParallelCopy);
            gridTool.Add(btnParallelCopy);

            updateNeeded = true;
        }
Beispiel #26
0
        public override void OnInitialize()
        {
            keyboardPanel = new UIPanel();
            keyboardPanel.SetPadding(8);
            keyboardPanel.Left.Set(-550f, 1f);
            keyboardPanel.Top.Set(-370f, 1f);
            keyboardPanel.Width.Set(500f, 0f);
            keyboardPanel.Height.Set(300f, 0f);
            keyboardPanel.BackgroundColor = new Color(73, 94, 171);

            codeTextBox = new NewUITextBoxMultiLine("Type code here", 1f);
            codeTextBox.SetUnfocusKeys(false, false);
            codeTextBox.BackgroundColor = Color.Transparent;
            codeTextBox.BorderColor     = Color.Transparent;
            codeTextBox.Left.Pixels     = 0;
            codeTextBox.Top.Pixels      = 0;
            codeTextBox.Width.Set(-20, 1f);
            //filterTextBox.OnTextChanged += () => { filterText = filterTextBox.Text; updateneeded = true; };
            codeTextBox.OnEnterPressed += EnterAction;
            codeTextBox.OnTabPressed   += TabAction;
            codeTextBox.OnUpPressed    += UpAction;
            //keyboardPanel.Append(codeTextBox);

            replOutput = new UIList();
            replOutput.Width.Set(-25f, 1f);             // left spacing plus scrollbar
            //replOutput.Height.Set(-codeTextBox.GetDimensions().Height - 32, 1f);
            replOutput.Height.Set(-26, 1f);
            replOutput.Left.Set(0, 0f);
            //replOutput.Top.Set(codeTextBox.GetDimensions().Height, 0f);
            replOutput.Top.Set(0, 0f);
            replOutput.ListPadding = 10f;
            replOutput.Add(codeTextBox);
            keyboardPanel.Append(replOutput);

            keyboardScrollbar = new UIElements.FixedUIScrollbar(userInterface);
            keyboardScrollbar.SetView(100f, 1000f);
            keyboardScrollbar.Top.Pixels = codeTextBox.GetDimensions().Height;
            keyboardScrollbar.Height.Set(-26, 1f);
            keyboardScrollbar.Left.Set(-4, 0f);
            keyboardScrollbar.HAlign = 1f;
            keyboardPanel.Append(keyboardScrollbar);

            replOutput.SetScrollbar(keyboardScrollbar);

            UIImageButton eyeDropperButton = new UIImageButton(ModdersToolkit.instance.GetTexture("UIElements/eyedropper"));

            eyeDropperButton.Height.Pixels = 20;
            //eyeDropperButton.Width.Pixels = 20;
            eyeDropperButton.OnClick += EyeDropperButton_OnClick;
            eyeDropperButton.Top.Set(-26, 1f);
            keyboardPanel.Append(eyeDropperButton);

            UIImageButton openText = new UIHoverImageButton(ModdersToolkit.instance.GetTexture("UIElements/CopyCodeButton"), "Open External Editor");

            openText.OnClick += OpenTextButton_OnClick;
            openText.Top.Set(-26, 1f);
            openText.Left.Set(26, 0f);
            keyboardPanel.Append(openText);

            UIImageButton runText = new UIHoverImageButton(TextureManager.Load("Images/UI/ButtonPlay"), "Execute External Code");

            runText.OnClick += RunTextButton_OnClick;
            runText.Top.Set(-26, 1f);
            runText.Left.Set(52, 0f);
            keyboardPanel.Append(runText);

            Append(keyboardPanel);
        }
Beispiel #27
0
        public void InitializeUI()
        {
            RemoveAllChildren();

            panelMain         = new UINPCInfoMainPanel(true, true, true);
            panelMain.caption = caption;
            panelMain.SetPadding(6);
            panelMain.Left.Set(400f, 0f);
            panelMain.Top.Set(400f, 0f);
            panelMain.Width.Set(290f, 0f);
            panelMain.MinWidth.Set(290f, 0f);
            panelMain.MaxWidth.Set(Main.screenWidth, 0f);
            panelMain.Height.Set(298, 0f);
            panelMain.MinHeight.Set(124, 0f);
            panelMain.MaxHeight.Set(Main.screenHeight, 0f);

            Texture2D texture = ModLoader.GetMod("NPCInfo").GetTexture("UIElements/closeButton");

            closeButton          = new UIHoverImageButton(texture, "Close");
            closeButton.OnClick += (a, b) => ShowNPCInfo = false;
            closeButton.Left.Set(-20f, 1f);
            closeButton.Top.Set(6f, 0f);
            panelMain.Append(closeButton);

            inlaidPanel = new UIPanel();
            inlaidPanel.SetPadding(5);
            inlaidPanel.Top.Pixels = 32;
            inlaidPanel.Width.Set(0, 1f);
            inlaidPanel.Height.Set(-50, 1f);
            panelMain.Append(inlaidPanel);

            gridNPC = new UIGrid();
            gridNPC.Width.Set(-20f, 1f);
            gridNPC.Height.Set(0, 1f);
            gridNPC.ListPadding = 2f;
            inlaidPanel.Append(gridNPC);

            var lootItemsScrollbar = new FixedUIScrollbar(userInterface);

            lootItemsScrollbar.SetView(100f, 1000f);
            lootItemsScrollbar.Height.Set(0, 1f);
            lootItemsScrollbar.Left.Set(-20, 1f);
            inlaidPanel.Append(lootItemsScrollbar);
            gridNPC.SetScrollbar(lootItemsScrollbar);

            int leftPos = menuMargin;

            btnViewMode = new UIImageListButton(
                new List <Texture2D>()
            {
                Main.itemTexture[ItemID.AlphabetStatue1].Resize(menuIconSize),
                Main.itemTexture[ItemID.AlphabetStatue2].Resize(menuIconSize),
                Main.itemTexture[ItemID.AlphabetStatue3].Resize(menuIconSize)
            },
                new List <object>()
            {
                ViewMode.CombatNPC, ViewMode.SpawnNPC, ViewMode.DropItem
            },
                new List <string>()
            {
                "Combat NPC", "Spawn NPC", "Drop Item"
            });
            btnViewMode.OnClick += (a, b) =>
            {
                btnViewMode.NextIamge();
                ChangeViewMode();
            };
            btnViewMode.OnRightClick += (a, b) =>
            {
                btnViewMode.PrevIamge();
                ChangeViewMode();
            };
            btnViewMode.Left.Set(leftPos, 0f);
            btnViewMode.Top.Set(0f, 0f);
            panelMain.Append(btnViewMode);

            btnSpawnNPCFilter = new UIImageListButton(
                new List <Texture2D>()
            {
                Main.itemTexture[ItemID.AlphabetStatue1].Resize(menuIconSize),
                Main.itemTexture[ItemID.AlphabetStatue2].Resize(menuIconSize)
            },
                new List <object>()
            {
                SpawnNPCFilter.All, SpawnNPCFilter.HideTownNPC
            },
                new List <string>()
            {
                "Spawn NPC: All", "Spawn NPC: Hide twon NPC"
            });
            btnSpawnNPCFilter.OnClick += (a, b) =>
            {
                btnSpawnNPCFilter.NextIamge();
                ChangeSpawnNPCFilter();
            };
            btnSpawnNPCFilter.OnRightClick += (a, b) =>
            {
                btnSpawnNPCFilter.PrevIamge();
                ChangeSpawnNPCFilter();
            };
            leftPos += menuIconSize + menuMargin;
            btnSpawnNPCFilter.Left.Set(leftPos, 0f);
            btnSpawnNPCFilter.Top.Set(0f, 0f);

            updateNeeded = true;
        }
Beispiel #28
0
        //static string modSourcespath = ModLoader.ModSourcePath

        public override void OnInitialize()
        {
            mainPanel = new UIPanel();
            mainPanel.Left.Set(-350f, 1f);
            mainPanel.Top.Set(-620f, 1f);
            mainPanel.Width.Set(310f, 0f);
            mainPanel.Height.Set(520f, 0f);
            mainPanel.SetPadding(12);
            mainPanel.BackgroundColor = Color.PeachPuff * 0.8f;

            int    top  = 0;
            UIText text = new UIText("Textures:", 0.85f);

            text.Top.Set(top, 0f);
            mainPanel.Append(text);
            top += 20;

            modList            = new UIList();
            modList.Top.Pixels = top;
            modList.Width.Set(-25f, 1f);
            modList.Height.Set(140, 0f);
            modList.ListPadding = 0f;
            mainPanel.Append(modList);

            var modListScrollbar = new UIElements.FixedUIScrollbar(userInterface);

            modListScrollbar.SetView(100f, 1000f);
            modListScrollbar.Top.Pixels = top + 10;            // + spacing;
            modListScrollbar.Height.Set(120, 0f);
            modListScrollbar.HAlign = 1f;
            mainPanel.Append(modListScrollbar);
            modList.SetScrollbar(modListScrollbar);

            top += 140;

            watchModSources = new UICheckbox("Watch Mod Sources", "Automatically Watch Mod Sources for Changes", false);
            watchModSources.Top.Set(top, 0);
            watchModSources.OnSelectedChanged += WatchModSources_OnSelectedChanged;
            mainPanel.Append(watchModSources);

            top += 20;

            UIText text2 = new UIText("Filter:", 0.85f);

            text2.Top.Set(top, 0f);
            mainPanel.Append(text2);

            searchFilter = new NewUITextBox("Search", 0.85f);
            searchFilter.SetPadding(0);
            searchFilter.OnTextChanged += () => { updateneeded = true; };
            searchFilter.Top.Set(top, 0f);
            searchFilter.Left.Set(text2.GetInnerDimensions().Width + 6, 0f);
            searchFilter.Width.Set(-(text2.GetInnerDimensions().Width + 6), 1f);
            searchFilter.Height.Set(20, 0f);
            mainPanel.Append(searchFilter);

            top += 20;

            currentTexture = new UIText("Current: None selected", 0.85f);
            currentTexture.Top.Set(top, 0f);
            currentTexture.Left.Set(0, 0f);
            currentTexture.Width.Set(0, 1);
            currentTexture.HAlign = 0;
            mainPanel.Append(currentTexture);

            top += 20;

            textureList            = new UIList();
            textureList.Top.Pixels = top;
            textureList.Width.Set(-25f, 1f);
            textureList.Height.Set(250, 0f);
            textureList.ListPadding = 6f;
            mainPanel.Append(textureList);

            var textureListScrollbar = new UIElements.FixedUIScrollbar(userInterface);

            textureListScrollbar.SetView(100f, 1000f);
            textureListScrollbar.Top.Pixels = top + 10;            // + spacing;
            textureListScrollbar.Height.Set(230, 0f);
            textureListScrollbar.HAlign = 1f;
            mainPanel.Append(textureListScrollbar);
            textureList.SetScrollbar(textureListScrollbar);

            top += 250;

            //UIHoverImageButton exportImageButton = new UIHoverImageButton(ModdersToolkit.instance.GetTexture("UIElements/CopyCodeButton"), "Export Image for Editing");
            //exportImageButton.OnClick += ExportImageButton_OnClick;
            //exportImageButton.Top.Set(top + 5, 0f);
            //exportImageButton.Left.Set(0, 0f);
            //mainPanel.Append(exportImageButton);

            UIHoverImageButton editImageButton = new UIHoverImageButton(ModdersToolkit.instance.GetTexture("UIElements/eyedropper"), "Open Exported Image in Default Editor");

            editImageButton.OnClick += EditImageButton_OnClick;
            editImageButton.Top.Set(top + 5, 0f);
            editImageButton.Left.Set(0, 0f);
            mainPanel.Append(editImageButton);

            updateneeded = true;
            Append(mainPanel);
        }
        public override void OnInitialize()
        {
            // Is initialize called? (Yes it is called on reload) I want to reset nicely with new character or new loaded mods: visible = false;

            announce          = false;    // overwritten by modplayer
            collectChestItems = false;
            showBadge         = false;

            checklistPanel = new UIPanel();
            checklistPanel.SetPadding(10);
            checklistPanel.Left.Pixels = 0;
            checklistPanel.HAlign      = 1f;
            checklistPanel.Top.Set(85f, 0f);
            checklistPanel.Left.Set(-40f, 0f);
            checklistPanel.Width.Set(250f, 0f);
            checklistPanel.Height.Set(-125, 1f);
            checklistPanel.BackgroundColor = new Color(73, 94, 171);

            int top  = 0;
            int left = 0;

            // Because OnInitialize Happens during load and because we need it to happen for OnEnterWorld, use dummy sprite.
            buttonsHaveDummyTextures = true;

            foundFilterButton               = new UIHoverImageButton(Main.magicPixel, "Cycle Found Filter: ??");
            foundFilterButton.OnClick      += (a, b) => ToggleFoundFilterButtonClicked(a, b, true);
            foundFilterButton.OnRightClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, false);
            foundFilterButton.Top.Pixels    = top;
            checklistPanel.Append(foundFilterButton);
            left += (int)spacing * 2 + 28;

            //sortButton = new UIHoverImageButton(sortButtonTexture, "Cycle Sort Method: ??");
            //sortButton.OnClick += (a, b) => ToggleSortButtonClicked(a, b, true);
            //sortButton.OnRightClick += (a, b) => ToggleSortButtonClicked(a, b, false);
            //sortButton.Left.Pixels = spacing * 4 + 28 * 2;
            //sortButton.Top.Pixels = top;
            //checklistPanel.Append(sortButton);

            modFilterButton               = new UIHoverImageButton(Main.magicPixel, "Cycle Mod Filter: ??");
            modFilterButton.OnClick      += (a, b) => ToggleModFilterButtonClicked(a, b, true);
            modFilterButton.OnRightClick += (a, b) => ToggleModFilterButtonClicked(a, b, false);
            modFilterButton.Left.Pixels   = left;
            modFilterButton.Top.Pixels    = top;
            checklistPanel.Append(modFilterButton);
            left += (int)spacing * 2 + 28;

            muteButton             = new UIToggleHoverImageButton(Main.magicPixel, ItemChecklist.instance.GetTexture("UIElements/closeButton"), "Toggle Messages", announce);
            muteButton.OnClick    += ToggleMuteButtonClicked;
            muteButton.Left.Pixels = left;
            muteButton.Top.Pixels  = top;
            checklistPanel.Append(muteButton);
            left += (int)spacing * 2 + 28;

            collectChestItemsButton             = new UIToggleHoverImageButton(Main.magicPixel, ItemChecklist.instance.GetTexture("UIElements/closeButton"), "Toggle Collect Chest Items", collectChestItems);
            collectChestItemsButton.OnClick    += ToggleFindChestItemsButtonClicked;
            collectChestItemsButton.Left.Pixels = left;
            collectChestItemsButton.Top.Pixels  = top;
            checklistPanel.Append(collectChestItemsButton);
            left += (int)spacing * 2 + 28;

            showBadgeButton             = new UIToggleHoverImageButton(Main.magicPixel, ItemChecklist.instance.GetTexture("UIElements/closeButton"), "Show Sort Value Text", showBadge);
            showBadgeButton.OnClick    += ToggleShowBadgeButtonClicked;
            showBadgeButton.Left.Pixels = left;
            showBadgeButton.Top.Pixels  = top;
            checklistPanel.Append(showBadgeButton);
            left += (int)spacing * 2 + 28;

            top += 34;

            itemNameFilter = new NewUITextBox("Filter by Name");
            itemNameFilter.OnTextChanged += () => { ValidateItemFilter(); updateNeeded = true; };
            itemNameFilter.OnTabPressed  += () => { itemDescriptionFilter.Focus(); };
            itemNameFilter.Top.Pixels     = top;
            //itemNameFilter.Left.Set(-152, 1f);
            itemNameFilter.Width.Set(0, 1f);
            itemNameFilter.Height.Set(25, 0f);
            checklistPanel.Append(itemNameFilter);

            top += 30;

            itemDescriptionFilter = new NewUITextBox("Filter by tooltip");
            itemDescriptionFilter.OnTextChanged += () => { ValidateItemDescription(); updateNeeded = true; };
            itemDescriptionFilter.OnTabPressed  += () => { itemNameFilter.Focus(); };
            itemDescriptionFilter.Top.Pixels     = top;
            //itemDescriptionFilter.Left.Set(-152, 1f);
            itemDescriptionFilter.Width.Set(0, 1f);
            itemDescriptionFilter.Height.Set(25, 0f);
            checklistPanel.Append(itemDescriptionFilter);

            top += 30;

            sharedUI = new SharedUI();
            sharedUI.Initialize();

            sharedUI.sortsAndFiltersPanel.Top.Set(top, 0f);
            sharedUI.sortsAndFiltersPanel.Width.Set(0f, 1);
            sharedUI.sortsAndFiltersPanel.Height.Set(60, 0f);
            checklistPanel.Append(sharedUI.sortsAndFiltersPanel);

            top += 68;

            checklistGrid = new UIGrid(5);
            checklistGrid.alternateSort = ItemGridSort;
            checklistGrid.Top.Pixels    = top;
            checklistGrid.Width.Set(-25f, 1f);
            checklistGrid.Height.Set(-top, 1f);
            checklistGrid.ListPadding = 2f;
            checklistPanel.Append(checklistGrid);

            FixedUIScrollbar checklistListScrollbar = new FixedUIScrollbar();

            checklistListScrollbar.SetView(100f, 1000f);
            checklistListScrollbar.Top.Pixels = top;
            checklistListScrollbar.Height.Set(-top, 1f);
            checklistListScrollbar.HAlign = 1f;
            checklistPanel.Append(checklistListScrollbar);
            checklistGrid.SetScrollbar(checklistListScrollbar);

            // Checklistlist populated when the panel is shown: UpdateCheckboxes()

            Append(checklistPanel);

            // load time impact, do this on first show?
            itemSlots = new UIItemSlot[ItemLoader.ItemCount];
            Item[] itemSlotItems = new Item[ItemLoader.ItemCount];
            for (int i = 0; i < ItemLoader.ItemCount; i++)
            {
                itemSlots[i]     = new UIItemSlot(i);
                itemSlotItems[i] = itemSlots[i].item;
            }

            FieldInfo inventoryGlowHue  = typeof(Terraria.UI.ItemSlot).GetField("inventoryGlowHue", BindingFlags.Static | BindingFlags.NonPublic);
            FieldInfo inventoryGlowTime = typeof(Terraria.UI.ItemSlot).GetField("inventoryGlowTime", BindingFlags.Static | BindingFlags.NonPublic);

            MethodInfo SortMethod = typeof(ItemSorting).GetMethod("Sort", BindingFlags.Static | BindingFlags.NonPublic);

            object[] parametersArray = new object[] { itemSlotItems, new int[0] };

            inventoryGlowHue.SetValue(null, new float[ItemLoader.ItemCount]);
            inventoryGlowTime.SetValue(null, new int[ItemLoader.ItemCount]);
            SortMethod.Invoke(null, parametersArray);
            inventoryGlowHue.SetValue(null, new float[58]);
            inventoryGlowTime.SetValue(null, new int[58]);

            int[] vanillaIDsInSortOrderTemp = itemSlotItems.Select((x) => x.type).ToArray();
            vanillaIDsInSortOrder = new int[ItemLoader.ItemCount];
            for (int i = 0; i < ItemLoader.ItemCount; i++)
            {
                vanillaIDsInSortOrder[i] = Array.FindIndex(vanillaIDsInSortOrderTemp, x => x == i);
            }

            modnames = new List <string>()
            {
                "All", "Vanilla"
            };
            modnames.AddRange(ModLoader.GetLoadedMods() /*.Where(x => x != "ModLoader")*/);

            updateNeeded = true;
        }