diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-07-12 08:50:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-12 08:50:19 +0200 |
commit | b27683111b95495daf2cf2a39de3ef56fd57bf20 (patch) | |
tree | 3adf290f437030e2c6e107fb33f07d060e85ad8c | |
parent | 514c8d586a21e2703deff17f7fcdf821809dc78d (diff) | |
parent | 74ab336fe349fc1a82785bcbfc22ad8c82c0e931 (diff) |
Merge pull request #50385 from Geometror/vsyncmode-int-enum
Change VSync mode project setting enum type from string to integer
-rw-r--r-- | core/config/project_settings.cpp | 3 | ||||
-rw-r--r-- | doc/classes/ProjectSettings.xml | 2 | ||||
-rw-r--r-- | main/main.cpp | 15 | ||||
-rw-r--r-- | 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 @@ <member name="display/window/size/width" type="int" setter="" getter="" default="1024"> 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. </member> - <member name="display/window/vsync/vsync_mode" type="String" setter="" getter="" default=""Enabled""> + <member name="display/window/vsync/vsync_mode" type="int" setter="" getter="" default="1"> 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, |