From a7bf643a7b08cd5f2e59a6834ff37e9af757adf9 Mon Sep 17 00:00:00 2001 From: Emmanuel Barroga Date: Tue, 13 Aug 2019 23:24:27 -0700 Subject: [PATCH] Add Min/Max Window Size Setting Add project settings to easily set the minimum and maximum window size. --- main/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main/main.cpp b/main/main.cpp index 027273c4f4a..8e279f2f926 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -902,6 +902,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/width", PropertyInfo(Variant::INT, "display/window/size/width", PROPERTY_HINT_RANGE, "0,7680,or_greater")); // 8K resolution GLOBAL_DEF("display/window/size/height", 600); ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/height", PropertyInfo(Variant::INT, "display/window/size/height", PROPERTY_HINT_RANGE, "0,4320,or_greater")); // 8K resolution + GLOBAL_DEF("display/window/size/min_width", 0); + ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/min_width", PropertyInfo(Variant::INT, "display/window/size/min_width", PROPERTY_HINT_RANGE, "0,7680,or_greater")); // 8K resolution + GLOBAL_DEF("display/window/size/min_height", 0); + ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/min_height", PropertyInfo(Variant::INT, "display/window/size/min_height", PROPERTY_HINT_RANGE, "0,4320,or_greater")); // 8K resolution + GLOBAL_DEF("display/window/size/max_width", 0); + ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/max_width", PropertyInfo(Variant::INT, "display/window/size/max_width", PROPERTY_HINT_RANGE, "0,7680,or_greater")); // 8K resolution + GLOBAL_DEF("display/window/size/max_height", 0); + ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/max_height", PropertyInfo(Variant::INT, "display/window/size/max_height", PROPERTY_HINT_RANGE, "0,4320,or_greater")); // 8K resolution GLOBAL_DEF("display/window/size/resizable", true); GLOBAL_DEF("display/window/size/borderless", false); GLOBAL_DEF("display/window/size/fullscreen", false); @@ -927,6 +935,18 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } } + int mw = GLOBAL_GET("display/window/size/min_width"); + int mh = GLOBAL_GET("display/window/size/min_height"); + OS::get_singleton()->set_min_window_size(Size2(mw, mh)); + + mw = GLOBAL_GET("display/window/size/max_width"); + if (mw <= 0) + mw = 7680; + mh = GLOBAL_GET("display/window/size/max_height"); + if (mh <= 0) + mh = 4320; + OS::get_singleton()->set_max_window_size(Size2(mw, mh)); + video_mode.resizable = GLOBAL_GET("display/window/size/resizable"); video_mode.borderless_window = GLOBAL_GET("display/window/size/borderless"); video_mode.fullscreen = GLOBAL_GET("display/window/size/fullscreen");