fix: add validates to camera commands missing them (#508)

Co-authored-by: Balloonpopper <balloonpopper@git.com>
This commit is contained in:
balloonpopper
2022-02-28 03:05:24 +11:00
committed by GitHub
parent 990dfb7ae4
commit 02a66fecda
2 changed files with 30 additions and 0 deletions

View File

@@ -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)

View File

@@ -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)