예제 #1
0
        private void CharacterEntered(object sender, EventInput.CharacterEventArgs e)
        {
            if (StateManager.GameState != GameStates.Menu || StateManager.MenuState != MenuStates.NewGame || Confirmation)
            {
                return;
            }
            // Add key to text buffer. If not a symbol key.
            if (!((int)e.Character < 32 || (int)e.Character > 126)) //From space to tilde
            {
                // Capitals are already supported in DLL so we don't have to worry about checking shift
                if (!(ShortcutProvider.IsKeyDown(Keys.LeftControl) || ShortcutProvider.IsKeyDown(Keys.RightControl)))
                {
                    if (TextBuffer.Length < 10)
                    {
                        TextBuffer += e.Character;
                    }
                }
            }

            // Backspace - remove character if there are any
            if ((int)e.Character == 0x08 && TextBuffer.Length > 0)
            {
                TextBuffer = TextBuffer.Remove(TextBuffer.Length - 1);
            }
        }