Beispiel #1
0
        public override void OnInitialize()
        {
            uIElement = new UIElement {
                Width    = { Percent = 0.8f },
                MaxWidth = UICommon.MaxPanelWidth,
                Top      = { Pixels = 220 },
                Height   = { Pixels = -220, Percent = 1f },
                HAlign   = 0.5f
            };

            uIPanel = new UIPanel {
                Width           = { Percent = 1f },
                Height          = { Pixels = -110, Percent = 1f },
                BackgroundColor = UICommon.mainPanelBackground,
                PaddingTop      = 0f
            };
            uIElement.Append(uIPanel);

            uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

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

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

            uIPanel.Append(uIScrollbar);

            modList.SetScrollbar(uIScrollbar);

            var uIHeaderTexTPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModsModsList"), 0.8f, true)
            {
                HAlign          = 0.5f,
                Top             = { Pixels = -35 },
                BackgroundColor = UICommon.defaultUIBlue
            }.WithPadding(15f);

            uIElement.Append(uIHeaderTexTPanel);

            buttonEA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsEnableAll"))
            {
                TextColor = Color.Green,
                Width     = new StyleDimension(-10f, 1f / 3f),
                Height    = { Pixels = 40 },
                VAlign    = 1f,
                Top       = { Pixels = -65 }
            }.WithFadedMouseOver();
            buttonEA.OnClick += EnableAll;
            uIElement.Append(buttonEA);

            // TODO CopyStyle doesn't capture all the duplication here, consider an inner method
            buttonDA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsDisableAll"));
            buttonDA.CopyStyle(buttonEA);
            buttonDA.TextColor = Color.Red;
            buttonDA.HAlign    = 0.5f;
            buttonDA.WithFadedMouseOver();
            buttonDA.OnClick += DisableAll;
            uIElement.Append(buttonDA);

            buttonRM = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsReloadMods"));
            buttonRM.CopyStyle(buttonEA);
            buttonRM.HAlign = 1f;
            buttonDA.WithFadedMouseOver();
            buttonRM.OnClick += ReloadMods;
            uIElement.Append(buttonRM);

            buttonB = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back"));
            buttonB.CopyStyle(buttonEA);
            buttonB.Top.Pixels = -20;
            buttonB.WithFadedMouseOver();
            buttonB.OnClick += BackClick;

            uIElement.Append(buttonB);
            buttonOMF = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsOpenModsFolder"));
            buttonOMF.CopyStyle(buttonB);
            buttonOMF.HAlign = 0.5f;
            buttonOMF.WithFadedMouseOver();
            buttonOMF.OnClick += OpenModsFolder;
            uIElement.Append(buttonOMF);

            var texture            = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.UIModBrowserIcons.png"));
            var upperMenuContainer = new UIElement {
                Width  = { Percent = 1f },
                Height = { Pixels = 32 },
                Top    = { Pixels = 10 }
            };

            UICycleImage toggleImage;

            for (int j = 0; j < 3; j++)
            {
                if (j == 0)                   //TODO: ouch, at least there's a loop but these click events look quite similar
                {
                    toggleImage = new UICycleImage(texture, 3, 32, 32, 34 * 3, 0);
                    toggleImage.setCurrentState((int)sortMode);
                    toggleImage.OnClick += (a, b) => {
                        sortMode     = sortMode.NextEnum();
                        updateNeeded = true;
                    };
                    toggleImage.OnRightClick += (a, b) => {
                        sortMode     = sortMode.PreviousEnum();
                        updateNeeded = true;
                    };
                }
                else if (j == 1)
                {
                    toggleImage = new UICycleImage(texture, 3, 32, 32, 34 * 4, 0);
                    toggleImage.setCurrentState((int)enabledFilterMode);
                    toggleImage.OnClick += (a, b) => {
                        enabledFilterMode = enabledFilterMode.NextEnum();
                        updateNeeded      = true;
                    };
                    toggleImage.OnRightClick += (a, b) => {
                        enabledFilterMode = enabledFilterMode.PreviousEnum();
                        updateNeeded      = true;
                    };
                }
                else
                {
                    toggleImage = new UICycleImage(texture, 5, 32, 32, 34 * 5, 0);
                    toggleImage.setCurrentState((int)modSideFilterMode);
                    toggleImage.OnClick += (a, b) => {
                        modSideFilterMode = modSideFilterMode.NextEnum();
                        updateNeeded      = true;
                    };
                    toggleImage.OnRightClick += (a, b) => {
                        modSideFilterMode = modSideFilterMode.PreviousEnum();
                        updateNeeded      = true;
                    };
                }
                toggleImage.Left.Pixels = j * 36 + 8;
                _categoryButtons.Add(toggleImage);
                upperMenuContainer.Append(toggleImage);
            }

            var filterTextBoxBackground = new UIPanel {
                Top    = { Percent = 0f },
                Left   = { Pixels = -170, Percent = 1f },
                Width  = { Pixels = 135 },
                Height = { Pixels = 40 }
            };

            filterTextBoxBackground.OnRightClick += (a, b) => filterTextBox.Text = "";
            upperMenuContainer.Append(filterTextBoxBackground);

            filterTextBox = new UIInputTextField(Language.GetTextValue("tModLoader.ModsTypeToSearch"))
            {
                Top    = { Pixels = 5 },
                Left   = { Pixels = -160, Percent = 1f },
                Width  = { Pixels = 120 },
                Height = { Pixels = 20 }
            };
            filterTextBox.OnTextChange += (a, b) => updateNeeded = true;
            upperMenuContainer.Append(filterTextBox);

            SearchFilterToggle = new UICycleImage(texture, 2, 32, 32, 34 * 2, 0)
            {
                Left = { Pixels = 545 }
            };
            SearchFilterToggle.setCurrentState((int)searchFilterMode);
            SearchFilterToggle.OnClick += (a, b) => {
                searchFilterMode = searchFilterMode.NextEnum();
                updateNeeded     = true;
            };
            SearchFilterToggle.OnRightClick += (a, b) => {
                searchFilterMode = searchFilterMode.PreviousEnum();
                updateNeeded     = true;
            };
            _categoryButtons.Add(SearchFilterToggle);
            upperMenuContainer.Append(SearchFilterToggle);

            buttonMP = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsModPacks"));
            buttonMP.CopyStyle(buttonOMF);
            buttonMP.HAlign = 1f;
            buttonMP.WithFadedMouseOver();
            buttonMP.OnClick += GotoModPacksMenu;
            uIElement.Append(buttonMP);

            uIPanel.Append(upperMenuContainer);
            Append(uIElement);
        }
