mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2355 from acemod/settingInitDelayFunctions
Setting init delay functions
This commit is contained in:
@ -150,6 +150,15 @@ call FUNC(checkFiles);
|
|||||||
//Event that settings are safe to use:
|
//Event that settings are safe to use:
|
||||||
["SettingsInitialized", []] call FUNC(localEvent);
|
["SettingsInitialized", []] call FUNC(localEvent);
|
||||||
|
|
||||||
|
//Set init finished and run all delayed functions:
|
||||||
|
GVAR(settingsInitFinished) = true;
|
||||||
|
diag_log text format ["[ACE] %1 delayed functions running", (count GVAR(runAtSettingsInitialized))];
|
||||||
|
{
|
||||||
|
_x params ["_func", "_params"];
|
||||||
|
_params call _func;
|
||||||
|
} forEach GVAR(runAtSettingsInitialized);
|
||||||
|
GVAR(runAtSettingsInitialized) = nil; //cleanup
|
||||||
|
|
||||||
}, 0, [false]] call CBA_fnc_addPerFrameHandler;
|
}, 0, [false]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
|
||||||
@ -326,7 +335,7 @@ GVAR(OldIsCamera) = false;
|
|||||||
if (didJip) then {
|
if (didJip) then {
|
||||||
// We are jipping! Get ready and wait, and throw the event
|
// We are jipping! Get ready and wait, and throw the event
|
||||||
[{
|
[{
|
||||||
if(!(isNull player)) then {
|
if((!(isNull player)) && GVAR(settingsInitFinished)) then {
|
||||||
["PlayerJip", [player] ] call FUNC(localEvent);
|
["PlayerJip", [player] ] call FUNC(localEvent);
|
||||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
@ -157,6 +157,7 @@ PREP(requestCallback);
|
|||||||
PREP(resetAllDefaults);
|
PREP(resetAllDefaults);
|
||||||
PREP(restoreVariablesJIP);
|
PREP(restoreVariablesJIP);
|
||||||
PREP(revertKeyCodeLocalized);
|
PREP(revertKeyCodeLocalized);
|
||||||
|
PREP(runAfterSettingsInit);
|
||||||
PREP(sanitizeString);
|
PREP(sanitizeString);
|
||||||
PREP(sendRequest);
|
PREP(sendRequest);
|
||||||
PREP(serverLog);
|
PREP(serverLog);
|
||||||
@ -303,6 +304,9 @@ GVAR(nextFrameNo) = diag_frameno;
|
|||||||
GVAR(nextFrameBufferA) = [];
|
GVAR(nextFrameBufferA) = [];
|
||||||
GVAR(nextFrameBufferB) = [];
|
GVAR(nextFrameBufferB) = [];
|
||||||
|
|
||||||
|
GVAR(settingsInitFinished) = false;
|
||||||
|
GVAR(runAtSettingsInitialized) = [];
|
||||||
|
|
||||||
// @TODO: Generic local-managed global-synced objects (createVehicleLocal)
|
// @TODO: Generic local-managed global-synced objects (createVehicleLocal)
|
||||||
|
|
||||||
//Debug
|
//Debug
|
||||||
|
27
addons/common/functions/fnc_runAfterSettingsInit.sqf
Normal file
27
addons/common/functions/fnc_runAfterSettingsInit.sqf
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Author: PabstMirror
|
||||||
|
* Executes code after setting are initilized.
|
||||||
|
*
|
||||||
|
* Argument:
|
||||||
|
* 0: Code to execute <CODE>
|
||||||
|
* 1: Parameters to run the code with <ANY>
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [{if (GVAR(setting) then {x} else {y};}, []] call ace_common_fnc_runAfterSettingsInit
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_func", "_params"];
|
||||||
|
|
||||||
|
if (GVAR(settingsInitFinished)) then {
|
||||||
|
//Setting Already Finished, Direct Run the code
|
||||||
|
_params call _func;
|
||||||
|
} else {
|
||||||
|
//Waiting on settings, throw it on the delayed run array
|
||||||
|
GVAR(runAtSettingsInitialized) pushBack [_func, _params];
|
||||||
|
};
|
Reference in New Issue
Block a user