diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.hx index 7408f59b..85c4a03f 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 hollywoo.Movie; import hollywoo.Scene; import hollywoo.Director; import hollywoo_flixel.FlxMovie; diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss index c2d236cf..315ba80c 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/FlxDirector.kiss @@ -1,5 +1,6 @@ (prop :FlxActionDigital continueAction) (prop actionManager (new FlxActionManager)) +(prop &mut :Movie movie) (defNew [] (set continueAction (new FlxActionDigital "Continue" onContinue)) @@ -44,15 +45,11 @@ (set nextCC null) (cc))) -(method :Void waitForInputOrDelay [:Float delaySeconds :Continuation cc] - // TODO allow user to choose between automatic delays and continue checks - (if true - //{ - (set nextCC cc) - // TODO show an indicator that input is needed - //} - ) - ) +(method :Void startWaitForInput [:Continuation cc] + (set nextCC cc)) + +(method :Void stopWaitForInput [] + (set nextCC null)) (var DIALOG_X 300) (var DIALOG_WIDTH (- 1280 ACTOR_WIDTH ACTOR_WIDTH)) @@ -95,9 +92,10 @@ (set dialogText.y DIALOG_Y)) (dialogText.revive) - // wait for input - // TODO customize the delay to the dialog length or voice-over length - (waitForInputOrDelay 5 + // wait for input or delay + // TODO customize the delay in a more sophisticated way to the dialog length or voice-over length, + // or rely on FlxTypeText to add breathing room + (movie.delay .length (text.split " ") ->{ (dialogText.kill) (speakerNameText.kill) diff --git a/projects/hollywoo/src/hollywoo/Director.hx b/projects/hollywoo/src/hollywoo/Director.hx index 44dba5bb..f81b6393 100644 --- a/projects/hollywoo/src/hollywoo/Director.hx +++ b/projects/hollywoo/src/hollywoo/Director.hx @@ -10,11 +10,13 @@ enum Appearance { typedef Continuation = Void -> Void; interface Director { + var movie(default, default):Movie; function showScene(scene:Scene, appearance:Appearance, cc:Continuation):Void; function showCharacter(character:Character, appearance:Appearance, cc:Continuation):Void; function playSound(sound:Sound, volumeMod:Float, waitForEnd:Bool, cc:Continuation):Void; function playSong(song:Song, volumeMod:Float, loop:Bool, waitForEnd:Bool, cc:Continuation):Void; function stopSong():Void; - function waitForInputOrDelay(delaySeconds:Float, cc:Continuation):Void; + function startWaitForInput(cc:Continuation):Void; + function stopWaitForInput():Void; function showDialog(speakerName:String, type:SpeechType, wryly:String, dialog:String, cc:Continuation):Void; } diff --git a/projects/hollywoo/src/hollywoo/Movie.hx b/projects/hollywoo/src/hollywoo/Movie.hx index c1f83a3a..a5bab778 100644 --- a/projects/hollywoo/src/hollywoo/Movie.hx +++ b/projects/hollywoo/src/hollywoo/Movie.hx @@ -1,11 +1,18 @@ package hollywoo; import haxe.Constraints.Function; +import haxe.Timer; import kiss.AsyncEmbeddedScript; import kiss.Prelude; import hollywoo.Scene; import hollywoo.Director; +enum DelayHandling { + Auto; + AutoWithSkip; + Manual; +} + /** * 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 e4b80477..3a5dd0a9 100644 --- a/projects/hollywoo/src/hollywoo/Movie.kiss +++ b/projects/hollywoo/src/hollywoo/Movie.kiss @@ -4,6 +4,8 @@ (prop :Map sounds (new Map)) (prop :Map songs (new Map)) +(prop &mut :DelayHandling delayHandling AutoWithSkip) + // TODO for some reason this won't work when declared in Kiss syntax: // Mutable representation of frames in time: // var scenes:Map> = []; @@ -30,8 +32,29 @@ &prop :Director director ] + (set director.movie this) + (super)) +(method :Void delay [sec :Continuation cc] + (case delayHandling + (Auto + (Timer.delay cc (* 1000 sec))) + (AutoWithSkip + (director.startWaitForInput cc) + (Timer.delay + ->{ + (director.stopWaitForInput) + (cc) + } + (* 1000 sec))) + (Manual + (director.startWaitForInput + ->{ + (director.stopWaitForInput) + (cc) + })))) + (method newSet [name :Set set] (assert isLoading) (dictSet sets name set))