From c7f001ccf5dc2efc8a533c26e284dc2d69932ad9 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Tue, 28 Jun 2022 18:13:00 +0300 Subject: [PATCH] Add boot splash display time setting Implements #8867. (cherry picked from commit dad9683d11ca174cf50d0039fb0f05fb7439984f) --- doc/classes/ProjectSettings.xml | 3 +++ main/main.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 5a518b456..58a495306 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -186,6 +186,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]. + + Minimum boot splash display time (in milliseconds). It is not recommended to set too high values for this setting. + 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]. diff --git a/main/main.cpp b/main/main.cpp index e244e289f..260ebbe4e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1647,6 +1647,13 @@ bool Main::start() { } } + 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")); // No negative numbers. + #ifdef TOOLS_ENABLED if (doc_tool_path != "") { Engine::get_singleton()->set_editor_hint(true); // Needed to instance editor-only classes for their default values @@ -2117,6 +2124,14 @@ bool Main::start() { OS::get_singleton()->set_main_loop(main_loop); + 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; }