diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-02-15 21:16:33 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-02-15 21:16:33 -0300 |
commit | 8c1731b67995add31361ae526b0e6af76346181e (patch) | |
tree | f96080fdbb6e0f0f3fcc12bf10fc92928f0310cb /script/gdscript | |
parent | 9afdb3e0ad5bfbdafe307212f5d4ebcc7c3ac852 (diff) | |
download | redot-engine-8c1731b67995add31361ae526b0e6af76346181e.tar.gz |
-project settings are saved when changed
-load() was in the GDScript docs but missing in the scripting-different music for platformer 2D and 3D
-fix how documentation is generated, built in doc browser should be always up to date
-copypaste, scrolling, etc in builtin doc
-built-in scripts get saved now (though debugger may not always work on them)
-Theme can be set to controls as a property
Diffstat (limited to 'script/gdscript')
-rw-r--r-- | script/gdscript/gd_functions.cpp | 17 | ||||
-rw-r--r-- | script/gdscript/gd_functions.h | 1 | ||||
-rw-r--r-- | script/gdscript/gd_parser.cpp | 10 | ||||
-rw-r--r-- | script/gdscript/gd_script.cpp | 15 | ||||
-rw-r--r-- | script/gdscript/gd_script.h | 2 |
5 files changed, 36 insertions, 9 deletions
diff --git a/script/gdscript/gd_functions.cpp b/script/gdscript/gd_functions.cpp index 4fc45eda9e..2930d9322c 100644 --- a/script/gdscript/gd_functions.cpp +++ b/script/gdscript/gd_functions.cpp @@ -88,6 +88,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "printerr", "printraw", "range", + "load", "inst2dict", "dict2inst", "print_stack", @@ -668,6 +669,16 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va } } break; + case RESOURCE_LOAD: { + VALIDATE_ARG_COUNT(1); + if (p_args[0]->get_type()!=Variant::STRING) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_ret=Variant(); + } + r_ret=ResourceLoader::load(*p_args[0]); + + } case INST2DICT: { VALIDATE_ARG_COUNT(1); @@ -1170,6 +1181,12 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type=Variant::ARRAY; return mi; } break; + case RESOURCE_LOAD: { + + MethodInfo mi("load",PropertyInfo(Variant::STRING,"path")); + mi.return_val.type=Variant::OBJECT; + return mi; + } break; case INST2DICT: { MethodInfo mi("inst2dict",PropertyInfo(Variant::OBJECT,"inst")); diff --git a/script/gdscript/gd_functions.h b/script/gdscript/gd_functions.h index af449783c1..2ab397d18a 100644 --- a/script/gdscript/gd_functions.h +++ b/script/gdscript/gd_functions.h @@ -85,6 +85,7 @@ public: TEXT_PRINTERR, TEXT_PRINTRAW, GEN_RANGE, + RESOURCE_LOAD, INST2DICT, DICT2INST, PRINT_STACK, diff --git a/script/gdscript/gd_parser.cpp b/script/gdscript/gd_parser.cpp index cfb324e1ae..e558ceb416 100644 --- a/script/gdscript/gd_parser.cpp +++ b/script/gdscript/gd_parser.cpp @@ -557,7 +557,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ //indexing using "." - if (tokenizer.get_token(1)!=GDTokenizer::TK_IDENTIFIER) { + if (tokenizer.get_token(1)!=GDTokenizer::TK_IDENTIFIER && tokenizer.get_token(1)!=GDTokenizer::TK_BUILT_IN_FUNC ) { _set_error("Expected identifier as member"); return NULL; } else if (tokenizer.get_token(2)==GDTokenizer::TK_PARENTHESIS_OPEN) { @@ -566,7 +566,13 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ op->op=OperatorNode::OP_CALL; IdentifierNode * id = alloc_node<IdentifierNode>(); - id->name=tokenizer.get_token_identifier(1); + if (tokenizer.get_token(1)==GDTokenizer::TK_BUILT_IN_FUNC ) { + //small hack so built in funcs don't obfuscate methods + + id->name=GDFunctions::get_func_name(tokenizer.get_token_built_in_func(1)); + } else { + id->name=tokenizer.get_token_identifier(1); + } op->arguments.push_back(expr); // call what op->arguments.push_back(id); // call func diff --git a/script/gdscript/gd_script.cpp b/script/gdscript/gd_script.cpp index 891cede030..5679e1e066 100644 --- a/script/gdscript/gd_script.cpp +++ b/script/gdscript/gd_script.cpp @@ -1524,21 +1524,21 @@ bool GDScript::_get(const StringName& p_name,Variant &r_ret) const { top=top->_base; } - return false; - } + if (p_name==GDScriptLanguage::get_singleton()->strings._script_source) { + r_ret=get_source_code(); + return true; + } + } - if (p_name=="script/source") { - r_ret=get_source_code(); - } - return true; + return false; } bool GDScript::_set(const StringName& p_name, const Variant& p_value) { - if (p_name=="script/source") { + if (p_name==GDScriptLanguage::get_singleton()->strings._script_source) { set_source_code(p_value); reload(); @@ -2115,6 +2115,7 @@ GDScriptLanguage::GDScriptLanguage() { strings._set= StaticCString::create("_set"); strings._get= StaticCString::create("_get"); strings._get_property_list= StaticCString::create("_get_property_list"); + strings._script_source=StaticCString::create("script/source"); _debug_parse_err_line=-1; _debug_parse_err_file=""; diff --git a/script/gdscript/gd_script.h b/script/gdscript/gd_script.h index d6f333f35d..bb9beaaf56 100644 --- a/script/gdscript/gd_script.h +++ b/script/gdscript/gd_script.h @@ -219,6 +219,7 @@ friend class GDFunctions; virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder); #endif + protected: bool _get(const StringName& p_name,Variant &r_ret) const; bool _set(const StringName& p_name, const Variant& p_value); @@ -392,6 +393,7 @@ public: StringName _set; StringName _get; StringName _get_property_list; + StringName _script_source; } strings; |