Spodii / netgore

Cross platform online rpg engine using C# and SFML
http://www.netgore.com/
40 stars 16 forks source link

Menu (Screen) Controls Tab Optimisation #381

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
in DemoGame.Client

find

[csharp]GameScreenHelper.cs[/csharp]

below

static readonly Font _defaultScreenFont;

add

[csharp] static readonly Font _defaultInterfaceFont;[/csharp]

encontre [csharp] _defaultMenuTitleFont = content.LoadFont("Font/journal", 72, 
ContentLevel.Global);[/csharp]

add

[csharp]_defaultInterfaceFont = content.LoadFont("Font/Arial", 24, 
ContentLevel.Global);[/csharp]

encontre [csharp]NewAccountScreen.cs[/csharp]

below

[csharp]_cNameText = new TextBox(cScreen, new Vector2(220, 180), new 
Vector2(200, 40)) { IsMultiLine = false, Text = string.Empty, Font = 
textBoxFont };[/csharp]

add

[csharp]            _cNameText.KeyPressed += cNameText_KeyPressed;
            _cNameText.TextChanged += cNameText_TextChanged;[/csharp]

below

[csharp]_cPasswordText = new TextBox(cScreen, new Vector2(220, 260), new 
Vector2(200, 40)) { IsMultiLine = false, Text = string.Empty, Font = 
textBoxFont };[/csharp]

add

[csharp]            _cPasswordText.KeyPressed += cPasswordText_KeyPressed;
            _cPasswordText.TextChanged += cPasswordText_TextChanged;[/csharp]

below

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

add

[csharp]            _cEmailText.KeyPressed += cEmailText_KeyPressed;
            _cEmailText.TextChanged += cEmailText_TextChanged;[/csharp]

below this sub

[csharp] void _sockets_StatusChanged(IClientSocketManager sender, 
ClientSocketManagerStatusChangedEventArgs e)[/csharp]

add

[csharp]        /// <summary>
        /// Handles the KeyPressed event of the _cNameText control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
        void cNameText_KeyPressed(object sender, KeyEventArgs e)
        {
            // Tab to the next control
            if (e.Code == Keyboard.Key.Tab)
            {
                _cPasswordText.SetFocus();
                _cPasswordText.CursorLinePosition = _cPasswordText.Text.Length;
            }
        }

        /// <summary>
        /// Handles the <see cref="TextBox.TextChanged"/> event of the <see cref="_cNameText"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        void cNameText_TextChanged(Control sender, EventArgs e)
        {
            var c = sender as TextBox;
            if (c == null)
                return;

            var clp = _cNameText.CursorLinePosition;
            _cNameText.Text = GameData.AccountName.AllowedChars.GetValidCharsOnly(_cNameText.Text);
            _cNameText.CursorLinePosition = clp;
        }

        /// <summary>
        /// Handles the KeyPressed event of the _cPasswordText control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
        void cPasswordText_KeyPressed(object sender, KeyEventArgs e)
        {
            // Tab to the next control
            if (e.Code == Keyboard.Key.Tab)
            {
                _cEmailText.SetFocus();
                _cEmailText.CursorLinePosition = _cEmailText.Text.Length;
            }
        }

        /// <summary>
        /// Handles the <see cref="TextBox.TextChanged"/> event of the <see cref="_cPasswordText"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        void cPasswordText_TextChanged(Control sender, EventArgs e)
        {
            var c = sender as TextBox;
            if (c == null)
                return;

            var clp = _cPasswordText.CursorLinePosition;
            _cPasswordText.Text = GameData.AccountPassword.AllowedChars.GetValidCharsOnly(_cPasswordText.Text);
            _cPasswordText.CursorLinePosition = clp;
        }

        void cEmailText_KeyPressed(object sender, KeyEventArgs e)
        {
            // Tab to the next control
            if (e.Code == Keyboard.Key.Tab)
            {
                _cNameText.SetFocus();
                _cNameText.CursorLinePosition = _cNameText.Text.Length;
            }
        }

        void cEmailText_TextChanged(Control sender, EventArgs e)
        {
            var c = sender as TextBox;
            if (c == null)
                return;

            var clp = _cEmailText.CursorLinePosition;
            _cEmailText.Text = GameData.AccountEmail.AllowedChars.GetValidCharsOnly(_cEmailText.Text);
            _cEmailText.CursorLinePosition = clp;
        }[/csharp]

find [csharp]OptionsScreen.cs[/csharp]

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

add

[csharp]            _txtSound.KeyPressed += cSoundText_KeyPressed;
            _txtSound.TextChanged += cSoundText_TextChanged;[/csharp]

below [csharp]_txtMusic = new TextBox(cScreen, pos + new 
Vector2(lblMusic.Size.X + 18, -6), 
                new Vector2(128, lblMusic.ClientSize.Y + 4)) { AllowKeysHandler = TextEventArgsFilters.IsDigitFunc };[/csharp]

add

[csharp]            _txtMusic.KeyPressed += cMusicText_KeyPressed;
            _txtMusic.TextChanged += cMusicText_TextChanged;[/csharp]

below this sub [csharp]void cancel_Clicked(object sender, MouseButtonEventArgs 
e)[/csharp]

add

[csharp]        void cSoundText_KeyPressed(object sender, KeyEventArgs e)
        {
            // Tab to the next control
            if (e.Code == Keyboard.Key.Tab)
            {
                _txtMusic.SetFocus();
                _txtMusic.CursorLinePosition = _txtSound.Text.Length;
            }
        }

        void cSoundText_TextChanged(Control sender, EventArgs e)
        {
            var c = sender as TextBox;
            if (c == null)
                return;

            var clp = _txtSound.CursorLinePosition;
            _txtSound.Text = (_txtSound.Text);
            _txtSound.CursorLinePosition = clp;
        }

        void cMusicText_KeyPressed(object sender, KeyEventArgs e)
        {
            // Tab to the next control
            if (e.Code == Keyboard.Key.Tab)
            {
                _txtSound.SetFocus();
                _txtSound.CursorLinePosition = _txtMusic.Text.Length;
            }
        }

        void cMusicText_TextChanged(Control sender, EventArgs e)
        {
            var c = sender as TextBox;
            if (c == null)
                return;

            var clp = _txtMusic.CursorLinePosition;
            _txtMusic.Text = (_txtMusic.Text);
            _txtMusic.CursorLinePosition = clp;
        }[/csharp]

these were some small bugs I found in the game menu netgore

[b]note if you find any errors English I apologize for this post and this not 
my native language[/b]

Original issue reported on code.google.com by ianADMki...@gmail.com on 30 Apr 2014 at 3:35

GoogleCodeExporter commented 9 years ago
This isn't a bug but rather an optional improvement you've decided to code for 
your project. Updated to reflect this.

Original comment by darksumm...@gmail.com on 10 May 2014 at 2:47