From 2a4c6b8d7f58cb9899629e503deff1ad8c634c06 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 26 May 2023 12:58:24 -0600 Subject: [PATCH] Keep loading when focus is lost --- src/hollywoo_flixel/FlxDirector.kiss | 7 +++++++ src/hollywoo_flixel/MovieFlxState.kiss | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/hollywoo_flixel/FlxDirector.kiss b/src/hollywoo_flixel/FlxDirector.kiss index daf6c4d..8743ebd 100644 --- a/src/hollywoo_flixel/FlxDirector.kiss +++ b/src/hollywoo_flixel/FlxDirector.kiss @@ -302,7 +302,10 @@ (FlxG.state.add titleCard) (cc)) +(prop &mut :Bool isLoading false) (method :Void doLoading [:ArrayVoid> _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)] diff --git a/src/hollywoo_flixel/MovieFlxState.kiss b/src/hollywoo_flixel/MovieFlxState.kiss index 61c25ff..249396c 100644 --- a/src/hollywoo_flixel/MovieFlxState.kiss +++ b/src/hollywoo_flixel/MovieFlxState.kiss @@ -3,4 +3,16 @@ (method &override :Void create [] (set destroySubStates false) (super.create) - (set director (new FlxDirector))) \ No newline at end of file + (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)) \ No newline at end of file