mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Reliable settings framework
This commit is contained in:
parent
032a2f3778
commit
5e3b6f389a
@ -1,12 +1,6 @@
|
||||
// ACE - Common
|
||||
#include "script_component.hpp"
|
||||
|
||||
// Load settings from profile
|
||||
if (hasInterface) then {
|
||||
call FUNC(loadSettingsFromProfile);
|
||||
call FUNC(loadSettingsLocalizedText);
|
||||
};
|
||||
|
||||
// Listens for global "SettingChanged" events, to update the force status locally
|
||||
["SettingChanged", {
|
||||
|
||||
@ -249,3 +243,17 @@ if(isMultiplayer && { time > 0 || isNull player } ) then {
|
||||
};
|
||||
}, 0, []] call cba_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
||||
GVAR(commonPostInited) = true;
|
||||
|
||||
// Create a pfh to wait until all postinits are ready and settings are initialized
|
||||
[{
|
||||
// If post inits are not ready then wait
|
||||
if !(SLX_XEH_MACHINE select 8) exitWith {};
|
||||
// If settings are not initialized then wait
|
||||
if !(GVAR(SettingsInitialized)) exitWith {};
|
||||
|
||||
diag_log text format["[ACE] Settings initialized"];
|
||||
["SettingsInitialized", []] call FUNC(localEvent);
|
||||
|
||||
}, 0, []] call cba_fnc_addPerFrameHandler;
|
||||
|
@ -291,9 +291,22 @@ GVAR(syncedEvents) = HASH_CREATE;
|
||||
//Debug
|
||||
ACE_COUNTERS = [];
|
||||
|
||||
// Load settings
|
||||
// Wait for server settings to arrive
|
||||
GVAR(SettingsInitialized) = false;
|
||||
["ServerSettingsReceived", {
|
||||
// Load user settings from profile
|
||||
if (hasInterface) then {
|
||||
call FUNC(loadSettingsFromProfile);
|
||||
call FUNC(loadSettingsLocalizedText);
|
||||
};
|
||||
GVAR(SettingsInitialized) = true;
|
||||
}] call FUNC(addEventhandler);
|
||||
|
||||
// Load settings on the server and broadcast them
|
||||
if (isServer) then {
|
||||
call FUNC(loadSettingsOnServer);
|
||||
// Raise a local event for other modules to listen too
|
||||
["SettingsInitialized", []] call FUNC(localEvent);
|
||||
};
|
||||
|
||||
ACE_player = player;
|
||||
|
Loading…
Reference in New Issue
Block a user