Skip to content

Commit

Permalink
bugfix related to lost focus state
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMakesGames committed Apr 25, 2024
1 parent 5dae9cc commit 90a2129
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Company>Ben Hendel-Doying</Company>
<Description>An opinionated framework for making smallish games with MonoGame.</Description>
<Copyright>2021-2024 Ben Hendel-Doying</Copyright>
<Version>4.6.1</Version>
<Version>4.6.2</Version>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageTags>monogame game engine framework di state</PackageTags>
Expand Down
11 changes: 8 additions & 3 deletions BenMakesGames.PlayPlayMini/GameStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 90a2129

Please # to comment.