//=========== 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(); } }
/** <summary> The sprite sheet used for the menu items. </summary> */ //internal SpriteAtlas debugMenuSprites; #endregion //========= CONSTRUCTORS ========= #region Constructors /** <summary> Constructs the main debug menu. </summary> */ public DebugMenu() { this.menu = new DebugMenuItem("root"); this.currentPath = new List <int>(); this.currentItem = null; this.mouseHoverItem = null; this.mouseHover = false; this.controlMode = MenuControlMode.Keyboard; this.open = false; this.debugMenuFont = null; this.debugMenuFontBold = null; this.debugMenuSprites = null; }
/** <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(); } }
/** <summary> Constructs the main debug menu. </summary> */ public DebugMenu() { this.menu = new DebugMenuItem("root"); this.currentPath = new List<int>(); this.currentItem = null; this.mouseHoverItem = null; this.mouseHover = false; this.controlMode = MenuControlMode.Keyboard; this.open = false; this.debugMenuFont = null; this.debugMenuFontBold = null; this.debugMenuSprites = null; }