summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanil Alexeev <danil@alexeev.xyz>2022-06-28 18:13:00 +0300
committerDanil Alexeev <danil@alexeev.xyz>2022-06-28 18:54:51 +0300
commitdad9683d11ca174cf50d0039fb0f05fb7439984f (patch)
tree1f2a444e9f4dda6e3c7f2d926ae88c45321243ca
parent2ea7765f7678cb187f15cf4bf585a2f5536f94c3 (diff)
Add boot splash display time setting
Implements #8867.
-rw-r--r--doc/classes/ProjectSettings.xml3
-rw-r--r--main/main.cpp16
2 files changed, 19 insertions, 0 deletions
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 2391cb892c..74cf178261 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -203,6 +203,9 @@
Path to an image used as the boot splash. If left empty, the default Godot Engine splash will be displayed instead.
[b]Note:[/b] Only effective if [member application/boot_splash/show_image] is [code]true[/code].
</member>
+ <member name="application/boot_splash/minimum_display_time" type="int" setter="" getter="" default="0">
+ Minimum boot splash display time (in milliseconds). It is not recommended to set too high values for this setting.
+ </member>
<member name="application/boot_splash/show_image" type="bool" setter="" getter="" default="true">
If [code]true[/code], displays the image specified in [member application/boot_splash/image] when the engine starts. If [code]false[/code], only displays the plain color specified in [member application/boot_splash/bg_color].
</member>
diff --git a/main/main.cpp b/main/main.cpp
index bfb0eacdfc..6ce16e03e9 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2175,6 +2175,13 @@ bool Main::start() {
#endif
}
+ uint64_t minimum_time_msec = GLOBAL_DEF("application/boot_splash/minimum_display_time", 0);
+ ProjectSettings::get_singleton()->set_custom_property_info("application/boot_splash/minimum_display_time",
+ PropertyInfo(Variant::INT,
+ "application/boot_splash/minimum_display_time",
+ PROPERTY_HINT_RANGE,
+ "0,100,1,or_greater,suffix:ms")); // No negative numbers.
+
#ifdef TOOLS_ENABLED
if (!doc_tool_path.is_empty()) {
// Needed to instance editor-only classes for their default values
@@ -2692,6 +2699,15 @@ bool Main::start() {
if (movie_writer) {
movie_writer->begin(DisplayServer::get_singleton()->window_get_size(), fixed_fps, write_movie_path);
}
+
+ if (minimum_time_msec) {
+ uint64_t minimum_time = 1000 * minimum_time_msec;
+ uint64_t elapsed_time = OS::get_singleton()->get_ticks_usec();
+ if (elapsed_time < minimum_time) {
+ OS::get_singleton()->delay_usec(minimum_time - elapsed_time);
+ }
+ }
+
return true;
}