Made forced settings through module in original entry, Reworked Draw3D handling, Some strings cleanup

This commit is contained in:
jonpas 2015-05-16 00:07:38 +02:00
parent 02b9df1bc3
commit 7c96c12bd5
7 changed files with 74 additions and 63 deletions

View File

@ -11,13 +11,7 @@ class ACE_Settings {
isClientSettable = 1;
displayName = "$STR_ACE_NameTags_ShowPlayerNames";
description = "$STR_ACE_NameTags_ShowPlayerNames_Desc";
values[] = {"$STR_ACE_NameTags_Disabled", "$STR_ACE_NameTags_Enabled", "$STR_ACE_NameTags_OnlyCursor", "$STR_ACE_NameTags_OnlyOnKeypress", "$STR_ACE_NameTags_OnlyCursorAndKeypress"};
};
class GVAR(showPlayerNamesForce) {
value = 0;
typeName = "BOOL";
displayName = "$STR_ACE_NameTags_ShowPlayerNamesForce";
description = "$STR_ACE_NameTags_ShowPlayerNamesForce_Desc";
values[] = {"$STR_ACE_NameTags_Disabled", "$STR_ACE_NameTags_Enabled", "$STR_ACE_NameTags_OnlyCursor", "$STR_ACE_NameTags_OnlyKeypress", "$STR_ACE_NameTags_OnlyCursorAndKeypress"};
};
class GVAR(showPlayerRanks) {
value = 1;

View File

@ -17,35 +17,33 @@ class CfgVehicles {
description = "$STR_ACE_NameTags_ShowPlayerNames_Desc";
typeName = "NUMBER";
class values {
class Disabled {
name = "$STR_ACE_NameTags_Disabled";
class DoNotForce {
default = 1;
name = "$STR_ACE_NameTags_DoNotForce";
value = -1;
};
class ForceHide {
name = "$STR_ACE_NameTags_ForceHide";
value = 0;
};
class Enabled {
default = 1;
name = "$STR_ACE_NameTags_Enabled";
class ForceShow {
name = "$STR_ACE_NameTags_ForceShow";
value = 1;
};
class OnlyCursor {
name = "$STR_ACE_NameTags_OnlyCursor";
class ForceShowOnlyCursor {
name = "$STR_ACE_NameTags_ForceShowOnlyCursor";
value = 2;
};
class OnlyOnKeypress {
name = "$STR_ACE_NameTags_OnlyOnKeypress";
class ForceShowOnlyKeypress {
name = "$STR_ACE_NameTags_ForceShowOnlyKeypress";
value = 3;
};
class OnlyCursorAndKeypress {
name = "$STR_ACE_NameTags_OnlyCursorAndKeypress";
class ForceShowOnlyCursorAndKeypress {
name = "$STR_ACE_NameTags_ForceShowOnlyCursorAndKeypress";
value = 4;
};
};
};
class showPlayerNamesForce {
displayName = "$STR_ACE_NameTags_ShowPlayerNamesForce";
description = "$STR_ACE_NameTags_ShowPlayerNamesForce_Desc";
typeName = "BOOL";
defaultValue = 0;
};
class playerNamesViewDistance {
displayName = "$STR_ACE_NameTags_PlayerNamesViewDistance_DisplayName";
description = "$STR_ACE_NameTags_PlayerNamesViewDistance_Description";

View File

@ -5,7 +5,7 @@
if (!hasInterface) exitWith {};
GVAR(ShowNamesTime) = -10;
GVAR(showNamesTime) = -10;
// Add keybinds
["ACE3 Common", QGVAR(showNameTags), localize "STR_ACE_NameTags_ShowNames",
@ -14,7 +14,7 @@ GVAR(ShowNamesTime) = -10;
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Statement
GVAR(ShowNamesTime) = time;
GVAR(showNamesTime) = time;
if (call FUNC(canShow)) then{ call FUNC(doShow); };
// Return false so it doesn't block other actions
false
@ -23,24 +23,13 @@ GVAR(ShowNamesTime) = -10;
[29, [false, false, false]], false] call cba_fnc_addKeybind; //LeftControl Key
// Draw handle on start if set
if (GVAR(showPlayerNames) > 0) then {
GVAR(drawHandler) = addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
};
// Draw handle
call FUNC(updateSettings);
// 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 (isNil(QGVAR(drawHandler)) && {_value > 0}) then {
GVAR(drawHandler) = addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
} else {
if (_value == 0) then {
removeMissionEventHandler ["Draw3D", GVAR(drawHandler)];
GVAR(drawHandler) = nil;
};
};
};
}] call EFUNC(common,addEventHandler);
};
// Change settings accordingly when they are changed
["SettingChanged", {
PARAMS_1(_name);
if (_name == QGVAR(showPlayerNames)) then {
call FUNC(updateSettings);
};
}] call EFUNC(common,addEventHandler);

View File

@ -10,5 +10,6 @@ PREP(initIsSpeaking);
PREP(moduleNameTags);
PREP(onDraw3d);
PREP(setText);
PREP(updateSettings);
ADDON = true;

View File

@ -21,13 +21,13 @@ if !(_activated) exitWith {};
GVAR(Module) = true;
[_logic, QGVAR(playerNamesViewDistance), "playerNamesViewDistance" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(ShowNamesForAI), "ShowNamesForAI" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(showNamesForAI), "showNamesForAI" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(showVehicleCrewInfo), "showVehicleCrewInfo" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(showCursorTagForVehicles), "showCursorTagForVehicles" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(showPlayerNamesForce), "showPlayerNamesForce" ] call EFUNC(common,readSettingFromModule);
if (GVAR(showPlayerNamesForce)) then {
// Do Not Force - read module setting only non-default is set due to using SCALAR
if ((_logic getVariable "showPlayerNames") != -1) then {
[_logic, QGVAR(showPlayerNames), "showPlayerNames" ] call EFUNC(common,readSettingFromModule);
};
diag_log format ["[ACE]: NameTags Module Initialized. Forced Name Tags Setting: %1",GVAR(showPlayerNamesForce)];
diag_log text "[ACE]: NameTags Module Initialized.";

View File

@ -0,0 +1,26 @@
/*
* Author: Jonpas
* Dynamically adds and removes Draw3D based on settings on run-time.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* call ace_nametags_fnc_updateSettings
*
* Public: No
*/
#include "script_component.hpp"
if (isNil QGVAR(drawHandler) && {GVAR(showPlayerNames) != 0}) then {
GVAR(drawHandler) = addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
} else {
if (!isNil QGVAR(drawHandler) && {GVAR(showPlayerNames) == 0}) then {
removeMissionEventHandler ["Draw3D", GVAR(drawHandler)];
GVAR(drawHandler) = nil;
};
};

View File

@ -25,12 +25,6 @@
<Italian>Mostra i nomi dei giocatori</Italian>
<Russian>Показывать имена игроков (включить имена)</Russian>
</Key>
<Key ID="STR_ACE_NameTags_ShowPlayerNamesForce">
<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>
</Key>
<Key ID="STR_ACE_NameTags_ShowPlayerNamesOnlyOnCursor">
<English>Show player name only on cursor (requires player names)</English>
<Polish>Pokaż imiona graczy tylko pod kursorem (wymagana opcja Pokaż imiona graczy)</Polish>
@ -144,7 +138,7 @@
<Polish>Wymuś ukrycie</Polish>
</Key>
<Key ID="STR_ACE_NameTags_ForceShow">
<English>Force show</English>
<English>Force Show</English>
<Polish>Wymuś wyświetlanie</Polish>
</Key>
<Key ID="STR_ACE_NameTags_showVehicleCrewInfo_DisplayName">
@ -164,7 +158,7 @@
<Polish>Pokazuj imię dowódcy pojazdu nad pojazdem (tylko jeżeli klient ma włączone imiona graczy). Domyślnie: Nie</Polish>
</Key>
<Key ID="STR_ACE_NameTags_Module_Description">
<English></English>
<English>This module allows you to customize settings and range of Name Tags.</English>
<Polish>Moduł ten pozwala dostosować ustawienia i zasięg wyświetlania imion.</Polish>
</Key>
<Key ID="STR_ACE_NameTags_Disabled">
@ -176,17 +170,26 @@
<Polish>Włączone</Polish>
</Key>
<Key ID="STR_ACE_NameTags_OnlyCursor">
<English>Only Cursor</English>
<English>Only on Cursor</English>
<Polish>Tylko pod kursorem</Polish>
</Key>
<Key ID="STR_ACE_NameTags_OnlyOnKeypress">
<English>Only On Keypress</English>
<Key ID="STR_ACE_NameTags_OnlyKeypress">
<English>Only on Keypress</English>
<Polish>Tylko po wciśnięciu klawisza</Polish>
</Key>
<Key ID="STR_ACE_NameTags_OnlyCursorAndKeypress">
<English>Only Cursor and Keypress</English>
<English>Only on Cursor and Keypress</English>
<Polish>Tylko pod kursorem i po wciśnięciu klawisza</Polish>
</Key>
<Key ID="STR_ACE_NameTags_ForceShowOnlyCursor">
<English>Force Show Only on Cursor</English>
</Key>
<Key ID="STR_ACE_NameTags_ForceShowOnlyKeypress">
<English>Force Show Only on Keypress</English>
</Key>
<Key ID="STR_ACE_NameTags_ForceShowOnlyCursorAndKeypress">
<English>Force Show Only on Cursor and Keypress</English>
</Key>
<Key ID="STR_ACE_NameTags_NameTagSettings">
<English>Use Nametag settings</English>
<Polish>Użyj ustawień imion</Polish>
@ -200,7 +203,7 @@
<Polish>Opcja ta pozwala dostosować sposób wyświetlania imion nad głowami graczy. Opcja "Tylko po wciśnięciu klawisza" wyświetla imiona tylko przytrzymania klawisza "Modyfikator" dostępnego w menu ustawień addonów -> ACE3.</Polish>
</Key>
<Key ID="STR_ACE_NameTags_ShowSoundWaves_Desc">
<English></English>
<English>Effect of sound waves above the heads of speaking players after holding the PTT key. This option works with TFAR and ACRE2.</English>
<Polish>Opcja ta pozwala dostosować sposób wyświetlania efektu fal dźwiękowych nad głowami mówiących graczy, wyświetlanych po przytrzymaniu klawisza PTT. Opcja ta współpracuje z TFAR oraz ACRE2.</Polish>
</Key>
</Package>