コード例 #1
0
        // private Texture2D ShowPasswordTexture;

        public override void OnInitialize()
        {
            // ShowPasswordTexture = TextureManager.Load("Images/UI/InfoIcon_5");

            float height = 0;

            Password = new UILabeledTextInput(Language.GetText(ValueIDPrefix + "PasswordLabel"));
            Password.Input.Sensitive = true;
            Password.Width.Set(0, 1);

            focusGroup.Add(Password.Input);
            height += UILabeledTextInput.DEFAULT_HEIGHT + PADDING;

            RememberPassword = new UILabeledCheckbox(Language.GetText(ValueIDPrefix + "RememberPasswordLabel"), true);
            RememberPassword.Top.Set(height, 0);

            focusGroup.Add(RememberPassword.Checkbox);
            height += UILabeledCheckbox.DEFAULT_HEIGHT + PADDING * 2;             // Add the top padding here as well

            UIPanel Panel = new UIPanel();

            Panel.Width.Set(0, 1);
            Panel.Height.Set(height, 0);
            Panel.SetPadding(PADDING);
            Panel.BackgroundColor = new Color(33, 43, 79) * 0.8f;

            Panel.Append(Password);
            Panel.Append(RememberPassword);

            UILargeButton CancelButton = new UILargeButton(Language.GetText("UI.Cancel"), CancelClick);

            CancelButton.Width.Set(-10, 0.5f);
            CancelButton.VAlign = 1;
            CancelButton.Top.Set(-0, 0);

            UILargeButton SubmitButton = new UILargeButton(Language.GetText("UI.Submit"), SubmitClick);

            SubmitButton.CopyStyle(CancelButton);
            SubmitButton.HAlign = 1;

            UIElement Element = new UIElement();

            Element.Width.Set(0, 0.8f);
            Element.MaxWidth.Set(420, 0);
            Element.Top.Set(220, 0);
            Element.Height.Set(height + 65, 0);
            Element.HAlign = 0.5f;

            Element.Append(Panel);
            Element.Append(CancelButton);
            Element.Append(SubmitButton);

            Append(Element);
        }
コード例 #2
0
        public override void OnInitialize()
        {
            UIElement Element = new UIElement();

            Element.Width.Set(0, 0.8f);
            Element.MaxWidth.Set(650, 0);
            Element.Top.Set(220, 0);
            Element.Height.Set(-220 - 45, 1);
            Element.HAlign = 0.5f;

            UIPanel Panel = new UIPanel();

            Panel.Width.Set(0, 1);
            Panel.Height.Set(-65 * 2, 1);
            Panel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            Element.Append(Panel);

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

            UIScrollbar Scrollbar = new UIScrollbar();

            Scrollbar.SetView(100, 1000);
            Scrollbar.Height.Set(0, 1);
            Scrollbar.HAlign = 1;
            Panel.Append(Scrollbar);
            ServerList.SetScrollbar(Scrollbar);

            UITextPanel <LocalizedText> PanelLabel = new UITextPanel <LocalizedText>(Language.GetText(ValueIDPrefix + "Label"), 0.8f, large: true);

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

            bool steamEnabled = SocialAPI.Network != null;

            UILargeButton HostAndPlayButton = new UILargeButton(Language.GetText("LegacyMenu.88"), HostAndPlayClick);

            if (steamEnabled)
            {
                HostAndPlayButton.Width.Set(-10, 0.5f);
            }
            else
            {
                HostAndPlayButton.Width.Set(0, 1);
            }

            HostAndPlayButton.VAlign = 1;
            HostAndPlayButton.Top.Set(-65, 0);
            Element.Append(HostAndPlayButton);

            if (steamEnabled)
            {
                UILargeButton SteamJoinButton = new UILargeButton(Language.GetText("LegacyMenu.145"), SteamJoinClick);
                SteamJoinButton.CopyStyle(HostAndPlayButton);
                SteamJoinButton.HAlign = 1f;
                Element.Append(SteamJoinButton);
            }

            UILargeButton BackButton = new UILargeButton(Language.GetText("UI.Back"), GoBackClick);

            BackButton.Width.Set(-10, 0.5f);
            BackButton.VAlign = 1;
            BackButton.Top.Set(-0, 0);
            Element.Append(BackButton);

            UILargeButton ConnectButton = new UILargeButton(Language.GetText(ValueIDPrefix + "AddServer"), AddServerClick);

            ConnectButton.CopyStyle(BackButton);
            ConnectButton.HAlign = 1;
            Element.Append(ConnectButton);

            Append(Element);
        }
