From 2716449a59aa627b83243bf620500660e3aafede Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 15 Aug 2024 17:51:07 -0500 Subject: [PATCH] fix titlecard/loading screen bugs --- haxe_libraries/hollywoo.hxml | 6 +-- src/hollywoo_flixel/FlxDirector.kiss | 47 ++++++++++++++-------- src/hollywoo_flixel/HollywooFlixelDSL.kiss | 10 ++--- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/haxe_libraries/hollywoo.hxml b/haxe_libraries/hollywoo.hxml index a44201b..8d8f1ee 100644 --- a/haxe_libraries/hollywoo.hxml +++ b/haxe_libraries/hollywoo.hxml @@ -1,6 +1,6 @@ -# @install: lix --silent download "gh://github.com/kiss-lang/hollywoo#f21d48eab624cac0d113cd653540a0b85403d072" into hollywoo/0.0.0/github/f21d48eab624cac0d113cd653540a0b85403d072 -# @run: haxelib run-dir hollywoo "${HAXE_LIBCACHE}/hollywoo/0.0.0/github/f21d48eab624cac0d113cd653540a0b85403d072" +# @install: lix --silent download "gh://github.com/kiss-lang/hollywoo#a555cbeb92a032dd31fd66c4717d71a71991d9fb" into hollywoo/0.0.0/github/a555cbeb92a032dd31fd66c4717d71a71991d9fb +# @run: haxelib run-dir hollywoo "${HAXE_LIBCACHE}/hollywoo/0.0.0/github/a555cbeb92a032dd31fd66c4717d71a71991d9fb" -lib kiss -lib kiss-tools --cp ${HAXE_LIBCACHE}/hollywoo/0.0.0/github/f21d48eab624cac0d113cd653540a0b85403d072/src/ +-cp ${HAXE_LIBCACHE}/hollywoo/0.0.0/github/a555cbeb92a032dd31fd66c4717d71a71991d9fb/src/ -D hollywoo=0.0.0 \ No newline at end of file diff --git a/src/hollywoo_flixel/FlxDirector.kiss b/src/hollywoo_flixel/FlxDirector.kiss index a88cc90..65fae7a 100644 --- a/src/hollywoo_flixel/FlxDirector.kiss +++ b/src/hollywoo_flixel/FlxDirector.kiss @@ -576,20 +576,28 @@ (var SUBTITLES_MARGIN 30) (var SUBTITLES_SIZE 48) (prop &mut :FlxSprite titleCard null) -(method :Void showTitleCard [:Array text :Continuation cc] - (set titleCard (new FlxSprite)) - (when flxMovie.isLoading - (dictSet kiss_flixel.SpriteTools.ignoreObjects titleCard true)) - (unless flxMovie.isLoading - (set titleCard.cameras [flxMovie.screenCamera])) - (titleCard.makeGraphic FlxG.width FlxG.height FlxColor.BLACK true) - (SpriteTools.writeOnSprite (text.shift) TITLE_SIZE titleCard (object x (Percent 0.5) y (Pixels TITLE_Y))) - (localVar &mut subtitleY (+ TITLE_Y TITLE_SIZE TITLE_MARGIN)) - (doFor subtitle text - (SpriteTools.writeOnSprite subtitle SUBTITLES_SIZE titleCard (object x (Percent 0.5) y (Pixels subtitleY))) - (+= subtitleY SUBTITLES_SIZE SUBTITLES_MARGIN)) - (FlxG.state.add titleCard) - (cc)) +(prop &mut :FlxSprite loadingCard null) +(method :Void showTitleCard [:Array text :Continuation cc &opt :Bool loading] + (if loading + { + (set loadingCard (new FlxSprite)) + // (dictSet kiss_flixel.SpriteTools.ignoreObjects loadingCard true) + (set loadingCard.cameras [flxMovie.uiCamera]) + } + { + (set titleCard (new FlxSprite)) + (set titleCard.cameras [flxMovie.screenCamera]) + }) + (let [card (if loading loadingCard titleCard)] + (card.makeGraphic FlxG.width FlxG.height FlxColor.BLACK true) + (SpriteTools.writeOnSprite (text.shift) TITLE_SIZE card (object x (Percent 0.5) y (Pixels TITLE_Y))) + (localVar &mut subtitleY (+ TITLE_Y TITLE_SIZE TITLE_MARGIN)) + (doFor subtitle text + (SpriteTools.writeOnSprite subtitle SUBTITLES_SIZE card (object x (Percent 0.5) y (Pixels subtitleY))) + (+= subtitleY SUBTITLES_SIZE SUBTITLES_MARGIN)) + (FlxG.state.add card) + (SpriteTools.logSprites) + (cc))) (prop &mut :Bool isLoading false) (var LOAD_CALLS_PER_FRAME 2) @@ -652,15 +660,20 @@ (bar.createColoredEmptyBar FlxColor.BLACK true FlxColor.WHITE) (bar.createColoredFilledBar FlxColor.WHITE false) (bar.screenCenter) + (set bar.camera flxMovie.uiCamera) (FlxG.state.add bar) (FlxG.state.add loop) (dictSet kiss_flixel.SpriteTools.ignoreObjects bar true) (dictSet kiss_flixel.SpriteTools.ignoreObjects loop true)) -(method :Void hideTitleCard [] - (when titleCard +(method :Void hideTitleCard [&opt :Bool loading] + (if loading { + (FlxG.state.remove loadingCard true) + (set loadingCard null) + } { (FlxG.state.remove titleCard true) - (set titleCard null))) + (set titleCard null) + })) // TODO these could be customizable to the Actor, wrylies, etc. (var DIALOG_BOX_COLOR FlxColor.BLACK) diff --git a/src/hollywoo_flixel/HollywooFlixelDSL.kiss b/src/hollywoo_flixel/HollywooFlixelDSL.kiss index 733b61b..397c127 100644 --- a/src/hollywoo_flixel/HollywooFlixelDSL.kiss +++ b/src/hollywoo_flixel/HollywooFlixelDSL.kiss @@ -449,15 +449,15 @@ (unless notSpecial (dictSet presetPositions (pos.stringify) true)))) (method &override :Void createCameras [] + (unless screenCamera + (set screenCamera (new flixel.FlxCamera)) + (set screenCamera.bgColor FlxColor.TRANSPARENT) + (FlxG.cameras.add screenCamera)) (unless uiCamera (set uiCamera (new flixel.FlxCamera)) (set uiCamera.bgColor FlxColor.TRANSPARENT) (flixel.FlxG.cameras.add uiCamera) - (set kiss_flixel.SimpleWindow.defaultCamera uiCamera)) - (unless screenCamera - (set screenCamera (new flixel.FlxCamera)) - (set screenCamera.bgColor FlxColor.TRANSPARENT) - (FlxG.cameras.add screenCamera))) + (set kiss_flixel.SimpleWindow.defaultCamera uiCamera))) (preload // I think it's safe to leave a cleaned-up movie as this reference,