Beispiel #1
0
        public override void OnInitialize()
        {
            this._panel = new DragableUIPanel();
            this._panel.Left.Set(((Main.screenWidth - this.PanelWidth) / 2) + this.OffsetX, 0f);
            this._panel.Top.Set(((Main.screenHeight - this.PanelHeight) / 2) + this.OffsetY, 0f);
            this._panel.Width.Set(this.PanelWidth, 0f);
            this._panel.Height.Set(this.PanelHeight, 0f);
            this._panel.BorderColor = new Color(0, 0, 0, 0);

            var textbox = new UIInputTextField(this.Value, "Enter a value");

            textbox.OnTextChange += (s, e) => { this.Value = textbox.Text; };
            textbox.OnSave       += (sender, args) => this.Save();
            textbox.OnCancel     += (sender, args) => this.Close();

            var button = new UIClickableButton("Save", (evt, element) => this.Save());

            this._panel.Append(textbox);

            button.Top.Set(50f, 0f);

            this._panel.Append(button);

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

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

            _loaderElement = new UILoaderAnimatedImage(0.5f, 0.5f);

            ModList = new UIList {
                Width       = { Pixels = -25, Percent = 1f },
                Height      = { Pixels = -50, Percent = 1f },
                Top         = { Pixels = 50 },
                ListPadding = 5f
            };

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

            _backgroundElement.Append(listScrollbar);

            _backgroundElement.Append(ModList);
            ModList.SetScrollbar(listScrollbar);

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

            _reloadButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBGettingData"))
            {
                Width  = { Pixels = -10, Percent = 0.5f },
                Height = { Pixels = 25 },
                VAlign = 1f,
                Top    = { Pixels = -65 }
            }.WithFadedMouseOver();

            _backButton = new UITextPanel <string>(Language.GetTextValue("UI.Back"))
            {
                Width  = { Pixels = -10, Percent = 0.5f },
                Height = { Pixels = 25 },
                VAlign = 1f,
                Top    = { Pixels = -20 }
            }.WithFadedMouseOver();

            _clearButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBClearSpecialFilter", "??"))
            {
                Width           = { Pixels = -10, Percent = 0.5f },
                Height          = { Pixels = 25 },
                HAlign          = 1f,
                VAlign          = 1f,
                Top             = { Pixels = -65 },
                BackgroundColor = Color.Purple * 0.7f
            }.WithFadedMouseOver(Color.Purple, Color.Purple * 0.7f);

            _updateAllButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBUpdateAll"))
            {
                Width           = { Pixels = -10, Percent = 0.5f },
                Height          = { Pixels = 25 },
                HAlign          = 1f,
                VAlign          = 1f,
                Top             = { Pixels = -20 },
                BackgroundColor = Color.Orange * 0.7f
            }.WithFadedMouseOver(Color.Orange, Color.Orange * 0.7f);

            _downloadAllButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBDownloadAll"))
            {
                Width           = { Pixels = -10, Percent = 0.5f },
                Height          = { Pixels = 25 },
                HAlign          = 1f,
                VAlign          = 1f,
                Top             = { Pixels = -20 },
                BackgroundColor = Color.Azure * 0.7f
            }.WithFadedMouseOver(Color.Azure, Color.Azure * 0.7f);

            NoModsFoundText = new UIText(Language.GetTextValue("tModLoader.MBNoModsFound"))
            {
                HAlign = 0.5f
            }.WithPadding(15f);

            FilterTextBox = new UIInputTextField(Language.GetTextValue("tModLoader.ModsTypeToSearch"))
            {
                Top    = { Pixels = 5 },
                Left   = { Pixels = -160, Percent = 1f },
                Width  = { Pixels = 100 },
                Height = { Pixels = 10 }
            };

            _upperMenuContainer = new UIElement {
                Width  = { Percent = 1f },
                Height = { Pixels = 32 },
                Top    = { Pixels = 10 }
            };

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

            SortModeFilterToggle = new UIBrowserFilterToggle <ModBrowserSortMode>(0, 0)
            {
                Left = new StyleDimension {
                    Pixels = 0 * 36 + 8
                }
            };
            UpdateFilterToggle = new UIBrowserFilterToggle <UpdateFilter>(34, 0)
            {
                Left = new StyleDimension {
                    Pixels = 1 * 36 + 8
                }
            };
            SearchFilterToggle = new UIBrowserFilterToggle <SearchFilter>(34 * 2, 0)
            {
                Left = new StyleDimension {
                    Pixels = 545f
                }
            };
            ModSideFilterToggle = new UIBrowserFilterToggle <ModSideFilter>(34 * 5, 0)
            {
                Left = new StyleDimension {
                    Pixels = 2 * 36 + 8
                }
            };
            SearchFilterToggle.SetCurrentState(SearchFilter.Name);
            UpdateFilterToggle.SetCurrentState(UpdateFilter.Available);
            ModSideFilterToggle.SetCurrentState(ModSideFilter.All);
            SortModeFilterToggle.SetCurrentState(ModBrowserSortMode.RecentlyUpdated);

            InitializeInteractions();

            _rootElement.Append(_reloadButton);
            _rootElement.Append(_backButton);

            CategoryButtons.Add(SortModeFilterToggle);
            _upperMenuContainer.Append(SortModeFilterToggle);
            CategoryButtons.Add(UpdateFilterToggle);
            _upperMenuContainer.Append(UpdateFilterToggle);
            CategoryButtons.Add(ModSideFilterToggle);
            _upperMenuContainer.Append(ModSideFilterToggle);
            CategoryButtons.Add(SearchFilterToggle);
            _upperMenuContainer.Append(SearchFilterToggle);

            _upperMenuContainer.Append(_filterTextBoxBackground);
            _upperMenuContainer.Append(FilterTextBox);
            _backgroundElement.Append(_upperMenuContainer);

            Append(_rootElement);
        }