Пример #1
0
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            if (input.IsMenuCancel(null, out playerIndex))
            {
                creditsFinished = true;
                OnCreditsEnd(playerIndex);
            }
        }
Пример #2
0
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            mouseState = Mouse.GetState();

            mousePosition = new Vector2(mouseState.X, mouseState.Y);

            if (input.IsNewKeyPress(Keys.Left, ControllingPlayer, out playerIndex) && !useMouse)
            {
                MoveMenuLeft();
                useMouse = false;
            }
            else if (input.IsNewKeyPress(Keys.Right, ControllingPlayer, out playerIndex) && !useMouse)
            {
                MoveMenuRight();
                useMouse = false;
            }
            else if (input.IsMenuUp(ControllingPlayer) && !useMouse)
            {
                MoveMenuLeft();
            }
            else if (input.IsMenuDown(ControllingPlayer) && !useMouse)
            {
                MoveMenuRight();
            }
            else if (input.IsNewLeftMouseClick())
            {
                foreach (MenuButton button in MenuEntries)
                {
                    CheckButtonClick(input, button);
                }
            }
            else if (input.IsMenuSelect(ControllingPlayer, out playerIndex) && !useMouse)
            {
                OnSelectEntry(selectedEntry, playerIndex);
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex) && !useMouse)
            {
                OnCancel(playerIndex);
            }

            for (int b = 0; b < menuEntries.Count; b++)
            {
                MenuButton button = menuEntries[b];

                button.IsHovering = false;

                CheckButtonHover(input, button);

                if (button.IsHovering)
                {
                    selectedEntry = b;
                }
            }

            // If the current mouse position doesn't equal the last, then our mouse is active!
            if (input.LastMouseState.X != mousePosition.X || input.LastMouseState.Y != mousePosition.Y)
            {
                useMouse = true;
            }

            if (!useMouse)
            {

            }
        }