Make stagePositions a JsonMap
This commit is contained in:
@@ -44,13 +44,13 @@ enum FlxScreenPosition {
|
|||||||
class FlxMovie extends Movie<FlxSprite, FlxScreenPosition, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera, FlxLightSource> {
|
class FlxMovie extends Movie<FlxSprite, FlxScreenPosition, 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, ?voiceLinesAssetPath:String, ?positionsJson:String) {
|
public function new(director:FlxDirector, lightSourceJsonFile:String, positionsJson: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), voiceLinesJson, positionsJson);
|
super(director, lightSourceJsonFile, new FlxLightSource([], FlxColor.TRANSPARENT), positionsJson, voiceLinesJson);
|
||||||
}
|
}
|
||||||
public var uiCamera:FlxCamera;
|
public var uiCamera:FlxCamera;
|
||||||
public var screenCamera:FlxCamera;
|
public var screenCamera:FlxCamera;
|
||||||
|
|||||||
@@ -85,24 +85,24 @@
|
|||||||
(set DIALOG_WIDTH (- FlxG.width ACTOR_WIDTH ACTOR_WIDTH))
|
(set DIALOG_WIDTH (- FlxG.width ACTOR_WIDTH ACTOR_WIDTH))
|
||||||
(set DIALOG_HEIGHT (- FlxG.height DIALOG_Y))
|
(set DIALOG_HEIGHT (- FlxG.height DIALOG_Y))
|
||||||
#{
|
#{
|
||||||
stagePositions["Left"] = {
|
stagePositions.put("Left", new StagePosition(
|
||||||
x: STAGE_LEFT_X,
|
STAGE_LEFT_X,
|
||||||
y: ACTOR_Y,
|
ACTOR_Y,
|
||||||
z: 0.0
|
0.0
|
||||||
};
|
));
|
||||||
stagePositions["Right"] = {
|
stagePositions.put("Right", new StagePosition(
|
||||||
x: STAGE_RIGHT_X,
|
STAGE_RIGHT_X,
|
||||||
y: ACTOR_Y,
|
ACTOR_Y,
|
||||||
z: 0.0
|
0.0
|
||||||
};
|
));
|
||||||
stagePositions["Left2"] = {
|
stagePositions.put("Left2", new StagePosition(
|
||||||
x: STAGE_LEFT_X,
|
STAGE_LEFT_X,
|
||||||
y: ACTOR_Y,
|
ACTOR_Y,
|
||||||
z: STAGE_BEHIND_DY
|
STAGE_BEHIND_DY
|
||||||
};
|
));
|
||||||
stagePositions["Right2"] = {
|
stagePositions.put("Right2", new StagePosition(
|
||||||
x: STAGE_RIGHT_X,
|
STAGE_RIGHT_X,
|
||||||
y: ACTOR_Y,
|
ACTOR_Y,
|
||||||
z: STAGE_BEHIND_DY
|
STAGE_BEHIND_DY
|
||||||
};
|
));
|
||||||
}#)
|
}#)
|
||||||
@@ -12,12 +12,6 @@ enum Appearance {
|
|||||||
|
|
||||||
typedef Continuation = Void -> Void;
|
typedef Continuation = Void -> Void;
|
||||||
|
|
||||||
typedef StagePosition = {
|
|
||||||
x:Float,
|
|
||||||
y:Float,
|
|
||||||
z:Float,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum StageFacing {
|
enum StageFacing {
|
||||||
TowardsCharacter(name:String);
|
TowardsCharacter(name:String);
|
||||||
AwayFromCharacter(name:String);
|
AwayFromCharacter(name:String);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import kiss.Stream;
|
|||||||
import kiss.FuzzyMap;
|
import kiss.FuzzyMap;
|
||||||
import hollywoo.Scene;
|
import hollywoo.Scene;
|
||||||
import hollywoo.Director;
|
import hollywoo.Director;
|
||||||
|
import hollywoo.StagePosition;
|
||||||
import haxe.Json;
|
import haxe.Json;
|
||||||
import uuid.Uuid;
|
import uuid.Uuid;
|
||||||
import haxe.ds.Option;
|
import haxe.ds.Option;
|
||||||
|
|||||||
@@ -146,15 +146,14 @@
|
|||||||
&prop :Director<Set,ScreenPosition,Actor,Sound,Song,Prop,VoiceTrack,Camera,LightSource> director
|
&prop :Director<Set,ScreenPosition,Actor,Sound,Song,Prop,VoiceTrack,Camera,LightSource> director
|
||||||
:String lightSourceJsonFile
|
:String lightSourceJsonFile
|
||||||
:LightSource defaultLightSource
|
:LightSource defaultLightSource
|
||||||
|
:String stagePositionsJson
|
||||||
&opt :String voiceLinesJson
|
&opt :String voiceLinesJson
|
||||||
&opt :String positionsJson
|
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
:Map<String,StagePosition> stagePositions
|
:JsonMap<StagePosition> stagePositions
|
||||||
(if positionsJson
|
(new JsonMap stagePositionsJson (new StagePosition 0 0 0))
|
||||||
(haxe.Json.parse (sys.io.File.getContent positionsJson))
|
:JsonMap<JsonableArray<LightSource>> lightSources
|
||||||
(new Map))
|
(new JsonMap lightSourceJsonFile (new JsonableArray [] defaultLightSource))
|
||||||
:JsonMap<JsonableArray<LightSource>> lightSources (new JsonMap lightSourceJsonFile (new JsonableArray [] defaultLightSource))
|
|
||||||
]
|
]
|
||||||
|
|
||||||
(set director.movie this)
|
(set director.movie this)
|
||||||
@@ -306,7 +305,7 @@
|
|||||||
|
|
||||||
(hollywooMethod addCharacter false [actorName :Dynamic position :StageFacing facing :Continuation cc]
|
(hollywooMethod addCharacter false [actorName :Dynamic position :StageFacing facing :Continuation cc]
|
||||||
(let [position (typeCase [position]
|
(let [position (typeCase [position]
|
||||||
([:String pKey] (dictGet stagePositions pKey))
|
([:String pKey] (stagePositions.get pKey))
|
||||||
(otherwise position))
|
(otherwise position))
|
||||||
character (object stagePosition position stageFacing facing actor (dictGet actors actorName))]
|
character (object stagePosition position stageFacing facing actor (dictGet actors actorName))]
|
||||||
(autoZProcess position
|
(autoZProcess position
|
||||||
@@ -326,7 +325,7 @@
|
|||||||
// INSTANTLY move a character:
|
// INSTANTLY move a character:
|
||||||
(hollywooMethod moveCharacter false [actorName :Dynamic newPosition :StageFacing newFacing :Continuation cc]
|
(hollywooMethod moveCharacter false [actorName :Dynamic newPosition :StageFacing newFacing :Continuation cc]
|
||||||
(let [newPosition (typeCase [newPosition]
|
(let [newPosition (typeCase [newPosition]
|
||||||
([:String pKey] (dictGet stagePositions pKey))
|
([:String pKey] (stagePositions.get pKey))
|
||||||
(otherwise newPosition))]
|
(otherwise newPosition))]
|
||||||
(removeCharacter actorName
|
(removeCharacter actorName
|
||||||
(makeCC
|
(makeCC
|
||||||
|
|||||||
7
projects/hollywoo/src/hollywoo/StagePosition.hx
Normal file
7
projects/hollywoo/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
projects/hollywoo/src/hollywoo/StagePosition.kiss
Normal file
6
projects/hollywoo/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