Merge pull request #1214 from acemod/reliableSettings

Reliable settings framework
This commit is contained in:
Nicolás Badano 2015-05-27 12:10:08 -03:00
commit d3a50bce53
4 changed files with 37 additions and 10 deletions

View File

@ -139,4 +139,4 @@
<Polish>Moduł ten pozwala aktywować zaawansowaną balistykę biorącą przy obliczeniach trajektorii lotu pocisku pod uwagę takie rzeczy jak temperatura powietrza, ciśnienie atmosferyczne, wilgotność powietrza, siły Coriolisa i Eotvosa, grawitację a także broń z jakiej wykonywany jest strzał oraz rodzaj amunicji. Wszystko to sprowadza się na bardzo dokładne odwzorowanie balistyki.</Polish>
</Key>
</Package>
</Project>
</Project>

View File

@ -3,12 +3,6 @@
//IGNORE_PRIVATE_WARNING("_handleNetEvent", "_handleRequestAllSyncedEvents", "_handleRequestSyncedEvent", "_handleSyncedEvent");
// 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", {
PARAMS_2(_name,_value);
@ -253,3 +247,19 @@ if(isMultiplayer && { ACE_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 {};
[(_this select 1)] call cba_fnc_removePerFrameHandler;
diag_log text format["[ACE] Settings initialized"];
["SettingsInitialized", []] call FUNC(localEvent);
}, 0, []] call cba_fnc_addPerFrameHandler;

View File

@ -293,9 +293,23 @@ GVAR(waitAndExecArray) = [];
//Debug
ACE_COUNTERS = [];
// Load settings
// Wait for server settings to arrive
GVAR(SettingsInitialized) = false;
["ServerSettingsReceived", {
diag_log text format["[ACE] Settings received from server"];
// 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
["ServerSettingsReceived", []] call FUNC(localEvent);
};
ACE_player = player;

View File

@ -58,5 +58,8 @@ GVAR(ShowNamesTime) = -10;
};
}, 5, []] call CBA_fnc_addPerFrameHandler;
// Draw handle
addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
// Wait until the colors are defined before starting to draw the nametags
["SettingsInitialized", {
// Draw handle
addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
}] call EFUNC(common,addEventHandler);