Beispiel #2
0
        public override void OnInitialize()
        {
            _uIElement = new UIElement {
                Width    = { Percent = 0.8f },
                MaxWidth = UICommon.MaxPanelWidth,
                Top      = { Pixels = 220 },
                Height   = { Pixels = -220, Percent = 1f },
                HAlign   = 0.5f
            };

            _uIPanel = new UIPanel {
                Width           = { Percent = 1f },
                Height          = { Pixels = -110, Percent = 1f },
                BackgroundColor = UICommon.MainPanelBackground
            };
            _uIElement.Append(_uIPanel);

            _uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

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

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

            _uIPanel.Append(uIScrollbar);
            _modList.SetScrollbar(uIScrollbar);

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

            _uIElement.Append(uIHeaderTextPanel);

            var buttonBA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildAll"))
            {
                Width  = { Pixels = -10, Percent = 1f / 3f },
                Height = { Pixels = 40 },
                VAlign = 1f,
                Top    = { Pixels = -65 }
            };

            buttonBA.WithFadedMouseOver();
            buttonBA.OnClick += BuildMods;
            _uIElement.Append(buttonBA);

            var buttonBRA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildReloadAll"));

            buttonBRA.CopyStyle(buttonBA);
            buttonBRA.HAlign = 0.5f;
            buttonBRA.WithFadedMouseOver();
            buttonBRA.OnClick += BuildAndReload;
            _uIElement.Append(buttonBRA);

            var buttonCreateMod = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSCreateMod"));

            buttonCreateMod.CopyStyle(buttonBA);
            buttonCreateMod.HAlign = 1f;
            buttonCreateMod.WithFadedMouseOver();
            buttonCreateMod.OnClick += ButtonCreateMod_OnClick;
            _uIElement.Append(buttonCreateMod);

            var buttonB = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back"));

            buttonB.CopyStyle(buttonBA);
            //buttonB.Width.Set(-10f, 1f / 3f);
            buttonB.Top.Pixels = -20;
            buttonB.WithFadedMouseOver();
            buttonB.OnClick += BackClick;
            _uIElement.Append(buttonB);

            var buttonOS = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSOpenSources"));

            buttonOS.CopyStyle(buttonB);
            buttonOS.HAlign = .5f;
            buttonOS.WithFadedMouseOver();
            buttonOS.OnClick += OpenSources;
            _uIElement.Append(buttonOS);

            var buttonMP = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSManagePublished"));

            buttonMP.CopyStyle(buttonB);
            buttonMP.HAlign = 1f;
            buttonMP.WithFadedMouseOver();
            buttonMP.OnClick += ManagePublished;
            _uIElement.Append(buttonMP);
            Append(_uIElement);
        }
Beispiel #3
0
        public override void OnInitialize()
        {
            UIElement uIElement = new UIElement();

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

            uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

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

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

            UIScrollbar uIScrollbar = new UIScrollbar();

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

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

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

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

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

            UIAutoScaleTextTextPanel <string> saveNewButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPacksSaveEnabledAsNewPack"), 1f, false);

            saveNewButton.TextColor = Color.Green;
            saveNewButton.CopyStyle(backButton);
            saveNewButton.HAlign       = 1f;
            saveNewButton.OnMouseOver += UICommon.FadedMouseOver;
            saveNewButton.OnMouseOut  += UICommon.FadedMouseOut;
            saveNewButton.OnClick     += SaveNewModList;
            uIElement.Append(saveNewButton);

            base.Append(uIElement);
        }
