From 90a2129befc7ffb281892cae1ffa91367e569e5a Mon Sep 17 00:00:00 2001 From: Ben H Date: Thu, 25 Apr 2024 17:32:43 -0400 Subject: [PATCH] bugfix related to lost focus state --- .../BenMakesGames.PlayPlayMini.csproj | 2 +- BenMakesGames.PlayPlayMini/GameStateManager.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj b/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj index e0e4dde..476843a 100644 --- a/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj +++ b/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj @@ -5,7 +5,7 @@ Ben Hendel-Doying An opinionated framework for making smallish games with MonoGame. 2021-2024 Ben Hendel-Doying - 4.6.1 + 4.6.2 true monogame game engine framework di state diff --git a/BenMakesGames.PlayPlayMini/GameStateManager.cs b/BenMakesGames.PlayPlayMini/GameStateManager.cs index 5989964..bda8c13 100644 --- a/BenMakesGames.PlayPlayMini/GameStateManager.cs +++ b/BenMakesGames.PlayPlayMini/GameStateManager.cs @@ -91,10 +91,15 @@ protected override void Update(GameTime gameTime) { SwitchState(); - if(!IsActive && LostFocusGameState is not null && CurrentState.GetType() != LostFocusGameState) + if(!IsActive && LostFocusGameState is not null) { - ChangeState(LostFocusGameState, new LostFocusConfig(CurrentState)); - SwitchState(); + var currentStateType = CurrentState.GetType(); + + if (currentStateType != LostFocusGameState && currentStateType != Config.InitialGameState && currentStateType != typeof(NoState)) + { + ChangeState(LostFocusGameState, new LostFocusConfig(CurrentState)); + SwitchState(); + } } Input(gameTime);