Add GDScript export hints for global filesystem and exponential ranges
- File in global filesystem: `String, FILE, GLOBAL, "*.png"`, tool scripts only - Directory in global filesystem: `String, DIR, GLOBAL`, tool scripts only - Exponential range: `float, EXP, 50, 150, 2`
This commit is contained in:
parent
3ecc9e07b7
commit
ef0c05430c
@ -2439,6 +2439,23 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
||||
break;
|
||||
}
|
||||
|
||||
// range
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="EXP") {
|
||||
|
||||
current_export.hint=PROPERTY_HINT_EXP_RANGE;
|
||||
tokenizer->advance();
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE)
|
||||
break;
|
||||
else if (tokenizer->get_token()!=GDTokenizer::TK_COMMA) {
|
||||
_set_error("Expected ')' or ',' in exponential range hint.");
|
||||
return;
|
||||
}
|
||||
tokenizer->advance();
|
||||
}
|
||||
else
|
||||
current_export.hint=PROPERTY_HINT_RANGE;
|
||||
|
||||
float sign=1.0;
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_OP_SUB) {
|
||||
@ -2452,8 +2469,6 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
||||
return;
|
||||
|
||||
}
|
||||
//enumeration
|
||||
current_export.hint=PROPERTY_HINT_RANGE;
|
||||
|
||||
current_export.hint_string=rtos(sign*double(tokenizer->get_token_constant()));
|
||||
tokenizer->advance();
|
||||
@ -2556,10 +2571,32 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="DIR") {
|
||||
|
||||
current_export.hint=PROPERTY_HINT_DIR;
|
||||
tokenizer->advance();
|
||||
if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
|
||||
_set_error("Expected ')' in hint.");
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE)
|
||||
current_export.hint=PROPERTY_HINT_DIR;
|
||||
else if (tokenizer->get_token()==GDTokenizer::TK_COMMA ) {
|
||||
|
||||
tokenizer->advance();
|
||||
|
||||
if (tokenizer->get_token()!=GDTokenizer::TK_IDENTIFIER || !(tokenizer->get_token_identifier()=="GLOBAL")) {
|
||||
_set_error("Expected 'GLOBAL' after comma in directory hint.");
|
||||
return;
|
||||
}
|
||||
if (!p_class->tool) {
|
||||
_set_error("Global filesystem hints may only be used in tool scripts.");
|
||||
return;
|
||||
}
|
||||
current_export.hint=PROPERTY_HINT_GLOBAL_DIR;
|
||||
tokenizer->advance();
|
||||
|
||||
if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
|
||||
_set_error("Expected ')' in hint.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_set_error("Expected ')' or ',' in hint.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@ -2573,9 +2610,32 @@ void GDParser::_parse_class(ClassNode *p_class) {
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_COMMA) {
|
||||
|
||||
tokenizer->advance();
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="GLOBAL") {
|
||||
|
||||
if (!p_class->tool) {
|
||||
_set_error("Global filesystem hints may only be used in tool scripts.");
|
||||
return;
|
||||
}
|
||||
current_export.hint=PROPERTY_HINT_GLOBAL_FILE;
|
||||
tokenizer->advance();
|
||||
|
||||
if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE)
|
||||
break;
|
||||
else if (tokenizer->get_token()==GDTokenizer::TK_COMMA)
|
||||
tokenizer->advance();
|
||||
else {
|
||||
_set_error("Expected ')' or ',' in hint.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (tokenizer->get_token()!=GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type()!=Variant::STRING) {
|
||||
|
||||
_set_error("Expected string constant with filter");
|
||||
if (current_export.hint==PROPERTY_HINT_GLOBAL_FILE)
|
||||
_set_error("Expected string constant with filter");
|
||||
else
|
||||
_set_error("Expected 'GLOBAL' or string constant with filter");
|
||||
return;
|
||||
}
|
||||
current_export.hint_string=tokenizer->get_token_constant();
|
||||
|
Loading…
Reference in New Issue
Block a user