Beispiel #1
0
        private void ButtonControls(GameTime gameTime)
        {
            if (!ControlManager.GamepadReady)
            {
                if (ControlManager.CheckPress(RebindableKeys.Down))
                {
                    cursorIndex++;
                    holdTimer = game.HoldKeyTreshold;

                    PlayHoverSound();

                    if (cursorIndex > menuOptions.Length / 2 - 1)
                    {
                        cursorIndex = 0;
                    }
                }

                else if (ControlManager.CheckHold(RebindableKeys.Down))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorIndex++;
                        holdTimer = game.ScrollSpeedFast;

                        PlayHoverSound();
                    }

                    if (cursorIndex > menuOptions.Length / 2 - 1)
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                }

                else if (ControlManager.CheckPress(RebindableKeys.Up))
                {
                    cursorIndex--;
                    holdTimer = game.HoldKeyTreshold;

                    PlayHoverSound();

                    if (cursorIndex < 0)
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                }

                else if (ControlManager.CheckHold(RebindableKeys.Up))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorIndex--;
                        holdTimer = game.ScrollSpeedFast;

                        PlayHoverSound();
                    }

                    if (cursorIndex < 0)
                    {
                        cursorIndex = 0;
                    }
                }
            }

            else
            {
                if (ControlManager.CheckButtonPress(Buttons.DPadDown) ||
                    ControlManager.CheckButtonPress(Buttons.LeftThumbstickDown))
                {
                    cursorIndex++;
                    holdTimer = game.HoldKeyTreshold;

                    PlayHoverSound();
                }

                else if (ControlManager.CurrentGamepadState.IsButtonDown(Buttons.DPadDown) ||
                         ControlManager.CurrentGamepadState.IsButtonDown(Buttons.LeftThumbstickDown))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorIndex++;
                        holdTimer = game.ScrollSpeedFast;

                        PlayHoverSound();
                    }
                }

                else if (ControlManager.CheckButtonPress(Buttons.DPadUp) ||
                         ControlManager.CheckButtonPress(Buttons.LeftThumbstickUp))
                {
                    cursorIndex--;
                    holdTimer = game.HoldKeyTreshold;

                    PlayHoverSound();
                }

                else if (ControlManager.CurrentGamepadState.IsButtonDown(Buttons.DPadUp) ||
                         ControlManager.CurrentGamepadState.IsButtonDown(Buttons.LeftThumbstickUp))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorIndex--;
                        holdTimer = game.ScrollSpeedFast;

                        PlayHoverSound();
                    }
                }

                if (cursorIndex < 0)
                {
                    if (ControlManager.CurrentGamepadState.IsButtonUp(Buttons.DPadUp))
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                    else if (ControlManager.CurrentGamepadState.IsButtonUp(Buttons.LeftThumbstickUp))
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                    else
                    {
                        cursorIndex = 0;
                    }
                }

                else if (cursorIndex > menuOptions.Length / 2 - 1)
                {
                    if (ControlManager.CurrentGamepadState.IsButtonUp(Buttons.DPadDown))
                    {
                        cursorIndex = 0;
                    }
                    else if (ControlManager.CurrentGamepadState.IsButtonUp(Buttons.LeftThumbstickUp))
                    {
                        cursorIndex = 0;
                    }
                    else
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                }
            }


            if (ControlManager.CheckPress(RebindableKeys.Action2) ||
                ControlManager.CheckPress(RebindableKeys.Pause))
            {
                optionsMenuState.LeaveSubState();
                OnLeave();
            }

            else if (ControlManager.CheckPress(RebindableKeys.Action1) ||
                     ControlManager.CheckKeyPress(Keys.Enter))
            {
                ButtonActions();
            }
        }