Jsonable, directable prop scales
This commit is contained in:
@@ -14,6 +14,7 @@ import hollywoo.Movie;
|
||||
import hollywoo.Scene;
|
||||
import hollywoo.Director;
|
||||
import hollywoo.StagePosition;
|
||||
import hollywoo.HFloat;
|
||||
import hollywoo_flixel.FlxMovie;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.text.FlxText;
|
||||
|
@@ -283,7 +283,7 @@
|
||||
(let [layer (- LAYER_MAX (Std.int (/ character.stagePosition.z flxMovie.STAGE_BEHIND_DY)))]
|
||||
(.add (nth spriteLayers layer) character.actor)))
|
||||
(true
|
||||
(.add (nth spriteLayers ~(min LAYER_MAX (Std.int character.stagePosition.z))) character.actor)))
|
||||
(.add (nth spriteLayers (min LAYER_MAX (Std.int character.stagePosition.z))) character.actor)))
|
||||
|
||||
(cc))
|
||||
|
||||
@@ -536,31 +536,42 @@
|
||||
(set prop.x position.x)
|
||||
(set prop.y position.y)
|
||||
|
||||
// When using preset positions, automatically move everything around
|
||||
(when (flxMovie.presetPositions.exists (position.stringify))
|
||||
(-= prop.x (/ prop.width 2))
|
||||
(-= prop.y (/ prop.height 2))
|
||||
// When using preset positions, automatically move everything around and scale it
|
||||
(cond
|
||||
((flxMovie.presetPositions.exists (position.stringify))
|
||||
(-= prop.x (/ prop.width 2))
|
||||
(-= prop.y (/ prop.height 2))
|
||||
|
||||
// if the prop is too tall, shrink it heightwise
|
||||
(when (> prop.height flxMovie.DIALOG_Y)
|
||||
(prop.setGraphicSize 0 (Std.int flxMovie.DIALOG_Y))
|
||||
(prop.updateHitbox))
|
||||
// if the prop is too tall, shrink it heightwise
|
||||
(when (> prop.height flxMovie.DIALOG_Y)
|
||||
(prop.setGraphicSize 0 (Std.int flxMovie.DIALOG_Y))
|
||||
(prop.updateHitbox))
|
||||
|
||||
(let [propBottom (+ prop.y prop.height)]
|
||||
// if a prop would block the dialogue box, bump it up
|
||||
(when (> propBottom flxMovie.DIALOG_Y)
|
||||
(-= prop.y (- propBottom flxMovie.DIALOG_Y)))
|
||||
// If a prop goes below the edge, bring it up
|
||||
(when (> propBottom FlxG.height)
|
||||
(-= prop.y (- propBottom FlxG.height)))))
|
||||
(let [propBottom (+ prop.y prop.height)]
|
||||
// if a prop would block the dialogue box, bump it up
|
||||
(when (> propBottom flxMovie.DIALOG_Y)
|
||||
(-= prop.y (- propBottom flxMovie.DIALOG_Y)))
|
||||
// If a prop goes below the edge, bring it up
|
||||
(when (> propBottom FlxG.height)
|
||||
(-= prop.y (- propBottom FlxG.height)))))
|
||||
// Otherwise, let the director scale props
|
||||
(true
|
||||
(let [propKey prop.graphic.assetsKey
|
||||
:Float scale .value (flxMovie.propScales.get propKey)]
|
||||
(unless (flxMovie.propsInScene.exists flxMovie.sceneKey)
|
||||
(dictSet flxMovie.propsInScene flxMovie.sceneKey []))
|
||||
(.push (dictGet flxMovie.propsInScene flxMovie.sceneKey) propKey)
|
||||
(prop.scale.set scale scale))))
|
||||
|
||||
(let [layerNum position.z]
|
||||
(assertEquals layerNum (Std.int layerNum))
|
||||
(.add (nth spriteLayers ~(+ 1 (Std.int layerNum))) prop)))
|
||||
(.add (nth spriteLayers (+ 1 (Std.int layerNum))) prop)))
|
||||
(cc))
|
||||
|
||||
(method :Void hideProp [:FlxSprite prop :FlxCamera camera cc]
|
||||
(FlxG.state.remove prop true)
|
||||
(let [propKey prop.graphic.assetsKey]
|
||||
(.remove (dictGet flxMovie.propsInScene flxMovie.sceneKey) propKey))
|
||||
(doFor layer spriteLayers
|
||||
(layer.remove prop true))
|
||||
(cc))
|
||||
|
@@ -10,6 +10,8 @@ import hollywoo.Movie;
|
||||
import hollywoo_flixel.ActorFlxSprite;
|
||||
import kiss_flixel.SpriteTools;
|
||||
import kiss_tools.FlxKeyShortcutHandler;
|
||||
import kiss_tools.JsonMap;
|
||||
import hollywoo.HFloat;
|
||||
import openfl.Assets;
|
||||
import flixel.tweens.FlxTween;
|
||||
|
||||
@@ -19,12 +21,17 @@ import flixel.tweens.FlxTween;
|
||||
class FlxMovie extends Movie<FlxSprite, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera, FlxLightSource> {
|
||||
// Think of HollywooFlixelDSL.kiss as the corresponding Kiss file for this class!
|
||||
|
||||
public function new(director:FlxDirector, lightSourceJsonFile:String, positionsJson:String, delayLengthsJson:String, voiceLineMatchesJson:String) {
|
||||
public function new(director:FlxDirector, lightSourceJsonFile:String, positionsJson:String, delayLengthsJson:String, voiceLineMatchesJson:String, propScalesJson:String) {
|
||||
super(director, lightSourceJsonFile, new FlxLightSource([], FlxColor.TRANSPARENT), positionsJson, delayLengthsJson, voiceLineMatchesJson);
|
||||
|
||||
propScales = new JsonMap(propScalesJson, new HFloat(1.0));
|
||||
}
|
||||
public var uiCamera:FlxCamera;
|
||||
public var screenCamera:FlxCamera;
|
||||
|
||||
public var propScales:JsonMap<HFloat>;
|
||||
public var propsInScene:Map<String,Array<String>> = [];
|
||||
|
||||
public var tweens:Array<FlxTween> = [];
|
||||
public var loopingOnCompletes:Map<FlxSound,Void->Void> = [];
|
||||
public var STAGE_LEFT_X:Float;
|
||||
|
@@ -165,7 +165,20 @@
|
||||
(putPresetPosition "ScreenLowerLeft" left lower layer)
|
||||
(putPresetPosition "ScreenLowerRight" right lower layer)
|
||||
(putPresetPosition "ScreenLowerCenter" centerX lower layer)
|
||||
(putPresetPosition "ScreenUpperCenter" centerX upper layer)))
|
||||
(putPresetPosition "ScreenUpperCenter" centerX upper layer))
|
||||
|
||||
(let [shortcutHandler (director.shortcutHandler)
|
||||
cc ->(resume)]
|
||||
(shortcutHandler.registerItem "[d]efine prop [s]cale"
|
||||
->cc
|
||||
(director.chooseString "Which prop?" (dictGet propsInScene sceneKey)
|
||||
->propKey
|
||||
(let [lastScale .value (propScales.get propKey)]
|
||||
(director.enterString "Redefine $propKey scale from ${lastScale}?"
|
||||
->scaleStr
|
||||
(let [scale (Std.parseFloat scaleStr)]
|
||||
(propScales.put propKey (new HFloat scale))
|
||||
(cc))))))))
|
||||
|
||||
(method overlayPropOnCurrentSet [propKey :Void->Void cc]
|
||||
(let [propKey (kiss.FuzzyMapTools.bestMatch props propKey)]
|
||||
|
Reference in New Issue
Block a user