Keep loading when focus is lost

This commit is contained in:
2023-05-26 12:58:24 -06:00
parent f15db577ba
commit 2a4c6b8d7f
2 changed files with 20 additions and 1 deletions

View File

@@ -302,7 +302,10 @@
(FlxG.state.add titleCard)
(cc))
(prop &mut :Bool isLoading false)
(method :Void doLoading [:Array<Void->Void> _load :Continuation cc]
(set isLoading true)
(set FlxG.autoPause false)
(set FlxG.mouse.visible false)
(let [doneFuncs []
bar (new FlxBar 0 0 LEFT_TO_RIGHT (iThird FlxG.width) SimpleWindow.textSize doneFuncs "length" 0 _load.length true)
@@ -315,6 +318,10 @@
}
{
(set FlxG.mouse.visible true)
(set isLoading false)
(unless MovieFlxState.focused
(pause))
(set FlxG.autoPause true)
(FlxG.state.remove bar)
(cc)
}) 1)]

View File

@@ -3,4 +3,16 @@
(method &override :Void create []
(set destroySubStates false)
(super.create)
(set director (new FlxDirector)))
(set director (new FlxDirector)))
(var &mut focused true)
(method &override :Void onFocusLost []
(when FlxG.autoPause
(director.pause))
(set focused false))
(method &override :Void onFocus []
(when (and FlxG.autoPause !director.movie.paused)
(director.resume))
(set focused true))