You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Merge pull request #76085 from spanzeri/better_remember_editor_window
Remember editor window mode, screen, size and position on restart
This commit is contained in:
@@ -702,6 +702,8 @@ void EditorNode::_notification(int p_what) {
|
||||
last_system_base_color = DisplayServer::get_singleton()->get_base_color();
|
||||
DisplayServer::get_singleton()->set_system_theme_change_callback(callable_mp(this, &EditorNode::_check_system_theme_changed));
|
||||
|
||||
get_viewport()->connect("size_changed", callable_mp(this, &EditorNode::_viewport_resized));
|
||||
|
||||
/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
|
||||
} break;
|
||||
|
||||
@@ -730,6 +732,7 @@ void EditorNode::_notification(int p_what) {
|
||||
FileAccess::set_file_close_fail_notify_callback(nullptr);
|
||||
log->deinit(); // Do not get messages anymore.
|
||||
editor_data.clear_edited_scenes();
|
||||
get_viewport()->disconnect("size_changed", callable_mp(this, &EditorNode::_viewport_resized));
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_READY: {
|
||||
@@ -1240,6 +1243,13 @@ void EditorNode::_reload_project_settings() {
|
||||
void EditorNode::_vp_resized() {
|
||||
}
|
||||
|
||||
void EditorNode::_viewport_resized() {
|
||||
Window *w = get_window();
|
||||
if (w) {
|
||||
was_window_windowed_last = w->get_mode() == Window::MODE_WINDOWED;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorNode::_titlebar_resized() {
|
||||
DisplayServer::get_singleton()->window_set_window_buttons_offset(Vector2i(title_bar->get_global_position().y + title_bar->get_size().y / 2, title_bar->get_global_position().y + title_bar->get_size().y / 2), DisplayServer::MAIN_WINDOW_ID);
|
||||
const Vector3i &margin = DisplayServer::get_singleton()->window_get_safe_title_margins(DisplayServer::MAIN_WINDOW_ID);
|
||||
@@ -5220,6 +5230,7 @@ void EditorNode::_save_editor_layout() {
|
||||
editor_dock_manager->save_docks_to_config(config, "docks");
|
||||
_save_open_scenes_to_config(config);
|
||||
_save_central_editor_layout_to_config(config);
|
||||
_save_window_settings_to_config(config, "EditorWindow");
|
||||
editor_data.get_plugin_window_layout(config);
|
||||
|
||||
config->save(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg"));
|
||||
@@ -5339,6 +5350,38 @@ void EditorNode::_load_central_editor_layout_from_config(Ref<ConfigFile> p_confi
|
||||
}
|
||||
}
|
||||
|
||||
void EditorNode::_save_window_settings_to_config(Ref<ConfigFile> p_layout, const String &p_section) {
|
||||
Window *w = get_window();
|
||||
if (w) {
|
||||
p_layout->set_value(p_section, "screen", w->get_current_screen());
|
||||
|
||||
Window::Mode mode = w->get_mode();
|
||||
switch (mode) {
|
||||
case Window::MODE_WINDOWED:
|
||||
p_layout->set_value(p_section, "mode", "windowed");
|
||||
p_layout->set_value(p_section, "size", w->get_size());
|
||||
break;
|
||||
case Window::MODE_FULLSCREEN:
|
||||
case Window::MODE_EXCLUSIVE_FULLSCREEN:
|
||||
p_layout->set_value(p_section, "mode", "fullscreen");
|
||||
break;
|
||||
case Window::MODE_MINIMIZED:
|
||||
if (was_window_windowed_last) {
|
||||
p_layout->set_value(p_section, "mode", "windowed");
|
||||
p_layout->set_value(p_section, "size", w->get_size());
|
||||
} else {
|
||||
p_layout->set_value(p_section, "mode", "maximized");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
p_layout->set_value(p_section, "mode", "maximized");
|
||||
break;
|
||||
}
|
||||
|
||||
p_layout->set_value(p_section, "position", w->get_position());
|
||||
}
|
||||
}
|
||||
|
||||
void EditorNode::_load_open_scenes_from_config(Ref<ConfigFile> p_layout) {
|
||||
if (!bool(EDITOR_GET("interface/scene_tabs/restore_scenes_on_load"))) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user