Exemple #1
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);

            modListAll = new UIList();
            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);
            uIHeaderTextPanel        = new UITextPanel <string>("Mod Browser", 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);

            reloadButton = new UITextPanel <string>("Getting data...", 1f, false);
            reloadButton.Width.Set(-10f, 0.5f);
            reloadButton.Height.Set(25f, 0f);
            reloadButton.VAlign = 1f;
            reloadButton.Top.Set(-65f, 0f);
            reloadButton.OnMouseOver += UICommon.FadedMouseOver;
            reloadButton.OnMouseOut  += UICommon.FadedMouseOut;
            reloadButton.OnClick     += ReloadList;
            uIElement.Append(reloadButton);

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

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

            clearButton = new UITextPanel <string>("Clear Special Filter: ??", 1f, false);
            clearButton.Width.Set(-10f, 0.5f);
            clearButton.Height.Set(25f, 0f);
            clearButton.HAlign = 1f;
            clearButton.VAlign = 1f;
            clearButton.Top.Set(-65f, 0f);
            clearButton.BackgroundColor = Color.Purple * 0.7f;
            clearButton.OnMouseOver    += (s, e) => UICommon.CustomFadedMouseOver(Color.Purple, s, e);
            clearButton.OnMouseOut     += (s, e) => UICommon.CustomFadedMouseOut(Color.Purple * 0.7f, s, e);
            clearButton.OnClick        += (s, e) =>
            {
                Interface.modBrowser.SpecialModPackFilter      = null;
                Interface.modBrowser.SpecialModPackFilterTitle = null;
                Interface.modBrowser.SortList();
                Main.PlaySound(SoundID.MenuTick);
            };

            Append(uIElement);

            UIElement upperMenuContainer = new UIElement();

            upperMenuContainer.Width.Set(0f, 1f);
            upperMenuContainer.Height.Set(32f, 0f);
            upperMenuContainer.Top.Set(10f, 0f);
            Texture2D texture = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.UIModBrowserIcons.png"));

            for (int j = 0; j < 2; j++)
            {
                if (j == 0)
                {
                    uIToggleImage = new UICycleImage(texture, 6, 32, 32, 0, 0);
                    uIToggleImage.setCurrentState((int)sortMode);
                    uIToggleImage.OnClick += (a, b) =>
                    {
                        sortMode = sortMode.NextEnum();
                        SortList();
                    };
                    uIToggleImage.OnRightClick += (a, b) =>
                    {
                        sortMode = sortMode.PreviousEnum();
                        SortList();
                    };
                }
                else
                {
                    uIToggleImage = new UICycleImage(texture, 3, 32, 32, 34, 0);
                    uIToggleImage.setCurrentState((int)updateFilterMode);
                    uIToggleImage.OnClick += (a, b) =>
                    {
                        updateFilterMode = updateFilterMode.NextEnum();
                        SortList();
                    };
                    uIToggleImage.OnRightClick += (a, b) =>
                    {
                        updateFilterMode = updateFilterMode.PreviousEnum();
                        SortList();
                    };
                }
                uIToggleImage.Left.Set((float)(j * 36 + 8), 0f);
                _categoryButtons.Add(uIToggleImage);
                upperMenuContainer.Append(uIToggleImage);
            }
            UIPanel filterTextBoxBackground = new UIPanel();

            filterTextBoxBackground.Top.Set(0f, 0f);
            filterTextBoxBackground.Left.Set(-170, 1f);
            filterTextBoxBackground.Width.Set(135f, 0f);
            filterTextBoxBackground.Height.Set(40f, 0f);
            upperMenuContainer.Append(filterTextBoxBackground);

            filterTextBox = new UIInputTextField("Type to search");
            filterTextBox.Top.Set(5, 0f);
            filterTextBox.Left.Set(-160, 1f);
            filterTextBox.OnTextChange += (sender, e) => SortList();
            upperMenuContainer.Append(filterTextBox);

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