diff options
Diffstat (limited to 'modules/visual_script/visual_script_builtin_funcs.cpp')
-rw-r--r-- | modules/visual_script/visual_script_builtin_funcs.cpp | 135 |
1 files changed, 80 insertions, 55 deletions
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 953d9a5fed..a0dcd76d10 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -111,8 +111,9 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::find_function(const String &p_string) { for (int i = 0; i < FUNC_MAX; i++) { - if (p_string == func_name[i]) + if (p_string == func_name[i]) { return BuiltinFunc(i); + } } return FUNC_MAX; @@ -269,95 +270,106 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const return PropertyInfo(Variant::FLOAT, "s"); } break; case MATH_ATAN2: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "y"); - else + } else { return PropertyInfo(Variant::FLOAT, "x"); + } } break; case MATH_FMOD: case MATH_FPOSMOD: case LOGIC_MAX: case LOGIC_MIN: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "a"); - else + } else { return PropertyInfo(Variant::FLOAT, "b"); + } } break; case MATH_POSMOD: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::INT, "a"); - else + } else { return PropertyInfo(Variant::INT, "b"); + } } break; case MATH_POW: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "base"); - else + } else { return PropertyInfo(Variant::FLOAT, "exp"); + } } break; case MATH_EASE: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "s"); - else + } else { return PropertyInfo(Variant::FLOAT, "curve"); + } } break; case MATH_STEP_DECIMALS: { return PropertyInfo(Variant::FLOAT, "step"); } break; case MATH_STEPIFY: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "s"); - else + } else { return PropertyInfo(Variant::FLOAT, "steps"); + } } break; case MATH_LERP: case MATH_LERP_ANGLE: case MATH_INVERSE_LERP: case MATH_SMOOTHSTEP: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "from"); - else if (p_idx == 1) + } else if (p_idx == 1) { return PropertyInfo(Variant::FLOAT, "to"); - else + } else { return PropertyInfo(Variant::FLOAT, "weight"); + } } break; case MATH_RANGE_LERP: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "value"); - else if (p_idx == 1) + } else if (p_idx == 1) { return PropertyInfo(Variant::FLOAT, "istart"); - else if (p_idx == 2) + } else if (p_idx == 2) { return PropertyInfo(Variant::FLOAT, "istop"); - else if (p_idx == 3) + } else if (p_idx == 3) { return PropertyInfo(Variant::FLOAT, "ostart"); - else + } else { return PropertyInfo(Variant::FLOAT, "ostop"); + } } break; case MATH_MOVE_TOWARD: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "from"); - else if (p_idx == 1) + } else if (p_idx == 1) { return PropertyInfo(Variant::FLOAT, "to"); - else + } else { return PropertyInfo(Variant::FLOAT, "delta"); + } } break; case MATH_DECTIME: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "value"); - else if (p_idx == 1) + } else if (p_idx == 1) { return PropertyInfo(Variant::FLOAT, "amount"); - else + } else { return PropertyInfo(Variant::FLOAT, "step"); + } } break; case MATH_RANDOMIZE: case MATH_RAND: case MATH_RANDF: { } break; case MATH_RANDOM: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "from"); - else + } else { return PropertyInfo(Variant::FLOAT, "to"); + } } break; case MATH_SEED: case MATH_RANDSEED: { @@ -376,33 +388,37 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const return PropertyInfo(Variant::FLOAT, "db"); } break; case MATH_POLAR2CARTESIAN: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "r"); - else + } else { return PropertyInfo(Variant::FLOAT, "th"); + } } break; case MATH_CARTESIAN2POLAR: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "x"); - else + } else { return PropertyInfo(Variant::FLOAT, "y"); + } } break; case MATH_WRAP: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::INT, "value"); - else if (p_idx == 1) + } else if (p_idx == 1) { return PropertyInfo(Variant::INT, "min"); - else + } else { return PropertyInfo(Variant::INT, "max"); + } } break; case MATH_WRAPF: case LOGIC_CLAMP: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "value"); - else if (p_idx == 1) + } else if (p_idx == 1) { return PropertyInfo(Variant::FLOAT, "min"); - else + } else { return PropertyInfo(Variant::FLOAT, "max"); + } } break; case LOGIC_NEAREST_PO2: { return PropertyInfo(Variant::INT, "value"); @@ -411,16 +427,18 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const return PropertyInfo(Variant::OBJECT, "source"); } break; case FUNC_FUNCREF: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::OBJECT, "instance"); - else + } else { return PropertyInfo(Variant::STRING, "funcname"); + } } break; case TYPE_CONVERT: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::NIL, "what"); - else + } else { return PropertyInfo(Variant::STRING, "type"); + } } break; case TYPE_OF: { return PropertyInfo(Variant::NIL, "what"); @@ -445,23 +463,26 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const } break; case VAR_TO_STR: case VAR_TO_BYTES: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::NIL, "var"); - else + } else { return PropertyInfo(Variant::BOOL, "full_objects"); + } } break; case BYTES_TO_VAR: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::PACKED_BYTE_ARRAY, "bytes"); - else + } else { return PropertyInfo(Variant::BOOL, "allow_objects"); + } } break; case COLORN: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::STRING, "name"); - else + } else { return PropertyInfo(Variant::FLOAT, "alpha"); + } } break; case FUNC_MAX: { } @@ -540,10 +561,11 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons case MATH_SEED: { } break; case MATH_RANDSEED: { - if (p_idx == 0) + if (p_idx == 0) { return PropertyInfo(Variant::INT, "rnd"); - else + } else { return PropertyInfo(Variant::INT, "seed"); + } } break; case MATH_DEG2RAD: case MATH_RAD2DEG: @@ -603,15 +625,17 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons case STR_TO_VAR: { } break; case VAR_TO_BYTES: { - if (p_idx == 0) + if (p_idx == 0) { t = Variant::PACKED_BYTE_ARRAY; - else + } else { t = Variant::BOOL; + } } break; case BYTES_TO_VAR: { - if (p_idx == 1) + if (p_idx == 1) { t = Variant::BOOL; + } } break; case COLORN: { t = Variant::COLOR; @@ -1220,8 +1244,9 @@ void VisualScriptBuiltinFunc::_bind_methods() { String cc; for (int i = 0; i < FUNC_MAX; i++) { - if (i > 0) + if (i > 0) { cc += ","; + } cc += func_name[i]; } ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, cc), "set_func", "get_func"); |