Merge pull request #1204 from usecforce/nametagsToggle

Disablable NameTags Module option
This commit is contained in:
Nicolás Badano 2015-06-02 17:03:47 -03:00
commit 0022548748
16 changed files with 219 additions and 126 deletions

View File

@ -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"};
};
};
};

View File

@ -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";

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) = 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);

View File

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

View File

@ -13,6 +13,7 @@ class CfgPatches {
};
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "ACE_Settings.hpp"
#include "CfgVehicles.hpp"
#include <RscTitles.hpp>

View File

@ -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

View File

@ -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 <BOOL>
*
* Example:
* call ace_nametags_fnc_doShow
*
* Public: No
*/
#include "script_component.hpp"
private["_player"];
private ["_player"];
_player = ACE_player;

View File

@ -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";

View File

@ -1,17 +1,21 @@
/*
* Author: commy2, esteldunedain
*
* Draw the nametag and rank icon.
*
* Argument:
* Arguments:
* 0: Unit (Player) <OBJECT>
* 1: Target <OBJECT>
* 2: alpha (Number)
* 4: Height offset (Number)
* 2: Alpha <NUMBER>
* 4: Height offset <NUMBER>
* 5: Draw Type <NUMBER>
*
* Return value:
* None.
* None
*
* Example:
* [ACE_player, _target, _alpha, _distance * 0.026, _icon] call ace_nametags_fnc_drawNameTagIcon
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -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 <ARRAY>
* 0: Vehicle inherits from Air <BOOL>
* 1: Categorized vehicle's turrets <ARRAY>
*
* 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;
};
};
};

View File

@ -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
*/

View File

@ -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.";

View File

@ -1,3 +1,18 @@
/*
* Author: <N/A>
* 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);
};

View File

@ -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 <STRING>
*
* 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;

View File

@ -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;
};
};

View File

@ -152,7 +152,7 @@
<German>Verstecken erzwingen</German>
</Key>
<Key ID="STR_ACE_NameTags_ForceShow">
<English>Force show</English>
<English>Force Show</English>
<Polish>Wymuś wyświetlanie</Polish>
<Spanish>Mostrar forzado</Spanish>
<German>Anzeigen erzwingen</German>
@ -182,64 +182,73 @@
<German>Zeige Maus-Namensanzeigen für Fahrzeugkommandanten (nur wenn der Client Namensanzeigen aktiviert hat). Standard: Nein</German>
</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>
<German>Dieses Modul erlaubt die Einstellungen der Anzeigenamen zu verändern.</German>
</Key>
<Key ID="STR_ACE_Common_Disabled">
<Key ID="STR_ACE_NameTags_Disabled">
<English>Disabled</English>
<Polish>Wyłączone</Polish>
<Spanish>Desactivado</Spanish>
<German>Deaktiviert</German>
</Key>
<Key ID="STR_ACE_Common_Enabled">
<Key ID="STR_ACE_NameTags_Enabled">
<English>Enabled</English>
<Polish>Włączone</Polish>
<Spanish>Activado</Spanish>
<German>Aktiviert</German>
</Key>
<Key ID="STR_ACE_Common_OnlyCursor">
<English>Only Cursor</English>
<Key ID="STR_ACE_NameTags_OnlyCursor">
<English>Only on Cursor</English>
<Polish>Tylko pod kursorem</Polish>
<Spanish>Solo cursor</Spanish>
<German>Nur bei Maus</German>
</Key>
<Key ID="STR_ACE_Common_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>
<Spanish>Solo al pulsar tecla</Spanish>
<German>Nur bei Tastendruck</German>
</Key>
<Key ID="STR_ACE_Common_OnlyCursorAndKeyPress">
<English>Only Cursor and KeyPress</English>
<Key ID="STR_ACE_NameTags_OnlyCursorAndKeypress">
<English>Only on Cursor and Keypress</English>
<Polish>Tylko pod kursorem i po wciśnięciu klawisza</Polish>
<Spanish>En cursor y al pulsar tecla</Spanish>
<German>Nur Maus und Tastendruck</German>
</Key>
<Key ID="STR_ACE_Common_NameTagSettings">
<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>
<Spanish>Usar ajustes de etiquetas de nombre</Spanish>
<German>Verwende Namenanzeigen</German>
</Key>
<Key ID="STR_ACE_Common_AlwaysShowAll">
<Key ID="STR_ACE_NameTags_AlwaysShowAll">
<English>Always Show All</English>
<Polish>Zawsze pokazuj wszystkie</Polish>
<Spanish>Mostrar siempre todo</Spanish>
<German>Immer alle zeigen</German>
</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 -&gt; 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>
<Key ID="STR_ACE_nametags_tagsize_name">
<Key ID="STR_ACE_NameTags_TagSize_Name">
<English>Nametags Size</English>
</Key>
<Key ID="STR_ACE_nametags_tagsize_description">
<Key ID="STR_ACE_NameTags_TagSize_Description">
<English>Text and Icon Size Scaling</English>
</Key>
</Package>