Пример #1
0
        //============ EVENTS ============
        #region Events

        /** <summary> Returns true if the control was pressed. </summary> */
        public override bool Pressed()
        {
            return((Ctrl == (Keyboard.IsKeyDown(Keys.LCtrl) || Keyboard.IsKeyDown(Keys.RCtrl))) &&
                   (Shift == (Keyboard.IsKeyDown(Keys.LShift) || Keyboard.IsKeyDown(Keys.RShift))) &&
                   (Alt == (Keyboard.IsKeyDown(Keys.LAlt) || Keyboard.IsKeyDown(Keys.RAlt))) &&
                   Keyboard.IsKeyPressed(KeyCode));
        }
Пример #2
0
        //-----------------------------------------------------------------------------
        // Updating
        //-----------------------------------------------------------------------------

        // Called every step to update the game.
        public void Update(float timeDelta)
        {
            //prop.Update(1.0 / 60.0, new Point2I(ScreenSize.X - Property<int>.Width, ScreenSize.Y / 2));

            //if (Keyboard.IsKeyPressed(Keys.F4))
            //	GameBase.IsFullScreen = !GameBase.IsFullScreen;

            // Update the menu
            Controls.Update();

            // Toggle debug mode
            if (Keyboard.IsKeyPressed(Keys.F2) || (GamePad.IsButtonDown(Buttons.Back) && GamePad.IsButtonPressed(Buttons.RightStickButton)))
            {
                debugMode = !debugMode;
            }

            // Update the game-state stack.
            if (!isGamePaused)
            {
                gameStateStack.Update();
            }

            elapsedTicks++;

            // DEBUG: Update debug keys.
            GameDebug.GameControl = gameControl;
            GameDebug.UpdateRoomDebugKeys();
        }
Пример #3
0
        //=========== UPDATING ===========
        #region Updating

        /** <summary> Updates the debug menu while it's open. </summary> */
        public void Update()
        {
            if (Mouse.IsMouseMoved())
            {
                if (Mouse.GetDistance().Length > 2.0 && mouseHoverItem != null)
                {
                    controlMode = MenuControlMode.Mouse;
                }
            }

            if (Keyboard.IsKeyPressed(Keys.Left) ||
                Keyboard.IsKeyPressed(Keys.Right) ||
                Keyboard.IsKeyPressed(Keys.Up) ||
                Keyboard.IsKeyPressed(Keys.Down) ||
                Keyboard.IsKeyPressed(Keys.X) ||
                Keyboard.IsKeyPressed(Keys.Z) ||
                Keyboard.IsKeyPressed(Keys.Space) ||
                Keyboard.IsKeyPressed(Keys.Enter) ||
                Keyboard.IsKeyPressed(Keys.Escape))
            {
                controlMode = MenuControlMode.Keyboard;
            }
            else if (GamePad.IsButtonPressed(Buttons.DPadLeft) ||
                     GamePad.IsButtonPressed(Buttons.DPadRight) ||
                     GamePad.IsButtonPressed(Buttons.DPadUp) ||
                     GamePad.IsButtonPressed(Buttons.DPadDown) ||
                     GamePad.IsButtonPressed(Buttons.LeftStickLeft) ||
                     GamePad.IsButtonPressed(Buttons.LeftStickRight) ||
                     GamePad.IsButtonPressed(Buttons.LeftStickUp) ||
                     GamePad.IsButtonPressed(Buttons.LeftStickDown) ||
                     GamePad.IsButtonPressed(Buttons.A) ||
                     GamePad.IsButtonPressed(Buttons.B) ||
                     GamePad.IsButtonPressed(Buttons.Start) ||
                     GamePad.IsButtonPressed(Buttons.Back) ||
                     GamePad.IsButtonPressed(Buttons.Y))
            {
                controlMode = MenuControlMode.GamePad;
            }

            if (controlMode == MenuControlMode.Mouse)
            {
                UpdateMouseControls();
            }
            else if (controlMode == MenuControlMode.Keyboard)
            {
                UpdateKeyboardControls();
            }
            else
            {
                UpdateGamePadControls();
            }
        }
Пример #4
0
 public override bool Pressed()
 {
     return(Keyboard.IsKeyPressed(KeyCode));
 }
Пример #5
0
        /** <summary> Updates the debug menu with keyboard controls. </summary> */
        private void UpdateKeyboardControls()
        {
            Keys keyNextItem = Keys.Down;
            Keys keyPrevItem = Keys.Up;
            Keys keyStepInto = Keys.Right;
            Keys keyStepOut  = Keys.Left;

            if (currentItem.Root.Root == null)
            {
                keyNextItem = Keys.Right;
                keyPrevItem = Keys.Left;
                keyStepInto = Keys.Down;
                keyStepOut  = Keys.Up;
            }

            // Select next root menu item.
            if (Keyboard.IsKeyPressed(Keys.Right) && currentItem.Items.Count == 0 && CurrentMenu != menu)
            {
                int index = currentPath[0];
                currentItem = menu.Items[index];
                currentPath.Clear();
                currentPath.Add(index);
                SelectNextItem();
                StepIntoSubMenu();
            }

            // Step into a sub-menu.
            else if (Keyboard.IsKeyPressed(keyStepInto))
            {
                StepIntoSubMenu();
            }

            // Select previous root menu item.
            if (Keyboard.IsKeyPressed(Keys.Left) && CurrentMenu.Root == menu)
            {
                currentItem = CurrentMenu;
                currentPath.RemoveAt(currentPath.Count - 1);
                SelectPreviousItem();
                StepIntoSubMenu();
            }
            // Step out of a sub-menu.
            else if (Keyboard.IsKeyPressed(keyStepOut))
            {
                StepOutOfSubMenu();
            }

            // Select next item.
            if (Keyboard.IsKeyPressed(keyNextItem))
            {
                SelectNextItem();
            }

            // Select previous item.
            if (Keyboard.IsKeyPressed(keyPrevItem))
            {
                SelectPreviousItem();
            }

            // Step out of a sub-menu.
            if (Keyboard.IsKeyPressed(Keys.X) || Keyboard.IsKeyPressed(Keys.Escape))
            {
                StepOutOfSubMenu();
            }

            // Press item.
            if (Keyboard.IsKeyPressed(Keys.Enter) || Keyboard.IsKeyPressed(Keys.Z) || Keyboard.IsKeyPressed(Keys.Space))
            {
                if (currentItem.Items.Count == 0)
                {
                    currentItem.Press();
                    if (!Keyboard.IsKeyPressed(Keys.Space))
                    {
                        Close();
                    }
                }
                else
                {
                    StepIntoSubMenu();
                }
            }
        }