コード例 #3
0
        public override void OnInitialize()
        {
            float height = 0;

            Name = new UILabeledTextInput(Language.GetText(ValueIDPrefix + "NameLabel"));
            focusGroup.Add(Name.Input);
            Name.Width.Set(0, 1);
            height += UILabeledTextInput.DEFAULT_HEIGHT + PADDING;

            Address = new UILabeledTextInput(Language.GetText(ValueIDPrefix + "AddressLabel"));
            Address.Top.Set(height, 0);
            Address.Width.Set(0 - PORT_WIDTH - PADDING, 1);
            focusGroup.Add(Address.Input);

            Port = new UILabeledTextInput(Language.GetText(ValueIDPrefix + "PortLabel"));
            Port.Top.Set(height, 0);
            Port.Width.Set(PORT_WIDTH, 0);
            Port.HAlign       = 1;
            Port.Input.Filter = (value) => {
                string cleaned = Regex.Replace(value, "[^0-9]", "");

                try {
                    return(Math.Max(0, Math.Min(65535, int.Parse(cleaned))).ToString());
                } catch { }

                return("");
            };

            focusGroup.Add(Port.Input);
            height += UILabeledTextInput.DEFAULT_HEIGHT + PADDING;

            HideAddress = new UILabeledCheckbox(Language.GetText(ValueIDPrefix + "HideAddressLabel"), true);
            HideAddress.Top.Set(height, 0);
            focusGroup.Add(HideAddress.Checkbox);
            height += UILabeledCheckbox.DEFAULT_HEIGHT + PADDING * 2;             // Add the top padding here as well

            UIPanel Panel = new UIPanel();

            Panel.Width.Set(0, 1);
            Panel.Height.Set(height, 0);
            Panel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            Panel.SetPadding(PADDING);
            Panel.Append(Name);
            Panel.Append(Port);
            Panel.Append(Address);
            Panel.Append(HideAddress);

            UIElement Element = new UIElement();

            Element.Width.Set(0, 0.8f);
            Element.MaxWidth.Set(420, 0);
            Element.Top.Set(220, 0);
            Element.Height.Set(height + 65 * 2, 0);             // 65 * 2 = 2 Buttons high
            Element.HAlign = 0.5f;
            Element.Append(Panel);

            UILargeButton BackButton = new UILargeButton(Language.GetText("UI.Back"), GoBackClick);

            BackButton.Top.Set(-0, 0);
            BackButton.Width.Set(-10, 0.5f);
            BackButton.VAlign = 1;
            Element.Append(BackButton);

            UILargeButton SaveButton = new UILargeButton(Language.GetText(ValueIDPrefix + "Save"), SaveServerClick);

            SaveButton.CopyStyle(BackButton);
            SaveButton.HAlign = 1;
            Element.Append(SaveButton);

            UILargeButton SaveAndConnectButton = new UILargeButton(Language.GetText(ValueIDPrefix + "SaveAndConnect"), SaveAndConnectClick);

            SaveAndConnectButton.Top.Set(-65, 0);
            SaveAndConnectButton.VAlign = 1;
            Element.Append(SaveAndConnectButton);

            Append(Element);

            // BackButton.SetSnapPoint("Back", 0);
            // SaveButton.SetSnapPoint("Save", 0);
            // SaveAndConnectButton.SetSnapPoint("Save&Connect", 0);
        }