From 85d19d7f3cc56ed12e864671c051a7fc5c55d3ef Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 9 Jun 2019 17:36:48 +0300 Subject: [PATCH] (53c44ee8a) Disallow shooting and attacking when hovering over a GUIComponent + added guimessagebox command --- .../BarotraumaClient/Source/DebugConsole.cs | 6 +++++ .../Source/GUI/GUIMessageBox.cs | 2 +- .../BarotraumaShared/Source/PlayerInput.cs | 27 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs index f0e44f86a..baeeb3e80 100644 --- a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs @@ -1172,6 +1172,12 @@ namespace Barotrauma if (args.Length == 0) return; LocalizationCSVtoXML.Convert(args[0]); })); + + commands.Add(new Command("guimessagebox", "guimessagebox [msg] -> Creates a message box with the parameter as a message.", (string[] args) => + { + if (args.Length == 0) return; + var dialog = new GUIMessageBox("Message box", args[0]); + })); #endif commands.Add(new Command("cleanbuild", "", (string[] args) => diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs index c633cc90e..99b5bbc14 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs @@ -179,7 +179,7 @@ namespace Barotrauma public bool Close(GUIButton button, object obj) { Close(); - + return true; } diff --git a/Barotrauma/BarotraumaShared/Source/PlayerInput.cs b/Barotrauma/BarotraumaShared/Source/PlayerInput.cs index 0e611ebbb..2b1d6f7c3 100644 --- a/Barotrauma/BarotraumaShared/Source/PlayerInput.cs +++ b/Barotrauma/BarotraumaShared/Source/PlayerInput.cs @@ -157,6 +157,33 @@ namespace Barotrauma get { return GameMain.Config.KeyBind(inputType); } } + private static bool AllowOnGUI(InputType input) + { + switch (input) + { + case InputType.Attack: + case InputType.Shoot: + return GUI.MouseOn == null; + default: + return true; + } + } + + public KeyOrMouse State + { + get { return binding; } + } + + public void SetState() + { + hit = binding.IsHit() && AllowOnGUI(inputType); + if (hit) hitQueue = true; + + held = binding.IsDown() && AllowOnGUI(inputType); + if (held) heldQueue = true; + } +#endif + public KeyOrMouse State { get { return binding; }