From 74ab336fe349fc1a82785bcbfc22ad8c82c0e931 Mon Sep 17 00:00:00 2001 From: Hendrik Brucker Date: Mon, 12 Jul 2021 03:35:51 +0200 Subject: Change VSync mode project setting enum type from string to integer --- core/config/project_settings.cpp | 3 ++- doc/classes/ProjectSettings.xml | 2 +- main/main.cpp | 15 +-------------- servers/display_server.h | 2 ++ 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 29f53482fa..ac4e0db5b7 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1114,7 +1114,8 @@ ProjectSettings::ProjectSettings() { // Keep the enum values in sync with the `DisplayServer::ScreenOrientation` enum. custom_prop_info["display/window/handheld/orientation"] = PropertyInfo(Variant::INT, "display/window/handheld/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait,Reverse Landscape,Reverse Portrait,Sensor Landscape,Sensor Portrait,Sensor"); - custom_prop_info["display/window/vsync/vsync_mode"] = PropertyInfo(Variant::STRING, "display/window/vsync/vsync_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Adaptive,Mailbox"); + // Keep the enum values in sync with the `DisplayServer::VSyncMode` enum. + custom_prop_info["display/window/vsync/vsync_mode"] = PropertyInfo(Variant::INT, "display/window/vsync/vsync_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Adaptive,Mailbox"); custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded"); GLOBAL_DEF("physics/2d/run_on_thread", false); GLOBAL_DEF("physics/3d/run_on_thread", false); diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 52bfd3b759..fbd257cdba 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -532,7 +532,7 @@ Sets the game's main viewport width. On desktop platforms, this is the default window size. Stretch mode settings also use this as a reference when enabled. - + Sets the VSync mode for the main game window. See [enum DisplayServer.VSyncMode] for possible values and how they affect the behavior of your application. Depending on the platform and used renderer, the engine will fall back to [code]Enabled[/code], if the desired mode is not supported. diff --git a/main/main.cpp b/main/main.cpp index 2b5f8d9315..1ab36701ff 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1335,20 +1335,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph window_orientation = DisplayServer::ScreenOrientation(int(GLOBAL_DEF_BASIC("display/window/handheld/orientation", DisplayServer::ScreenOrientation::SCREEN_LANDSCAPE))); } { - String vsync_mode = GLOBAL_DEF("display/window/vsync/vsync_mode", "Enabled"); - - if (vsync_mode == "Disabled") { - window_vsync_mode = DisplayServer::VSYNC_DISABLED; - } else if (vsync_mode == "Enabled") { - window_vsync_mode = DisplayServer::VSYNC_ENABLED; - } else if (vsync_mode == "Adaptive") { - window_vsync_mode = DisplayServer::VSYNC_ADAPTIVE; - } else if (vsync_mode == "Mailbox") { - window_vsync_mode = DisplayServer::VSYNC_MAILBOX; - } else { - WARN_PRINT("VSync mode unknown."); - window_vsync_mode = DisplayServer::VSYNC_ENABLED; - } + window_vsync_mode = DisplayServer::VSyncMode(int(GLOBAL_DEF("display/window/vsync/vsync_mode", DisplayServer::VSyncMode::VSYNC_ENABLED))); } Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF_BASIC("physics/common/physics_fps", 60)); ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_fps", diff --git a/servers/display_server.h b/servers/display_server.h index caffdc941d..8d289b10fd 100644 --- a/servers/display_server.h +++ b/servers/display_server.h @@ -56,6 +56,8 @@ public: WINDOW_MODE_FULLSCREEN }; + // Keep the VSyncMode enum values in sync with the `display/window/vsync/vsync_mode` + // project setting hint. enum VSyncMode { VSYNC_DISABLED, VSYNC_ENABLED, -- cgit v1.2.3