From 02a66fecda5a3193ed495d6ef449862b4f375d01 Mon Sep 17 00:00:00 2001 From: balloonpopper <5151242+balloonpopper@users.noreply.github.com> Date: Mon, 28 Feb 2022 03:05:24 +1100 Subject: [PATCH] fix: add validates to camera commands missing them (#508) Co-authored-by: Balloonpopper --- .../core-scripts/esc/commands/camera_push.gd | 13 +++++++++++++ .../core-scripts/esc/commands/camera_shift.gd | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd b/addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd index 80be219f..e92fa5a3 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd @@ -21,6 +21,10 @@ extends ESCBaseCommand class_name CameraPushCommand +# The list of supported transitions as per the link mentioned above +const SUPPORTED_TRANSITIONS = ["LINEAR","SINE","QUINT","QUART","QUAD" ,"EXPO","ELASTIC","CUBIC", + "CIRC","BOUNCE","BACK"] + # Return the descriptor of the arguments of this command func configure() -> ESCCommandArgumentDescriptor: @@ -41,6 +45,15 @@ func validate(arguments: Array): ] ) return false + if not arguments[3] in SUPPORTED_TRANSITIONS: + escoria.logger.report_errors( + "camera_shift: invalid transition type", + [ + "Transition type {t_type} is not one of the accepted types : {allowed_types}".format( + {"t_type":arguments[3],"allowed_types":SUPPORTED_TRANSITIONS}) + ] + ) + return false return .validate(arguments) diff --git a/addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd b/addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd index 76640667..aff990d4 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd @@ -21,6 +21,9 @@ extends ESCBaseCommand class_name CameraShiftCommand +# The list of supported transitions as per the link mentioned above +const SUPPORTED_TRANSITIONS = ["LINEAR","SINE","QUINT","QUART","QUAD" ,"EXPO","ELASTIC","CUBIC", + "CIRC","BOUNCE","BACK"] # Return the descriptor of the arguments of this command func configure() -> ESCCommandArgumentDescriptor: @@ -48,3 +51,17 @@ func run(command_params: Array) -> int: Tween.new().get("TRANS_%s" % command_params[3]) ) return ESCExecution.RC_OK + +# Validate whether the given arguments match the command descriptor +func validate(arguments: Array): + if not arguments[3] in SUPPORTED_TRANSITIONS: + escoria.logger.report_errors( + "camera_shift: invalid transition type", + [ + "Transition type {t_type} is not one of the accepted types : {allowed_types}".format( + {"t_type":arguments[3],"allowed_types":SUPPORTED_TRANSITIONS}) + ] + ) + return false + + return .validate(arguments)