diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx index c2ff5c4d..311b0512 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx @@ -7,6 +7,7 @@ import flixel.FlxSprite; import flixel.input.actions.FlxAction; import flixel.input.actions.FlxActionManager; import flixel.input.mouse.FlxMouseButton; +import flixel.tweens.FlxTween; import hollywoo.Movie; import hollywoo.Scene; import hollywoo.Director; diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss index 6a69efda..b8ea3617 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss @@ -219,4 +219,59 @@ (method :Void hideProp [prop cc] (currentState.remove prop) - (cc)) \ No newline at end of file + (cc)) + +(prop :Array creditsText []) +(method _ctext [:String text :Int size] + (let [t (new FlxText 0 0 0 text size)] + (creditsText.push t) + t)) + +// TODO maybe credits need their own substate so an after-credits scene could be done. +// currently the bg will cover whatever the final scene was. +(method :Void rollCredits [:Array credits cc] + (localVar bg (new FlxSprite)) + (bg.makeGraphic 1280 720 FlxColor.BLACK true) + (currentState.add bg) + (localVar &mut textY 720) + (var oneColSize 64) + (var twoColSize 48) + (var threeColSize 32) + (var creditMargin 10) + (var twoColumnGap 50) + (doFor line credits + (case line + (Break + (+= textY oneColSize)) + // Centered, big one column lines + ((OneColumn col1) + (let [t (_ctext col1 oneColSize)] + (t.screenCenter) + (set t.y textY)) + (+= textY oneColSize creditMargin)) + // Centered left/right two column lines + ((TwoColumn col1 col2) + (let [t1 (_ctext col1 twoColSize) + t2 (_ctext col2 twoColSize)] + (set t1.x (- (/ 1280 2) t1.width (/ twoColumnGap 2))) + (set t1.y textY) + (set t2.x (+ (/ 1280 2) (/ twoColumnGap 2))) + (set t2.y textY)) + (+= textY twoColSize creditMargin)) + // Left-justified, centered, right-justified three column lines + ((ThreeColumn col1 col2 col3) + (let [t1 (_ctext col1 threeColSize) + t2 (_ctext col2 threeColSize) + t3 (_ctext col3 threeColSize)] + (set t1.x creditMargin) + (set t1.y textY) + (t2.screenCenter) + (set t2.y textY) + (set t3.x (- 1280 creditMargin t3.width)) + (set t3.y textY)) + (+= textY threeColSize creditMargin)) + (otherwise))) + + (doFor text creditsText + (currentState.add text) + (FlxTween.linearMotion text text.x text.y text.x (- text.y textY) 200 false (object onComplete ->:Void _ (cc))))) \ No newline at end of file diff --git a/projects/hollywoo/src/hollywoo/Director.hx b/projects/hollywoo/src/hollywoo/Director.hx index 08c06e26..628f039e 100644 --- a/projects/hollywoo/src/hollywoo/Director.hx +++ b/projects/hollywoo/src/hollywoo/Director.hx @@ -1,6 +1,7 @@ package hollywoo; import hollywoo.Scene; +import hollywoo.Movie; enum Appearance { FirstAppearance; @@ -29,5 +30,7 @@ interface Director, cc:Continuation):Void; + function cleanup():Void; } diff --git a/projects/hollywoo/src/hollywoo/Movie.hx b/projects/hollywoo/src/hollywoo/Movie.hx index ea6745f8..c61ab749 100644 --- a/projects/hollywoo/src/hollywoo/Movie.hx +++ b/projects/hollywoo/src/hollywoo/Movie.hx @@ -4,6 +4,7 @@ import haxe.Constraints.Function; import haxe.Timer; import kiss.AsyncEmbeddedScript; import kiss.Prelude; +import kiss.Stream; import kiss.FuzzyMap; import hollywoo.Scene; import hollywoo.Director; @@ -24,6 +25,13 @@ typedef VoiceLine = { end:Float }; +enum CreditsLine { + OneColumn(s:String); + TwoColumn(left:String, right:String); + ThreeColumn(left:String, center:String, right:String); + Break; +} + /** * Model/controller of a Hollywoo film, and main execution script */ diff --git a/projects/hollywoo/src/hollywoo/Movie.kiss b/projects/hollywoo/src/hollywoo/Movie.kiss index 7e3399c2..ce0240f5 100644 --- a/projects/hollywoo/src/hollywoo/Movie.kiss +++ b/projects/hollywoo/src/hollywoo/Movie.kiss @@ -258,4 +258,21 @@ (hollywooMethod onPhoneSpeech true [actorName wryly text :Continuation cc] (showDialog actorName (ifLet [charOnScreen (dictGet .characters (_currentScene) actorName)] (OnScreen charOnScreen) - (FromPhone (dictGet actors actorName))) wryly text cc)) \ No newline at end of file + (FromPhone (dictGet actors actorName))) wryly text cc)) + +// TODO themedRollCredits +(hollywooMethod rollCredits true [:String creditsTSV :Continuation cc] + (director.rollCredits + (for line (.split .content (Stream.fromString creditsTSV) "\n") + (case (line.split "\t") + ((unless line [_]) + Break) + ([col1] + (OneColumn col1)) + ([col1 col2] + (TwoColumn col1 col2)) + ([col1 col2 col3] + (ThreeColumn col1 col2 col3)) + (otherwise + (throw "unsupported credits line $line")))) + cc)) \ No newline at end of file