mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 21:51:22 +00:00 
			
		
		
		
	Merge pull request #16418 from bojidar-bg/15961-gdscript-array-export
Allow exporting arrays of resources in GDScript
This commit is contained in:
		
						commit
						460e551ddf
					
				
					 2 changed files with 46 additions and 36 deletions
				
			
		|  | @ -3440,6 +3440,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(); | ||||
|  | @ -3455,28 +3471,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(); | ||||
|  | @ -3830,13 +3824,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 { | ||||
| 
 | ||||
|  | @ -3923,6 +3910,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(); | ||||
| 				} | ||||
| 
 | ||||
|  | @ -4090,7 +4087,8 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { | |||
| 
 | ||||
| 							member._export.type=Variant::DICTIONARY; | ||||
| 
 | ||||
| 						} else*/ { | ||||
| 						} else*/ | ||||
| 						{ | ||||
| 
 | ||||
| 							if (subexpr->type != Node::TYPE_CONSTANT) { | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rémi Verschelde
						Rémi Verschelde