From ee081cbcf95101a5b469efadab56f6c5233894ee Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Thu, 5 Oct 2023 12:30:06 +0200 Subject: [PATCH] Disable input white `QuickMenu` is open --- StoneRed.LogicSimulator/Srls.cs | 1 + .../UserInterface/Screens/WorldScreen.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/StoneRed.LogicSimulator/Srls.cs b/StoneRed.LogicSimulator/Srls.cs index ff773f2..2950bd4 100644 --- a/StoneRed.LogicSimulator/Srls.cs +++ b/StoneRed.LogicSimulator/Srls.cs @@ -24,6 +24,7 @@ internal class Srls : Game private SrlsWindow? currentSrlsWindow = null; private SrlsScreen? currentSrlsScreen = null; public float Scale { get; private set; } + public bool WindowOpen => currentSrlsWindow is not null; public GraphicsDeviceManager Graphics { get; } public Desktop Desktop { get; private set; } = null!; diff --git a/StoneRed.LogicSimulator/UserInterface/Screens/WorldScreen.cs b/StoneRed.LogicSimulator/UserInterface/Screens/WorldScreen.cs index facd0ff..17357a5 100644 --- a/StoneRed.LogicSimulator/UserInterface/Screens/WorldScreen.cs +++ b/StoneRed.LogicSimulator/UserInterface/Screens/WorldScreen.cs @@ -36,8 +36,11 @@ internal class WorldScreen : SrlsScreen private SpinButton frequency = null!; private CheckBox highPerformance = null!; private ListBox nativeComponentsListBox = null!; + private float fps; + private bool blockInput; + private MouseStateExtended previousMouseState; private ConnectionContext? connectionContext = null; @@ -183,6 +186,12 @@ internal class WorldScreen : SrlsScreen upsLabel.Font = srls.FontSystem.GetFont(10 * srls.Scale); positionLabel.Font = srls.FontSystem.GetFont(10 * srls.Scale); + if (blockInput) + { + blockInput = srls.WindowOpen; + return; + } + MouseStateExtended mouseState = MouseExtended.GetState(); KeyboardStateExtended keyboardState = KeyboardExtended.GetState(); @@ -248,8 +257,11 @@ internal class WorldScreen : SrlsScreen if (keyboardState.IsKeyDown(Keys.Q)) { + blockInput = true; + UnSelectLogicGate(); worldData.LogicGates = simulator.GetLogicGates(); + srls.ShowWindow(new QuickMenu(worldData)); }