diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-12-31 00:33:07 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-12-31 00:33:07 -0300 |
commit | 335c52ba03ecbccd0c9af8f9278b69da09a3e931 (patch) | |
tree | 5e4f5e2ea0d735228de7733e2fb689abbc2bc9c9 /modules/gdscript/gd_editor.cpp | |
parent | fd836cad270f7eb9645356cd583c8f11bf737b0f (diff) | |
parent | ac13c8c0c6fc346462b21ee00139dddd2e4ec1e3 (diff) | |
download | redot-engine-335c52ba03ecbccd0c9af8f9278b69da09a3e931.tar.gz |
Merge branch 'master' of https://github.com/godotengine/godot
Diffstat (limited to 'modules/gdscript/gd_editor.cpp')
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 381edcba50..6255cfd86a 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -1147,8 +1147,54 @@ static bool _guess_identifier_type(GDCompletionContext& context,int p_line,const } } + //autoloads as singletons + List<PropertyInfo> props; + Globals::get_singleton()->get_property_list(&props); + for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) { + String s = E->get().name; + if (!s.begins_with("autoload/")) + continue; + String name = s.get_slice("/",1); + if (name==String(p_identifier)) { + + String path = Globals::get_singleton()->get(s); + if (path.begins_with("*")) { + String script =path.substr(1,path.length()); + + if (!script.ends_with(".gd")) { + //not a script, try find the script anyway, + //may have some success + script=script.basename()+".gd"; + } + + if (FileAccess::exists(script)) { + + //print_line("is a script"); + + + Ref<Script> scr; + if (ScriptCodeCompletionCache::get_sigleton()) + scr = ScriptCodeCompletionCache::get_sigleton()->get_cached_resource(script); + else + scr = ResourceLoader::load(script); + + + r_type.obj_type="Node"; + r_type.type=Variant::OBJECT; + r_type.script=scr; + r_type.value=Variant(); + + return true; + + } + } + } + + } + + //global for(Map<StringName,int>::Element *E=GDScriptLanguage::get_singleton()->get_global_map().front();E;E=E->next()) { if (E->key()==p_identifier) { @@ -1336,6 +1382,24 @@ static void _find_identifiers(GDCompletionContext& context,int p_line,bool p_onl result.insert(_type_names[i]); } + //autoload singletons + List<PropertyInfo> props; + Globals::get_singleton()->get_property_list(&props); + + for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) { + + String s = E->get().name; + if (!s.begins_with("autoload/")) + continue; + String name = s.get_slice("/",1); + String path = Globals::get_singleton()->get(s); + if (path.begins_with("*")) { + result.insert(name); + } + + } + + for(const Map<StringName,int>::Element *E=GDScriptLanguage::get_singleton()->get_global_map().front();E;E=E->next()) { result.insert(E->key().operator String()); } |