Преглед изворни кода

Merge pull request #2609 from eska014/export-hints

GDScript export hints: Add float w/ ease, remove duplicate, adapt multiline to established format
Juan Linietsky пре 10 година
родитељ
комит
f44d15e4fc
1 измењених фајлова са 30 додато и 16 уклоњено
  1. 30 16
      modules/gdscript/gd_parser.cpp

+ 30 - 16
modules/gdscript/gd_parser.cpp

@@ -2421,6 +2421,16 @@ void GDParser::_parse_class(ClassNode *p_class) {
 								}; //fallthrough to use the same
 								case Variant::REAL: {
 
+									if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="EASE") {
+										current_export.hint=PROPERTY_HINT_EXP_EASING;
+										tokenizer->advance();
+										if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
+											_set_error("Expected ')' in hint.");
+											return;
+										}
+										break;
+									}
+
 									float sign=1.0;
 
 									if (tokenizer->get_token()==GDTokenizer::TK_OP_SUB) {
@@ -2571,6 +2581,17 @@ void GDParser::_parse_class(ClassNode *p_class) {
 										}
 										break;
 									}
+
+									if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="MULTILINE") {
+
+										current_export.hint=PROPERTY_HINT_MULTILINE_TEXT;
+										tokenizer->advance();
+										if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
+											_set_error("Expected ')' in hint.");
+											return;
+										}
+										break;
+									}
 								} break;
 								case Variant::COLOR: {
 
@@ -2607,23 +2628,16 @@ void GDParser::_parse_class(ClassNode *p_class) {
 					} else if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER) {
 
 						String identifier = tokenizer->get_token_identifier();
-						if (identifier == "flag") {
-							current_export.type=Variant::INT;
-							current_export.hint=PROPERTY_HINT_ALL_FLAGS;
-						}else if (identifier == "multiline"){
-							current_export.type=Variant::STRING;
-							current_export.hint=PROPERTY_HINT_MULTILINE_TEXT;
-						} else {
-							if (!ObjectTypeDB::is_type(identifier,"Resource")) {
-	
-								current_export=PropertyInfo();
-								_set_error("Export hint not a type or resource.");
-							}
-	
-							current_export.type=Variant::OBJECT;
-							current_export.hint=PROPERTY_HINT_RESOURCE_TYPE;
-							current_export.hint_string=identifier;
+						if (!ObjectTypeDB::is_type(identifier,"Resource")) {
+
+							current_export=PropertyInfo();
+							_set_error("Export hint not a type or resource.");
 						}
+
+						current_export.type=Variant::OBJECT;
+						current_export.hint=PROPERTY_HINT_RESOURCE_TYPE;
+						current_export.hint_string=identifier;
+
 						tokenizer->advance();
 					}