You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Merge pull request #27309 from KoBeWi/main_scene_on_android
Ensure main scene is set when running on device
This commit is contained in:
@@ -1296,7 +1296,12 @@ void EditorNode::_dialog_action(String p_file) {
|
||||
ProjectSettings::get_singleton()->set("application/run/main_scene", p_file);
|
||||
ProjectSettings::get_singleton()->save();
|
||||
//would be nice to show the project manager opened with the highlighted field..
|
||||
_run(false, ""); // automatically run the project
|
||||
|
||||
if (pick_main_scene->has_meta("from_native") && (bool)pick_main_scene->get_meta("from_native")) {
|
||||
run_native->resume_run_native();
|
||||
} else {
|
||||
_run(false, ""); // automatically run the project
|
||||
}
|
||||
} break;
|
||||
case FILE_CLOSE:
|
||||
case FILE_CLOSE_ALL_AND_QUIT:
|
||||
@@ -1809,28 +1814,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
|
||||
if (run_filename == "") {
|
||||
|
||||
//evidently, run the scene
|
||||
main_scene = GLOBAL_DEF("application/run/main_scene", "");
|
||||
if (main_scene == "") {
|
||||
|
||||
current_option = -1;
|
||||
pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
|
||||
pick_main_scene->popup_centered_minsize();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FileAccess::exists(main_scene)) {
|
||||
|
||||
current_option = -1;
|
||||
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
|
||||
pick_main_scene->popup_centered_minsize();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") {
|
||||
|
||||
current_option = -1;
|
||||
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
|
||||
pick_main_scene->popup_centered_minsize();
|
||||
if (!ensure_main_scene(false)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -4167,6 +4151,37 @@ bool EditorNode::has_scenes_in_session() {
|
||||
return !scenes.empty();
|
||||
}
|
||||
|
||||
bool EditorNode::ensure_main_scene(bool p_from_native) {
|
||||
pick_main_scene->set_meta("from_native", p_from_native); //whether from play button or native run
|
||||
String main_scene = GLOBAL_DEF("application/run/main_scene", "");
|
||||
|
||||
if (main_scene == "") {
|
||||
|
||||
current_option = -1;
|
||||
pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
|
||||
pick_main_scene->popup_centered_minsize();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FileAccess::exists(main_scene)) {
|
||||
|
||||
current_option = -1;
|
||||
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
|
||||
pick_main_scene->popup_centered_minsize();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") {
|
||||
|
||||
current_option = -1;
|
||||
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
|
||||
pick_main_scene->popup_centered_minsize();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EditorNode::_update_layouts_menu() {
|
||||
|
||||
editor_layouts->clear();
|
||||
|
||||
Reference in New Issue
Block a user