示例#1
0
        private void handleKeyboard()
        {
            if (InputManager.KeyPressed(Keys.Up))
            {
                m_ActiveMenuItemIndex = (m_ActiveMenuItemIndex - 1) >= 0 ? (m_ActiveMenuItemIndex - 1) : (Menu.Count - 1);
            }
            else if (InputManager.KeyPressed(Keys.Down))
            {
                m_ActiveMenuItemIndex = (m_ActiveMenuItemIndex + 1) <= (Menu.Count - 1) ? (m_ActiveMenuItemIndex + 1) : 0;
            }
            else if (InputManager.KeyPressed(Keys.Enter))
            {
                if (m_ActiveMenuItemIndex >= 0)
                {
                    m_Menu[m_ActiveMenuItemIndex].RunMethod(Keys.Enter);
                }
            }

            if (m_ActiveMenuItemIndex > -1)
            {
                activateCurrentMenuItem();
                ToggleMenuItem toggleItem = m_Menu[m_ActiveMenuItemIndex] as ToggleMenuItem;
                if (toggleItem != null)
                {
                    if (InputManager.KeyPressed(toggleItem.ToggleRightMethod.ActivateKey))
                    {
                        toggleItem.ToggleRight();
                    }
                    else if (InputManager.KeyPressed(toggleItem.ToggleLeftMethod.ActivateKey))
                    {
                        toggleItem.ToggleLeft();
                    }
                }
                else
                {
                    RangeMenuItem rangeItem = m_Menu[m_ActiveMenuItemIndex] as RangeMenuItem;
                    if (rangeItem != null)
                    {
                        if (InputManager.KeyPressed(rangeItem.DecreaseMethod.ActivateKey))
                        {
                            rangeItem.DecreaseJump();
                        }
                        else if (InputManager.KeyPressed(rangeItem.IncreaseMethod.ActivateKey))
                        {
                            rangeItem.IncreaseJump();
                        }
                    }
                }
            }
        }
示例#2
0
        private void handleMouse()
        {
            bool isMouseHover = isMouseHoverMenuItem();

            if (isMouseHover && InputManager.MouseState.LeftButton == ButtonState.Pressed && m_LastBTNState == ButtonState.Released)
            {
                runMenuItemMethod();
            }
            else if (m_ActiveMenuItemIndex > -1)
            {
                GameMenuItem item = Menu[m_ActiveMenuItemIndex] as GameMenuItem;
                if (isMouseHover && !item.IsActive)
                {
                    activateCurrentMenuItem();
                }
                else if (isMouseHover)
                {
                    RangeMenuItem rangeItem = m_Menu[m_ActiveMenuItemIndex] as RangeMenuItem;
                    if (rangeItem != null)
                    {
                        if (InputManager.MouseState.ScrollWheelValue > m_LastMouseWheelValue)
                        {
                            rangeItem.IncreaseJump();
                        }
                        else if (InputManager.MouseState.ScrollWheelValue < m_LastMouseWheelValue)
                        {
                            rangeItem.DecreaseJump();
                        }

                        m_LastMouseWheelValue = InputManager.MouseState.ScrollWheelValue;
                    }
                }
            }

            m_LastBTNState = InputManager.MouseState.LeftButton;
        }