GameStateManagement.InputState.IsMenuLeft C# (CSharp) Method

IsMenuLeft() public method

public IsMenuLeft ( ) : bool
return bool
        public bool IsMenuLeft()
        {
            return IsNewKeyPress(Keys.Left);
        }

Usage Example

Example #1
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input.IsMenuCancel())
            {
                OnCancel(null, null);
            }

            if (input.IsMenuUp())
            {
                selectedEntry--;
                if (selectedEntry < 0)
                {
                    selectedEntry = menuEntries.Count - 1;
                }
                while (!menuEntries[selectedEntry].Enabled)
                {
                    selectedEntry--;
                    if (selectedEntry < 0)
                    {
                        selectedEntry = menuEntries.Count - 1;
                    }
                }
            }
            if (input.IsMenuDown())
            {
                selectedEntry++;
                if (selectedEntry >= menuEntries.Count)
                {
                    selectedEntry = 0;
                }
                while (!menuEntries[selectedEntry].Enabled)
                {
                    selectedEntry++;
                    if (selectedEntry >= menuEntries.Count)
                    {
                        selectedEntry = 0;
                    }
                }
            }
            if (input.IsMenuLeft())
            {
                menuEntries[selectedEntry].Left();
            }
            if (input.IsMenuRight())
            {
                menuEntries[selectedEntry].Right();
            }

            if (input.IsMenuSelect())
            {
                OnSelectEntry(selectedEntry);
            }
            if (selectedEntry < 0)
            {
                selectedEntry = menuEntries.Count - 1;
            }
            if (selectedEntry >= menuEntries.Count)
            {
                selectedEntry = 0;
            }


            Point mouseLocation = ScreenManager.ScaledMousePos;

            for (int i = 0; i < menuEntries.Count; i++)
            {
                MenuEntry menuEntry = menuEntries[i];

                if (GetMenuEntryHitBounds(menuEntry).Contains(mouseLocation))
                {
                    selectedEntry = i;

                    // Mouse left click?
                    if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed)
                    {
                        menuEntry.Click(mouseLocation.X, mouseLocation.Y);
                    }
                }
            }
        }
All Usage Examples Of GameStateManagement.InputState::IsMenuLeft