Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disablable NameTags Module option #1204

Merged
merged 16 commits into from Jun 2, 2015
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions addons/nametags/ACE_Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ class ACE_Settings {
isClientSettable = 1;
displayName = "$STR_ACE_NameTags_ShowPlayerNames";
description = "$STR_ACE_NameTags_ShowPlayerNames_Desc";
values[] = {"$STR_ACE_Common_Disabled", "$STR_ACE_Common_Enabled", "$STR_ACE_Common_OnlyCursor", "$STR_ACE_Common_OnlyOnKeypress", "$STR_ACE_Common_OnlyCursorAndKeyPress"};
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";
};
class GVAR(showPlayerRanks) {
value = 1;
Expand Down Expand Up @@ -42,16 +48,16 @@ class ACE_Settings {
isClientSettable = 1;
displayName = "$STR_ACE_NameTags_ShowSoundWaves";
description = "$STR_ACE_NameTags_ShowSoundWaves_Desc";
values[] = {"$STR_ACE_Common_Disabled", "$STR_ACE_Common_NameTagSettings", "$STR_ACE_Common_AlwaysShowAll"};
values[] = {"$STR_ACE_NameTags_Disabled", "$STR_ACE_NameTags_NameTagSettings", "$STR_ACE_NameTags_AlwaysShowAll"};
};
class GVAR(PlayerNamesViewDistance) {
class GVAR(playerNamesViewDistance) {
value = 5;
typeName = "SCALAR";
isClientSettable = 0;
};
class GVAR(PlayerNamesMaxAlpha) {
class GVAR(playerNamesMaxAlpha) {
value = 0.8;
typeName = "SCALAR";
isClientSettable = 0;
};
};
};
36 changes: 35 additions & 1 deletion addons/nametags/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,41 @@ class CfgVehicles {
isGlobal = 1;
icon = QUOTE(PATHTOF(UI\Icon_Module_NameTags_ca.paa));
class Arguments {
class PlayerNamesViewDistance {
class showPlayerNames {
displayName = "$STR_ACE_NameTags_ShowPlayerNames";
description = "$STR_ACE_NameTags_ShowPlayerNames_Desc";
typeName = "NUMBER";
class values {
class Disabled {
name = "$STR_ACE_NameTags_Disabled";
value = 0;
};
class Enabled {
default = 1;
name = "$STR_ACE_NameTags_Enabled";
value = 1;
};
class OnlyCursor {
name = "$STR_ACE_NameTags_OnlyCursor";
value = 2;
};
class OnlyOnKeypress {
name = "$STR_ACE_NameTags_OnlyOnKeypress";
value = 3;
};
class OnlyCursorAndKeypress {
name = "$STR_ACE_NameTags_OnlyCursorAndKeypress";
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";
typeName = "NUMBER";
Expand Down
23 changes: 21 additions & 2 deletions addons/nametags/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,24 @@ GVAR(ShowNamesTime) = -10;
[29, [false, false, false]], false] call cba_fnc_addKeybind; //LeftControl Key


// Draw handle
addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}];
// Draw handle on start if set
if (GVAR(showPlayerNames) > 0) then {
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not guaranteed to be set to the correct most up to date value on clients and JIP. Maybe make it so this if statement is inside the settingChanged EH?

Same goes for the lines 27/29.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can only be changed in module/userconfig though.

The idea why it isn't inside SettingChanged is so that EH doesn't get installed at all, as if showPlayerNamesForce is enabled clients can't set it anyways.

What would you recommend for lines 27-29?

EDIT: 6774739 would solve it, I'd just throw entire thing under there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@esteldunedain is working on the init thingy, was decided to leave as is for now.

["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);
};
3 changes: 2 additions & 1 deletion addons/nametags/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CfgPatches {
};

#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "ACE_Settings.hpp"
#include "CfgVehicles.hpp"

#include <RscTitles.hpp>
11 changes: 8 additions & 3 deletions addons/nametags/functions/fnc_moduleNameTags.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ if !(_activated) exitWith {};

GVAR(Module) = true;

[_logic, QGVAR(PlayerNamesViewDistance), "PlayerNamesViewDistance" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(playerNamesViewDistance), "playerNamesViewDistance" ] 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(showCursorTagForVehicles), "showCursorTagForVehicles" ] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(showPlayerNamesForce), "showPlayerNamesForce" ] call EFUNC(common,readSettingFromModule);

diag_log text "[ACE]: NameTags Module Initialized.";
if (GVAR(showPlayerNamesForce)) then {
[_logic, QGVAR(showPlayerNames), "showPlayerNames" ] call EFUNC(common,readSettingFromModule);
};

diag_log format ["[ACE]: NameTags Module Initialized. Forced Name Tags Setting: %1",GVAR(showPlayerNamesForce)];
24 changes: 15 additions & 9 deletions addons/nametags/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<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>
Expand Down Expand Up @@ -161,36 +167,36 @@
<English></English>
<Polish>Moduł ten pozwala dostosować ustawienia i zasięg wyświetlania imion.</Polish>
</Key>
<Key ID="STR_ACE_Common_Disabled">
<Key ID="STR_ACE_NameTags_Disabled">
<English>Disabled</English>
<Polish>Wyłączone</Polish>
</Key>
<Key ID="STR_ACE_Common_Enabled">
<Key ID="STR_ACE_NameTags_Enabled">
<English>Enabled</English>
<Polish>Włączone</Polish>
</Key>
<Key ID="STR_ACE_Common_OnlyCursor">
<Key ID="STR_ACE_NameTags_OnlyCursor">
<English>Only Cursor</English>
<Polish>Tylko pod kursorem</Polish>
</Key>
<Key ID="STR_ACE_Common_OnlyOnKeypress">
<Key ID="STR_ACE_NameTags_OnlyOnKeypress">
<English>Only On Keypress</English>
<Polish>Tylko po wciśnięciu klawisza</Polish>
</Key>
<Key ID="STR_ACE_Common_OnlyCursorAndKeyPress">
<English>Only Cursor and KeyPress</English>
<Key ID="STR_ACE_NameTags_OnlyCursorAndKeypress">
<English>Only Cursor and Keypress</English>
<Polish>Tylko pod kursorem i po wciśnięciu klawisza</Polish>
</Key>
<Key ID="STR_ACE_Common_NameTagSettings">
<Key ID="STR_ACE_NameTags_NameTagSettings">
<English>Use Nametag settings</English>
<Polish>Użyj ustawień imion</Polish>
</Key>
<Key ID="STR_ACE_Common_AlwaysShowAll">
<Key ID="STR_ACE_NameTags_AlwaysShowAll">
<English>Always Show All</English>
<Polish>Zawsze pokazuj wszystkie</Polish>
</Key>
<Key ID="STR_ACE_NameTags_ShowPlayerNames_Desc">
<English></English>
<English>Show player names and set their activation. Default: Enabled</English>
<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">
Expand Down