Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boot splash minimum display time setting #41833

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
16 changes: 16 additions & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

dalexeev marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

Expand Down