Make stagePositions a JsonMap
This commit is contained in:
@@ -12,12 +12,6 @@ enum Appearance {
|
||||
|
||||
typedef Continuation = Void -> Void;
|
||||
|
||||
typedef StagePosition = {
|
||||
x:Float,
|
||||
y:Float,
|
||||
z:Float,
|
||||
};
|
||||
|
||||
enum StageFacing {
|
||||
TowardsCharacter(name:String);
|
||||
AwayFromCharacter(name:String);
|
||||
|
@@ -8,6 +8,7 @@ import kiss.Stream;
|
||||
import kiss.FuzzyMap;
|
||||
import hollywoo.Scene;
|
||||
import hollywoo.Director;
|
||||
import hollywoo.StagePosition;
|
||||
import haxe.Json;
|
||||
import uuid.Uuid;
|
||||
import haxe.ds.Option;
|
||||
|
@@ -146,15 +146,14 @@
|
||||
&prop :Director<Set,ScreenPosition,Actor,Sound,Song,Prop,VoiceTrack,Camera,LightSource> director
|
||||
:String lightSourceJsonFile
|
||||
:LightSource defaultLightSource
|
||||
:String stagePositionsJson
|
||||
&opt :String voiceLinesJson
|
||||
&opt :String positionsJson
|
||||
]
|
||||
[
|
||||
:Map<String,StagePosition> stagePositions
|
||||
(if positionsJson
|
||||
(haxe.Json.parse (sys.io.File.getContent positionsJson))
|
||||
(new Map))
|
||||
:JsonMap<JsonableArray<LightSource>> lightSources (new JsonMap lightSourceJsonFile (new JsonableArray [] defaultLightSource))
|
||||
:JsonMap<StagePosition> stagePositions
|
||||
(new JsonMap stagePositionsJson (new StagePosition 0 0 0))
|
||||
:JsonMap<JsonableArray<LightSource>> lightSources
|
||||
(new JsonMap lightSourceJsonFile (new JsonableArray [] defaultLightSource))
|
||||
]
|
||||
|
||||
(set director.movie this)
|
||||
@@ -306,7 +305,7 @@
|
||||
|
||||
(hollywooMethod addCharacter false [actorName :Dynamic position :StageFacing facing :Continuation cc]
|
||||
(let [position (typeCase [position]
|
||||
([:String pKey] (dictGet stagePositions pKey))
|
||||
([:String pKey] (stagePositions.get pKey))
|
||||
(otherwise position))
|
||||
character (object stagePosition position stageFacing facing actor (dictGet actors actorName))]
|
||||
(autoZProcess position
|
||||
@@ -326,7 +325,7 @@
|
||||
// INSTANTLY move a character:
|
||||
(hollywooMethod moveCharacter false [actorName :Dynamic newPosition :StageFacing newFacing :Continuation cc]
|
||||
(let [newPosition (typeCase [newPosition]
|
||||
([:String pKey] (dictGet stagePositions pKey))
|
||||
([:String pKey] (stagePositions.get pKey))
|
||||
(otherwise newPosition))]
|
||||
(removeCharacter actorName
|
||||
(makeCC
|
||||
|
7
src/hollywoo/StagePosition.hx
Normal file
7
src/hollywoo/StagePosition.hx
Normal file
@@ -0,0 +1,7 @@
|
||||
package hollywoo;
|
||||
|
||||
import kiss.Prelude;
|
||||
import kiss.List;
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
class StagePosition {}
|
6
src/hollywoo/StagePosition.kiss
Normal file
6
src/hollywoo/StagePosition.kiss
Normal file
@@ -0,0 +1,6 @@
|
||||
(defNew [&prop :Float x &prop :Float y &prop :Float z])
|
||||
|
||||
(method stringify [] "${x}|${y}|${z}")
|
||||
(method parse [:String data]
|
||||
(let [[x y z] (for coord (data.split "|") (Std.parseFloat coord))]
|
||||
(new StagePosition x y z)))
|
Reference in New Issue
Block a user