Example #1
0
        public UIModSourceItem(string mod, LocalMod builtMod)
        {
            _mod = mod;

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

            string addendum = Path.GetFileName(mod).Contains(" ") ? $"  [c/FF0000:{Language.GetTextValue("tModLoader.MSModSourcesCantHaveSpaces")}]" : "";

            modName  = Path.GetFileName(mod);
            _modName = new UIText(modName + addendum)
            {
                Left = { Pixels = 10 },
                Top  = { Pixels = 5 }
            };
            Append(_modName);

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

            buildButton.PaddingTop    -= 2f;
            buildButton.PaddingBottom -= 2f;
            buildButton.OnClick       += BuildMod;
            Append(buildButton);

            var buildReloadButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildReload"));

            buildReloadButton.CopyStyle(buildButton);
            buildReloadButton.Width.Pixels = 200;
            buildReloadButton.Left.Pixels  = 150;
            buildReloadButton.WithFadedMouseOver();
            buildReloadButton.OnClick += BuildAndReload;
            Append(buildReloadButton);

            _builtMod = builtMod;
            if (builtMod != null)
            {
                var publishButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSPublish"));
                publishButton.CopyStyle(buildReloadButton);
                publishButton.Width.Pixels = 100;
                publishButton.Left.Pixels  = 390;
                publishButton.WithFadedMouseOver();
                publishButton.OnClick += PublishMod;
                Append(publishButton);
            }
            OnDoubleClick += BuildAndReload;
        }
Example #2
0
        public UIModSourceItem(string mod, LocalMod builtMod)
        {
            this.mod = mod;

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

            string addendum = Path.GetFileName(mod).Contains(" ") ? $"  [c/FF0000:{Language.GetTextValue("tModLoader.MSModSourcesCantHaveSpaces")}]" : "";

            modName = new UIText(Path.GetFileName(mod) + addendum)
            {
                Left = { Pixels = 10 },
                Top  = { Pixels = 5 }
            };
            Append(modName);

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

            button.PaddingTop    -= 2f;
            button.PaddingBottom -= 2f;
            button.OnClick       += BuildMod;
            Append(button);

            var button2 = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildReload"));

            button2.CopyStyle(button);
            button2.Width.Pixels = 200;
            button2.Left.Pixels  = 150;
            button2.WithFadedMouseOver();
            button2.OnClick += BuildAndReload;
            Append(button2);

            this.builtMod = builtMod;
            if (builtMod != null)
            {
                var button3 = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSPublish"));
                button3.CopyStyle(button2);
                button3.Width.Pixels = 100;
                button3.Left.Pixels  = 390;
                button3.WithFadedMouseOver();
                button3.OnClick += this.Publish;
                Append(button3);
            }
            OnDoubleClick += BuildAndReload;
        }
Example #3
0
        public UIModSourceItem(string mod, LocalMod builtMod)
        {
            this.mod            = mod;
            this.BorderColor    = new Color(89, 116, 213) * 0.7f;
            this.dividerTexture = TextureManager.Load("Images/UI/Divider");
            this.Height.Set(90f, 0f);
            this.Width.Set(0f, 1f);
            base.SetPadding(6f);
            string addendum = Path.GetFileName(mod).Contains(" ") ? $"  [c/FF0000:{Language.GetTextValue("tModLoader.MSModSourcesCantHaveSpaces")}]" : "";

            this.modName = new UIText(Path.GetFileName(mod) + addendum, 1f, false);
            this.modName.Left.Set(10f, 0f);
            this.modName.Top.Set(5f, 0f);
            base.Append(this.modName);
            UIAutoScaleTextTextPanel <string> button = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuild"), 1f, false);

            button.Width.Set(100f, 0f);
            button.Height.Set(36f, 0f);
            button.Left.Set(10f, 0f);
            button.Top.Set(40f, 0f);
            button.PaddingTop    -= 2f;
            button.PaddingBottom -= 2f;
            button.OnMouseOver   += UICommon.FadedMouseOver;
            button.OnMouseOut    += UICommon.FadedMouseOut;
            button.OnClick       += this.BuildMod;
            base.Append(button);
            UIAutoScaleTextTextPanel <string> button2 = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildReload"), 1f, false);

            button2.CopyStyle(button);
            button2.Width.Set(200f, 0f);
            button2.Left.Set(150f, 0f);
            button2.OnMouseOver += UICommon.FadedMouseOver;
            button2.OnMouseOut  += UICommon.FadedMouseOut;
            button2.OnClick     += this.BuildAndReload;
            base.Append(button2);
            this.builtMod = builtMod;
            if (builtMod != null)
            {
                UIAutoScaleTextTextPanel <string> button3 = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSPublish"), 1f, false);
                button3.CopyStyle(button2);
                button3.Width.Set(100f, 0f);
                button3.Left.Set(390f, 0f);
                button3.OnMouseOver += UICommon.FadedMouseOver;
                button3.OnMouseOut  += UICommon.FadedMouseOut;
                button3.OnClick     += this.Publish;
                base.Append(button3);
            }
            base.OnDoubleClick += this.BuildAndReload;
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
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);
        }
Example #7
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;
        }
Example #8
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);
        }
Example #9
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);
        }
Example #10
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);
        }
Example #11
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);
        }