Example #1
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the menu buttons
            _menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Accept", "Cancel");

            _menuButtons["Accept"].Clicked += accept_Clicked;
            _menuButtons["Cancel"].Clicked += cancel_Clicked;

            // Create the options
            var pos      = new Vector2(60, 180);
            var lblSound = GameScreenHelper.CreateMenuLabel(cScreen, pos, "Sound (0 to 100):");

            _txtSound = new TextBox(cScreen, pos + new Vector2(lblSound.Size.X + 10, -6),
                                    new Vector2(128, lblSound.ClientSize.Y + 4))
            {
                AllowKeysHandler = TextEventArgsFilters.IsDigitFunc
            };

            pos.Y += _txtSound.Size.Y + 16;
            var lblMusic = GameScreenHelper.CreateMenuLabel(cScreen, pos, "Music (0 to 100):");

            _txtMusic = new TextBox(cScreen, pos + new Vector2(lblMusic.Size.X + 10, -6),
                                    new Vector2(128, lblMusic.ClientSize.Y + 4))
            {
                AllowKeysHandler = TextEventArgsFilters.IsDigitFunc
            };
        }
Example #2
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Create character", "Back");

            _btnCreateCharacter          = menuButtons["Create character"];
            _btnCreateCharacter.Clicked += ClickButton_CreateCharacter;
            menuButtons["Back"].Clicked += ClickButton_Back;

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 260), "Name:");

            _txtName = new TextBox(cScreen, new Vector2(220, 260), new Vector2(200, 40))
            {
                IsMultiLine = false, Text = "", IsEnabled = true
            };
            _txtName.TextChanged += _txtName_TextChanged;

            _lblValidNameMarker = new Label(cScreen, _txtName.Position + new Vector2(_txtName.Size.X + 10, 0))
            {
                Text = "*", IsVisible = false, ForeColor = Color.Red
            };

            var textBoxPos  = new Vector2(60, _txtName.Position.Y + _txtName.Size.Y + 20);
            var textBoxSize = new Vector2(cScreen.ClientSize.X - (textBoxPos.X * 2), cScreen.ClientSize.Y - textBoxPos.Y - 60);

            _cStatus = new TextBox(cScreen, textBoxPos, textBoxSize)
            {
                ForeColor = Color.Red, Border = null, CanFocus = false, IsMultiLine = true, IsEnabled = false
            };
        }
Example #3
0
            Label CreateChildLabel(Vector2 position, string text, bool enabled = false)
            {
                var ret = GameScreenHelper.CreateMenuLabel(this, position, text);

                ret.IsEnabled           = enabled;
                ret.CanFocus            = enabled;
                ret.IsBoundToParentArea = false;
                return(ret);
            }
Example #4
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            _sockets = ClientSockets.Instance;

            _sockets.PacketHandler.ReceivedCreateAccount -= PacketHandler_ReceivedCreateAccount;
            _sockets.PacketHandler.ReceivedCreateAccount += PacketHandler_ReceivedCreateAccount;

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the new account fields. Use a different font since our default TextBox font doesn't support some characters
            // needed for email, and it'd look funny to only change it for the email textbox.
            var textBoxFont = GameScreenHelper.DefaultChatFont;

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 180), "Name:");
            _cNameText = new TextBox(cScreen, new Vector2(220, 180), new Vector2(200, 40))
            {
                IsMultiLine = false, Text = string.Empty, Font = textBoxFont
            };

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 260), "Password:"******"Email:");
            _cEmailText = new TextBox(cScreen, new Vector2(220, 320), new Vector2(200, 40))
            {
                IsMultiLine = false, Text = string.Empty, Font = textBoxFont
            };

            var textBoxPos  = new Vector2(60, _cEmailText.Position.Y + _cEmailText.Size.Y + 20);
            var textBoxSize = new Vector2(cScreen.ClientSize.X - (textBoxPos.X * 2), cScreen.ClientSize.Y - textBoxPos.Y - 60);

            _cStatus = new TextBox(cScreen, textBoxPos, textBoxSize)
            {
                ForeColor = Color.Red, Border = null, CanFocus = false, IsMultiLine = true, IsEnabled = false
            };

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Create Account", "Back");

            menuButtons["Create Account"].Clicked += ClickButton_CreateAccount;
            menuButtons["Back"].Clicked           += delegate { ScreenManager.SetScreen <MainMenuScreen>(); };

            _createAccountButton = menuButtons["Create Account"];

            _sockets.StatusChanged -= _sockets_StatusChanged;
            _sockets.StatusChanged += _sockets_StatusChanged;
        }
Example #5
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var decodedPass = MachineCrypto.ValidatedDecode(ClientSettings.Default.UI_EnteredPassword) ?? string.Empty;

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the login fields
            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 260), "Name:");
            _cNameText = new TextBox(cScreen, new Vector2(220, 260), new Vector2(200, 40))
            {
                IsMultiLine = false, Text = ClientSettings.Default.UI_EnteredUserName
            };
            _cNameText.KeyPressed  += cNameText_KeyPressed;
            _cNameText.TextChanged += cNameText_TextChanged;

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 320), "Password:"******"Remember Password",
                Value     = ClientSettings.Default.UI_RememberPassword,
                ForeColor = Color.White,
                Font      = GameScreenHelper.DefaultChatFont
            };
            _cRememberPassword.ValueChanged += _cRememberPassword_ValueChanged;

            // NOTE: Display the admin account info
            const string adminAccountInfo =
                "Use the following account for the default admin account:" + "\n    Username: Spodi" + "\n    Password: qwerty123";

            new Label(cScreen, _cRememberPassword.Position + new Vector2(-32, _cRememberPassword.Size.Y + 32))
            {
                Text = adminAccountInfo, ForeColor = Color.Green, Font = GameScreenHelper.DefaultChatFont
            };

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Login", "Back");

            _btnLogin                    = menuButtons["Login"];
            _btnLogin.Clicked           += _btnLogin_Clicked;
            menuButtons["Back"].Clicked += LoginScreen_Clicked;

            cScreen.SetFocus();

            // Set up the networking stuff for this screen
            _sockets = ClientSockets.Instance;
            _sockets.StatusChanged -= _sockets_StatusChanged;
            _sockets.StatusChanged += _sockets_StatusChanged;
            _sockets.PacketHandler.ReceivedLoginSuccessful   += PacketHandler_ReceivedLoginSuccessful;
            _sockets.PacketHandler.ReceivedLoginUnsuccessful += PacketHandler_ReceivedLoginUnsuccessful;
        }