diff options
Diffstat (limited to 'modules/visual_script/visual_script_nodes.cpp')
-rw-r--r-- | modules/visual_script/visual_script_nodes.cpp | 265 |
1 files changed, 129 insertions, 136 deletions
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 471d8ef0ae..dbbe74f3d5 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -204,7 +204,7 @@ PropertyInfo VisualScriptFunction::get_output_value_port_info(int p_idx) const { } String VisualScriptFunction::get_caption() const { - return "Function"; + return RTR("Function"); } String VisualScriptFunction::get_text() const { @@ -253,7 +253,7 @@ String VisualScriptFunction::get_argument_name(int p_argidx) const { void VisualScriptFunction::remove_argument(int p_argidx) { ERR_FAIL_INDEX(p_argidx, arguments.size()); - arguments.remove(p_argidx); + arguments.remove_at(p_argidx); ports_changed_notify(); } @@ -271,12 +271,12 @@ Multiplayer::RPCMode VisualScriptFunction::get_rpc_mode() const { class VisualScriptNodeInstanceFunction : public VisualScriptNodeInstance { public: - VisualScriptFunction *node; - VisualScriptInstance *instance; + VisualScriptFunction *node = nullptr; + VisualScriptInstance *instance = nullptr; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { int ac = node->get_argument_count(); for (int i = 0; i < ac; i++) { @@ -623,7 +623,7 @@ void VisualScriptLists::remove_input_data_port(int p_argidx) { ERR_FAIL_INDEX(p_argidx, inputports.size()); - inputports.remove(p_argidx); + inputports.remove_at(p_argidx); ports_changed_notify(); notify_property_list_changed(); @@ -679,7 +679,7 @@ void VisualScriptLists::remove_output_data_port(int p_argidx) { ERR_FAIL_INDEX(p_argidx, outputports.size()); - outputports.remove(p_argidx); + outputports.remove_at(p_argidx); ports_changed_notify(); notify_property_list_changed(); @@ -767,7 +767,7 @@ PropertyInfo VisualScriptComposeArray::get_output_value_port_info(int p_idx) con } String VisualScriptComposeArray::get_caption() const { - return "Compose Array"; + return RTR("Compose Array"); } String VisualScriptComposeArray::get_text() const { @@ -777,9 +777,9 @@ String VisualScriptComposeArray::get_text() const { class VisualScriptComposeArrayNode : public VisualScriptNodeInstance { public: int input_count = 0; - virtual int get_working_memory_size() const { return 0; } + virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { if (input_count > 0) { Array arr; for (int i = 0; i < input_count; i++) { @@ -1097,12 +1097,12 @@ void VisualScriptOperator::_bind_methods() { class VisualScriptNodeInstanceOperator : public VisualScriptNodeInstance { public: - bool unary; + bool unary = false; Variant::Operator op; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { bool valid; if (unary) { Variant::evaluate(op, *p_inputs[0], Variant(), *p_outputs[0], valid); @@ -1186,11 +1186,11 @@ PropertyInfo VisualScriptSelect::get_output_value_port_info(int p_idx) const { } String VisualScriptSelect::get_caption() const { - return "Select"; + return RTR("Select"); } String VisualScriptSelect::get_text() const { - return "a if cond, else b"; + return RTR("a if cond, else b"); } void VisualScriptSelect::set_typed(Variant::Type p_op) { @@ -1220,9 +1220,9 @@ void VisualScriptSelect::_bind_methods() { class VisualScriptNodeInstanceSelect : public VisualScriptNodeInstance { public: - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { bool cond = *p_inputs[0]; if (cond) { *p_outputs[0] = *p_inputs[1]; @@ -1284,7 +1284,7 @@ PropertyInfo VisualScriptVariableGet::get_output_value_port_info(int p_idx) cons } String VisualScriptVariableGet::get_caption() const { - return "Get " + variable; + return vformat(RTR("Get %s"), variable); } void VisualScriptVariableGet::set_variable(StringName p_variable) { @@ -1307,7 +1307,7 @@ void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const { String vhint; for (const StringName &E : vars) { - if (vhint != String()) { + if (!vhint.is_empty()) { vhint += ","; } @@ -1328,11 +1328,11 @@ void VisualScriptVariableGet::_bind_methods() { class VisualScriptNodeInstanceVariableGet : public VisualScriptNodeInstance { public: - VisualScriptVariableGet *node; - VisualScriptInstance *instance; + VisualScriptVariableGet *node = nullptr; + VisualScriptInstance *instance = nullptr; StringName variable; - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { if (!instance->get_variable(variable, p_outputs[0])) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = RTR("VariableGet not found in script: ") + "'" + String(variable) + "'"; @@ -1394,7 +1394,7 @@ PropertyInfo VisualScriptVariableSet::get_output_value_port_info(int p_idx) cons } String VisualScriptVariableSet::get_caption() const { - return "Set " + variable; + return vformat(RTR("Set %s"), variable); } void VisualScriptVariableSet::set_variable(StringName p_variable) { @@ -1417,7 +1417,7 @@ void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const { String vhint; for (const StringName &E : vars) { - if (vhint != String()) { + if (!vhint.is_empty()) { vhint += ","; } @@ -1438,13 +1438,13 @@ void VisualScriptVariableSet::_bind_methods() { class VisualScriptNodeInstanceVariableSet : public VisualScriptNodeInstance { public: - VisualScriptVariableSet *node; - VisualScriptInstance *instance; + VisualScriptVariableSet *node = nullptr; + VisualScriptInstance *instance = nullptr; StringName variable; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { if (!instance->set_variable(variable, *p_inputs[0])) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = RTR("VariableSet not found in script: ") + "'" + String(variable) + "'"; @@ -1501,7 +1501,7 @@ PropertyInfo VisualScriptConstant::get_output_value_port_info(int p_idx) const { } String VisualScriptConstant::get_caption() const { - return "Constant"; + return RTR("Constant"); } void VisualScriptConstant::set_constant_type(Variant::Type p_type) { @@ -1561,9 +1561,9 @@ void VisualScriptConstant::_bind_methods() { class VisualScriptNodeInstanceConstant : public VisualScriptNodeInstance { public: Variant constant; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { *p_outputs[0] = constant; return 0; } @@ -1615,7 +1615,7 @@ PropertyInfo VisualScriptPreload::get_output_value_port_info(int p_idx) const { pinfo.hint_string = preload->get_class(); if (preload->get_path().is_resource_file()) { pinfo.name = preload->get_path(); - } else if (preload->get_name() != String()) { + } else if (!preload->get_name().is_empty()) { pinfo.name = preload->get_name(); } else { pinfo.name = preload->get_class(); @@ -1628,7 +1628,7 @@ PropertyInfo VisualScriptPreload::get_output_value_port_info(int p_idx) const { } String VisualScriptPreload::get_caption() const { - return "Preload"; + return RTR("Preload"); } void VisualScriptPreload::set_preload(const Ref<Resource> &p_preload) { @@ -1654,9 +1654,9 @@ void VisualScriptPreload::_bind_methods() { class VisualScriptNodeInstancePreload : public VisualScriptNodeInstance { public: Ref<Resource> preload; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { *p_outputs[0] = preload; return 0; } @@ -1708,14 +1708,14 @@ PropertyInfo VisualScriptIndexGet::get_output_value_port_info(int p_idx) const { } String VisualScriptIndexGet::get_caption() const { - return "Get Index"; + return RTR("Get Index"); } class VisualScriptNodeInstanceIndexGet : public VisualScriptNodeInstance { public: - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { bool valid; *p_outputs[0] = p_inputs[0]->get(*p_inputs[1], &valid); @@ -1775,19 +1775,16 @@ PropertyInfo VisualScriptIndexSet::get_output_value_port_info(int p_idx) const { } String VisualScriptIndexSet::get_caption() const { - return "Set Index"; + return RTR("Set Index"); } class VisualScriptNodeInstanceIndexSet : public VisualScriptNodeInstance { public: - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { bool valid; - // *p_output[0] points to the same place as *p_inputs[2] so we need a temp to store the value before the change in the next line - Variant temp = *p_inputs[2]; - *p_outputs[0] = *p_inputs[0]; - p_outputs[0]->set(*p_inputs[1], temp, &valid); + ((Variant *)p_inputs[0])->set(*p_inputs[1], *p_inputs[2], &valid); if (!valid) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; @@ -1839,7 +1836,7 @@ PropertyInfo VisualScriptGlobalConstant::get_output_value_port_info(int p_idx) c } String VisualScriptGlobalConstant::get_caption() const { - return "Global Constant"; + return RTR("Global Constant"); } void VisualScriptGlobalConstant::set_global_constant(int p_which) { @@ -1854,10 +1851,9 @@ int VisualScriptGlobalConstant::get_global_constant() { class VisualScriptNodeInstanceGlobalConstant : public VisualScriptNodeInstance { public: - int index; - //virtual int get_working_memory_size() const { return 0; } + int index = 0; - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { *p_outputs[0] = CoreConstants::get_global_constant_value(index); return 0; } @@ -1925,7 +1921,7 @@ PropertyInfo VisualScriptClassConstant::get_output_value_port_info(int p_idx) co } String VisualScriptClassConstant::get_caption() const { - return "Class Constant"; + return RTR("Class Constant"); } void VisualScriptClassConstant::set_class_constant(const StringName &p_which) { @@ -1966,11 +1962,10 @@ StringName VisualScriptClassConstant::get_base_type() { class VisualScriptNodeInstanceClassConstant : public VisualScriptNodeInstance { public: - int value; - bool valid; - //virtual int get_working_memory_size() const { return 0; } + int value = 0; + bool valid = false; - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { if (!valid) { r_error_str = "Invalid constant name, pick a valid class constant."; r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; @@ -1994,7 +1989,7 @@ void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const property.hint_string = ""; for (const String &E : constants) { - if (property.hint_string != String()) { + if (!property.hint_string.is_empty()) { property.hint_string += ","; } property.hint_string += E; @@ -2050,7 +2045,7 @@ PropertyInfo VisualScriptBasicTypeConstant::get_output_value_port_info(int p_idx } String VisualScriptBasicTypeConstant::get_caption() const { - return "Basic Constant"; + return RTR("Basic Constant"); } String VisualScriptBasicTypeConstant::get_text() const { @@ -2101,10 +2096,9 @@ Variant::Type VisualScriptBasicTypeConstant::get_basic_type() const { class VisualScriptNodeInstanceBasicTypeConstant : public VisualScriptNodeInstance { public: Variant value; - bool valid; - //virtual int get_working_memory_size() const { return 0; } + bool valid = false; - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { if (!valid) { r_error_str = "Invalid constant name, pick a valid basic type constant."; r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; @@ -2132,7 +2126,7 @@ void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) c } property.hint_string = ""; for (const StringName &E : constants) { - if (property.hint_string != String()) { + if (!property.hint_string.is_empty()) { property.hint_string += ","; } property.hint_string += String(E); @@ -2215,7 +2209,7 @@ PropertyInfo VisualScriptMathConstant::get_output_value_port_info(int p_idx) con } String VisualScriptMathConstant::get_caption() const { - return "Math Constant"; + return RTR("Math Constant"); } void VisualScriptMathConstant::set_math_constant(MathConstant p_which) { @@ -2230,10 +2224,9 @@ VisualScriptMathConstant::MathConstant VisualScriptMathConstant::get_math_consta class VisualScriptNodeInstanceMathConstant : public VisualScriptNodeInstance { public: - float value; - //virtual int get_working_memory_size() const { return 0; } + float value = 0.0f; - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { *p_outputs[0] = value; return 0; } @@ -2307,7 +2300,7 @@ PropertyInfo VisualScriptEngineSingleton::get_output_value_port_info(int p_idx) } String VisualScriptEngineSingleton::get_caption() const { - return "Get Engine Singleton"; + return RTR("Get Engine Singleton"); } void VisualScriptEngineSingleton::set_singleton(const String &p_string) { @@ -2323,11 +2316,11 @@ String VisualScriptEngineSingleton::get_singleton() { class VisualScriptNodeInstanceEngineSingleton : public VisualScriptNodeInstance { public: - Object *singleton; + Object *singleton = nullptr; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { *p_outputs[0] = singleton; return 0; } @@ -2363,7 +2356,7 @@ void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) con continue; //skip these, too simple named } - if (cc != String()) { + if (!cc.is_empty()) { cc += ","; } cc += E.name; @@ -2417,7 +2410,7 @@ PropertyInfo VisualScriptSceneNode::get_output_value_port_info(int p_idx) const } String VisualScriptSceneNode::get_caption() const { - return "Get Scene Node"; + return RTR("Get Scene Node"); } void VisualScriptSceneNode::set_node_path(const NodePath &p_path) { @@ -2432,13 +2425,13 @@ NodePath VisualScriptSceneNode::get_node_path() { class VisualScriptNodeInstanceSceneNode : public VisualScriptNodeInstance { public: - VisualScriptSceneNode *node; - VisualScriptInstance *instance; + VisualScriptSceneNode *node = nullptr; + VisualScriptInstance *instance = nullptr; NodePath path; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { Node *node = Object::cast_to<Node>(instance->get_owner_ptr()); if (!node) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; @@ -2495,7 +2488,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const VisualScriptSceneNode::TypeGuess VisualScriptSceneNode::guess_output_type(TypeGuess *p_inputs, int p_output) const { VisualScriptSceneNode::TypeGuess tg; tg.type = Variant::OBJECT; - tg.gdclass = "Node"; + tg.gdclass = SNAME("Node"); #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); @@ -2608,17 +2601,17 @@ PropertyInfo VisualScriptSceneTree::get_output_value_port_info(int p_idx) const } String VisualScriptSceneTree::get_caption() const { - return "Get Scene Tree"; + return RTR("Get Scene Tree"); } class VisualScriptNodeInstanceSceneTree : public VisualScriptNodeInstance { public: - VisualScriptSceneTree *node; - VisualScriptInstance *instance; + VisualScriptSceneTree *node = nullptr; + VisualScriptInstance *instance = nullptr; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { Node *node = Object::cast_to<Node>(instance->get_owner_ptr()); if (!node) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; @@ -2649,7 +2642,7 @@ VisualScriptNodeInstance *VisualScriptSceneTree::instantiate(VisualScriptInstanc VisualScriptSceneTree::TypeGuess VisualScriptSceneTree::guess_output_type(TypeGuess *p_inputs, int p_output) const { TypeGuess tg; tg.type = Variant::OBJECT; - tg.gdclass = "SceneTree"; + tg.gdclass = SNAME("SceneTree"); return tg; } @@ -2695,7 +2688,7 @@ PropertyInfo VisualScriptResourcePath::get_output_value_port_info(int p_idx) con } String VisualScriptResourcePath::get_caption() const { - return "Resource Path"; + return RTR("Resource Path"); } void VisualScriptResourcePath::set_resource_path(const String &p_path) { @@ -2712,9 +2705,9 @@ class VisualScriptNodeInstanceResourcePath : public VisualScriptNodeInstance { public: String path; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { *p_outputs[0] = path; return 0; } @@ -2766,27 +2759,27 @@ PropertyInfo VisualScriptSelf::get_input_value_port_info(int p_idx) const { } PropertyInfo VisualScriptSelf::get_output_value_port_info(int p_idx) const { - String type_name; + StringName type_name; if (get_visual_script().is_valid()) { type_name = get_visual_script()->get_instance_base_type(); } else { - type_name = "instance"; + type_name = SNAME("instance"); } return PropertyInfo(Variant::OBJECT, type_name); } String VisualScriptSelf::get_caption() const { - return "Get Self"; + return RTR("Get Self"); } class VisualScriptNodeInstanceSelf : public VisualScriptNodeInstance { public: - VisualScriptInstance *instance; + VisualScriptInstance *instance = nullptr; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { *p_outputs[0] = instance->get_owner_ptr(); return 0; } @@ -2801,7 +2794,7 @@ VisualScriptNodeInstance *VisualScriptSelf::instantiate(VisualScriptInstance *p_ VisualScriptSelf::TypeGuess VisualScriptSelf::guess_output_type(TypeGuess *p_inputs, int p_output) const { VisualScriptSceneNode::TypeGuess tg; tg.type = Variant::OBJECT; - tg.gdclass = "Object"; + tg.gdclass = SNAME("Object"); Ref<Script> script = get_visual_script(); if (!script.is_valid()) { @@ -2947,7 +2940,7 @@ String VisualScriptCustomNode::get_caption() const { if (GDVIRTUAL_CALL(_get_caption, ret)) { return ret; } - return "CustomNode"; + return RTR("CustomNode"); } String VisualScriptCustomNode::get_text() const { @@ -2968,14 +2961,14 @@ String VisualScriptCustomNode::get_category() const { class VisualScriptNodeInstanceCustomNode : public VisualScriptNodeInstance { public: - VisualScriptInstance *instance; - VisualScriptCustomNode *node; - int in_count; - int out_count; - int work_mem_size; - - virtual int get_working_memory_size() const { return work_mem_size; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + VisualScriptInstance *instance = nullptr; + VisualScriptCustomNode *node = nullptr; + int in_count = 0; + int out_count = 0; + int work_mem_size = 0; + + virtual int get_working_memory_size() const override { return work_mem_size; } + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { if (GDVIRTUAL_IS_OVERRIDDEN_PTR(node, _step)) { Array in_values; Array out_values; @@ -3141,13 +3134,13 @@ PropertyInfo VisualScriptSubCall::get_output_value_port_info(int p_idx) const { } String VisualScriptSubCall::get_caption() const { - return "SubCall"; + return RTR("SubCall"); } String VisualScriptSubCall::get_text() const { Ref<Script> script = get_script(); if (script.is_valid()) { - if (script->get_name() != String()) { + if (!script->get_name().is_empty()) { return script->get_name(); } if (script->get_path().is_resource_file()) { @@ -3164,20 +3157,20 @@ String VisualScriptSubCall::get_category() const { class VisualScriptNodeInstanceSubCall : public VisualScriptNodeInstance { public: - VisualScriptInstance *instance; - VisualScriptSubCall *subcall; - int input_args; - bool valid; + VisualScriptInstance *instance = nullptr; + VisualScriptSubCall *subcall = nullptr; + int input_args = 0; + bool valid = false; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { if (!valid) { r_error_str = "Node requires a script with a _subcall(<args>) method to work."; r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; return 0; } - *p_outputs[0] = subcall->call(VisualScriptLanguage::singleton->_subcall, p_inputs, input_args, r_error); + *p_outputs[0] = subcall->callp(VisualScriptLanguage::singleton->_subcall, p_inputs, input_args, r_error); return 0; } }; @@ -3284,11 +3277,11 @@ String VisualScriptComment::get_category() const { class VisualScriptNodeInstanceComment : public VisualScriptNodeInstance { public: - VisualScriptInstance *instance; + VisualScriptInstance *instance = nullptr; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { return 0; } }; @@ -3352,7 +3345,7 @@ PropertyInfo VisualScriptConstructor::get_output_value_port_info(int p_idx) cons } String VisualScriptConstructor::get_caption() const { - return "Construct " + Variant::get_type_name(type); + return vformat(RTR("Construct %s"), Variant::get_type_name(type)); } String VisualScriptConstructor::get_category() const { @@ -3383,13 +3376,13 @@ Dictionary VisualScriptConstructor::get_constructor() const { class VisualScriptNodeInstanceConstructor : public VisualScriptNodeInstance { public: - VisualScriptInstance *instance; + VisualScriptInstance *instance = nullptr; Variant::Type type; - int argcount; + int argcount = 0; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { Callable::CallError ce; Variant::construct(type, *p_outputs[0], p_inputs, argcount, ce); if (ce.error != Callable::CallError::CALL_OK) { @@ -3469,7 +3462,7 @@ PropertyInfo VisualScriptLocalVar::get_output_value_port_info(int p_idx) const { } String VisualScriptLocalVar::get_caption() const { - return "Get Local Var"; + return RTR("Get Local Var"); } String VisualScriptLocalVar::get_category() const { @@ -3500,11 +3493,11 @@ Variant::Type VisualScriptLocalVar::get_var_type() const { class VisualScriptNodeInstanceLocalVar : public VisualScriptNodeInstance { public: - VisualScriptInstance *instance; + VisualScriptInstance *instance = nullptr; StringName name; - virtual int get_working_memory_size() const { return 1; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int get_working_memory_size() const override { return 1; } + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { *p_outputs[0] = *p_working_mem; return 0; } @@ -3572,7 +3565,7 @@ PropertyInfo VisualScriptLocalVarSet::get_output_value_port_info(int p_idx) cons } String VisualScriptLocalVarSet::get_caption() const { - return "Set Local Var"; + return RTR("Set Local Var"); } String VisualScriptLocalVarSet::get_text() const { @@ -3607,11 +3600,11 @@ Variant::Type VisualScriptLocalVarSet::get_var_type() const { class VisualScriptNodeInstanceLocalVarSet : public VisualScriptNodeInstance { public: - VisualScriptInstance *instance; + VisualScriptInstance *instance = nullptr; StringName name; - virtual int get_working_memory_size() const { return 1; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int get_working_memory_size() const override { return 1; } + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { *p_working_mem = *p_inputs[0]; *p_outputs[0] = *p_working_mem; return 0; @@ -3696,7 +3689,7 @@ PropertyInfo VisualScriptInputAction::get_output_value_port_info(int p_idx) cons } String VisualScriptInputAction::get_caption() const { - return "Action " + name; + return vformat(RTR("Action %s"), name); } String VisualScriptInputAction::get_category() const { @@ -3731,11 +3724,11 @@ VisualScriptInputAction::Mode VisualScriptInputAction::get_action_mode() const { class VisualScriptNodeInstanceInputAction : public VisualScriptNodeInstance { public: - VisualScriptInstance *instance; + VisualScriptInstance *instance = nullptr; StringName action; VisualScriptInputAction::Mode mode; - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { switch (mode) { case VisualScriptInputAction::MODE_PRESSED: { *p_outputs[0] = Input::get_singleton()->is_action_pressed(action); @@ -3786,7 +3779,7 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const { al.sort(); for (int i = 0; i < al.size(); i++) { - if (actions != String()) { + if (!actions.is_empty()) { actions += ","; } actions += al[i]; @@ -3850,7 +3843,7 @@ PropertyInfo VisualScriptDeconstruct::get_output_value_port_info(int p_idx) cons } String VisualScriptDeconstruct::get_caption() const { - return "Deconstruct " + Variant::get_type_name(type); + return vformat(RTR("Deconstruct %s"), Variant::get_type_name(type)); } String VisualScriptDeconstruct::get_category() const { @@ -3909,12 +3902,12 @@ Array VisualScriptDeconstruct::_get_elem_cache() const { class VisualScriptNodeInstanceDeconstruct : public VisualScriptNodeInstance { public: - VisualScriptInstance *instance; + VisualScriptInstance *instance = nullptr; Vector<StringName> outputs; - //virtual int get_working_memory_size() const { return 0; } + //virtual int get_working_memory_size() const override { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override { Variant in = *p_inputs[0]; for (int i = 0; i < outputs.size(); i++) { |