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 CBA_loadingScreenDone event #806

Merged
merged 5 commits into from
Dec 9, 2017
Merged

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Nov 23, 2017

Documentation:

https://github.com/CBATeam/CBA_A3/wiki/Loading-Screen-Event-Handler

When merged this pull request will:

  • title

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 and bis_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.

@commy2 commy2 added the WIP label Nov 23, 2017
@Cuel
Copy link
Contributor

Cuel commented Nov 23, 2017

This is very useful.

@commy2
Copy link
Contributor Author

commy2 commented Nov 23, 2017

Updated OP with my findings.

@Cyruz143
Copy link

Cyruz143 commented Dec 4, 2017

I'd make use of this @commy2, good for doing text overlays at the start of the mission etc. Sometimes they'll fire before the client can actually see them!

@commy2
Copy link
Contributor Author

commy2 commented Dec 7, 2017

Usage:

// init.sqf
["CBA_loadingScreenDone", {
    // blah
}] call CBA_fnc_addEventHandler;

@commy2 commy2 added Feature and removed WIP labels Dec 7, 2017
@commy2 commy2 added this to the 3.5.1 milestone Dec 7, 2017
@Killswitch00 Killswitch00 merged commit 3905337 into master Dec 9, 2017
@commy2 commy2 deleted the loadingscreen-events branch December 9, 2017 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants