mirror of
https://github.com/godotengine/godot.git
synced 2025-10-24 02:13:36 +00:00
Improve and streamline VisualScriptFuncNodes Call Set Get
This PR improves and streamlines the workflow for VisualScriptFunctionNodes Call Set Get Uniform design. Drag in set-get from tree is now working. port 'pass' not backported to 3.x to keep script backwards compatibility
This commit is contained in:
parent
40b57319e2
commit
af1ea1800d
4 changed files with 147 additions and 68 deletions
|
|
@ -254,25 +254,31 @@ 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 {
|
||||
if (rpc_call_mode) {
|
||||
return "RPC";
|
||||
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) + "()";
|
||||
}
|
||||
return "";
|
||||
|
||||
if (rpc_call_mode) {
|
||||
text += " RPC";
|
||||
if (rpc_call_mode == RPC_UNRELIABLE || rpc_call_mode == RPC_UNRELIABLE_TO_ID) {
|
||||
text += " UNREL";
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) {
|
||||
|
|
@ -895,11 +901,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 {
|
||||
|
|
@ -993,21 +999,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 {
|
||||
|
|
@ -1029,17 +1038,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() {
|
||||
|
|
@ -1692,6 +1702,7 @@ int VisualScriptPropertyGet::get_input_value_port_count() const {
|
|||
return (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 1 : 0;
|
||||
}
|
||||
int VisualScriptPropertyGet::get_output_value_port_count() const {
|
||||
// port 'pass' not backported to 3.x to keep script backwards compatibility
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -1712,33 +1723,41 @@ PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const
|
|||
}
|
||||
|
||||
PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) const {
|
||||
// port 'pass' not backported to 3.x to keep script backwards compatibility
|
||||
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));
|
||||
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) {
|
||||
|
|
@ -1916,6 +1935,18 @@ Variant::Type VisualScriptPropertyGet::_get_type_cache() const {
|
|||
return type_cache;
|
||||
}
|
||||
|
||||
void VisualScriptPropertyGet::_adjust_input_index(PropertyInfo &pinfo) const {
|
||||
if (index != StringName()) {
|
||||
Variant v;
|
||||
Variant::CallError ce;
|
||||
v = Variant::construct(pinfo.type, nullptr, 0, ce);
|
||||
Variant i = v.get(index);
|
||||
pinfo.type = i.get_type();
|
||||
} else {
|
||||
pinfo.name = String(property);
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptPropertyGet::set_index(const StringName &p_type) {
|
||||
if (index == p_type) {
|
||||
return;
|
||||
|
|
@ -2141,6 +2172,7 @@ public:
|
|||
bool valid;
|
||||
Variant v = *p_inputs[0];
|
||||
|
||||
// port 'pass' not backported to 3.x to keep script backwards compatibility
|
||||
*p_outputs[0] = v.get(property, &valid);
|
||||
if (index != StringName()) {
|
||||
*p_outputs[0] = p_outputs[0]->get_named(index);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue