GDScript: Fix subscript resolution for constant non-metatypes

This commit is contained in:
Danil Alexeev 2023-09-19 20:35:45 +03:00
parent 571cd0eb79
commit c35cb51d74
No known key found for this signature in database
GPG key ID: 124453E157DA8DC7
5 changed files with 193 additions and 17 deletions

View file

@ -4095,25 +4095,29 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
}
} break;
case GDScriptParser::DataType::ENUM: {
variable->export_info.type = Variant::INT;
variable->export_info.hint = PROPERTY_HINT_ENUM;
if (export_type.is_meta_type) {
variable->export_info.type = Variant::DICTIONARY;
} else {
variable->export_info.type = Variant::INT;
variable->export_info.hint = PROPERTY_HINT_ENUM;
String enum_hint_string;
bool first = true;
for (const KeyValue<StringName, int64_t> &E : export_type.enum_values) {
if (!first) {
enum_hint_string += ",";
} else {
first = false;
String enum_hint_string;
bool first = true;
for (const KeyValue<StringName, int64_t> &E : export_type.enum_values) {
if (!first) {
enum_hint_string += ",";
} else {
first = false;
}
enum_hint_string += E.key.operator String().capitalize().xml_escape();
enum_hint_string += ":";
enum_hint_string += String::num_int64(E.value).xml_escape();
}
enum_hint_string += E.key.operator String().capitalize().xml_escape();
enum_hint_string += ":";
enum_hint_string += String::num_int64(E.value).xml_escape();
}
variable->export_info.hint_string = enum_hint_string;
variable->export_info.usage |= PROPERTY_USAGE_CLASS_IS_ENUM;
variable->export_info.class_name = String(export_type.native_type).replace("::", ".");
variable->export_info.hint_string = enum_hint_string;
variable->export_info.usage |= PROPERTY_USAGE_CLASS_IS_ENUM;
variable->export_info.class_name = String(export_type.native_type).replace("::", ".");
}
} break;
default:
push_error(R"(Export type can only be built-in, a resource, a node, or an enum.)", variable);