mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
Expose visual script custom node type hints
This commit is contained in:
parent
40b57319e2
commit
9178e24d30
3 changed files with 72 additions and 2 deletions
|
@ -2736,6 +2736,12 @@ PropertyInfo VisualScriptCustomNode::get_input_value_port_info(int p_idx) const
|
|||
if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_name")) {
|
||||
info.name = get_script_instance()->call("_get_input_value_port_name", p_idx);
|
||||
}
|
||||
if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_hint")) {
|
||||
info.hint = PropertyHint(int(get_script_instance()->call("_get_input_value_port_hint", p_idx)));
|
||||
}
|
||||
if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_hint_string")) {
|
||||
info.hint_string = get_script_instance()->call("_get_input_value_port_hint_string", p_idx);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -2747,9 +2753,31 @@ PropertyInfo VisualScriptCustomNode::get_output_value_port_info(int p_idx) const
|
|||
if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_name")) {
|
||||
info.name = get_script_instance()->call("_get_output_value_port_name", p_idx);
|
||||
}
|
||||
if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_hint")) {
|
||||
info.hint = PropertyHint(int(get_script_instance()->call("_get_output_value_port_hint", p_idx)));
|
||||
}
|
||||
if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_hint_string")) {
|
||||
info.hint_string = get_script_instance()->call("_get_output_value_port_hint_string", p_idx);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
VisualScriptCustomNode::TypeGuess VisualScriptCustomNode::guess_output_type(TypeGuess *p_inputs, int p_output) const {
|
||||
TypeGuess tg;
|
||||
PropertyInfo pi = VisualScriptCustomNode::get_output_value_port_info(p_output);
|
||||
tg.type = pi.type;
|
||||
if (pi.type == Variant::OBJECT) {
|
||||
if (pi.hint == PROPERTY_HINT_RESOURCE_TYPE) {
|
||||
if (pi.hint_string.is_resource_file()) {
|
||||
tg.script = ResourceLoader::load(pi.hint_string);
|
||||
} else if (ClassDB::class_exists(pi.hint_string)) {
|
||||
tg.gdclass = pi.hint_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tg;
|
||||
}
|
||||
|
||||
String VisualScriptCustomNode::get_caption() const {
|
||||
if (get_script_instance() && get_script_instance()->has_method("_get_caption")) {
|
||||
return get_script_instance()->call("_get_caption");
|
||||
|
@ -2871,9 +2899,13 @@ void VisualScriptCustomNode::_bind_methods() {
|
|||
|
||||
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_input_value_port_type", PropertyInfo(Variant::INT, "idx")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_input_value_port_name", PropertyInfo(Variant::INT, "idx")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_input_value_port_hint", PropertyInfo(Variant::INT, "idx")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_input_value_port_hint_string", PropertyInfo(Variant::INT, "idx")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_value_port_type", PropertyInfo(Variant::INT, "idx")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_output_value_port_name", PropertyInfo(Variant::INT, "idx")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_value_port_hint", PropertyInfo(Variant::INT, "idx")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_output_value_port_hint_string", PropertyInfo(Variant::INT, "idx")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_caption"));
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_text"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue