Make delayLengths a JsonMap

This commit is contained in:
2023-04-03 05:02:11 -06:00
parent 10816aa51e
commit 168c5b9599
4 changed files with 42 additions and 24 deletions

View File

@@ -17,13 +17,13 @@ import openfl.Assets;
class FlxMovie extends Movie<FlxSprite, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera, FlxLightSource> { class FlxMovie extends Movie<FlxSprite, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera, FlxLightSource> {
// Think of HollywooFlixelDSL.kiss as the corresponding Kiss file for this class! // Think of HollywooFlixelDSL.kiss as the corresponding Kiss file for this class!
public function new(director:FlxDirector, lightSourceJsonFile:String, positionsJson:String, ?voiceLinesAssetPath:String) { public function new(director:FlxDirector, lightSourceJsonFile:String, positionsJson:String, delayLengthsJson:String, ?voiceLinesAssetPath:String) {
var voiceLinesJson = null; var voiceLinesJson = null;
if (voiceLinesAssetPath != null) { if (voiceLinesAssetPath != null) {
voiceLinesJson = Assets.getText(voiceLinesAssetPath); voiceLinesJson = Assets.getText(voiceLinesAssetPath);
} }
super(director, lightSourceJsonFile, new FlxLightSource([], FlxColor.TRANSPARENT), positionsJson, voiceLinesJson); super(director, lightSourceJsonFile, new FlxLightSource([], FlxColor.TRANSPARENT), positionsJson, delayLengthsJson, voiceLinesJson);
} }
public var uiCamera:FlxCamera; public var uiCamera:FlxCamera;
public var screenCamera:FlxCamera; public var screenCamera:FlxCamera;

View File

@@ -0,0 +1,7 @@
package hollywoo;
import kiss.Prelude;
import kiss.List;
@:build(kiss.Kiss.build())
class DelayLength {}

View File

@@ -0,0 +1,4 @@
(defNew [&prop :Float length])
(method stringify [] "$length")
(method parse [:String data] (new DelayLength (Std.parseFloat data)))

View File

@@ -155,6 +155,7 @@
:String lightSourceJsonFile :String lightSourceJsonFile
:LightSource defaultLightSource :LightSource defaultLightSource
:String stagePositionsJson :String stagePositionsJson
:String delayLengthsJson
&opt :String voiceLinesJson &opt :String voiceLinesJson
] ]
[ [
@@ -162,6 +163,8 @@
(new JsonMap stagePositionsJson (new StagePosition 0 0 0)) (new JsonMap stagePositionsJson (new StagePosition 0 0 0))
:JsonMap<JsonableArray<LightSource>> lightSources :JsonMap<JsonableArray<LightSource>> lightSources
(new JsonMap lightSourceJsonFile (new JsonableArray [] defaultLightSource)) (new JsonMap lightSourceJsonFile (new JsonableArray [] defaultLightSource))
:JsonMap<DelayLength> delayLengths
(new JsonMap delayLengthsJson (new DelayLength 0.5))
] ]
(set director.movie this) (set director.movie this)
@@ -203,31 +206,35 @@
(#unless subclass (method ,nameAndType ,argList ,@body)) (#unless subclass (method ,nameAndType ,argList ,@body))
})) }))
(hollywooMethod :Void delay true [sec :Continuation cc] (hollywooMethod :Void delay true [:Dynamic length :Continuation cc]
(case delayHandling (let [sec (typeCase [length]
(Auto ([:Float sec] sec)
(Timer.delay cc (* 1000 sec))) ([:String key] .length (delayLengths.get key))
(AutoWithSkip (never otherwise))]
(let [autoDelay (case delayHandling
(Timer.delay (Auto
->{ (Timer.delay cc (* 1000 sec)))
(director.stopWaitForInput cc) (AutoWithSkip
(cc) (let [autoDelay
} (Timer.delay
(* 1000 sec))] ->{
(director.stopWaitForInput cc)
(cc)
}
(* 1000 sec))]
(director.startWaitForInput
->{
(director.stopWaitForInput cc)
(autoDelay.stop)
(cc)
})))
(Manual
(director.startWaitForInput (director.startWaitForInput
->{ ->{
(director.stopWaitForInput cc) (director.stopWaitForInput cc)
(autoDelay.stop)
(cc) (cc)
}))) }))
(Manual (otherwise (throw "Unsupported delay type $delayHandling")))))
(director.startWaitForInput
->{
(director.stopWaitForInput cc)
(cc)
}))
(otherwise (throw "Unsupported delay type $delayHandling"))))
(hollywooMethod newSet true [name :Set set] (hollywooMethod newSet true [name :Set set]
(assert isLoading) (assert isLoading)