diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-20 13:09:17 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-20 13:09:17 +0200 |
| commit | 971f678442a3754d4a2f1dd53b97a8e900fa9a4c (patch) | |
| tree | 02d0cd2f3fc4a4989a79e83796456e1594924398 /modules/gdscript/gdscript_parser.cpp | |
| parent | 21b132616bf167bf42e019cf3b7757ca56ea28b3 (diff) | |
| parent | c35cb51d7432f32ed04357f0d09875bce8288b4e (diff) | |
| download | redot-engine-971f678442a3754d4a2f1dd53b97a8e900fa9a4c.tar.gz | |
Merge pull request #79510 from dalexeev/gds-fix-const-non-metatype-subscript
GDScript: Fix subscript resolution for constant non-metatypes
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
| -rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 52c1a5b141..662a36d96f 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -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; - - 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; + 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; + } + 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); |