Beispiel #4
0
        public UIModDownloadItem(string displayname, string name, string version, string author, string modreferences, ModSide modside, string modIconURL, string download, int downloads, int hot, string timeStamp, bool update, bool updateIsDowngrade, LocalMod installed)
        {
            this.displayname       = displayname;
            this.mod               = name;
            this.version           = version;
            this.author            = author;
            this.modreferences     = modreferences;
            this.modside           = modside;
            this.modIconURL        = modIconURL;
            this.download          = download;
            this.downloads         = downloads;
            this.hot               = hot;
            this.timeStamp         = timeStamp;
            this.update            = update;
            this.updateIsDowngrade = updateIsDowngrade;
            this.installed         = installed;

            BorderColor       = new Color(89, 116, 213) * 0.7f;
            dividerTexture    = TextureManager.Load("Images/UI/Divider");
            innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            Height.Pixels     = 90;
            Width.Percent     = 1f;
            SetPadding(6f);

            left = HasModIcon ? 85f : 0f;
            string text = displayname + " " + version;

            modName = new UIText(text)
            {
                Left = new StyleDimension(left + 5, 0f),
                Top  = { Pixels = 5 }
            };
            Append(modName);

            moreInfoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo"))
            {
                Width  = { Pixels = 100 },
                Height = { Pixels = 36 },
                Left   = { Pixels = left },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();
            moreInfoButton.PaddingTop    -= 2f;
            moreInfoButton.PaddingBottom -= 2f;
            moreInfoButton.OnClick       += RequestMoreinfo;
            Append(moreInfoButton);

            if (update || installed == null)
            {
                updateButton = new UIAutoScaleTextTextPanel <string>(this.update ? (updateIsDowngrade ? Language.GetTextValue("tModLoader.MBDowngrade") : Language.GetTextValue("tModLoader.MBUpdate")) : Language.GetTextValue("tModLoader.MBDownload"), 1f,
                                                                     false);
                updateButton.CopyStyle(moreInfoButton);
                updateButton.Width.Pixels = HasModIcon ? 120 : 200;
                updateButton.Left.Pixels  = moreInfoButton.Width.Pixels + moreInfoButton.Left.Pixels + 5f;
                updateButton.WithFadedMouseOver();
                updateButton.OnClick += DownloadMod;
                Append(updateButton);
            }
            if (modreferences.Length > 0)
            {
                var icon = Texture2D.FromStream(Main.instance.GraphicsDevice,
                                                Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonExclamation.png"));
                var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.MBClickToViewDependencyMods", string.Join("\n", modreferences.Split(',').Select(x => x.Trim()))))
                {
                    Left = { Pixels = -149, Percent = 1f },
                    Top  = { Pixels = 48 }
                };
                modReferenceIcon.OnClick += (s, e) => {
                    var modListItem = (UIModDownloadItem)e.Parent;
                    Interface.modBrowser.SpecialModPackFilter      = modListItem.modreferences.Split(',').Select(x => x.Trim()).ToList();
                    Interface.modBrowser.SpecialModPackFilterTitle = Language.GetTextValue("tModLoader.MBFilterDependencies");                     // Toolong of \n" + modListItem.modName.Text;
                    Interface.modBrowser.filterTextBox.Text        = "";
                    Interface.modBrowser.updateNeeded = true;
                    Main.PlaySound(SoundID.MenuOpen);
                };
                Append(modReferenceIcon);
            }
            OnDoubleClick += RequestMoreinfo;
        }
Beispiel #5
0
        public override void OnInitialize()
        {
            _uIElement = new UIElement {
                Width    = { Percent = 0.8f },
                MaxWidth = UICommon.MaxPanelWidth,
                Top      = { Pixels = 220 },
                Height   = { Pixels = -220, Percent = 1f },
                HAlign   = 0.5f
            };

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

            _uIElement.Append(uIPanel);

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

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

            uIPanel.Append(uIScrollbar);

            _modInfo.SetScrollbar(uIScrollbar);
            _uITextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModInfoHeader"), 0.8f, true)
            {
                HAlign          = 0.5f,
                Top             = { Pixels = -35 },
                BackgroundColor = UICommon.DefaultUIBlue
            }.WithPadding(15f);
            _uIElement.Append(_uITextPanel);

            _modHomepageButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModInfoVisitHomepage"))
            {
                Width  = { Percent = 1f },
                Height = { Pixels = 40 },
                VAlign = 1f,
                Top    = { Pixels = -65 }
            }.WithFadedMouseOver();
            _modHomepageButton.OnClick += VisitModHomePage;

            var backButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back"))
            {
                Width  = { Pixels = -10, Percent = 0.333f },
                Height = { Pixels = 40 },
                VAlign = 1f,
                Top    = { Pixels = -20 }
            }.WithFadedMouseOver();

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

            _extractButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModInfoExtract"))
            {
                Width  = { Pixels = -10, Percent = 0.333f },
                Height = { Pixels = 40 },
                VAlign = 1f,
                HAlign = 0.5f,
                Top    = { Pixels = -20 }
            }.WithFadedMouseOver();
            _extractButton.OnClick += ExtractMod;

            _deleteButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Delete"))
            {
                Width  = { Pixels = -10, Percent = 0.333f },
                Height = { Pixels = 40 },
                VAlign = 1f,
                HAlign = 1f,
                Top    = { Pixels = -20 }
            }.WithFadedMouseOver();
            _deleteButton.OnClick += DeleteMod;

            _fakeDeleteButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Delete"))
            {
                Width  = { Pixels = -10, Percent = 0.333f },
                Height = { Pixels = 40 },
                VAlign = 1f,
                HAlign = 1f,
                Top    = { Pixels = -20 }
            };
            _fakeDeleteButton.BackgroundColor = Color.Gray;

            Append(_uIElement);
        }
Beispiel #6
0
        public UIModItem(LocalMod mod)
        {
            this.mod          = mod;
            BorderColor       = new Color(89, 116, 213) * 0.7f;
            dividerTexture    = TextureManager.Load("Images/UI/Divider");
            innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            Height.Pixels     = 90;
            Width.Percent     = 1f;
            SetPadding(6f);
            //base.OnClick += this.ToggleEnabled;
            string text = mod.DisplayName + " v" + mod.modFile.version;

            if (mod.tModLoaderVersion < new Version(0, 10))
            {
                text += $" [c/FF0000:({Language.GetTextValue("tModLoader.ModOldWarning")})]";
            }

            if (mod.modFile.HasFile("icon.png"))
            {
                try {
                    Texture2D modIconTexture;
                    using (mod.modFile.Open())
                        using (var s = mod.modFile.GetStream("icon.png"))
                            modIconTexture = Texture2D.FromStream(Main.instance.GraphicsDevice, s);

                    if (modIconTexture.Width == 80 && modIconTexture.Height == 80)
                    {
                        modIcon = new UIImage(modIconTexture)
                        {
                            Left = { Percent = 0f },
                            Top  = { Percent = 0f }
                        };
                        Append(modIcon);
                        modIconAdjust += 85;
                    }
                }
                catch { }
            }
            modName = new UIText(text)
            {
                Left = new StyleDimension(modIconAdjust + 10f, 0f),
                Top  = { Pixels = 5 }
            };
            Append(modName);

            var moreInfoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo"))
            {
                Width  = { Pixels = 100 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 430 },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();

            moreInfoButton.PaddingTop    -= 2f;
            moreInfoButton.PaddingBottom -= 2f;
            moreInfoButton.OnClick       += Moreinfo;
            Append(moreInfoButton);

            toggleModEnabledButton = new UIAutoScaleTextTextPanel <string>(mod.Enabled ? Language.GetTextValue("tModLoader.ModsDisable") : Language.GetTextValue("tModLoader.ModsEnable"))
            {
                Width  = { Pixels = 100 },
                Height = { Pixels = 36 },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();
            toggleModEnabledButton.Left.Pixels    = moreInfoButton.Left.Pixels - toggleModEnabledButton.Width.Pixels - 5f;
            toggleModEnabledButton.PaddingTop    -= 2f;
            toggleModEnabledButton.PaddingBottom -= 2f;
            toggleModEnabledButton.OnClick       += ToggleEnabled;
            Append(toggleModEnabledButton);

            Mod loadedMod = ModLoader.GetMod(mod.Name);

            if (loadedMod != null && ConfigManager.Configs.ContainsKey(loadedMod))             // and has config
            {
                configButton = new UITextPanel <string>("Config", 1f, false);
                configButton.Width.Set(100f, 0f);
                configButton.Height.Set(30f, 0f);
                configButton.Left.Set(toggleModEnabledButton.Left.Pixels - configButton.Width.Pixels - 5f, 0f);
                configButton.Top.Set(40f, 0f);
                configButton.PaddingTop    -= 2f;
                configButton.PaddingBottom -= 2f;
                configButton.WithFadedMouseOver();
                configButton.OnClick += this.OpenConfig;
                Append(configButton);
                if (ConfigManager.ModNeedsReload(loadedMod))
                {
                    configChangesRequireReload = true;
                }
            }

            var modRefs = mod.properties.modReferences.Select(x => x.mod).ToArray();

            if (modRefs.Length > 0 && !mod.Enabled)
            {
                string refs = string.Join(", ", mod.properties.modReferences);
                var    icon = Texture2D.FromStream(Main.instance.GraphicsDevice,
                                                   Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonExclamation.png"));
                var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.ModDependencyClickTooltip", refs))
                {
                    Left = new StyleDimension(toggleModEnabledButton.Left.Pixels - 24f, 0f),
                    Top  = { Pixels = 47 }
                };
                modReferenceIcon.OnClick += (a, b) => {
                    var modList = ModOrganizer.FindMods();
                    var missing = new List <string>();
                    foreach (var modRef in modRefs)
                    {
                        ModLoader.EnableMod(modRef);
                        if (!modList.Any(m => m.Name == modRef))
                        {
                            missing.Add(modRef);
                        }
                    }

                    Main.menuMode = Interface.modsMenuID;
                    if (missing.Any())
                    {
                        Interface.infoMessage.Show(Language.GetTextValue("tModLoader.ModDependencyModsNotFound", String.Join(",", missing)), Interface.modsMenuID);
                    }
                };
                Append(modReferenceIcon);
            }
            if (mod.modFile.ValidModBrowserSignature)
            {
                keyImage = new UIHoverImage(Main.itemTexture[ID.ItemID.GoldenKey], Language.GetTextValue("tModLoader.ModsOriginatedFromModBrowser"))
                {
                    Left = { Pixels = -20, Percent = 1f }
                };
                Append(keyImage);
            }
            if (ModLoader.badUnloaders.Contains(mod.Name))
            {
                keyImage = new UIHoverImage(Texture2D.FromStream(Main.instance.GraphicsDevice,
                                                                 Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonError.png")), "This mod did not fully unload during last unload.")
                {
                    Left = { Pixels = modIconAdjust + 4 },
                    Top  = { Pixels = 3 }
                };
                Append(keyImage);
                modName.Left.Pixels += 20;
            }
            if (mod.properties.beta)
            {
                keyImage = new UIHoverImage(Main.itemTexture[ID.ItemID.ShadowKey], Language.GetTextValue("tModLoader.BetaModCantPublish"))
                {
                    Left = { Pixels = -10, Percent = 1f }
                };
                Append(keyImage);
            }
            if (loadedMod != null)
            {
                loaded = true;
                int[]    values           = { loadedMod.items.Count, loadedMod.npcs.Count, loadedMod.tiles.Count, loadedMod.walls.Count, loadedMod.buffs.Count, loadedMod.mountDatas.Count };
                string[] localizationKeys = { "ModsXItems", "ModsXNPCs", "ModsXTiles", "ModsXWalls", "ModsXBuffs", "ModsXMounts" };
                int      xOffset          = -40;
                for (int i = 0; i < values.Length; i++)
                {
                    if (values[i] > 0)
                    {
                        Texture2D iconTexture = Main.instance.infoIconTexture[i];
                        keyImage = new UIHoverImage(iconTexture, Language.GetTextValue($"tModLoader.{localizationKeys[i]}", values[i]))
                        {
                            Left = { Pixels = xOffset, Percent = 1f }
                        };
                        Append(keyImage);
                        xOffset -= 18;
                    }
                }
            }
        }
Beispiel #7
0
        public override void OnInitialize()
        {
            _uIElement = new UIElement {
                Width    = { Percent = 0.8f },
                MaxWidth = UICommon.MaxPanelWidth,
                Top      = { Pixels = 220 },
                Height   = { Pixels = -220, Percent = 1f },
                HAlign   = 0.5f
            };

            _uIPanel = new UIPanel {
                Width           = { Percent = 1f },
                Height          = { Pixels = -110, Percent = 1f },
                BackgroundColor = UICommon.MainPanelBackground,
                PaddingTop      = 0f
            };
            _uIElement.Append(_uIPanel);

            _uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

            var upperMenuContainer = new UIElement {
                Width  = { Percent = 1f },
                Height = { Pixels = 32 },
                Top    = { Pixels = 10 }
            };
            var filterTextBoxBackground = new UIPanel {
                Top    = { Percent = 0f },
                Left   = { Pixels = -135, Percent = 1f },
                Width  = { Pixels = 135 },
                Height = { Pixels = 40 }
            };

            filterTextBoxBackground.OnRightClick += (a, b) => filterTextBox.Text = "";
            upperMenuContainer.Append(filterTextBoxBackground);

            filterTextBox = new UIInputTextField(Language.GetTextValue("tModLoader.ModsTypeToSearch"))
            {
                Top    = { Pixels = 5 },
                Left   = { Pixels = -125, Percent = 1f },
                Width  = { Pixels = 120 },
                Height = { Pixels = 20 }
            };
            filterTextBox.OnTextChange += (a, b) => _updateNeeded = true;
            upperMenuContainer.Append(filterTextBox);
            _uIPanel.Append(upperMenuContainer);

            _modList = new UIList {
                Width       = { Pixels = -25, Percent = 1f },
                Height      = { Pixels = -50, Percent = 1f },
                Top         = { Pixels = 50 },
                ListPadding = 5f
            };
            _uIPanel.Append(_modList);

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

            _uIPanel.Append(uIScrollbar);
            _modList.SetScrollbar(uIScrollbar);

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

            _uIElement.Append(uIHeaderTextPanel);

            var buttonBA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildAll"))
            {
                Width  = { Pixels = -10, Percent = 1f / 3f },
                Height = { Pixels = 40 },
                VAlign = 1f,
                Top    = { Pixels = -65 }
            };

            buttonBA.WithFadedMouseOver();
            buttonBA.OnClick += BuildMods;
            //_uIElement.Append(buttonBA);

            var buttonBRA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildReloadAll"));

            buttonBRA.CopyStyle(buttonBA);
            buttonBRA.HAlign = 0.5f;
            buttonBRA.WithFadedMouseOver();
            buttonBRA.OnClick += BuildAndReload;
            //_uIElement.Append(buttonBRA);

            var buttonCreateMod = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSCreateMod"));

            buttonCreateMod.CopyStyle(buttonBA);
            buttonCreateMod.HAlign = 1f;
            buttonCreateMod.WithFadedMouseOver();
            buttonCreateMod.OnClick += ButtonCreateMod_OnClick;
            _uIElement.Append(buttonCreateMod);

            var buttonB = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back"));

            buttonB.CopyStyle(buttonBA);
            //buttonB.Width.Set(-10f, 1f / 3f);
            buttonB.Top.Pixels = -20;
            buttonB.WithFadedMouseOver();
            buttonB.OnClick += BackClick;
            _uIElement.Append(buttonB);

            var buttonOS = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSOpenSources"));

            buttonOS.CopyStyle(buttonB);
            buttonOS.HAlign = .5f;
            buttonOS.WithFadedMouseOver();
            buttonOS.OnClick += OpenSources;
            _uIElement.Append(buttonOS);

            var buttonMP = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSManagePublished"));

            buttonMP.CopyStyle(buttonB);
            buttonMP.HAlign = 1f;
            buttonMP.WithFadedMouseOver();
            buttonMP.OnClick += ManagePublished;
            _uIElement.Append(buttonMP);
            Append(_uIElement);
        }
Beispiel #8
0
        public override void OnInitialize()
        {
            uIElement = new UIElement();
            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

            UIPanel uIPanel = new UIPanel();

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

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

            UIScrollbar uIScrollbar = new UIScrollbar();

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

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

            modHomepageButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModInfoVisitHomepage"), 1f, false);
            modHomepageButton.Width.Set(0f, 1f);
            modHomepageButton.Height.Set(40f, 0f);
            modHomepageButton.VAlign = 1f;
            modHomepageButton.Top.Set(-65f, 0f);
            modHomepageButton.OnMouseOver += UICommon.FadedMouseOver;
            modHomepageButton.OnMouseOut  += UICommon.FadedMouseOut;
            modHomepageButton.OnClick     += VisitModHomePage;
            uIElement.Append(modHomepageButton);

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

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

            extractButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModInfoExtract"), 1f, false);
            extractButton.Width.Set(-10f, 0.333f);
            extractButton.Height.Set(40f, 0f);
            extractButton.VAlign = 1f;
            extractButton.HAlign = 0.5f;
            extractButton.Top.Set(-20f, 0f);
            extractButton.OnMouseOver += UICommon.FadedMouseOver;
            extractButton.OnMouseOut  += UICommon.FadedMouseOut;
            extractButton.OnClick     += ExtractClick;
            uIElement.Append(extractButton);

            deleteButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Delete"), 1f, false);
            deleteButton.Width.Set(-10f, 0.333f);
            deleteButton.Height.Set(40f, 0f);
            deleteButton.VAlign = 1f;
            deleteButton.HAlign = 1f;
            deleteButton.Top.Set(-20f, 0f);
            deleteButton.OnMouseOver += UICommon.FadedMouseOver;
            deleteButton.OnMouseOut  += UICommon.FadedMouseOut;
            deleteButton.OnClick     += DeleteClick;
            uIElement.Append(deleteButton);

            Append(uIElement);
        }
Beispiel #9
0
        public UIModPackItem(string name, string[] mods)
        {
            this.filename   = name;
            this.mods       = mods;
            this.numMods    = mods.Length;
            modMissing      = new bool[mods.Length];
            numModsEnabled  = 0;
            numModsDisabled = 0;
            numModsMissing  = 0;
            for (int i = 0; i < mods.Length; i++)
            {
                if (UIModPacks.mods.Contains(mods[i]))
                {
                    if (ModLoader.IsEnabled(mods[i]))
                    {
                        numModsEnabled++;
                    }
                    else
                    {
                        numModsDisabled++;
                    }
                }
                else
                {
                    modMissing[i] = true;
                    numModsMissing++;
                }
            }

            BorderColor       = new Color(89, 116, 213) * 0.7f;
            dividerTexture    = TextureManager.Load("Images/UI/Divider");
            innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            Height.Pixels     = 126;
            Width.Percent     = 1f;
            SetPadding(6f);

            modName = new UIText(name)
            {
                Left = { Pixels = 10 },
                Top  = { Pixels = 5 }
            };
            Append(modName);

            var viewListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewList"))
            {
                Width  = { Pixels = 100 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 407 },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();

            viewListButton.PaddingTop    -= 2f;
            viewListButton.PaddingBottom -= 2f;
            viewListButton.OnClick       += ViewListInfo;
            Append(viewListButton);

            enableListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableThisList"))
            {
                Width  = { Pixels = 151 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 248 },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();
            enableListButton.PaddingTop    -= 2f;
            enableListButton.PaddingBottom -= 2f;
            enableListButton.OnClick       += EnableList;
            Append(enableListButton);

            enableListOnlyButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableOnlyThisList"))
            {
                Width  = { Pixels = 190 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 50 },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();
            enableListOnlyButton.PaddingTop    -= 2f;
            enableListOnlyButton.PaddingBottom -= 2f;
            enableListOnlyButton.OnClick       += EnableListOnly;
            Append(enableListOnlyButton);

            viewInModBrowserButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewModsInModBrowser"))
            {
                Width  = { Pixels = 246 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 50 },
                Top    = { Pixels = 80 }
            }.WithFadedMouseOver();
            viewInModBrowserButton.PaddingTop    -= 2f;
            viewInModBrowserButton.PaddingBottom -= 2f;
            viewInModBrowserButton.OnClick       += ViewInModBrowser;
            Append(viewInModBrowserButton);

            updateListWithEnabledButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackUpdateListWithEnabled"))
            {
                Width  = { Pixels = 225 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 304 },
                Top    = { Pixels = 80 }
            }.WithFadedMouseOver();
            updateListWithEnabledButton.PaddingTop    -= 2f;
            updateListWithEnabledButton.PaddingBottom -= 2f;
            updateListWithEnabledButton.OnClick       += (a, b) => UIModPacks.SaveModList(filename);
            Append(updateListWithEnabledButton);

            deleteButton = new UIImageButton(TextureManager.Load("Images/UI/ButtonDelete"))
            {
                Top = { Pixels = 40 }
            };
            deleteButton.OnClick += DeleteButtonClick;
            Append(deleteButton);
        }
Beispiel #10
0
        public override void OnInitialize()
        {
            var uIElement = new UIElement {
                Width    = { Percent = 0.8f },
                MaxWidth = UICommon.MaxPanelWidth,
                Top      = { Pixels = 220 },
                Height   = { Pixels = -220, Percent = 1f },
                HAlign   = 0.5f
            };

            uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

            scrollPanel = new UIPanel {
                Width           = { Percent = 1f },
                Height          = { Pixels = -65, Percent = 1f },
                BackgroundColor = UICommon.mainPanelBackground
            };
            uIElement.Append(scrollPanel);

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

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

            scrollPanel.Append(uIScrollbar);
            modPacks.SetScrollbar(uIScrollbar);

            var titleTextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModPacksHeader"), 0.8f, true)
            {
                HAlign          = 0.5f,
                Top             = { Pixels = -35 },
                BackgroundColor = UICommon.defaultUIBlue
            }.WithPadding(15f);

            uIElement.Append(titleTextPanel);

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

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

            var saveNewButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPacksSaveEnabledAsNewPack"));

            saveNewButton.CopyStyle(backButton);
            saveNewButton.TextColor = Color.Green;
            saveNewButton.HAlign    = 1f;
            saveNewButton.WithFadedMouseOver();
            saveNewButton.OnClick += SaveNewModList;
            uIElement.Append(saveNewButton);

            Append(uIElement);
        }
Beispiel #11
0
        public UIModItem(LocalMod mod)
        {
            this.mod               = mod;
            this.BorderColor       = new Color(89, 116, 213) * 0.7f;
            this.dividerTexture    = TextureManager.Load("Images/UI/Divider");
            this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            this.Height.Set(90f, 0f);
            this.Width.Set(0f, 1f);
            base.SetPadding(6f);
            //base.OnClick += this.ToggleEnabled;
            string text = mod.DisplayName + " v" + mod.modFile.version;

            if (mod.tModLoaderVersion < new Version(0, 10))
            {
                text += $" [c/FF0000:({Language.GetTextValue("tModLoader.ModOldWarning")})]";
            }

            if (mod.modFile.HasFile("icon.png"))
            {
                try
                {
                    Texture2D modIconTexture;
                    using (mod.modFile.EnsureOpen())
                        using (var s = mod.modFile.GetStream("icon.png"))
                            modIconTexture = Texture2D.FromStream(Main.instance.GraphicsDevice, s);

                    if (modIconTexture.Width == 80 && modIconTexture.Height == 80)
                    {
                        modIcon = new UIImage(modIconTexture);
                        modIcon.Left.Set(0f, 0f);
                        modIcon.Top.Set(0f, 0f);
                        Append(modIcon);
                        modIconAdjust += 85;
                    }
                }
                catch { }
            }
            this.modName = new UIText(text, 1f, false);
            this.modName.Left.Set(modIconAdjust + 10f, 0f);
            this.modName.Top.Set(5f, 0f);
            base.Append(this.modName);
            UIAutoScaleTextTextPanel <string> moreInfoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo"), 1f, false);

            moreInfoButton.Width.Set(100f, 0f);
            moreInfoButton.Height.Set(36f, 0f);
            moreInfoButton.Left.Set(430f, 0f);
            moreInfoButton.Top.Set(40f, 0f);
            moreInfoButton.PaddingTop    -= 2f;
            moreInfoButton.PaddingBottom -= 2f;
            moreInfoButton.OnMouseOver   += UICommon.FadedMouseOver;
            moreInfoButton.OnMouseOut    += UICommon.FadedMouseOut;
            moreInfoButton.OnClick       += this.Moreinfo;
            base.Append(moreInfoButton);
            toggleModEnabledButton = new UIAutoScaleTextTextPanel <string>(mod.Enabled ? Language.GetTextValue("tModLoader.ModsDisable") : Language.GetTextValue("tModLoader.ModsEnable"), 1f, false);
            toggleModEnabledButton.Width.Set(100f, 0f);
            toggleModEnabledButton.Height.Set(36f, 0f);
            toggleModEnabledButton.Left.Set(moreInfoButton.Left.Pixels - toggleModEnabledButton.Width.Pixels - 5f, 0f);
            toggleModEnabledButton.Top.Set(40f, 0f);
            toggleModEnabledButton.PaddingTop    -= 2f;
            toggleModEnabledButton.PaddingBottom -= 2f;
            toggleModEnabledButton.OnMouseOver   += UICommon.FadedMouseOver;
            toggleModEnabledButton.OnMouseOut    += UICommon.FadedMouseOut;
            toggleModEnabledButton.OnClick       += this.ToggleEnabled;
            base.Append(toggleModEnabledButton);

            var modRefs = mod.properties.modReferences.Select(x => x.mod).ToArray();

            if (modRefs.Length > 0 && !mod.Enabled)
            {
                string    refs = String.Join(", ", mod.properties.modReferences);
                Texture2D icon = Texture2D.FromStream(Main.instance.GraphicsDevice,
                                                      Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonExclamation.png"));
                UIHoverImage modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.ModDependencyClickTooltip", refs));
                modReferenceIcon.Left.Set(toggleModEnabledButton.Left.Pixels - 24f, 0f);
                modReferenceIcon.Top.Set(47f, 0f);
                modReferenceIcon.OnClick += (a, b) =>
                {
                    var modList = ModOrganizer.FindMods();
                    var missing = new List <string>();
                    foreach (var modRef in modRefs)
                    {
                        ModLoader.EnableMod(modRef);
                        if (!modList.Any(m => m.Name == modRef))
                        {
                            missing.Add(modRef);
                        }
                    }

                    Main.menuMode = Interface.modsMenuID;
                    if (missing.Any())
                    {
                        Interface.infoMessage.SetMessage(Language.GetTextValue("tModLoader.ModDependencyModsNotFound", String.Join(",", missing)));
                        Interface.infoMessage.SetGotoMenu(Interface.modsMenuID);
                        Main.menuMode = Interface.infoMessageID;
                    }
                };
                base.Append(modReferenceIcon);
            }
            if (mod.modFile.ValidModBrowserSignature)
            {
                keyImage = new UIHoverImage(Main.itemTexture[ID.ItemID.GoldenKey], Language.GetTextValue("tModLoader.ModsOriginatedFromModBrowser"));
                keyImage.Left.Set(-20, 1f);
                base.Append(keyImage);
            }
            if (mod.properties.beta)
            {
                keyImage = new UIHoverImage(Main.itemTexture[ID.ItemID.ShadowKey], Language.GetTextValue("tModLoader.BetaModCantPublish"));
                keyImage.Left.Set(-10, 1f);
                Append(keyImage);
            }
            Mod loadedMod = ModLoader.GetMod(mod.Name);

            if (loadedMod != null)
            {
                loaded = true;
                int[]    values           = { loadedMod.items.Count, loadedMod.npcs.Count, loadedMod.tiles.Count, loadedMod.walls.Count, loadedMod.buffs.Count, loadedMod.mountDatas.Count };
                string[] localizationKeys = { "ModsXItems", "ModsXNPCs", "ModsXTiles", "ModsXWalls", "ModsXBuffs", "ModsXMounts" };
                int      xOffset          = -40;
                for (int i = 0; i < values.Length; i++)
                {
                    if (values[i] > 0)
                    {
                        Texture2D iconTexture = Main.instance.infoIconTexture[i];
                        keyImage = new UIHoverImage(iconTexture, Language.GetTextValue($"tModLoader.{localizationKeys[i]}", values[i]));
                        keyImage.Left.Set(xOffset, 1f);
                        base.Append(keyImage);
                        xOffset -= 18;
                    }
                }
            }
        }
Beispiel #12
0
        private void QuickModDelete(UIMouseEvent evt, UIElement listeningElement)
        {
            bool shiftPressed = Main.keyState.PressingShift();

            if (!shiftPressed)
            {
                SoundEngine.PlaySound(10, -1, -1, 1);
                _blockInput = new UIImage(TextureAssets.Extra[190])
                {
                    Width      = { Percent = 1 },
                    Height     = { Percent = 1 },
                    Color      = new Color(0, 0, 0, 0),
                    ScaleToFit = true
                };
                _blockInput.OnMouseDown += CloseDialog;
                Interface.modsMenu.Append(_blockInput);

                _deleteModDialog = new UIPanel()
                {
                    Width           = { Percent = .20f },
                    Height          = { Percent = .20f },
                    HAlign          = .5f,
                    VAlign          = .5f,
                    BackgroundColor = new Color(63, 82, 151),
                    BorderColor     = Color.Black
                };
                _deleteModDialog.SetPadding(6f);
                Interface.modsMenu.Append(_deleteModDialog);

                _dialogYesButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("LegacyMenu.104"))
                {
                    TextColor = Color.White,
                    Width     = new StyleDimension(-10f, 1f / 3f),
                    Height    = { Pixels = 40 },
                    VAlign    = .85f,
                    HAlign    = .15f
                }.WithFadedMouseOver();
                _dialogYesButton.OnClick += DeleteMod;
                _deleteModDialog.Append(_dialogYesButton);

                _dialogNoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("LegacyMenu.105"))
                {
                    TextColor = Color.White,
                    Width     = new StyleDimension(-10f, 1f / 3f),
                    Height    = { Pixels = 40 },
                    VAlign    = .85f,
                    HAlign    = .85f
                }.WithFadedMouseOver();
                _dialogNoButton.OnClick += CloseDialog;
                _deleteModDialog.Append(_dialogNoButton);

                _dialogText = new UIText(Language.GetTextValue("tModLoader.DeleteModConfirm"))
                {
                    Width     = { Percent = .75f },
                    HAlign    = .5f,
                    VAlign    = .3f,
                    IsWrapped = true
                };
                _deleteModDialog.Append(_dialogText);
            }
            else
            {
                DeleteMod(evt, listeningElement);
            }
        }
Beispiel #13
0
        public UIModPackItem(string name, string[] mods)
        {
            _filename        = name;
            _mods            = mods;
            _numMods         = mods.Length;
            _modMissing      = new bool[mods.Length];
            _numModsEnabled  = 0;
            _numModsDisabled = 0;
            _numModsMissing  = 0;
            for (int i = 0; i < mods.Length; i++)
            {
                if (UIModPacks.Mods.Contains(mods[i]))
                {
                    if (ModLoader.IsEnabled(mods[i]))
                    {
                        _numModsEnabled++;
                    }
                    else
                    {
                        _numModsDisabled++;
                    }
                }
                else
                {
                    _modMissing[i] = true;
                    _numModsMissing++;
                }
            }

            BorderColor        = new Color(89, 116, 213) * 0.7f;
            _dividerTexture    = UICommon.DividerTexture;
            _innerPanelTexture = UICommon.InnerPanelTexture;
            Height.Pixels      = 126;
            Width.Percent      = 1f;
            SetPadding(6f);

            _modName = new UIText(name)
            {
                Left = { Pixels = 10 },
                Top  = { Pixels = 5 }
            };
            Append(_modName);

            var viewListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewList"))
            {
                Width  = { Pixels = 100 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 407 },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();

            viewListButton.PaddingTop    -= 2f;
            viewListButton.PaddingBottom -= 2f;
            viewListButton.OnClick       += ViewListInfo;
            Append(viewListButton);

            _enableListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableThisList"))
            {
                Width  = { Pixels = 151 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 248 },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();
            _enableListButton.PaddingTop    -= 2f;
            _enableListButton.PaddingBottom -= 2f;
            _enableListButton.OnClick       += EnableList;
            Append(_enableListButton);

            _enableListOnlyButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableOnlyThisList"))
            {
                Width  = { Pixels = 190 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 50 },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();
            _enableListOnlyButton.PaddingTop    -= 2f;
            _enableListOnlyButton.PaddingBottom -= 2f;
            _enableListOnlyButton.OnClick       += EnableListOnly;
            Append(_enableListOnlyButton);

            _viewInModBrowserButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewModsInModBrowser"))
            {
                Width  = { Pixels = 246 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 50 },
                Top    = { Pixels = 80 }
            }.WithFadedMouseOver();
            _viewInModBrowserButton.PaddingTop    -= 2f;
            _viewInModBrowserButton.PaddingBottom -= 2f;
            _viewInModBrowserButton.OnClick       += ViewInModBrowser;
            Append(_viewInModBrowserButton);

            _updateListWithEnabledButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackUpdateListWithEnabled"))
            {
                Width  = { Pixels = 225 },
                Height = { Pixels = 36 },
                Left   = { Pixels = 304 },
                Top    = { Pixels = 80 }
            }.WithFadedMouseOver();
            _updateListWithEnabledButton.PaddingTop    -= 2f;
            _updateListWithEnabledButton.PaddingBottom -= 2f;
            _updateListWithEnabledButton.OnClick       += (a, b) => UIModPacks.SaveModList(_filename);
            Append(_updateListWithEnabledButton);

            _deleteButton = new UIImageButton(Main.Assets.Request <Texture2D>("Images/UI/ButtonDelete"))
            {
                Top = { Pixels = 40 }
            };
            _deleteButton.OnClick += DeleteButtonClick;
            Append(_deleteButton);
        }
Beispiel #14
0
        public UIModPackItem(string name, string[] mods)
        {
            this.filename   = name;
            this.mods       = mods;
            this.numMods    = mods.Length;
            modMissing      = new bool[mods.Length];
            numModsEnabled  = 0;
            numModsDisabled = 0;
            numModsMissing  = 0;
            for (int i = 0; i < mods.Length; i++)
            {
                if (UIModPacks.mods.Contains(mods[i]))
                {
                    if (ModLoader.IsEnabled(mods[i]))
                    {
                        numModsEnabled++;
                    }
                    else
                    {
                        numModsDisabled++;
                    }
                }
                else
                {
                    modMissing[i] = true;
                    numModsMissing++;
                }
            }

            this.BorderColor       = new Color(89, 116, 213) * 0.7f;
            this.dividerTexture    = TextureManager.Load("Images/UI/Divider");
            this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            this.Height.Set(126f, 0f);
            this.Width.Set(0f, 1f);
            base.SetPadding(6f);

            this.modName = new UIText(name, 1f, false);
            this.modName.Left.Set(10f, 0f);
            this.modName.Top.Set(5f, 0f);
            base.Append(this.modName);

            UIAutoScaleTextTextPanel <string> viewListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewList"), 1f, false);

            viewListButton.Width.Set(100f, 0f);
            viewListButton.Height.Set(40f, 0f);
            viewListButton.Left.Set(407f, 0f);
            viewListButton.Top.Set(40f, 0f);
            viewListButton.PaddingTop    -= 2f;
            viewListButton.PaddingBottom -= 2f;
            viewListButton.OnMouseOver   += UICommon.FadedMouseOver;
            viewListButton.OnMouseOut    += UICommon.FadedMouseOut;
            viewListButton.OnClick       += ViewListInfo;
            base.Append(viewListButton);

            enableListButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableThisList"), 1f, false);
            enableListButton.Width.Set(151f, 0f);
            enableListButton.Height.Set(36f, 0f);
            enableListButton.Left.Set(248f, 0f);
            enableListButton.Top.Set(40f, 0f);
            enableListButton.PaddingTop    -= 2f;
            enableListButton.PaddingBottom -= 2f;
            enableListButton.OnMouseOver   += UICommon.FadedMouseOver;
            enableListButton.OnMouseOut    += UICommon.FadedMouseOut;
            enableListButton.OnClick       += EnableList;
            base.Append(enableListButton);

            enableListOnlyButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackEnableOnlyThisList"), 1f, false);
            enableListOnlyButton.Width.Set(190f, 0f);
            enableListOnlyButton.Height.Set(36f, 0f);
            enableListOnlyButton.Left.Set(50f, 0f);
            enableListOnlyButton.Top.Set(40f, 0f);
            enableListOnlyButton.PaddingTop    -= 2f;
            enableListOnlyButton.PaddingBottom -= 2f;
            enableListOnlyButton.OnMouseOver   += UICommon.FadedMouseOver;
            enableListOnlyButton.OnMouseOut    += UICommon.FadedMouseOut;
            enableListOnlyButton.OnClick       += EnableListOnly;
            base.Append(enableListOnlyButton);

            viewInModBrowserButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackViewModsInModBrowser"), 1f, false);
            viewInModBrowserButton.Width.Set(246f, 0f);
            viewInModBrowserButton.Height.Set(36f, 0f);
            viewInModBrowserButton.Left.Set(50f, 0f);
            viewInModBrowserButton.Top.Set(80f, 0f);
            viewInModBrowserButton.PaddingTop    -= 2f;
            viewInModBrowserButton.PaddingBottom -= 2f;
            viewInModBrowserButton.OnMouseOver   += UICommon.FadedMouseOver;
            viewInModBrowserButton.OnMouseOut    += UICommon.FadedMouseOut;
            viewInModBrowserButton.OnClick       += ViewInModBrowser;
            base.Append(viewInModBrowserButton);

            updateListWithEnabledButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPackUpdateListWithEnabled"), 1f, false);
            updateListWithEnabledButton.Width.Set(225f, 0f);
            updateListWithEnabledButton.Height.Set(36f, 0f);
            updateListWithEnabledButton.Left.Set(304f, 0f);
            updateListWithEnabledButton.Top.Set(80f, 0f);
            updateListWithEnabledButton.PaddingTop    -= 2f;
            updateListWithEnabledButton.PaddingBottom -= 2f;
            updateListWithEnabledButton.OnMouseOver   += UICommon.FadedMouseOver;
            updateListWithEnabledButton.OnMouseOut    += UICommon.FadedMouseOut;
            updateListWithEnabledButton.OnClick       += (a, b) => UIModPacks.SaveModList(filename);
            Append(updateListWithEnabledButton);

            deleteButton = new UIImageButton(TextureManager.Load("Images/UI/ButtonDelete"));
            deleteButton.Top.Set(40f, 0f);
            deleteButton.OnClick += this.DeleteButtonClick;
            base.Append(deleteButton);
        }
Beispiel #15
0
        public override void OnInitialize()
        {
            uIElement = new UIElement();
            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

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

            uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

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

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(0f, 1f);
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);
            modList.SetScrollbar(uIScrollbar);
            UITextPanel <string> uIHeaderTextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.MenuModSources"), 0.8f, true)
            {
                HAlign = 0.5f
            };

            uIHeaderTextPanel.Top.Set(-35f, 0f);
            uIHeaderTextPanel.SetPadding(15f);
            uIHeaderTextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uIHeaderTextPanel);
            UIAutoScaleTextTextPanel <string> buttonBA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildAll"), 1f, false);

            buttonBA.Width.Set(-10f, 0.5f);
            buttonBA.Height.Set(40f, 0f);
            buttonBA.VAlign = 1f;
            buttonBA.Top.Set(-65f, 0f);
            buttonBA.OnMouseOver += UICommon.FadedMouseOver;
            buttonBA.OnMouseOut  += UICommon.FadedMouseOut;
            buttonBA.OnClick     += BuildMods;
            uIElement.Append(buttonBA);
            UIAutoScaleTextTextPanel <string> buttonBRA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildReloadAll"), 1f, false);

            buttonBRA.CopyStyle(buttonBA);
            buttonBRA.HAlign       = 1f;
            buttonBRA.OnMouseOver += UICommon.FadedMouseOver;
            buttonBRA.OnMouseOut  += UICommon.FadedMouseOut;
            buttonBRA.OnClick     += BuildAndReload;
            uIElement.Append(buttonBRA);
            UIAutoScaleTextTextPanel <string> buttonB = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back"), 1f, false);

            buttonB.CopyStyle(buttonBA);
            buttonB.Width.Set(-10f, 1f / 3f);
            buttonB.Top.Set(-20f, 0f);
            buttonB.OnMouseOver += UICommon.FadedMouseOver;
            buttonB.OnMouseOut  += UICommon.FadedMouseOut;
            buttonB.OnClick     += BackClick;
            uIElement.Append(buttonB);
            UIAutoScaleTextTextPanel <string> buttonOS = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSOpenSources"), 1f, false);

            buttonOS.CopyStyle(buttonB);
            buttonOS.HAlign       = .5f;
            buttonOS.OnMouseOver += UICommon.FadedMouseOver;
            buttonOS.OnMouseOut  += UICommon.FadedMouseOut;
            buttonOS.OnClick     += OpenSources;
            uIElement.Append(buttonOS);
            UIAutoScaleTextTextPanel <string> buttonMP = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSManagePublished"), 1f, false);

            buttonMP.CopyStyle(buttonB);
            buttonMP.HAlign       = 1f;
            buttonMP.OnMouseOver += UICommon.FadedMouseOver;
            buttonMP.OnMouseOut  += UICommon.FadedMouseOut;
            buttonMP.OnClick     += ManagePublished;
            uIElement.Append(buttonMP);
            base.Append(uIElement);
        }
Beispiel #16
0
        public override void OnInitialize()
        {
            uIElement = new UIElement();
            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

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

            uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

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

            UIScrollbar uIScrollbar = new UIScrollbar();

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

            modList.SetScrollbar(uIScrollbar);

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

            uIHeaderTexTPanel.HAlign = 0.5f;
            uIHeaderTexTPanel.Top.Set(-35f, 0f);
            uIHeaderTexTPanel.SetPadding(15f);
            uIHeaderTexTPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uIHeaderTexTPanel);
            buttonEA           = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsEnableAll"), 1f, false);
            buttonEA.TextColor = Color.Green;
            buttonEA.Width.Set(-10f, 1f / 3f);
            buttonEA.Height.Set(40f, 0f);
            buttonEA.VAlign = 1f;
            buttonEA.Top.Set(-65f, 0f);
            buttonEA.OnMouseOver += UICommon.FadedMouseOver;
            buttonEA.OnMouseOut  += UICommon.FadedMouseOut;
            buttonEA.OnClick     += this.EnableAll;
            uIElement.Append(buttonEA);
            buttonDA           = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsDisableAll"), 1f, false);
            buttonDA.TextColor = Color.Red;
            buttonDA.CopyStyle(buttonEA);
            buttonDA.HAlign       = 0.5f;
            buttonDA.OnMouseOver += UICommon.FadedMouseOver;
            buttonDA.OnMouseOut  += UICommon.FadedMouseOut;
            buttonDA.OnClick     += this.DisableAll;
            uIElement.Append(buttonDA);
            buttonRM = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsReloadMods"), 1f, false);
            buttonRM.CopyStyle(buttonEA);
            buttonRM.HAlign       = 1f;
            buttonRM.OnMouseOver += UICommon.FadedMouseOver;
            buttonRM.OnMouseOut  += UICommon.FadedMouseOut;
            buttonRM.OnClick     += ReloadMods;
            uIElement.Append(buttonRM);
            buttonB = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back"), 1f, false);
            buttonB.CopyStyle(buttonEA);
            buttonB.Top.Set(-20f, 0f);
            buttonB.OnMouseOver += UICommon.FadedMouseOver;
            buttonB.OnMouseOut  += UICommon.FadedMouseOut;
            buttonB.OnClick     += BackClick;
            uIElement.Append(buttonB);
            buttonOMF = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsOpenModsFolder"), 1f, false);
            buttonOMF.CopyStyle(buttonB);
            buttonOMF.HAlign       = 0.5f;
            buttonOMF.OnMouseOver += UICommon.FadedMouseOver;
            buttonOMF.OnMouseOut  += UICommon.FadedMouseOut;
            buttonOMF.OnClick     += OpenModsFolder;
            uIElement.Append(buttonOMF);

            Texture2D texture            = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.UIModBrowserIcons.png"));
            UIElement upperMenuContainer = new UIElement();

            upperMenuContainer.Width.Set(0f, 1f);
            upperMenuContainer.Height.Set(32f, 0f);
            upperMenuContainer.Top.Set(10f, 0f);

            UICycleImage toggleImage;

            for (int j = 0; j < 3; j++)
            {
                if (j == 0)
                {
                    toggleImage = new UICycleImage(texture, 3, 32, 32, 34 * 3, 0);
                    toggleImage.setCurrentState((int)sortMode);
                    toggleImage.OnClick += (a, b) =>
                    {
                        sortMode     = sortMode.NextEnum();
                        updateNeeded = true;
                    };
                    toggleImage.OnRightClick += (a, b) =>
                    {
                        sortMode     = sortMode.PreviousEnum();
                        updateNeeded = true;
                    };
                }
                else if (j == 1)
                {
                    toggleImage = new UICycleImage(texture, 3, 32, 32, 34 * 4, 0);
                    toggleImage.setCurrentState((int)enabledFilterMode);
                    toggleImage.OnClick += (a, b) =>
                    {
                        enabledFilterMode = enabledFilterMode.NextEnum();
                        updateNeeded      = true;
                    };
                    toggleImage.OnRightClick += (a, b) =>
                    {
                        enabledFilterMode = enabledFilterMode.PreviousEnum();
                        updateNeeded      = true;
                    };
                }
                else
                {
                    toggleImage = new UICycleImage(texture, 5, 32, 32, 34 * 5, 0);
                    toggleImage.setCurrentState((int)modSideFilterMode);
                    toggleImage.OnClick += (a, b) =>
                    {
                        modSideFilterMode = modSideFilterMode.NextEnum();
                        updateNeeded      = true;
                    };
                    toggleImage.OnRightClick += (a, b) =>
                    {
                        modSideFilterMode = modSideFilterMode.PreviousEnum();
                        updateNeeded      = true;
                    };
                }
                toggleImage.Left.Set((float)(j * 36 + 8), 0f);
                _categoryButtons.Add(toggleImage);
                upperMenuContainer.Append(toggleImage);
            }

            UIPanel filterTextBoxBackground = new UIPanel();

            filterTextBoxBackground.Top.Set(0f, 0f);
            filterTextBoxBackground.Left.Set(-170f, 1f);
            filterTextBoxBackground.Width.Set(135f, 0f);
            filterTextBoxBackground.Height.Set(40f, 0f);
            filterTextBoxBackground.OnRightClick += (a, b) => filterTextBox.SetText("");
            upperMenuContainer.Append(filterTextBoxBackground);

            filterTextBox = new UIInputTextField(Language.GetTextValue("tModLoader.ModsTypeToSearch"));
            filterTextBox.Top.Set(5f, 0f);
            filterTextBox.Left.Set(-160f, 1f);
            filterTextBox.Width.Set(160f, 0f);
            filterTextBox.Height.Set(20f, 0f);
            filterTextBox.OnTextChange += (a, b) => { updateNeeded = true; };
            upperMenuContainer.Append(filterTextBox);

            SearchFilterToggle = new UICycleImage(texture, 2, 32, 32, 34 * 2, 0);
            SearchFilterToggle.setCurrentState((int)searchFilterMode);
            SearchFilterToggle.OnClick += (a, b) =>
            {
                searchFilterMode = searchFilterMode.NextEnum();
                updateNeeded     = true;
            };
            SearchFilterToggle.OnRightClick += (a, b) =>
            {
                searchFilterMode = searchFilterMode.PreviousEnum();
                updateNeeded     = true;
            };
            SearchFilterToggle.Left.Set(545f, 0f);
            _categoryButtons.Add(SearchFilterToggle);
            upperMenuContainer.Append(SearchFilterToggle);

            buttonMP = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsModPacks"), 1f, false);
            buttonMP.CopyStyle(buttonOMF);
            buttonMP.HAlign       = 1f;
            buttonMP.OnMouseOver += UICommon.FadedMouseOver;
            buttonMP.OnMouseOut  += UICommon.FadedMouseOut;
            buttonMP.OnClick     += GotoModPacksMenu;
            uIElement.Append(buttonMP);

            uIPanel.Append(upperMenuContainer);
            Append(uIElement);
        }