diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index e4cc0f9c03b..1b97335f01c 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1497,9 +1497,10 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/mode", PROPERTY_HINT_ENUM, "Windowed,Minimized,Maximized,Fullscreen,Exclusive Fullscreen"), 0); - // Keep the enum values in sync with the `DisplayServer::SCREEN_` enum. - GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/initial_position_type", PROPERTY_HINT_ENUM, "Absolute,Center of Primary Screen,Center of Other Screen,Center of Screen With Mouse Pointer,Center of Screen With Keyboard Focus"), 1); + // Keep the enum values in sync with the `Window::WINDOW_INITIAL_POSITION_` enum. + GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/initial_position_type", PROPERTY_HINT_ENUM, "Absolute:0,Center of Primary Screen:1,Center of Other Screen:3,Center of Screen With Mouse Pointer:4,Center of Screen With Keyboard Focus:5"), 1); GLOBAL_DEF_BASIC(PropertyInfo(Variant::VECTOR2I, "display/window/size/initial_position"), Vector2i()); + // Keep the enum values in sync with the `DisplayServer::SCREEN_` enum. GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/initial_screen", PROPERTY_HINT_RANGE, "0,64,1,or_greater"), 0); GLOBAL_DEF_BASIC("display/window/size/resizable", true); diff --git a/main/main.cpp b/main/main.cpp index 12709491e42..c4a6f19e0a8 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2479,27 +2479,27 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } window_mode = (DisplayServer::WindowMode)(GLOBAL_GET("display/window/size/mode").operator int()); int initial_position_type = GLOBAL_GET("display/window/size/initial_position_type").operator int(); - if (initial_position_type == 0) { // Absolute. + if (initial_position_type == Window::WINDOW_INITIAL_POSITION_ABSOLUTE) { // Absolute. if (!init_use_custom_pos) { init_custom_pos = GLOBAL_GET("display/window/size/initial_position").operator Vector2i(); init_use_custom_pos = true; } - } else if (initial_position_type == 1) { // Center of Primary Screen. + } else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN || initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN) { // Center of Primary Screen. if (!init_use_custom_screen) { init_screen = DisplayServer::SCREEN_PRIMARY; init_use_custom_screen = true; } - } else if (initial_position_type == 2) { // Center of Other Screen. + } else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN) { // Center of Other Screen. if (!init_use_custom_screen) { init_screen = GLOBAL_GET("display/window/size/initial_screen").operator int(); init_use_custom_screen = true; } - } else if (initial_position_type == 3) { // Center of Screen With Mouse Pointer. + } else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_MOUSE_FOCUS) { // Center of Screen With Mouse Pointer. if (!init_use_custom_screen) { init_screen = DisplayServer::SCREEN_WITH_MOUSE_FOCUS; init_use_custom_screen = true; } - } else if (initial_position_type == 4) { // Center of Screen With Keyboard Focus. + } else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_KEYBOARD_FOCUS) { // Center of Screen With Keyboard Focus. if (!init_use_custom_screen) { init_screen = DisplayServer::SCREEN_WITH_KEYBOARD_FOCUS; init_use_custom_screen = true; diff --git a/scene/main/window.h b/scene/main/window.h index 285fd95db10..e664e4e2c73 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -103,7 +103,7 @@ public: DEFAULT_WINDOW_SIZE = 100, }; - // Keep synced with enum hint for `initial_position` property. + // Keep synced with enum hint for `initial_position` property and `display/window/size/initial_position_type` project setting. enum WindowInitialPosition { WINDOW_INITIAL_POSITION_ABSOLUTE, WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN,