Splash image support and new progress bar for HTML5 Web Export #91128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Intro
With the increasing popularity of the Godot engine, more and more users are reaching for it, often trying their hand at creating small games during organized compo/jams. Due to the nature of such events, the preferred export type for their production is HTML5.
So far, it's the only export that hasn't supported the ability to display a splash image when the game loads, despite the fact that the image is included in the saved project. The user has the option to create a custom HTML template, but for small games basically no one does this, relying on the engine's default settings.
That being said, I would like to propose an upgrade to the default HTML Shell used by Export to Web.
Goals
Display splash image (Godot or user-selected) when loading game files in the browser. This required exposing a new constant $GODOT_SPLASH from /platform/web/export/export_plugin.cpp.
Minor HTML, CSS and JS optimization to better handle the game loading status overlay.
Unify the progress bar by using a <progress> element that supports both percentage progress and indeterminate mode display. Browser support
Demo
Loading example game:
Loading in landscape mode:
Loading in portrait mode:
Error dialog:
Changes in HTML
A warning has been added when JavaScript in the browser is disabled.
The “status” div has been greatly simplified.
An <img> tag has been added to display the splash image.
HTML5 <progress> tag has been added in place of the custom created progress bar and spinning wheel.
Changes in CSS
Common settings for elements are set together.
The #status overlay is made invisible at first by visibility: hidden, so it doesn't obscure a possible error message about Javascript not being supported.
Splash image is centered on viewport and responsive up to 100% horizontally and vertically.
The progress bar displays over the splash image at 10% of the viepower height from the bottom.
The background color of the error message has been changed to a more reddish.
Javascript
Added reference to #status and removed references to #statusProgressInner and #statusIndeterminate
Changed startup statusMode in case onProgress is never called before setStatusMode('hidden')
Removed manual animation of the spinning wheel.
Simplified setStatusMode removes the #status block completely when the status is changed to 'hidden' after loading the game.
Simplified onProgress using the capabilities of the HTML5 <progress> element (when value and max are removed, the browser automatically displays a bounce animation).
export_plugin.cpp