Browse Source

suport old-style engine.cfg colors in VariantParser, fixes #3176

Juan Linietsky 9 years ago
parent
commit
bc2b1696e6
2 changed files with 29 additions and 0 deletions
  1. 28 0
      core/variant_parser.cpp
  2. 1 0
      core/variant_parser.h

+ 28 - 0
core/variant_parser.cpp

@@ -49,6 +49,7 @@ const char * VariantParser::tk_name[TK_MAX] = {
 	"identifier",
 	"identifier",
 	"string",
 	"string",
 	"number",
 	"number",
+	"color",
 	"':'",
 	"':'",
 	"','",
 	"','",
 	"'='",
 	"'='",
@@ -144,6 +145,29 @@ Error VariantParser::get_token(Stream *p_stream, Token& r_token, int &line, Stri
 				r_token.type=TK_EQUAL;
 				r_token.type=TK_EQUAL;
 				return OK;
 				return OK;
 			};
 			};
+			case '#': {
+
+
+				String color_str="#";
+				while(true) {
+					CharType ch=p_stream->get_char();
+					if (p_stream->is_eof()) {
+						r_token.type=TK_EOF;
+						return OK;
+					} else if ( (ch>='0' && ch<='9') || (ch>='a' && ch<='f') || (ch>='A' && ch<='F') ) {
+						color_str+=String::chr(ch);
+
+					} else {
+						p_stream->saved=ch;
+						break;
+					}
+				}
+
+				r_token.value=Color::html(color_str);
+				r_token.type=TK_COLOR;
+				return OK;
+
+			};
 			case '"': {
 			case '"': {
 
 
 
 
@@ -1369,6 +1393,10 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
 		return OK;
 		return OK;
 	} else if (token.type==TK_STRING) {
 	} else if (token.type==TK_STRING) {
 
 
+		value=token.value;
+		return OK;
+	} else if (token.type==TK_COLOR) {
+
 		value=token.value;
 		value=token.value;
 		return OK;
 		return OK;
 	} else {
 	} else {

+ 1 - 0
core/variant_parser.h

@@ -66,6 +66,7 @@ public:
 		TK_IDENTIFIER,
 		TK_IDENTIFIER,
 		TK_STRING,
 		TK_STRING,
 		TK_NUMBER,
 		TK_NUMBER,
+		TK_COLOR,
 		TK_COLON,
 		TK_COLON,
 		TK_COMMA,
 		TK_COMMA,
 		TK_EQUAL,
 		TK_EQUAL,