Added SettingChanged EH and proper handling

This commit is contained in:
jonpas 2015-05-15 17:16:55 +02:00
parent a7cd36bc3e
commit 2edbacd15b
3 changed files with 20 additions and 4 deletions

View File

@ -23,7 +23,23 @@ GVAR(ShowNamesTime) = -10;
[29, [false, false, false]], false] call cba_fnc_addKeybind; //LeftControl Key
// Draw handle
// Draw handle on start if set
if (GVAR(showPlayerNames) > 0) then {
addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
GVAR(drawHandler) = addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
};
// Set the EH which waits for a setting to be changed, so that the effect is shown immediately
if (!GVAR(showPlayerNamesForce)) then {
["SettingChanged", {
PARAMS_2(_name,_value)
if (_name == QGVAR(showPlayerNames)) then {
if ((GVAR(showPlayerNames) > 0) && (_value == 0)) then {
removeMissionEventHandler ["Draw3D", GVAR(drawHandler)];
GVAR(drawHandler) = nil;
};
if ((GVAR(showPlayerNames) == 0) && (_value > 0)) then {
GVAR(drawHandler) = addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
};
};
}] call ace_common_fnc_addEventHandler;
};

View File

@ -30,4 +30,4 @@ if (GVAR(showPlayerNamesForce)) then {
[_logic, QGVAR(showPlayerNames), "showPlayerNames" ] call EFUNC(common,readSettingFromModule);
};
diag_log text "[ACE]: NameTags Module Initialized.";
diag_log format ["[ACE]: NameTags Module Initialized. Forced Name Tags Setting: %1",GVAR(showPlayerNamesForce)];

View File

@ -26,7 +26,7 @@
<Russian>Показывать имена игроков (включить имена)</Russian>
</Key>
<Key ID="STR_ACE_NameTags_ShowPlayerNamesForce">
<English>Force show player names setting</English>
<English>Force names setting</English>
</Key>
<Key ID="STR_ACE_NameTags_ShowPlayerNamesForce_Desc">
<English>Force name tags option, or by default allows players to choose it on their own. Default: Do Not Force</English>