From 3992c42c0f098f21008126d3903b391871009fa9 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 16 May 2023 16:11:57 -0600 Subject: [PATCH] allow disabling prop autoplacement --- src/hollywoo_flixel/FlxDirector.kiss | 33 +++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/hollywoo_flixel/FlxDirector.kiss b/src/hollywoo_flixel/FlxDirector.kiss index 72d2a4e..b1064db 100644 --- a/src/hollywoo_flixel/FlxDirector.kiss +++ b/src/hollywoo_flixel/FlxDirector.kiss @@ -478,27 +478,30 @@ (var PROP_MIN_WIDTH 200) (var PROP_MAX_WIDTH 500) +(prop &mut :Bool autoPlaceProps true) + (method :Void showProp [:FlxSprite prop :StagePosition position :Continuation cc] (set prop.cameras [flxMovie.screenCamera]) (let [width (min (max prop.width PROP_MIN_WIDTH) PROP_MAX_WIDTH)] - (prop.setGraphicSize width) + (when autoPlaceProps + (prop.setGraphicSize width) - (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)) + (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)) - (set prop.x (- position.x (/ prop.width 2))) - (set prop.y (- position.y (/ prop.height 2))) + (set prop.x (- position.x (/ prop.width 2))) + (set prop.y (- position.y (/ prop.height 2))) - (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))))) (let [layerNum position.z] (assertEquals layerNum (Std.int layerNum))