mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 12:12:28 +00:00
Editor: Improve signal callback generation
This commit is contained in:
parent
221884e6bc
commit
4b5daf06ef
@ -517,16 +517,41 @@ String ConnectDialog::get_signature(const MethodInfo &p_method, PackedStringArra
|
||||
}
|
||||
|
||||
const PropertyInfo &pi = p_method.arguments[i];
|
||||
String tname = "var";
|
||||
if (pi.type == Variant::OBJECT && pi.class_name != StringName()) {
|
||||
tname = pi.class_name.operator String();
|
||||
} else if (pi.type != Variant::NIL) {
|
||||
tname = Variant::get_type_name(pi.type);
|
||||
String type_name;
|
||||
switch (pi.type) {
|
||||
case Variant::NIL:
|
||||
type_name = "Variant";
|
||||
break;
|
||||
case Variant::INT:
|
||||
if ((pi.usage & PROPERTY_USAGE_CLASS_IS_ENUM) && pi.class_name != StringName() && !String(pi.class_name).begins_with("res://")) {
|
||||
type_name = pi.class_name;
|
||||
} else {
|
||||
type_name = "int";
|
||||
}
|
||||
break;
|
||||
case Variant::ARRAY:
|
||||
if (pi.hint == PROPERTY_HINT_ARRAY_TYPE && !pi.hint_string.is_empty() && !pi.hint_string.begins_with("res://")) {
|
||||
type_name = "Array[" + pi.hint_string + "]";
|
||||
} else {
|
||||
type_name = "Array";
|
||||
}
|
||||
break;
|
||||
case Variant::OBJECT:
|
||||
if (pi.class_name != StringName()) {
|
||||
type_name = pi.class_name;
|
||||
} else {
|
||||
type_name = "Object";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
type_name = Variant::get_type_name(pi.type);
|
||||
break;
|
||||
}
|
||||
|
||||
signature.append((pi.name.is_empty() ? String("arg " + itos(i)) : pi.name) + ": " + tname);
|
||||
String arg_name = pi.name.is_empty() ? "arg" + itos(i) : pi.name;
|
||||
signature.append(arg_name + ": " + type_name);
|
||||
if (r_arg_names) {
|
||||
r_arg_names->push_back(pi.name + ":" + tname);
|
||||
r_arg_names->push_back(arg_name + ":" + type_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,7 +500,7 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
|
||||
s += p_args[i].get_slice(":", 0);
|
||||
if (th) {
|
||||
String type = p_args[i].get_slice(":", 1);
|
||||
if (!type.is_empty() && type != "var") {
|
||||
if (!type.is_empty()) {
|
||||
s += ": " + type;
|
||||
}
|
||||
}
|
||||
|
@ -435,6 +435,11 @@ static String variant_type_to_managed_name(const String &p_var_type_name) {
|
||||
return "Collections.Dictionary";
|
||||
}
|
||||
|
||||
if (p_var_type_name.begins_with(Variant::get_type_name(Variant::ARRAY) + "[")) {
|
||||
String element_type = p_var_type_name.trim_prefix(Variant::get_type_name(Variant::ARRAY) + "[").trim_suffix("]");
|
||||
return "Collections.Array<" + variant_type_to_managed_name(element_type) + ">";
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::ARRAY)) {
|
||||
return "Collections.Array";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user