diff options
Diffstat (limited to 'modules/visual_script/visual_script_func_nodes.cpp')
-rw-r--r-- | modules/visual_script/visual_script_func_nodes.cpp | 146 |
1 files changed, 98 insertions, 48 deletions
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 8f7b514881..7b5ca56dcc 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -254,25 +254,32 @@ PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) con } String VisualScriptFunctionCall::get_caption() const { - if (call_mode == CALL_MODE_SELF) { - return " " + String(function) + "()"; - } - if (call_mode == CALL_MODE_SINGLETON) { - return String(singleton) + ":" + String(function) + "()"; - } else if (call_mode == CALL_MODE_BASIC_TYPE) { - return Variant::get_type_name(basic_type) + "." + String(function) + "()"; - } else if (call_mode == CALL_MODE_NODE_PATH) { - return " [" + String(base_path.simplified()) + "]." + String(function) + "()"; - } else { - return " " + base_type + "." + String(function) + "()"; - } + return " " + String(function) + "()"; } String VisualScriptFunctionCall::get_text() const { + String text; + + if (call_mode == CALL_MODE_BASIC_TYPE) { + text = String("On ") + Variant::get_type_name(basic_type); + } else if (call_mode == CALL_MODE_INSTANCE) { + text = String("On ") + base_type; + } else if (call_mode == CALL_MODE_NODE_PATH) { + text = "[" + String(base_path.simplified()) + "]"; + } else if (call_mode == CALL_MODE_SELF) { + text = "On Self"; + } else if (call_mode == CALL_MODE_SINGLETON) { + text = String(singleton) + ":" + String(function) + "()"; + } + if (rpc_call_mode) { - return "RPC"; + text += " RPC"; + if (rpc_call_mode == RPC_UNRELIABLE || rpc_call_mode == RPC_UNRELIABLE_TO_ID) { + text += " UNREL"; + } } - return ""; + + return text; } void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) { @@ -901,11 +908,11 @@ static Ref<VisualScriptNode> create_function_call_node(const String &p_name) { ////////////////////////////////////////// int VisualScriptPropertySet::get_output_sequence_port_count() const { - return call_mode != CALL_MODE_BASIC_TYPE ? 1 : 0; + return 1; } bool VisualScriptPropertySet::has_input_sequence_port() const { - return call_mode != CALL_MODE_BASIC_TYPE; + return 1; } Node *VisualScriptPropertySet::_get_base_node() const { @@ -990,8 +997,7 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const if (p_idx == 0) { PropertyInfo pi; pi.type = (call_mode == CALL_MODE_INSTANCE ? Variant::OBJECT : basic_type); - pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower()); - _adjust_input_index(pi); + pi.name = "instance"; return pi; } } @@ -1000,21 +1006,24 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const ClassDB::get_property_list(_get_base_type(), &props, false); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { if (E->get().name == property) { - PropertyInfo pinfo = PropertyInfo(E->get().type, "value", PROPERTY_HINT_TYPE_STRING, E->get().hint_string); + String detail_prop_name = property; + if (index != StringName()) { + detail_prop_name += "." + String(index); + } + PropertyInfo pinfo = PropertyInfo(E->get().type, detail_prop_name, PROPERTY_HINT_TYPE_STRING, E->get().hint_string); _adjust_input_index(pinfo); return pinfo; } } PropertyInfo pinfo = type_cache; - pinfo.name = "value"; _adjust_input_index(pinfo); return pinfo; } PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) const { if (call_mode == CALL_MODE_BASIC_TYPE) { - return PropertyInfo(basic_type, "out"); + return PropertyInfo(basic_type, "pass"); } else if (call_mode == CALL_MODE_INSTANCE) { return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type()); } else { @@ -1036,17 +1045,18 @@ String VisualScriptPropertySet::get_caption() const { } String VisualScriptPropertySet::get_text() const { + if (!has_input_sequence_port()) { + return ""; + } if (call_mode == CALL_MODE_BASIC_TYPE) { return String("On ") + Variant::get_type_name(basic_type); + } else if (call_mode == CALL_MODE_INSTANCE) { + return String("On ") + base_type; + } else if (call_mode == CALL_MODE_NODE_PATH) { + return " [" + String(base_path.simplified()) + "]"; + } else { + return "On Self"; } - - static const char *cname[3] = { - "Self", - "Scene Node", - "Instance" - }; - - return String("On ") + cname[call_mode]; } void VisualScriptPropertySet::_update_base_type() { @@ -1707,7 +1717,9 @@ int VisualScriptPropertyGet::get_input_value_port_count() const { } int VisualScriptPropertyGet::get_output_value_port_count() const { - return 1; + int pc = (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 2 : 1; + + return pc; } String VisualScriptPropertyGet::get_output_sequence_port_text(int p_port) const { @@ -1727,33 +1739,46 @@ PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const } PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) const { - List<PropertyInfo> props; - ClassDB::get_property_list(_get_base_type(), &props, false); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name == property) { - return PropertyInfo(E->get().type, "value." + String(index)); + if (call_mode == CALL_MODE_BASIC_TYPE && p_idx == 0) { + return PropertyInfo(basic_type, "pass"); + } else if (call_mode == CALL_MODE_INSTANCE && p_idx == 0) { + return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type()); + } else { + List<PropertyInfo> props; + ClassDB::get_property_list(_get_base_type(), &props, false); + for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + if (E->get().name == property) { + PropertyInfo pinfo = PropertyInfo(E->get().type, String(property) + "." + String(index), E->get().hint, E->get().hint_string); + _adjust_input_index(pinfo); + return pinfo; + } } } - return PropertyInfo(type_cache, "value"); + PropertyInfo pinfo = PropertyInfo(type_cache, "value"); + _adjust_input_index(pinfo); + return pinfo; } String VisualScriptPropertyGet::get_caption() const { - return String("Get ") + property; + String prop = String("Get ") + property; + if (index != StringName()) { + prop += "." + String(index); + } + + return prop; } String VisualScriptPropertyGet::get_text() const { if (call_mode == CALL_MODE_BASIC_TYPE) { return String("On ") + Variant::get_type_name(basic_type); + } else if (call_mode == CALL_MODE_INSTANCE) { + return String("On ") + base_type; + } else if (call_mode == CALL_MODE_NODE_PATH) { + return " [" + String(base_path.simplified()) + "]"; + } else { + return "On Self"; } - - static const char *cname[3] = { - "Self", - "Scene Node", - "Instance" - }; - - return String("On ") + cname[call_mode]; } void VisualScriptPropertyGet::set_base_type(const StringName &p_type) { @@ -1933,6 +1958,19 @@ Variant::Type VisualScriptPropertyGet::_get_type_cache() const { return type_cache; } +void VisualScriptPropertyGet::_adjust_input_index(PropertyInfo &pinfo) const { + if (index != StringName()) { + Variant v; + Callable::CallError ce; + Variant::construct(pinfo.type, v, nullptr, 0, ce); + Variant i = v.get(index); + pinfo.type = i.get_type(); + pinfo.name = String(property) + "." + index; + } else { + pinfo.name = String(property); + } +} + void VisualScriptPropertyGet::set_index(const StringName &p_type) { if (index == p_type) { return; @@ -2159,15 +2197,17 @@ public: bool valid; Variant v = *p_inputs[0]; - *p_outputs[0] = v.get(property, &valid); + *p_outputs[1] = v.get(property, &valid); if (index != StringName()) { - *p_outputs[0] = p_outputs[0]->get_named(index, valid); + *p_outputs[1] = p_outputs[1]->get_named(index, valid); } if (!valid) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = RTR("Invalid index property name."); } + + *p_outputs[0] = v; }; } @@ -2228,7 +2268,7 @@ int VisualScriptEmitSignal::get_input_value_port_count() const { } int VisualScriptEmitSignal::get_output_value_port_count() const { - return 0; + return 1; } String VisualScriptEmitSignal::get_output_sequence_port_text(int p_port) const { @@ -2271,6 +2311,16 @@ StringName VisualScriptEmitSignal::get_signal() const { return name; } +void VisualScriptEmitSignal::_adjust_input_index(PropertyInfo &pinfo) const { + if (index != StringName()) { + Variant v; + Callable::CallError ce; + Variant::construct(pinfo.type, v, nullptr, 0, ce); + Variant i = v.get(index); + pinfo.type = i.get_type(); + } +} + void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const { if (property.name == "signal") { property.hint = PROPERTY_HINT_ENUM; |