diff --git a/OctoAwesome/OctoAwesome.Client/Screens/GameScreen.cs b/OctoAwesome/OctoAwesome.Client/Screens/GameScreen.cs index 11d7998a..09c4a089 100644 --- a/OctoAwesome/OctoAwesome.Client/Screens/GameScreen.cs +++ b/OctoAwesome/OctoAwesome.Client/Screens/GameScreen.cs @@ -281,6 +281,7 @@ private void RegisterKeyActions() #region GamePad Input private bool pressedGamepadInventory = false; + private bool pressedGamepadPause = false; private bool pressedGamepadInteract = false; private bool pressedGamepadApply = false; private bool pressedGamepadJump = false; @@ -333,6 +334,10 @@ private void HandleGamePad() if (gamePadState.Buttons.Back == ButtonState.Pressed && !pressedGamepadInventory) Manager.NavigateToScreen(new InventoryScreen(Manager)); pressedGamepadInventory = gamePadState.Buttons.Back == ButtonState.Pressed; + + if (gamePadState.Buttons.Start == ButtonState.Pressed && !pressedGamepadPause) + Manager.NavigateToScreen(new PauseScreen(Manager)); + pressedGamepadPause = gamePadState.Buttons.Start == ButtonState.Pressed; } } diff --git a/OctoAwesome/OctoAwesome.Client/Screens/PauseScreen.cs b/OctoAwesome/OctoAwesome.Client/Screens/PauseScreen.cs index 503378ce..2f392faf 100644 --- a/OctoAwesome/OctoAwesome.Client/Screens/PauseScreen.cs +++ b/OctoAwesome/OctoAwesome.Client/Screens/PauseScreen.cs @@ -1,6 +1,8 @@ -using engenious.Input; +using engenious; +using engenious.Input; using MonoGameUi; using OctoAwesome.Client.Components; +using System; namespace OctoAwesome.Client.Screens { @@ -12,8 +14,8 @@ public PauseScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; - // IsOverlay = true; - // Background = new BorderBrush(new Color(Color.Black, 0.5f)); + //IsOverlay = true; + //Background = new BorderBrush(new Color(Color.Black, 0.5f)); Background = new TextureBrush(assets.LoadTexture(typeof(ScreenComponent), "background"), TextureBrushMode.Stretch); @@ -70,5 +72,23 @@ protected override void OnKeyDown(KeyEventArgs args) base.OnKeyDown(args); } + + private bool pressedGamepadBack = false; + + protected override void OnUpdate(GameTime gameTime) + { + if (!IsActiveScreen) return; + + try + { + var gamePadState = GamePad.GetState(0); + if (gamePadState.Buttons.Back == ButtonState.Pressed && !pressedGamepadBack) + Manager.NavigateBack(); + pressedGamepadBack = gamePadState.Buttons.Back == ButtonState.Pressed; + } + catch (Exception) { } + + base.OnUpdate(gameTime); + } } }