You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Merge pull request #102017 from KoBeWi/this_one_line_will_save_so_many_scenes
Ask before restarting project from settings
This commit is contained in:
@@ -2057,45 +2057,7 @@ void EditorNode::try_autosave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::restart_editor(bool p_goto_project_manager) {
|
void EditorNode::restart_editor(bool p_goto_project_manager) {
|
||||||
exiting = true;
|
_menu_option_confirm(p_goto_project_manager ? PROJECT_QUIT_TO_PROJECT_MANAGER : PROJECT_RELOAD_CURRENT_PROJECT, false);
|
||||||
|
|
||||||
if (project_run_bar->is_playing()) {
|
|
||||||
project_run_bar->stop_playing();
|
|
||||||
}
|
|
||||||
|
|
||||||
String to_reopen;
|
|
||||||
if (!p_goto_project_manager && get_tree()->get_edited_scene_root()) {
|
|
||||||
to_reopen = get_tree()->get_edited_scene_root()->get_scene_file_path();
|
|
||||||
}
|
|
||||||
|
|
||||||
_exit_editor(EXIT_SUCCESS);
|
|
||||||
|
|
||||||
List<String> args;
|
|
||||||
for (const String &a : Main::get_forwardable_cli_arguments(Main::CLI_SCOPE_TOOL)) {
|
|
||||||
args.push_back(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_goto_project_manager) {
|
|
||||||
args.push_back("--project-manager");
|
|
||||||
|
|
||||||
// Setup working directory.
|
|
||||||
const String exec_dir = OS::get_singleton()->get_executable_path().get_base_dir();
|
|
||||||
if (!exec_dir.is_empty()) {
|
|
||||||
args.push_back("--path");
|
|
||||||
args.push_back(exec_dir);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
args.push_back("--path");
|
|
||||||
args.push_back(ProjectSettings::get_singleton()->get_resource_path());
|
|
||||||
|
|
||||||
args.push_back("-e");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!to_reopen.is_empty()) {
|
|
||||||
args.push_back(to_reopen);
|
|
||||||
}
|
|
||||||
|
|
||||||
OS::get_singleton()->set_restart_on_exit(true, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_save_all_scenes() {
|
void EditorNode::_save_all_scenes() {
|
||||||
@@ -3480,10 +3442,10 @@ void EditorNode::_discard_changes(const String &p_str) {
|
|||||||
|
|
||||||
} break;
|
} break;
|
||||||
case PROJECT_QUIT_TO_PROJECT_MANAGER: {
|
case PROJECT_QUIT_TO_PROJECT_MANAGER: {
|
||||||
restart_editor(true);
|
_restart_editor(true);
|
||||||
} break;
|
} break;
|
||||||
case PROJECT_RELOAD_CURRENT_PROJECT: {
|
case PROJECT_RELOAD_CURRENT_PROJECT: {
|
||||||
restart_editor();
|
_restart_editor();
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5508,11 +5470,11 @@ bool EditorNode::has_scenes_in_session() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::undo() {
|
void EditorNode::undo() {
|
||||||
trigger_menu_option(FILE_UNDO, true);
|
_menu_option_confirm(FILE_UNDO, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::redo() {
|
void EditorNode::redo() {
|
||||||
trigger_menu_option(FILE_REDO, true);
|
_menu_option_confirm(FILE_REDO, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorNode::ensure_main_scene(bool p_from_native) {
|
bool EditorNode::ensure_main_scene(bool p_from_native) {
|
||||||
@@ -5680,6 +5642,48 @@ bool EditorNode::_is_closing_editor() const {
|
|||||||
return tab_closing_menu_option == FILE_QUIT || tab_closing_menu_option == PROJECT_QUIT_TO_PROJECT_MANAGER || tab_closing_menu_option == PROJECT_RELOAD_CURRENT_PROJECT;
|
return tab_closing_menu_option == FILE_QUIT || tab_closing_menu_option == PROJECT_QUIT_TO_PROJECT_MANAGER || tab_closing_menu_option == PROJECT_RELOAD_CURRENT_PROJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorNode::_restart_editor(bool p_goto_project_manager) {
|
||||||
|
exiting = true;
|
||||||
|
|
||||||
|
if (project_run_bar->is_playing()) {
|
||||||
|
project_run_bar->stop_playing();
|
||||||
|
}
|
||||||
|
|
||||||
|
String to_reopen;
|
||||||
|
if (!p_goto_project_manager && get_tree()->get_edited_scene_root()) {
|
||||||
|
to_reopen = get_tree()->get_edited_scene_root()->get_scene_file_path();
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit_editor(EXIT_SUCCESS);
|
||||||
|
|
||||||
|
List<String> args;
|
||||||
|
for (const String &a : Main::get_forwardable_cli_arguments(Main::CLI_SCOPE_TOOL)) {
|
||||||
|
args.push_back(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_goto_project_manager) {
|
||||||
|
args.push_back("--project-manager");
|
||||||
|
|
||||||
|
// Setup working directory.
|
||||||
|
const String exec_dir = OS::get_singleton()->get_executable_path().get_base_dir();
|
||||||
|
if (!exec_dir.is_empty()) {
|
||||||
|
args.push_back("--path");
|
||||||
|
args.push_back(exec_dir);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
args.push_back("--path");
|
||||||
|
args.push_back(ProjectSettings::get_singleton()->get_resource_path());
|
||||||
|
|
||||||
|
args.push_back("-e");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!to_reopen.is_empty()) {
|
||||||
|
args.push_back(to_reopen);
|
||||||
|
}
|
||||||
|
|
||||||
|
OS::get_singleton()->set_restart_on_exit(true, args);
|
||||||
|
}
|
||||||
|
|
||||||
void EditorNode::_scene_tab_closed(int p_tab) {
|
void EditorNode::_scene_tab_closed(int p_tab) {
|
||||||
current_menu_option = SCENE_TAB_CLOSE;
|
current_menu_option = SCENE_TAB_CLOSE;
|
||||||
tab_closing_idx = p_tab;
|
tab_closing_idx = p_tab;
|
||||||
|
|||||||
@@ -624,6 +624,7 @@ private:
|
|||||||
|
|
||||||
void _proceed_closing_scene_tabs();
|
void _proceed_closing_scene_tabs();
|
||||||
bool _is_closing_editor() const;
|
bool _is_closing_editor() const;
|
||||||
|
void _restart_editor(bool p_goto_project_manager = false);
|
||||||
|
|
||||||
Dictionary _get_main_scene_state();
|
Dictionary _get_main_scene_state();
|
||||||
void _set_main_scene_state(Dictionary p_state, Node *p_for_scene);
|
void _set_main_scene_state(Dictionary p_state, Node *p_for_scene);
|
||||||
|
|||||||
Reference in New Issue
Block a user