From e0957c2fa3d3c796fd738ae3d06ff410e763e30d Mon Sep 17 00:00:00 2001 From: Brandon Chang Date: Sun, 22 Sep 2024 13:36:41 -0400 Subject: [PATCH] Consolidate remembering window settings into single config --- doc/classes/EditorSettings.xml | 5 +---- editor/editor_settings.cpp | 12 ++++++++---- editor/editor_settings.h | 7 +++++++ main/main.cpp | 15 ++++++--------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 5eb8ac61990..748a6211144 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -772,7 +772,7 @@ Translations are provided by the community. If you spot a mistake, [url=$DOCS_URL/contributing/documentation/editor_and_docs_localization.html]contribute to editor translations on Weblate![/url] - The preferred monitor to display the editor. + The preferred monitor to display the editor. If [b]Auto[/b], the editor will remember the last screen it was displayed on across restarts. Expanding main editor window content to the title, if supported by [DisplayServer]. See [constant DisplayServer.WINDOW_FLAG_EXTEND_TO_TITLE]. @@ -826,9 +826,6 @@ The preferred monitor to display the project manager. - - If [code]true[/code], the editor window will remember its size, position, and which screen it was displayed on across restarts. - If [code]false[/code], the editor will save all scenes when confirming the [b]Save[/b] action when quitting the editor or quitting to the project list. If [code]true[/code], the editor will ask to save each scene individually. diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index c972a6ab27c..6e8312e8c55 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -426,12 +426,17 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/display_scale", 0, display_scale_hint_string, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING) EDITOR_SETTING_USAGE(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/editor/custom_display_scale", 1.0, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING) - String ed_screen_hints = "Screen With Mouse Pointer:-4,Screen With Keyboard Focus:-3,Primary Screen:-2"; // Note: Main Window Screen:-1 is not used for the main window. + String ed_screen_hints = "Auto (Remembers last position):-5,Screen With Mouse Pointer:-4,Screen With Keyboard Focus:-3,Primary Screen:-2"; for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) { ed_screen_hints += ",Screen " + itos(i + 1) + ":" + itos(i); } - EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/editor_screen", -2, ed_screen_hints) - EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/project_manager_screen", -2, ed_screen_hints) + EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/editor_screen", EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO, ed_screen_hints) + + String project_manager_screen_hints = "Screen With Mouse Pointer:-4,Screen With Keyboard Focus:-3,Primary Screen:-2"; + for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) { + project_manager_screen_hints += ",Screen " + itos(i + 1) + ":" + itos(i); + } + EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/project_manager_screen", EditorSettings::InitialScreen::INITIAL_SCREEN_PRIMARY, project_manager_screen_hints) { EngineUpdateLabel::UpdateMode default_update_mode = EngineUpdateLabel::UpdateMode::NEWEST_UNSTABLE; @@ -466,7 +471,6 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { _initial_set("interface/editor/separate_distraction_mode", false, true); _initial_set("interface/editor/automatically_open_screenshots", true, true); EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/single_window_mode", false, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING) - _initial_set("interface/editor/remember_window_size_and_position", true, true); _initial_set("interface/editor/mouse_extra_buttons_navigate_history", true); _initial_set("interface/editor/save_each_scene_on_quit", true, true); // Regression EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/save_on_focus_loss", false, "") diff --git a/editor/editor_settings.h b/editor/editor_settings.h index e850406839d..d1ccedfe6c8 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -62,6 +62,13 @@ public: NETWORK_ONLINE, }; + enum InitialScreen { + INITIAL_SCREEN_AUTO = -5, // Remembers last screen position. + INITIAL_SCREEN_WITH_MOUSE_FOCUS = -4, + INITIAL_SCREEN_WITH_KEYBOARD_FOCUS = -3, + INITIAL_SCREEN_PRIMARY = -2, + }; + private: struct VariantContainer { int order = 0; diff --git a/main/main.cpp b/main/main.cpp index 9014bfad294..36912c4fa39 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2755,7 +2755,6 @@ Error Main::setup2(bool p_show_boot_logo) { bool prefer_wayland_found = false; bool prefer_wayland = false; - bool remember_window_size_and_position_found = false; if (editor) { screen_property = "interface/editor/editor_screen"; @@ -2771,7 +2770,7 @@ Error Main::setup2(bool p_show_boot_logo) { prefer_wayland_found = true; } - while (!screen_found || !prefer_wayland_found || !remember_window_size_and_position_found) { + while (!screen_found || !prefer_wayland_found) { assign = Variant(); next_tag.fields.clear(); next_tag.name = String(); @@ -2785,17 +2784,16 @@ Error Main::setup2(bool p_show_boot_logo) { if (!screen_found && assign == screen_property) { init_screen = value; screen_found = true; + + if (editor) { + restore_editor_window_layout = value.operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO; + } } if (!prefer_wayland_found && assign == "run/platforms/linuxbsd/prefer_wayland") { prefer_wayland = value; prefer_wayland_found = true; } - - if (!remember_window_size_and_position_found && assign == "interface/editor/remember_window_size_and_position") { - restore_editor_window_layout = value; - remember_window_size_and_position_found = true; - } } } @@ -4095,8 +4093,7 @@ int Main::start() { if (editor_embed_subwindows) { sml->get_root()->set_embedding_subwindows(true); } - restore_editor_window_layout = EditorSettings::get_singleton()->get_setting( - "interface/editor/remember_window_size_and_position"); + restore_editor_window_layout = EditorSettings::get_singleton()->get_setting("interface/editor/editor_screen").operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO; } #endif