Merge pull request #6413 from caryoscelus/script_load_singletons

enable autoload for command-line scripts
This commit is contained in:
Juan Linietsky 2016-09-10 11:47:12 -03:00 committed by GitHub
commit c2b70fdd69
1 changed files with 84 additions and 87 deletions

View File

@ -1294,9 +1294,10 @@ bool Main::start() {
} }
String local_game_path;
if (game_path!="" && !project_manager_request) { if (game_path!="" && !project_manager_request) {
String local_game_path=game_path.replace("\\","/"); local_game_path=game_path.replace("\\","/");
if (!local_game_path.begins_with("res://")) { if (!local_game_path.begins_with("res://")) {
bool absolute=(local_game_path.size()>1) && (local_game_path[0]=='/' || local_game_path[1]==':'); bool absolute=(local_game_path.size()>1) && (local_game_path[0]=='/' || local_game_path[1]==':');
@ -1363,10 +1364,12 @@ bool Main::start() {
OS::get_singleton()->set_context(OS::CONTEXT_EDITOR); OS::get_singleton()->set_context(OS::CONTEXT_EDITOR);
//editor_node->set_edited_scene(game); //editor_node->set_edited_scene(game);
} else { }
#endif #endif
}
{ if (!project_manager_request && !editor) {
if (game_path!="" || script!="") {
//autoload //autoload
List<PropertyInfo> props; List<PropertyInfo> props;
Globals::get_singleton()->get_property_list(&props); Globals::get_singleton()->get_property_list(&props);
@ -1450,11 +1453,10 @@ bool Main::start() {
sml->get_root()->add_child(E->get()); sml->get_root()->add_child(E->get());
} }
//singletons
} }
if (game_path!="") {
Node *scene=NULL; Node *scene=NULL;
Ref<PackedScene> scenedata = ResourceLoader::load(local_game_path); Ref<PackedScene> scenedata = ResourceLoader::load(local_game_path);
if (scenedata.is_valid()) if (scenedata.is_valid())
@ -1471,12 +1473,7 @@ bool Main::start() {
if (icon.load(iconpath)==OK) if (icon.load(iconpath)==OK)
OS::get_singleton()->set_icon(icon); OS::get_singleton()->set_icon(icon);
} }
//singletons
#ifdef TOOLS_ENABLED
} }
#endif
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED