From ce2131df4278daf69114bf1b7a07d5a6dded0df6 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 29 Mar 2019 17:23:05 +0200 Subject: [PATCH] (e4064088d) Close in-game interfaces when pressing esc. Currently only registered when the mouse is over the interface. Originally I intended to make it so that pressing esc always closes the open interface. But let's test this. --- Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs | 3 +++ Barotrauma/BarotraumaClient/Source/GameMain.cs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs b/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs index e395f08c0..1a0b79cd9 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/HUDLayoutSettings.cs @@ -200,6 +200,9 @@ namespace Barotrauma { public static bool CloseHUD(Rectangle rect) { + // Always close when hitting escape + if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape)) { return true; } + //don't close when the cursor is on a UI element if (GUI.MouseOn != null) return false; diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index ded8f0896..91174caa9 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -601,8 +601,9 @@ namespace Barotrauma { ((GUIMessageBox)GUIMessageBox.VisibleBox).Close(); } - else // Otherwise toggle pausing. + else if (GUI.MouseOn == null && Inventory.SelectedSlot == null && CharacterHealth.OpenHealthWindow == null) { + // Otherwise toggle pausing, unless another window/interface is open. GUI.TogglePauseMenu(); } }