diff options
Diffstat (limited to 'modules/visual_script')
3 files changed, 26 insertions, 10 deletions
diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml index 92f3d6532c..942d92311b 100644 --- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml +++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml @@ -179,32 +179,34 @@ <constant name="TEXT_PRINTRAW" value="55" enum="BuiltinFunc"> Print the given string to the standard output, without adding a newline. </constant> - <constant name="VAR_TO_STR" value="56" enum="BuiltinFunc"> + <constant name="TEXT_PRINT_VERBOSE" value="56" enum="BuiltinFunc"> + </constant> + <constant name="VAR_TO_STR" value="57" enum="BuiltinFunc"> Serialize a [Variant] to a string. </constant> - <constant name="STR_TO_VAR" value="57" enum="BuiltinFunc"> + <constant name="STR_TO_VAR" value="58" enum="BuiltinFunc"> Deserialize a [Variant] from a string serialized using [constant VAR_TO_STR]. </constant> - <constant name="VAR_TO_BYTES" value="58" enum="BuiltinFunc"> + <constant name="VAR_TO_BYTES" value="59" enum="BuiltinFunc"> Serialize a [Variant] to a [PackedByteArray]. </constant> - <constant name="BYTES_TO_VAR" value="59" enum="BuiltinFunc"> + <constant name="BYTES_TO_VAR" value="60" enum="BuiltinFunc"> Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES]. </constant> - <constant name="MATH_SMOOTHSTEP" value="60" enum="BuiltinFunc"> + <constant name="MATH_SMOOTHSTEP" value="61" enum="BuiltinFunc"> Return a number smoothly interpolated between the first two inputs, based on the third input. Similar to [constant MATH_LERP], but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula: [codeblock] var t = clamp((weight - from) / (to - from), 0.0, 1.0) return t * t * (3.0 - 2.0 * t) [/codeblock] </constant> - <constant name="MATH_POSMOD" value="61" enum="BuiltinFunc"> + <constant name="MATH_POSMOD" value="62" enum="BuiltinFunc"> </constant> - <constant name="MATH_LERP_ANGLE" value="62" enum="BuiltinFunc"> + <constant name="MATH_LERP_ANGLE" value="63" enum="BuiltinFunc"> </constant> - <constant name="TEXT_ORD" value="63" enum="BuiltinFunc"> + <constant name="TEXT_ORD" value="64" enum="BuiltinFunc"> </constant> - <constant name="FUNC_MAX" value="64" enum="BuiltinFunc"> + <constant name="FUNC_MAX" value="65" enum="BuiltinFunc"> Represents the size of the [enum BuiltinFunc] enum. </constant> </constants> diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 2bd7220d15..7e01031128 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -94,6 +94,7 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX "print", "printerr", "printraw", + "print_verbose", "var2str", "str2var", "var2bytes", @@ -129,6 +130,7 @@ bool VisualScriptBuiltinFunc::has_input_sequence_port() const { case TEXT_PRINT: case TEXT_PRINTERR: case TEXT_PRINTRAW: + case TEXT_PRINT_VERBOSE: case MATH_SEED: return true; default: @@ -177,6 +179,7 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) { case TEXT_PRINT: case TEXT_PRINTERR: case TEXT_PRINTRAW: + case TEXT_PRINT_VERBOSE: case VAR_TO_STR: case STR_TO_VAR: case TYPE_EXISTS: @@ -223,6 +226,7 @@ int VisualScriptBuiltinFunc::get_output_value_port_count() const { case TEXT_PRINT: case TEXT_PRINTERR: case TEXT_PRINTRAW: + case TEXT_PRINT_VERBOSE: case MATH_SEED: return 0; case MATH_RANDSEED: @@ -424,7 +428,8 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const case TEXT_STR: case TEXT_PRINT: case TEXT_PRINTERR: - case TEXT_PRINTRAW: { + case TEXT_PRINTRAW: + case TEXT_PRINT_VERBOSE: { return PropertyInfo(Variant::NIL, "value"); } break; case STR_TO_VAR: { @@ -572,6 +577,8 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons } break; case TEXT_PRINTRAW: { } break; + case TEXT_PRINT_VERBOSE: { + } break; case VAR_TO_STR: { t = Variant::STRING; } break; @@ -1020,6 +1027,10 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in OS::get_singleton()->print("%s", str.utf8().get_data()); } break; + case VisualScriptBuiltinFunc::TEXT_PRINT_VERBOSE: { + String str = *p_inputs[0]; + print_verbose(str); + } break; case VisualScriptBuiltinFunc::VAR_TO_STR: { String vars; VariantWriter::write_to_string(*p_inputs[0], vars); @@ -1208,6 +1219,7 @@ void VisualScriptBuiltinFunc::_bind_methods() { BIND_ENUM_CONSTANT(TEXT_PRINT); BIND_ENUM_CONSTANT(TEXT_PRINTERR); BIND_ENUM_CONSTANT(TEXT_PRINTRAW); + BIND_ENUM_CONSTANT(TEXT_PRINT_VERBOSE); BIND_ENUM_CONSTANT(VAR_TO_STR); BIND_ENUM_CONSTANT(STR_TO_VAR); BIND_ENUM_CONSTANT(VAR_TO_BYTES); @@ -1300,6 +1312,7 @@ void register_visual_script_builtin_func_node() { VisualScriptLanguage::singleton->add_register_func("functions/built_in/print", create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINT>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/printerr", create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTERR>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/printraw", create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTRAW>); + VisualScriptLanguage::singleton->add_register_func("functions/built_in/print_verbose", create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINT_VERBOSE>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/var2str", create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_STR>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/str2var", create_builtin_func_node<VisualScriptBuiltinFunc::STR_TO_VAR>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/var2bytes", create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_BYTES>); diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h index 26abc1e479..f9eb7e983f 100644 --- a/modules/visual_script/visual_script_builtin_funcs.h +++ b/modules/visual_script/visual_script_builtin_funcs.h @@ -94,6 +94,7 @@ public: TEXT_PRINT, TEXT_PRINTERR, TEXT_PRINTRAW, + TEXT_PRINT_VERBOSE, VAR_TO_STR, STR_TO_VAR, VAR_TO_BYTES, |