diff --git a/addons/nametags/ACE_Settings.hpp b/addons/nametags/ACE_Settings.hpp index 90d2b7d8c9..5270321768 100644 --- a/addons/nametags/ACE_Settings.hpp +++ b/addons/nametags/ACE_Settings.hpp @@ -11,7 +11,7 @@ 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_OnlyKeypress", "$STR_ACE_NameTags_OnlyCursorAndKeypress"}; }; class GVAR(showPlayerRanks) { value = 1; @@ -42,14 +42,14 @@ 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; @@ -58,8 +58,8 @@ class ACE_Settings { value = 2; typeName = "SCALAR"; isClientSettable = 1; - displayName = "$STR_ACE_nametags_tagsize_name"; - description = "$STR_ACE_nametags_tagsize_description"; + displayName = "$STR_ACE_NameTags_TagSize_Name"; + description = "$STR_ACE_NameTags_TagSize_Description"; values[] = {"$str_very_small", "$str_small", "$str_medium", "$str_large", "$str_very_large"}; }; -}; \ No newline at end of file +}; diff --git a/addons/nametags/CfgVehicles.hpp b/addons/nametags/CfgVehicles.hpp index 50439218aa..1719ee69ce 100644 --- a/addons/nametags/CfgVehicles.hpp +++ b/addons/nametags/CfgVehicles.hpp @@ -9,7 +9,39 @@ 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 DoNotForce { + default = 1; + name = "$STR_ACE_NameTags_DoNotForce"; + value = -1; + }; + class ForceHide { + name = "$STR_ACE_NameTags_ForceHide"; + value = 0; + }; + class ForceShow { + name = "$STR_ACE_NameTags_ForceShow"; + value = 1; + }; + class ForceShowOnlyCursor { + name = "$STR_ACE_NameTags_ForceShowOnlyCursor"; + value = 2; + }; + class ForceShowOnlyKeypress { + name = "$STR_ACE_NameTags_ForceShowOnlyKeypress"; + value = 3; + }; + class ForceShowOnlyCursorAndKeypress { + name = "$STR_ACE_NameTags_ForceShowOnlyCursorAndKeypress"; + value = 4; + }; + }; + }; + class playerNamesViewDistance { displayName = "$STR_ACE_NameTags_PlayerNamesViewDistance_DisplayName"; description = "$STR_ACE_NameTags_PlayerNamesViewDistance_Description"; typeName = "NUMBER"; diff --git a/addons/nametags/XEH_postInit.sqf b/addons/nametags/XEH_postInit.sqf index e34038950a..433de7c494 100644 --- a/addons/nametags/XEH_postInit.sqf +++ b/addons/nametags/XEH_postInit.sqf @@ -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) = ACE_time; + GVAR(showNamesTime) = ACE_time; if (call FUNC(canShow)) then{ call FUNC(doShow); }; // Return false so it doesn't block other actions false @@ -61,5 +61,13 @@ GVAR(ShowNamesTime) = -10; // Wait until the colors are defined before starting to draw the nametags ["SettingsInitialized", { // Draw handle - addMissionEventHandler ["Draw3D", {_this call FUNC(onDraw3d);}]; + call FUNC(updateSettings); +}] 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); diff --git a/addons/nametags/XEH_preInit.sqf b/addons/nametags/XEH_preInit.sqf index f3c9a97cba..51b926cbb3 100644 --- a/addons/nametags/XEH_preInit.sqf +++ b/addons/nametags/XEH_preInit.sqf @@ -10,5 +10,6 @@ PREP(initIsSpeaking); PREP(moduleNameTags); PREP(onDraw3d); PREP(setText); +PREP(updateSettings); ADDON = true; diff --git a/addons/nametags/config.cpp b/addons/nametags/config.cpp index 77e90b3b6b..a2d38254f1 100644 --- a/addons/nametags/config.cpp +++ b/addons/nametags/config.cpp @@ -13,6 +13,7 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" -#include "CfgVehicles.hpp" #include "ACE_Settings.hpp" +#include "CfgVehicles.hpp" + #include diff --git a/addons/nametags/functions/common.hpp b/addons/nametags/functions/common.hpp index caa7a3e982..6aeb24fc5a 100644 --- a/addons/nametags/functions/common.hpp +++ b/addons/nametags/functions/common.hpp @@ -1,12 +1,8 @@ /* - Author: aeroson - - Description: - Images, index in images and order of roles. - Defined number also implies order, lower number shows more on top of the list. -*/ - -#include "script_component.hpp" + * Author: aeroson + * Images, index in images and order of roles. + * Defined number also implies order, lower number shows more on top of the list. + */ #define PILOT 0 #define DRIVER 1 diff --git a/addons/nametags/functions/fnc_canShow.sqf b/addons/nametags/functions/fnc_canShow.sqf index 0e187fee0f..b53f50c93e 100644 --- a/addons/nametags/functions/fnc_canShow.sqf +++ b/addons/nametags/functions/fnc_canShow.sqf @@ -1,19 +1,22 @@ /* - Author: aeroson - - Description: - Might be called several times a second - - Parameters: - None - - Returns: - true if CrewInfo can be shown, false otherwise -*/ - + * Author: aeroson + * Checks if crew info can be shown. + * Might be called several times a second. + * + * Arguments: + * None + * + * Return Value: + * Can show Crew Info + * + * Example: + * call ace_nametags_fnc_doShow + * + * Public: No + */ #include "script_component.hpp" -private["_player"]; +private ["_player"]; _player = ACE_player; diff --git a/addons/nametags/functions/fnc_doShow.sqf b/addons/nametags/functions/fnc_doShow.sqf index 16a6329347..1b7323921f 100644 --- a/addons/nametags/functions/fnc_doShow.sqf +++ b/addons/nametags/functions/fnc_doShow.sqf @@ -1,16 +1,18 @@ /* - Author: aeroson - - Description: - Shows the actual text and sets text the crew info - - Parameters: - None - - Returns: - Nothing -*/ - + * Author: aeroson + * Shows the actual text and sets text the crew info. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_nametags_fnc_doShow + * + * Public: No + */ #include "script_component.hpp" #include "common.hpp"; diff --git a/addons/nametags/functions/fnc_drawNameTagIcon.sqf b/addons/nametags/functions/fnc_drawNameTagIcon.sqf index 1fdd703d62..7b6bbda138 100644 --- a/addons/nametags/functions/fnc_drawNameTagIcon.sqf +++ b/addons/nametags/functions/fnc_drawNameTagIcon.sqf @@ -1,17 +1,21 @@ /* * Author: commy2, esteldunedain - * * Draw the nametag and rank icon. * - * Argument: + * Arguments: * 0: Unit (Player) * 1: Target - * 2: alpha (Number) - * 4: Height offset (Number) + * 2: Alpha + * 4: Height offset * 5: Draw Type * * Return value: - * None. + * None + * + * Example: + * [ACE_player, _target, _alpha, _distance * 0.026, _icon] call ace_nametags_fnc_drawNameTagIcon + * + * Public: No */ #include "script_component.hpp" diff --git a/addons/nametags/functions/fnc_getVehicleData.sqf b/addons/nametags/functions/fnc_getVehicleData.sqf index 1538c345a1..6d83b0f573 100644 --- a/addons/nametags/functions/fnc_getVehicleData.sqf +++ b/addons/nametags/functions/fnc_getVehicleData.sqf @@ -1,46 +1,38 @@ /* - Author: aeroson - - Description: - Gathers and caches data needed by AGM_CrewInfo_fnc_doShow - What really does make difference for the engine is simulation of CfgAmmo - Priority of roles is: driver/pilot, gunner, copilot, commander, ffv, cargo - - Parameters: - None - - Returns: - [ - Is vehicle inherited from Air ? - Array categorizing each vehicle's turret - ] -*/ - + * Author: aeroson + * Gathers and caches data needed by AGM_CrewInfo_fnc_doShow. + * What really does make difference for the engine is simulation of CfgAmmo. + * Priority of roles is: driver/pilot, gunner, copilot, commander, FFV, cargo. + * + * Arguments: + * None + * + * Return Value: + * Data + * 0: Vehicle inherits from Air + * 1: Categorized vehicle's turrets + * + * Example: + * call ace_nametags_fnc_updateSettings + * + * Public: No + */ #include "script_component.hpp" #include "common.hpp"; +private ["_type", "_varName", "_data", "_isAir", "_config", "_fnc_addTurret", "_fnc_addTurretUnit"]; -private ["_type", "_varName", "_data"]; - -_type = _this select 0; +PARAMS_1(_type); _varName = format ["ACE_CrewInfo_Cache_%1", _type]; _data = + (uiNamespace getVariable _varName); -if (!isNil "_data") exitWith { - _data -}; +if (!isNil "_data") exitWith {_data}; _data = []; - - - -private ["_isAir", "_config", "_fnc_addTurret", "_fnc_addTurretUnit"]; - _isAir = _type isKindOf "Air"; _fnc_addTurretUnit = { - private ["_config", "_path", "_role", "_simulationEmpty", "_simulationLaserDesignate", "_simulationOther", "_magazine", "_ammo", "_simulation"]; _config = _this select 0; @@ -83,7 +75,6 @@ _fnc_addTurretUnit = { }; _data pushBack [_path, _role]; - }; @@ -108,9 +99,7 @@ _fnc_addTurret = { } else { _offset = _offset + 1; }; - }; - }; diff --git a/addons/nametags/functions/fnc_initIsSpeaking.sqf b/addons/nametags/functions/fnc_initIsSpeaking.sqf index c6087541a8..897d223930 100644 --- a/addons/nametags/functions/fnc_initIsSpeaking.sqf +++ b/addons/nametags/functions/fnc_initIsSpeaking.sqf @@ -4,13 +4,13 @@ * Compatiblity with TFR/ACRE and Arma's VON * * Arguments: - * NONE + * None * * Return Value: - * NONE + * None * * Example: - * [] call ACE_nametags_fnc_initIsSpeaking + * [] call ace_nametags_fnc_initIsSpeaking * * Public: No */ diff --git a/addons/nametags/functions/fnc_moduleNameTags.sqf b/addons/nametags/functions/fnc_moduleNameTags.sqf index 1bbd4d8efb..7373d85de1 100644 --- a/addons/nametags/functions/fnc_moduleNameTags.sqf +++ b/addons/nametags/functions/fnc_moduleNameTags.sqf @@ -20,9 +20,14 @@ if !(_activated) exitWith {}; GVAR(Module) = true; -[_logic, QGVAR(PlayerNamesViewDistance), "PlayerNamesViewDistance" ] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(ShowNamesForAI), "ShowNamesForAI" ] 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); + +// 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 text "[ACE]: NameTags Module Initialized."; diff --git a/addons/nametags/functions/fnc_onDraw3d.sqf b/addons/nametags/functions/fnc_onDraw3d.sqf index 8ea8b63298..43996e17b2 100644 --- a/addons/nametags/functions/fnc_onDraw3d.sqf +++ b/addons/nametags/functions/fnc_onDraw3d.sqf @@ -1,3 +1,18 @@ +/* + * Author: + * Draws names and icons. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_nametags_fnc_onDraw3d + * + * Public: No + */ #include "script_component.hpp" private ["_onKeyPressAlphaMax", "_defaultIcon", "_distance", "_alpha", "_icon", "_targets", "_pos2", "_vecy", "_relPos", "_projDist", "_pos", "_target", "_targetEyePosASL", "_ambientBrightness", "_maxDistance"]; @@ -9,7 +24,7 @@ _ambientBrightness = ((([] call EFUNC(common,ambientBrightness)) + ([0, 0.4] sel _maxDistance = _ambientBrightness * GVAR(PlayerNamesViewDistance); _onKeyPressAlphaMax = if ((GVAR(showPlayerNames) in [3,4])) then { - 2 + (GVAR(ShowNamesTime) - ACE_time); //after release 1 second of full opacity, 1 second of fading to 0 + 2 + (GVAR(showNamesTime) - ACE_time); //after release 1 second of full opacity, 1 second of fading to 0 } else { 1 }; @@ -29,10 +44,10 @@ if (GVAR(showCursorTagForVehicles) && {_onKeyPressAlphaMax > 0}) then { if ((!isNull _target) && {(side (group _target)) == (side (group ACE_player))} && {_target != ACE_player} && - {GVAR(ShowNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} && + {GVAR(showNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} && {!(_target getVariable ["ACE_hideName", false])}) then { _distance = ACE_player distance _target; - _alpha = (((1 - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(PlayerNamesMaxAlpha)) min _onKeyPressAlphaMax; + _alpha = (((1 - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(playerNamesMaxAlpha)) min _onKeyPressAlphaMax; [ACE_player, _target, _alpha, _distance * 0.026, _defaultIcon] call FUNC(drawNameTagIcon); }; }; @@ -45,10 +60,10 @@ if ((GVAR(showPlayerNames) in [2,4]) && {_onKeyPressAlphaMax > 0}) then { {_target isKindOf "CAManBase"} && {(side (group _target)) == (side (group ACE_player))} && {_target != ACE_player} && - {GVAR(ShowNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} && + {GVAR(showNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} && {!(_target getVariable ["ACE_hideName", false])}) then { _distance = ACE_player distance _target; - _alpha = (((1 - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(PlayerNamesMaxAlpha)) min _onKeyPressAlphaMax; + _alpha = (((1 - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(playerNamesMaxAlpha)) min _onKeyPressAlphaMax; _icon = ICON_NONE; if (GVAR(showSoundWaves) == 2) then { //icon will be drawn below, so only show name here _icon = if (([_target] call FUNC(isSpeaking)) && {(vehicle _target) == _target}) then {ICON_NAME} else {_defaultIcon}; @@ -87,7 +102,7 @@ if (((GVAR(showPlayerNames) in [1,3]) && {_onKeyPressAlphaMax > 0}) || {GVAR(sho if ((_icon != ICON_NONE) && {(side (group _target)) == (side (group ACE_player))} && {_target != ACE_player} && - {GVAR(ShowNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} && + {GVAR(showNamesForAI) || {[_target] call EFUNC(common,isPlayer)}} && {!(_target getVariable ["ACE_hideName", false])}) then { _targetEyePosASL = eyePos _target; @@ -97,7 +112,7 @@ if (((GVAR(showPlayerNames) in [1,3]) && {_onKeyPressAlphaMax > 0}) || {GVAR(sho _distance = vectorMagnitude _relPos; _projDist = _relPos vectorDistance (_vecy vectorMultiply (_relPos vectorDotProduct _vecy)); - _alpha = (((1 - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(PlayerNamesMaxAlpha)) min _onKeyPressAlphaMax; + _alpha = (((1 - 0.2 * (_distance - _maxDistance)) min 1) * GVAR(playerNamesMaxAlpha)) min _onKeyPressAlphaMax; [ACE_player, _target, _alpha, _distance * 0.026, _icon] call FUNC(drawNameTagIcon); }; diff --git a/addons/nametags/functions/fnc_setText.sqf b/addons/nametags/functions/fnc_setText.sqf index e7d1b748b1..33112c31d0 100644 --- a/addons/nametags/functions/fnc_setText.sqf +++ b/addons/nametags/functions/fnc_setText.sqf @@ -1,25 +1,28 @@ -/* - Author: aeroson - - Description: - Sets the text on the dialog - - Parameters: - None - - Returns: - Nothing -*/ - +/* + * Author: aeroson + * Sets the text on the dialog. + * + * Arguments: + * 0: Text + * + * Return Value: + * None + * + * Example: + * call ace_nametags_fnc_setText + * + * Public: No + */ #include "script_component.hpp" #define TextIDC 11123 -private["_text", "_ctrl"]; +PARAMS_1(_text); + +private["_ctrl"]; disableSerialization; -_text = _this select 0; _ctrl = (uiNamespace getVariable QGVAR(dialog)) displayCtrl TextIDC; _ctrl ctrlSetStructuredText parseText _text; _ctrl ctrlCommit 0; diff --git a/addons/nametags/functions/fnc_updateSettings.sqf b/addons/nametags/functions/fnc_updateSettings.sqf new file mode 100644 index 0000000000..76110b4f79 --- /dev/null +++ b/addons/nametags/functions/fnc_updateSettings.sqf @@ -0,0 +1,25 @@ +/* + * 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; + }; +}; diff --git a/addons/nametags/stringtable.xml b/addons/nametags/stringtable.xml index 0eb7cdaea9..a39547ff1d 100644 --- a/addons/nametags/stringtable.xml +++ b/addons/nametags/stringtable.xml @@ -152,7 +152,7 @@ Verstecken erzwingen - Force show + Force Show Wymuś wyświetlanie Mostrar forzado Anzeigen erzwingen @@ -182,64 +182,73 @@ Zeige Maus-Namensanzeigen für Fahrzeugkommandanten (nur wenn der Client Namensanzeigen aktiviert hat). Standard: Nein - + This module allows you to customize settings and range of Name Tags. Moduł ten pozwala dostosować ustawienia i zasięg wyświetlania imion. Dieses Modul erlaubt die Einstellungen der Anzeigenamen zu verändern. - + Disabled Wyłączone Desactivado Deaktiviert - + Enabled Włączone Activado Aktiviert - - Only Cursor + + Only on Cursor Tylko pod kursorem Solo cursor Nur bei Maus - - Only On Keypress + + Only on Keypress Tylko po wciśnięciu klawisza Solo al pulsar tecla Nur bei Tastendruck - - Only Cursor and KeyPress + + Only on Cursor and Keypress Tylko pod kursorem i po wciśnięciu klawisza En cursor y al pulsar tecla Nur Maus und Tastendruck - + + Force Show Only on Cursor + + + Force Show Only on Keypress + + + Force Show Only on Cursor and Keypress + + Use Nametag settings Użyj ustawień imion Usar ajustes de etiquetas de nombre Verwende Namenanzeigen - + Always Show All Zawsze pokazuj wszystkie Mostrar siempre todo Immer alle zeigen - + Show player names and set their activation. Default: Enabled 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. - + Effect of sound waves above the heads of speaking players after holding the PTT key. This option works with TFAR and ACRE2. 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. - + Nametags Size - + Text and Icon Size Scaling