From 110de2ccace05ade4d9fbdded7f4c158dfaa13c1 Mon Sep 17 00:00:00 2001 From: reduz Date: Mon, 28 Dec 2015 16:36:29 -0300 Subject: [PATCH] -Added proper code completion for singletons --- modules/gdscript/gd_editor.cpp | 64 +++++++++++++++++++++++++++++++ tools/editor/project_settings.cpp | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 381edcba502..6255cfd86a5 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 props; + Globals::get_singleton()->get_property_list(&props); + + for(List::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