Ejemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            ControlManager.Update(gameTime, PlayerIndex.One);

            if (textCursorBlinkFrequency >= 0f)
            {
                textCursorBlinkFrequency -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else
            {
                textCursorBlinkFrequency = Config.TextCursorBlinkFrequency;
            }

            if (indexMenu == 0 || indexMenu == 1)
            {
                isActive = true;
            }
            else
            {
                isActive = false;
            }

            if (isActive)
            {
                if (login[indexMenu].Length < 40)
                {
                    pressedKeys = InputHandler.KeyboardState.GetPressedKeys();
                }

                shiftPressed = InputHandler.KeyboardState.IsKeyDown(Keys.LeftShift) || InputHandler.KeyboardState.IsKeyDown(Keys.RightShift);

                if (InputHandler.KeyboardState != InputHandler.LastKeyboardState)
                {
                    if (InputHandler.KeyboardState.IsKeyDown(Keys.Space))
                    {
                        login[indexMenu] += " ";
                    }
                    if (InputHandler.KeyboardState.IsKeyDown(Keys.Back) && login[indexMenu].Length > 0)
                    {
                        login[indexMenu] = login[indexMenu].Remove(login[indexMenu].Length - 1, 1);
                    }
                }

                foreach (Keys key in pressedKeys)
                {
                    if (!prevPressedKeys.Contains(key))
                    {
                        string keyString = key.ToString();

                        if (keyString.Length > 1)
                        {
                            keyString = Keyboarding.SpecialChar(keyString, shiftPressed, false);
                        }

                        if (keyString != null)
                        {
                            if (!shiftPressed)
                            {
                                keyString = keyString.ToLower();
                            }

                            login[indexMenu] += keyString;
                        }
                    }
                }
                prevPressedKeys = pressedKeys;
            }

            if (InputHandler.KeyPressed(Keys.Enter))
            {
                switch (indexMenu)
                {
                case 0:
                    break;

                case 1:
                    break;

                case 2:
                    //StateManager.ChangeState(FinalBomber.Instance.NetworkMenuScreen);
                    //FinalBomber.Instance.Server.SendLogin(login[0], login[1]);
                    break;

                case 3:
                    Exit();
                    break;
                }
            }

            if (InputHandler.KeyPressed(Keys.Up))
            {
                if (indexMenu <= 0)
                {
                    indexMenu = menuString.Length - 1;
                }
                else
                {
                    indexMenu--;
                }
            }
            else if (InputHandler.KeyPressed(Keys.Down) || InputHandler.KeyPressed(Keys.Tab))
            {
                indexMenu = (indexMenu + 1) % menuString.Length;
            }

            base.Update(gameTime);

            //FinalBomber.Instance.Server.RunMainConnection();
        }
Ejemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            ControlManager.Update(gameTime, PlayerIndex.One);

            if (textCursorBlinkFrequency >= 0f)
            {
                textCursorBlinkFrequency -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else
            {
                textCursorBlinkFrequency = Config.TextCursorBlinkFrequency;
            }

            if (indexMenu >= 0 && indexMenu <= 3)
            {
                isActive = true;
            }
            else
            {
                isActive = false;
            }

            if (isActive)
            {
                if (login[indexMenu].Length < 40)
                {
                    pressedKeys = InputHandler.KeyboardState.GetPressedKeys();
                }

                shiftPressed = InputHandler.KeyboardState.IsKeyDown(Keys.LeftShift) || InputHandler.KeyboardState.IsKeyDown(Keys.RightShift);
                altGrPressed = InputHandler.KeyboardState.IsKeyDown(Keys.RightAlt) ||
                               (InputHandler.KeyboardState.IsKeyDown(Keys.LeftControl) && InputHandler.KeyboardState.IsKeyDown(Keys.LeftAlt));

                if (InputHandler.KeyboardState != InputHandler.LastKeyboardState)
                {
                    if (InputHandler.KeyboardState.IsKeyDown(Keys.Space))
                    {
                        login[indexMenu] += " ";
                    }
                    if (InputHandler.KeyboardState.IsKeyDown(Keys.Back) && login[indexMenu].Length > 0)
                    {
                        login[indexMenu] = login[indexMenu].Remove(login[indexMenu].Length - 1, 1);
                    }
                }

                foreach (Keys key in pressedKeys)
                {
                    if (!prevPressedKeys.Contains(key))
                    {
                        string keyString = key.ToString();

                        if (keyString.Length > 1)
                        {
                            keyString = Keyboarding.SpecialChar(keyString, shiftPressed, altGrPressed);
                        }

                        if (keyString != null)
                        {
                            if (!shiftPressed)
                            {
                                keyString = keyString.ToLower();
                            }

                            login[indexMenu] += keyString;
                        }
                    }
                }
                prevPressedKeys = pressedKeys;
            }

            if (InputHandler.KeyPressed(Keys.Enter) && indexMenu == 4)
            {
                statusMsg = "";
                if (!(login[0] == "" || login[1] == "" || login[2] == "" || login[3] == ""))
                {
                    if (Functions.CheckChars(login[0]))
                    {
                        if (login[1] == login[2])
                        {
                            if (login[1].Length >= 6 && login[1].Length <= 15)
                            {
                                if (login[0].Length < 20)
                                {
                                    //FinalBomber.Instance.Server.SendCreateAccount(login[0], login[1]);
                                }
                                else
                                {
                                    statusMsg = "Le nom d'utilisateur est trop long ! (20 caractères maximum)";
                                }
                            }
                            else
                            {
                                statusMsg = "Le mot de passe doit être compris\n entre 6 et 15 caractères !";
                            }
                        }
                        else
                        {
                            statusMsg = "Les mots passe sont différents !";
                        }
                    }
                    else
                    {
                        statusMsg = "Le nom d'utilisateur contient\n des caractères non autorisés !";
                    }
                }
                else
                {
                    statusMsg = "Veuillez remplir tous les champs !";
                }
            }

            if (InputHandler.KeyPressed(Keys.Up) ||
                (InputHandler.KeyPressed(Keys.Tab) && InputHandler.KeyDown(Keys.LeftShift)))
            {
                IndexMenuGoUp();
            }
            else if (InputHandler.KeyPressed(Keys.Down) || InputHandler.KeyPressed(Keys.Tab))
            {
                IndexMenuGoDown();
            }

            //FinalBomber.Instance.Server.RunMainConnection();

            base.Update(gameTime);
        }