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.
Documentation:
https://github.com/CBATeam/CBA_A3/wiki/Loading-Screen-Event-Handler
When merged this pull request will:
Explanations:
I sometimes get asked if there is a way to execute code when Arma is done with the loading screen at the start of the mission. This PR adds a cba event for that by hooking into BI's internal framework for loading screens (
BIS_fnc_start/endLoadingScreen
).There are up to 3 loading screens that happen at the start of the mission.
bis_fnc_preload
,bis_fnc_initRespawn
andbis_fnc_initFunctions
, named after the scripts that initiates them.bis_fnc_preload
is started before even preInit runs and it essentially makes clients wait for the server to load the mission first. It waits for a dummy public global variable to be synched.bis_fnc_initRespawn
sets up some kind of respawn screen, which is done even in SP surprisingly, and is for some insane reason done in scheduled environment (hence the need for a loading screen I guess).bis_fnc_initFunctions
makes the client wait for all postInit functions to be finished. But it only appears on dedicated clients, which is a very strange choice, because it means that someone could make an eternal loop in postInit stalling all other postInit scripts forever in SP. But it also means that the mission still ends the loading screen in SP if a script error occured which is helpful for debugging in some way - no need to kill the game (reminder that postInit CfgFunctions is scheduled).There is no way to tell which of these finishes first, so we just wait for all 3.
During the mission there can be many more of course, but this event is only supposed to fire once. Perfect for mission intros etc.
I can't decide if the demand is there or if it would be bloat.
Note that the debug beep sound seems to happen right before the loading screen disappears. This is because the
endLoadingScreen
command BI uses makes it fade out slowly. The event is triggered when the loading screen starts fading.