diff options
author | Bojidar Marinov <bojidar.marinov.bg@gmail.com> | 2018-02-05 16:41:13 +0200 |
---|---|---|
committer | Bojidar Marinov <bojidar.marinov.bg@gmail.com> | 2018-02-05 16:41:13 +0200 |
commit | d855fdb45130a5029c07131c42e42cfe6c9fdf6e (patch) | |
tree | 23ba6987df33ea24c06a7366057ab87a7b95adef /modules/gdscript | |
parent | ea99b90a77228189d6dc38ab7b7ada967d668ed8 (diff) |
Allow exporting arrays of resources in GDScript
Fixes #15961
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 1392323d56..e6d83dd9f3 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3408,6 +3408,22 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) { tokenizer->advance(); + + String hint_prefix = ""; + bool is_arrayed = false; + + while (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE && + tokenizer->get_token_type() == Variant::ARRAY && + tokenizer->get_token(1) == GDScriptTokenizer::TK_COMMA) { + tokenizer->advance(); // Array + tokenizer->advance(); // Comma + if (is_arrayed) { + hint_prefix += itos(Variant::ARRAY) + ":"; + } else { + is_arrayed = true; + } + } + if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) { Variant::Type type = tokenizer->get_token_type(); @@ -3423,28 +3439,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { current_export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; tokenizer->advance(); - String hint_prefix = ""; - - if (type == Variant::ARRAY && tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { - tokenizer->advance(); - - while (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) { - type = tokenizer->get_token_type(); - - tokenizer->advance(); - - if (type == Variant::ARRAY) { - hint_prefix += itos(Variant::ARRAY) + ":"; - if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { - tokenizer->advance(); - } - } else { - hint_prefix += itos(type); - break; - } - } - } - if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { // hint expected next! tokenizer->advance(); @@ -3798,13 +3792,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { } break; } } - if (current_export.type == Variant::ARRAY && !hint_prefix.empty()) { - if (current_export.hint) { - hint_prefix += "/" + itos(current_export.hint); - } - current_export.hint_string = hint_prefix + ":" + current_export.hint_string; - current_export.hint = PROPERTY_HINT_NONE; - } } else { @@ -3891,6 +3878,16 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { return; } + if (is_arrayed) { + hint_prefix += itos(current_export.type); + if (current_export.hint) { + hint_prefix += "/" + itos(current_export.hint); + } + current_export.hint_string = hint_prefix + ":" + current_export.hint_string; + current_export.hint = PROPERTY_HINT_TYPE_STRING; + current_export.type = Variant::ARRAY; + } + tokenizer->advance(); } @@ -4058,7 +4055,8 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { member._export.type=Variant::DICTIONARY; - } else*/ { + } else*/ + { if (subexpr->type != Node::TYPE_CONSTANT) { |