diff --git a/TO_MERGE/agm/NameTags/RscTitles.hpp b/TO_MERGE/agm/NameTags/RscTitles.hpp deleted file mode 100644 index 32ea8d5c3d..0000000000 --- a/TO_MERGE/agm/NameTags/RscTitles.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#define AGM_CrewInfo_TextIDC 11123 - -#define CT_STRUCTURED_TEXT 13 -#define ST_LEFT 0 - -class RscTitles { - titles[]={"AGM_CrewInfo_dialog"}; - class AGM_CrewInfo_dialog { - idd = -1; - movingEnable = 1; - duration = 1; - fadein = 0; - fadeout = 999999; - name = "AGM_CrewInfo_dialog"; - controlsBackground[] = {"AGM_CrewInfo_text"}; - onLoad = "uiNamespace setVariable ['AGM_CrewInfo_dialog', _this select 0]"; - onUnload = "uiNamespace setVariable ['AGM_CrewInfo_dialog', objNull]"; - - class AGM_CrewInfo_text { - idc = AGM_CrewInfo_TextIDC; - type = CT_STRUCTURED_TEXT; - style = ST_LEFT; - x = SafeZonex + SafezoneW - 0.31; - y = SafeZoneY + SafeZoneH*0.4; - w = 0.3; - h = 0.6; - size = 0.018; - colorBackground[] = { 0, 0, 0, 0 }; - colortext[] = { - "(profilenamespace getvariable ['IGUI_TEXT_RGB_R',0])", - "(profilenamespace getvariable ['IGUI_TEXT_RGB_G',1])", - "(profilenamespace getvariable ['IGUI_TEXT_RGB_B',1])", - "(profilenamespace getvariable ['IGUI_TEXT_RGB_A',0.8])" - }; - text=""; - class Attributes { - align = right; - }; - }; - }; -}; diff --git a/TO_MERGE/agm/NameTags/config.cpp b/TO_MERGE/agm/NameTags/config.cpp deleted file mode 100644 index aa0be72b5e..0000000000 --- a/TO_MERGE/agm/NameTags/config.cpp +++ /dev/null @@ -1,143 +0,0 @@ -class CfgPatches { - class AGM_NameTags { - units[] = {}; - weapons[] = {}; - requiredVersion = 0.60; - requiredAddons[] = {AGM_Core, AGM_Interaction}; - version = "0.95"; - versionStr = "0.95"; - versionAr[] = {0,95,0}; - author[] = {"commy2", "CAA-Picard"}; - authorUrl = "https://github.com/commy2/"; - }; -}; - -class CfgFunctions { - class AGM_NameTags { - class AGM_NameTags { - file = "\AGM_NameTags\functions"; - class drawNameTagIcon; - class moduleNameTags; - }; - }; - class AGM_CrewInfo { - class AGM_CrewInfo { - file = "AGM_NameTags\functions\CrewInfo"; - class canShow; - class doShow; - class getVehicleData; - class onMouseZChanged; - class setText; - }; - }; -}; - -class Extended_PostInit_EventHandlers { - class AGM_NameTags { - clientInit = "call compile preprocessFileLineNumbers '\AGM_NameTags\clientInit.sqf'"; - }; -}; - -class AGM_Core_Default_Keys { - class showNames { - displayName = "$STR_AGM_NameTags_ShowNames"; - condition = "true"; - statement = "AGM_NameTags_ShowNamesTime = time; if (call AGM_CrewInfo_fnc_canShow) then {call AGM_CrewInfo_fnc_doShow;};"; - key = 29; - shift = 0; - control = 0; - alt = 0; - allowHolding = 1; - }; -}; - -class AGM_Core_Options { - class showPlayerNames { - displayName = "$STR_AGM_NameTags_ShowPlayerNames"; - default = 1; - }; - class showPlayerNamesOnlyOnCursor { - displayName = "$STR_AGM_NameTags_ShowPlayerNamesOnlyOnCursor"; - default = 1; - }; - class showPlayerNamesOnlyOnKeyPress { - displayName = "$STR_AGM_NameTags_ShowPlayerNamesOnlyOnKeyPress"; - default = 0; - }; - class showPlayerRanks { - displayName = "$STR_AGM_NameTags_ShowPlayerRanks"; - default = 1; - }; - class showVehicleCrewInfo { - displayName = "$STR_AGM_CrewInfo_ShowVehicleCrewInfo"; - default = 1; - }; -}; - -class AGM_Parameters_Numeric { - AGM_NameTags_PlayerNamesViewDistance = 5; - AGM_NameTags_PlayerNamesMaxAlpha = 0.8; - AGM_NameTags_CrewInfoVisibility = 0; -}; -class AGM_Parameters_Boolean { - AGM_NameTags_ShowNamesForAI = 0; -}; - -class CfgVehicles { - class Module_F; - class AGM_ModuleNameTags: Module_F { - author = "$STR_AGM_Core_AGMTeam"; - category = "AGM"; - displayName = "Name Tags"; - function = "AGM_NameTags_fnc_moduleNameTags"; - scope = 2; - isGlobal = 1; - icon = "\AGM_NameTags\UI\IconNameTags_ca.paa"; - class Arguments { - class PlayerNamesViewDistance { - displayName = "Player Names View Dist."; - description = "Distance in meters at which player names are shown. Default: 5"; - typeName = "NUMBER"; - defaultValue = 5; - }; - class ShowNamesForAI { - displayName = "Show name tags for AI?"; - description = "Show the name and rank tags for friendly AI units? Default: No"; - typeName = "BOOL"; - class values { - class Yes { - name = "Yes"; - value = 1; - }; - class No { - default = 1; - name = "No"; - value = 0; - }; - }; - }; - class Visibility { - displayName = "Visibility of crew info"; - description = "Forces visibility of vehicle crew info, or by default allows players to choose it on their own. Default: Do Not Force"; - typeName = "INT"; - class values { - class DoNotForce { - default = 1; - name = "Do Not Force"; - value = 0; - }; - class ForceShow { - name = "Force Show"; - value = 1; - }; - class ForceHide { - name = "Force Hide"; - value = -1; - }; - }; - }; - }; - }; -}; - -#include diff --git a/TO_MERGE/agm/NameTags/functions/CrewInfo/common.sqf b/TO_MERGE/agm/NameTags/functions/CrewInfo/common.sqf deleted file mode 100644 index aa80cdfa8d..0000000000 --- a/TO_MERGE/agm/NameTags/functions/CrewInfo/common.sqf +++ /dev/null @@ -1,24 +0,0 @@ -/* - 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. -*/ - -#define PILOT 0 -#define DRIVER 1 -#define COPILOT PILOT -#define COMMANDER 2 -#define GUNNER 3 -#define FFV 4 -#define CARGO 5 - -#define ROLE_IMAGES [ \ - "a3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa", \ - "a3\ui_f\data\IGUI\Cfg\Actions\getindriver_ca.paa", \ - "a3\ui_f\data\IGUI\Cfg\Actions\getincommander_ca.paa", \ - "a3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa", \ - "AGM_NameTags\UI\icon_position_ffv.paa", \ - "a3\ui_f\data\IGUI\Cfg\Actions\getincargo_ca.paa" \ -] diff --git a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_canShow.sqf b/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_canShow.sqf deleted file mode 100644 index 8e3dadedec..0000000000 --- a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_canShow.sqf +++ /dev/null @@ -1,26 +0,0 @@ -/* - Author: aeroson - - Description: - Might be called several times a second - - Parameters: - None - - Returns: - true if CrewInfo can be shown, false otherwise -*/ - -private["_player"]; - - -_player = AGM_player; - -// AGM_NameTags_ShowVehicleCrewInfo: -1 force NO, 0 doesnt care, 1 force YES - -vehicle _player != _player && -{ - (AGM_NameTags_CrewInfoVisibility == 1) || - (AGM_NameTags_CrewInfoVisibility != -1 && profileNamespace getVariable ["AGM_showVehicleCrewInfo", false]) -} && -{!(vehicle _player isKindOf "ParachuteBase")}; diff --git a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_doShow.sqf b/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_doShow.sqf deleted file mode 100644 index 869cdb6fb7..0000000000 --- a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_doShow.sqf +++ /dev/null @@ -1,92 +0,0 @@ -/* - Author: aeroson - - Description: - Shows the actual text and sets text the crew info - - Parameters: - None - - Returns: - Nothing -*/ - -#include "common.sqf" - -private["_roleImages", "_player", "_vehicle", "_type", "_config", "_text", "_data", "_isAir", "_turretUnits", "_turretRoles", "_index", "_roleType", "_unit", "_toShow"]; - - -_player = AGM_player; -_vehicle = vehicle _player; -_type = typeOf _vehicle; -_config = configFile >> "CfgVehicles" >> _type; -_text = format[" %2
", getText(_config>>"picture"), getText (_config >> "DisplayName")]; - - - -_data = [_type] call AGM_CrewInfo_fnc_getVehicleData; - -_isAir = _data select 0; -_data = _data select 1; - -_turretUnits = [_data, { _vehicle turretUnit (_x select 0) } ] call AGM_Core_fnc_map; -_turretRoles = [_data, { _x select 1 } ] call AGM_Core_fnc_map; - - -_roleType = CARGO; -_toShow = []; -{ - switch (_x) do { - case commander _vehicle: { - _roleType = COMMANDER; - }; - case gunner _vehicle: { - _roleType = GUNNER; - }; - case driver _vehicle: { - _roleType = if(_isAir) then { PILOT } else { DRIVER }; - }; - default { - _index = _turretUnits find _x; - if(_index !=-1 ) then { - _roleType = _turretRoles select _index; - } else { - _roleType = CARGO; - }; - }; - }; - _toShow pushBack [_x, _roleType]; -} forEach crew _vehicle; - - -_toShow = [ - _toShow, - [], - { - _x select 1 - }, - "ASCEND", - { - _unit = _x select 0; - alive _unit - } -] call BIS_fnc_sortBy; - - -_roleImages = ROLE_IMAGES; -{ - _unit = _x select 0; - _roleType = _x select 1; - _text = _text + format["%1
", [_unit] call AGM_Core_fnc_getName, _roleImages select _roleType]; -} forEach _toShow; - - -("AGM_CrewInfo_CrewInfo" call BIS_fnc_rscLayer) cutRsc ["AGM_CrewInfo_dialog", "PLAIN", 1, false]; - -terminate (missionNamespace getVariable ["AGM_CrewInfo_hideCrewInfoHandle", scriptNull]); -AGM_CrewInfo_hideCrewInfoHandle = 0 spawn { - sleep 2; - ("AGM_CrewInfo_CrewInfo" call BIS_fnc_rscLayer) cutFadeOut 2; -}; - -[_text] call AGM_CrewInfo_fnc_setText; diff --git a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_getVehicleData.sqf b/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_getVehicleData.sqf deleted file mode 100644 index d58c0ec458..0000000000 --- a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_getVehicleData.sqf +++ /dev/null @@ -1,123 +0,0 @@ -/* - 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 - ] -*/ - -#include "common.sqf" - - - -private ["_type", "_varName", "_data"]; - -_type = _this select 0; - -_varName = format ["AGM_CrewInfo_Cache_%1", _type]; -_data = + (uiNamespace getVariable _varName); - -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; - _path = _this select 1; - _role = CARGO; - - _simulationEmpty = 0; - _simulationLaserDesignate = 0; - _simulationOther = 0; - { - { - _magazine = configFile >> "CfgMagazines" >> _x; - _ammo = configfile >> "CfgAmmo" >> getText (_magazine >> "ammo"); - _simulation = getText (_ammo >> "simulation"); - - if(_simulation=="") then { - _simulationEmpty = _simulationEmpty + 1; - } else { - if(_simulation=="laserDesignate") then { - _simulationLaserDesignate = _simulationLaserDesignate + 1; - } else { - _simulationOther = _simulationOther + 1; - }; - }; - - } forEach getArray (configfile >> "CfgWeapons" >> _x >> "magazines"); - } forEach getArray (_config >> "weapons"); - - if(_simulationOther>0) then { - _role = GUNNER; - }; - if (_role == CARGO && {getNumber (_config >> "isCopilot") == 1}) then { - _role = COPILOT; - }; - if (_role == CARGO && {_simulationLaserDesignate>0 || getNumber (_config >> "primaryObserver") == 1}) then { - _role = COMMANDER; - }; - if (_role == CARGO && {getNumber (_config >> "isPersonTurret") == 1}) then { - _role = FFV; - }; - - _data pushBack [_path, _role]; - -}; - - -_fnc_addTurret = { - - private ["_config", "_path", "_count", "_offset", "_index", "_turretPath", "_turretConfig"]; - - _config = _this select 0; - _path = _this select 1; - - _config = _config >> "Turrets"; - _count = count _config; - - _offset = 0; - - for "_index" from 0 to (_count - 1) do { - _turretPath = _path + [_index - _offset]; - _turretConfig = _config select _index; - if (isClass _turretConfig) then { - [_turretConfig, _turretPath] call _fnc_addTurretUnit; - [_turretConfig, _turretPath] call _fnc_addTurret; - } else { - _offset = _offset + 1; - }; - - }; - -}; - - -_config = configFile >> "CfgVehicles" >> _type; -[_config, []] call _fnc_addTurret; - -_data = [_isAir, _data]; -uiNamespace setVariable [_varName, _data]; - -_data diff --git a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_onMouseZChanged.sqf b/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_onMouseZChanged.sqf deleted file mode 100644 index 92cb5255c3..0000000000 --- a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_onMouseZChanged.sqf +++ /dev/null @@ -1,16 +0,0 @@ -/* - Author: aeroson - - Description: - Callback for mouse wheel change - - Parameters: - None - - Returns: - Nothing -*/ - -if(call AGM_CrewInfo_fnc_canShow) then { - call AGM_CrewInfo_fnc_doShow; -}; diff --git a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_setText.sqf b/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_setText.sqf deleted file mode 100644 index 7c31b910c8..0000000000 --- a/TO_MERGE/agm/NameTags/functions/CrewInfo/fn_setText.sqf +++ /dev/null @@ -1,23 +0,0 @@ -/* - Author: aeroson - - Description: - Sets the text on the dialog - - Parameters: - None - - Returns: - Nothing -*/ - -#define AGM_CrewInfo_TextIDC 11123 - -private["_text", "_ctrl"]; - -disableSerialization; - -_text = _this select 0; -_ctrl = (uiNamespace getVariable "AGM_CrewInfo_dialog") displayCtrl AGM_CrewInfo_TextIDC; -_ctrl ctrlSetStructuredText parseText _text; -_ctrl ctrlCommit 0; diff --git a/TO_MERGE/agm/NameTags/functions/fn_moduleNameTags.sqf b/TO_MERGE/agm/NameTags/functions/fn_moduleNameTags.sqf deleted file mode 100644 index 33b3941dc6..0000000000 --- a/TO_MERGE/agm/NameTags/functions/fn_moduleNameTags.sqf +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Author: CAA-Picard - * - * Initializes the name tags module. - * - * Arguments: - * Whatever the module provides. - * - * Return Value: - * None - */ - -if !(isServer) exitWith {}; - -_logic = _this select 0; -_units = _this select 1; -_activated = _this select 2; - -if !(_activated) exitWith {}; - -AGM_NameTags_Module = true; - -[_logic, "AGM_NameTags_PlayerNamesViewDistance", "PlayerNamesViewDistance" ] call AGM_Core_fnc_readNumericParameterFromModule; -[_logic, "AGM_NameTags_ShowNamesForAI", "ShowNamesForAI" ] call AGM_Core_fnc_readBooleanParameterFromModule; -[_logic, "AGM_NameTags_CrewInfoVisibility", "Visibility" ] call AGM_Core_fnc_readNumericParameterFromModule; - -diag_log text "[AGM]: NameTags Module Initialized."; diff --git a/addons/nametags/$PBOPREFIX$ b/addons/nametags/$PBOPREFIX$ new file mode 100644 index 0000000000..d0e4754193 --- /dev/null +++ b/addons/nametags/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\nametags \ No newline at end of file diff --git a/addons/nametags/CfgEventHandlers.hpp b/addons/nametags/CfgEventHandlers.hpp new file mode 100644 index 0000000000..e75956f440 --- /dev/null +++ b/addons/nametags/CfgEventHandlers.hpp @@ -0,0 +1,11 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/nametags/CfgVehicles.hpp b/addons/nametags/CfgVehicles.hpp new file mode 100644 index 0000000000..444622f0ed --- /dev/null +++ b/addons/nametags/CfgVehicles.hpp @@ -0,0 +1,56 @@ +class CfgVehicles { + class Module_F; + class ACE_ModuleNameTags : Module_F { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + displayName = "Name Tags"; + function = QFUNC(moduleNameTags); + scope = 2; + isGlobal = 1; + icon = QUOTE(PATHTOF(UI\IconNameTags_ca.paa)); + class Arguments { + class PlayerNamesViewDistance { + displayName = "Player Names View Dist."; + description = "Distance in meters at which player names are shown. Default: 5"; + typeName = "NUMBER"; + defaultValue = 5; + }; + class ShowNamesForAI { + displayName = "Show name tags for AI?"; + description = "Show the name and rank tags for friendly AI units? Default: No"; + typeName = "BOOL"; + class values { + class Yes { + name = "Yes"; + value = 1; + }; + class No { + default = 1; + name = "No"; + value = 0; + }; + }; + }; + class Visibility { + displayName = "Visibility of crew info"; + description = "Forces visibility of vehicle crew info, or by default allows players to choose it on their own. Default: Do Not Force"; + typeName = "INT"; + class values { + class DoNotForce { + default = 1; + name = "Do Not Force"; + value = 0; + }; + class ForceShow { + name = "Force Show"; + value = 1; + }; + class ForceHide { + name = "Force Hide"; + value = -1; + }; + }; + }; + }; + }; +}; diff --git a/addons/nametags/RscTitles.hpp b/addons/nametags/RscTitles.hpp new file mode 100644 index 0000000000..7f0ddc2135 --- /dev/null +++ b/addons/nametags/RscTitles.hpp @@ -0,0 +1,41 @@ +#define ACE_CrewInfo_TextIDC 11123 + +#define CT_STRUCTURED_TEXT 13 +#define ST_LEFT 0 + +class RscTitles { + titles[] = { "ACE_CrewInfo_dialog" }; + class ACE_CrewInfo_dialog { + idd = -1; + movingEnable = 1; + duration = 1; + fadein = 0; + fadeout = 999999; + name = "ACE_CrewInfo_dialog"; + controlsBackground[] = { "ACE_CrewInfo_text" }; + onLoad = "uiNamespace setVariable ['ACE_CrewInfo_dialog', _this select 0]"; + onUnload = "uiNamespace setVariable ['ACE_CrewInfo_dialog', objNull]"; + + class ACE_CrewInfo_text { + idc = ACE_CrewInfo_TextIDC; + type = CT_STRUCTURED_TEXT; + style = ST_LEFT; + x = SafeZonex + SafezoneW - 0.31; + y = SafeZoneY + SafeZoneH * 0.4; + w = 0.3; + h = 0.6; + size = 0.018; + colorBackground[] = { 0, 0, 0, 0 }; + colortext[] = { + "(profilenamespace getvariable ['IGUI_TEXT_RGB_R',0])", + "(profilenamespace getvariable ['IGUI_TEXT_RGB_G',1])", + "(profilenamespace getvariable ['IGUI_TEXT_RGB_B',1])", + "(profilenamespace getvariable ['IGUI_TEXT_RGB_A',0.8])" + }; + text = ""; + class Attributes { + align = right; + }; + }; + }; +}; diff --git a/TO_MERGE/agm/NameTags/UI/IconNameTags_ca.paa b/addons/nametags/UI/IconNameTags_ca.paa similarity index 100% rename from TO_MERGE/agm/NameTags/UI/IconNameTags_ca.paa rename to addons/nametags/UI/IconNameTags_ca.paa diff --git a/TO_MERGE/agm/NameTags/UI/icon_position_ffv.paa b/addons/nametags/UI/icon_position_ffv.paa similarity index 100% rename from TO_MERGE/agm/NameTags/UI/icon_position_ffv.paa rename to addons/nametags/UI/icon_position_ffv.paa diff --git a/TO_MERGE/agm/NameTags/clientInit.sqf b/addons/nametags/XEH_postInit.sqf similarity index 51% rename from TO_MERGE/agm/NameTags/clientInit.sqf rename to addons/nametags/XEH_postInit.sqf index aa325bbd7e..a7c084a73e 100644 --- a/TO_MERGE/agm/NameTags/clientInit.sqf +++ b/addons/nametags/XEH_postInit.sqf @@ -1,28 +1,29 @@ -// by commy2 and CAA-Picard +#include "script_component.hpp" +// by commy2 and CAA-Picard if (!hasInterface) exitWith {}; -AGM_NameTags_ShowNamesTime = -10; +GVAR(ShowNamesTime) = -10; addMissionEventHandler ["Draw3D", { - if !(profileNamespace getVariable ["AGM_showPlayerNames", true]) exitWith {}; + if !(profileNamespace getVariable ["ACE_showPlayerNames", true]) exitWith {}; - _player = AGM_player; - if (profileNamespace getVariable ["AGM_showPlayerNamesOnlyOnCursor", true]) then { + _player = ACE_player; + if (profileNamespace getVariable ["ACE_showPlayerNamesOnlyOnCursor", true]) then { _target = cursorTarget; _target = if (_target in allUnitsUAV) then {objNull} else {effectiveCommander _target}; - if (!isNull _target && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {AGM_NameTags_ShowNamesForAI}} && {!(_target getVariable ["AGM_hideName", false])}) then { + if (!isNull _target && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {GVAR(ShowNamesForAI)}} && {!(_target getVariable ["ACE_hideName", false])}) then { _distance = _player distance _target; - _alpha = ((1 - 0.2 * (_distance - AGM_NameTags_PlayerNamesViewDistance)) min 1) * AGM_NameTags_PlayerNamesMaxAlpha; - if (profileNamespace getVariable ["AGM_showPlayerNamesOnlyOnKeyPress", false]) then { - _alpha = _alpha min (1 - (time - AGM_NameTags_ShowNamesTime - 1)); + _alpha = ((1 - 0.2 * (_distance - GVAR(PlayerNamesViewDistance))) min 1) * GVAR(PlayerNamesMaxAlpha); + if (profileNamespace getVariable ["ACE_showPlayerNamesOnlyOnKeyPress", false]) then { + _alpha = _alpha min (1 - (time - GVAR(ShowNamesTime) - 1)); }; - [_player, _target, _alpha, _distance * 0.026] call AGM_NameTags_fnc_drawNameTagIcon; + [_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon); }; } else { _pos = positionCameraToWorld [0, 0, 0]; - _targets = _pos nearObjects ["Man", AGM_NameTags_PlayerNamesViewDistance + 5]; + _targets = _pos nearObjects ["Man", GVAR(PlayerNamesViewDistance) + 5]; if (!surfaceIsWater _pos) then { _pos = ATLtoASL _pos; @@ -36,15 +37,15 @@ addMissionEventHandler ["Draw3D", { { _target = if (_x in allUnitsUAV) then {objNull} else {effectiveCommander _x}; - if (!isNull _target && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {AGM_NameTags_ShowNamesForAI}} && {!(_target getVariable ["AGM_hideName", false])}) then { + if (!isNull _target && {side group _target == playerSide} && {_target != _player} && {isPlayer _target || {GVAR(ShowNamesForAI)}} && {!(_target getVariable ["ACE_hideName", false])}) then { _relPos = (visiblePositionASL _target) vectorDiff _pos; _distance = vectorMagnitude _relPos; _projDist = _relPos vectorDistance (_vecy vectorMultiply (_relPos vectorDotProduct _vecy)); - _alpha = ((1 - 0.2 * (_distance - AGM_NameTags_PlayerNamesViewDistance)) min (1 - 0.15 * (_projDist * 5 - _distance - 3)) min 1) * AGM_NameTags_PlayerNamesMaxAlpha; + _alpha = ((1 - 0.2 * (_distance - GVAR(PlayerNamesViewDistance))) min (1 - 0.15 * (_projDist * 5 - _distance - 3)) min 1) * GVAR(PlayerNamesMaxAlpha); - if (profileNamespace getVariable ["AGM_showPlayerNamesOnlyOnKeyPress", false]) then { - _alpha = _alpha min (1 - (time - AGM_NameTags_ShowNamesTime - 1)); + if (profileNamespace getVariable ["ACE_showPlayerNamesOnlyOnKeyPress", false]) then { + _alpha = _alpha min (1 - (time - GVAR(ShowNamesTime) - 1)); }; // Check if there is line of sight @@ -53,7 +54,7 @@ addMissionEventHandler ["Draw3D", { _alpha = 0; }; }; - [_player, _target, _alpha, _distance * 0.026] call AGM_NameTags_fnc_drawNameTagIcon; + [_player, _target, _alpha, _distance * 0.026] call FUNC(drawNameTagIcon); }; } forEach _targets; }; diff --git a/addons/nametags/XEH_preInit.sqf b/addons/nametags/XEH_preInit.sqf new file mode 100644 index 0000000000..940135dd47 --- /dev/null +++ b/addons/nametags/XEH_preInit.sqf @@ -0,0 +1,10 @@ +#include "script_component.hpp" + + +PREP(canShow); +PREP(doShow); +PREP(drawNameTagIcon); +PREP(getVehicleData); +PREP(moduleNameTags); +PREP(onMouseZChanged); +PREP(setText); diff --git a/addons/nametags/config.cpp b/addons/nametags/config.cpp new file mode 100644 index 0000000000..d979bb2bb4 --- /dev/null +++ b/addons/nametags/config.cpp @@ -0,0 +1,65 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = 0.60; + requiredAddons[] = { "ace_main", "ace_common", "ace_interaction" }; + version = QUOTE(VERSION); + versionStr = QUOTE(VERSION); + versionAr[] = { VERSION_AR }; + author[] = { "commy2", "CAA-Picard" }; + authorUrl = "https://github.com/commy2/"; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" + +class ACE_Common_Default_Keys { + class showNames { + displayName = "$STR_ACE_NameTags_ShowNames"; + condition = "true"; + statement = QUOTE(GVAR(ShowNamesTime) = time; if (call FUNC(canShow)) then{ call FUNC(doShow); };); + key = 29; + shift = 0; + control = 0; + alt = 0; + allowHolding = 1; + }; +}; + +class ACE_Common_Options { + class showPlayerNames { + displayName = "$STR_ACE_NameTags_ShowPlayerNames"; + default = 1; + }; + class showPlayerNamesOnlyOnCursor { + displayName = "$STR_ACE_NameTags_ShowPlayerNamesOnlyOnCursor"; + default = 1; + }; + class showPlayerNamesOnlyOnKeyPress { + displayName = "$STR_ACE_NameTags_ShowPlayerNamesOnlyOnKeyPress"; + default = 0; + }; + class showPlayerRanks { + displayName = "$STR_ACE_NameTags_ShowPlayerRanks"; + default = 1; + }; + class showVehicleCrewInfo { + displayName = "$STR_ACE_CrewInfo_ShowVehicleCrewInfo"; + default = 1; + }; +}; + +class ACE_Parameters_Numeric { + GVAR(PlayerNamesViewDistance) = 5; + GVAR(PlayerNamesMaxAlpha) = 0.8; + GVAR(CrewInfoVisibility) = 0; +}; +class ACE_Parameters_Boolean { + GVAR(ShowNamesForAI) = 0; +}; + +#include diff --git a/addons/nametags/functions/common.hpp b/addons/nametags/functions/common.hpp new file mode 100644 index 0000000000..caa7a3e982 --- /dev/null +++ b/addons/nametags/functions/common.hpp @@ -0,0 +1,26 @@ +/* + 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" + +#define PILOT 0 +#define DRIVER 1 +#define COPILOT PILOT +#define COMMANDER 2 +#define GUNNER 3 +#define FFV 4 +#define CARGO 5 + +#define ROLE_IMAGES [ \ + "a3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa", \ + "a3\ui_f\data\IGUI\Cfg\Actions\getindriver_ca.paa", \ + "a3\ui_f\data\IGUI\Cfg\Actions\getincommander_ca.paa", \ + "a3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa", \ + QUOTE(PATHTOF(UI\icon_position_ffv.paa)), \ + "a3\ui_f\data\IGUI\Cfg\Actions\getincargo_ca.paa" \ +] diff --git a/addons/nametags/functions/fnc_canShow.sqf b/addons/nametags/functions/fnc_canShow.sqf new file mode 100644 index 0000000000..612baac2d3 --- /dev/null +++ b/addons/nametags/functions/fnc_canShow.sqf @@ -0,0 +1,27 @@ +/* + Author: aeroson + + Description: + Might be called several times a second + + Parameters: + None + + Returns: + true if CrewInfo can be shown, false otherwise +*/ + +#include "script_component.hpp" + +private["_player"]; + +_player = ACE_player; + +// AGM_NameTags_ShowVehicleCrewInfo: -1 force NO, 0 doesnt care, 1 force YES + +vehicle _player != _player && +{ + (GVAR(CrewInfoVisibility) == 1) || + (GVAR(CrewInfoVisibility) != -1 && profileNamespace getVariable ["ACE_showVehicleCrewInfo", false]) +} && +{!(vehicle _player isKindOf "ParachuteBase")}; diff --git a/addons/nametags/functions/fnc_doShow.sqf b/addons/nametags/functions/fnc_doShow.sqf new file mode 100644 index 0000000000..16a6329347 --- /dev/null +++ b/addons/nametags/functions/fnc_doShow.sqf @@ -0,0 +1,93 @@ +/* + Author: aeroson + + Description: + Shows the actual text and sets text the crew info + + Parameters: + None + + Returns: + Nothing +*/ + +#include "script_component.hpp" +#include "common.hpp"; + +private["_roleImages", "_player", "_vehicle", "_type", "_config", "_text", "_data", "_isAir", "_turretUnits", "_turretRoles", "_index", "_roleType", "_unit", "_toShow"]; + + +_player = ACE_player; +_vehicle = vehicle _player; +_type = typeOf _vehicle; +_config = configFile >> "CfgVehicles" >> _type; +_text = format[" %2
", getText(_config>>"picture"), getText (_config >> "DisplayName")]; + + + +_data = [_type] call FUNC(getVehicleData); + +_isAir = _data select 0; +_data = _data select 1; + +_turretUnits = [_data, { _vehicle turretUnit (_x select 0) } ] call EFUNC(common,map); +_turretRoles = [_data, { _x select 1 } ] call EFUNC(common,map); + + +_roleType = CARGO; +_toShow = []; +{ + switch (_x) do { + case commander _vehicle: { + _roleType = COMMANDER; + }; + case gunner _vehicle: { + _roleType = GUNNER; + }; + case driver _vehicle: { + _roleType = if(_isAir) then { PILOT } else { DRIVER }; + }; + default { + _index = _turretUnits find _x; + if(_index !=-1 ) then { + _roleType = _turretRoles select _index; + } else { + _roleType = CARGO; + }; + }; + }; + _toShow pushBack [_x, _roleType]; +} forEach crew _vehicle; + + +_toShow = [ + _toShow, + [], + { + _x select 1 + }, + "ASCEND", + { + _unit = _x select 0; + alive _unit + } +] call BIS_fnc_sortBy; + + +_roleImages = ROLE_IMAGES; +{ + _unit = _x select 0; + _roleType = _x select 1; + _text = _text + format["%1
", [_unit] call EFUNC(common,getName), _roleImages select _roleType]; +} forEach _toShow; + + +("ACE_CrewInfo_CrewInfo" call BIS_fnc_rscLayer) cutRsc ["ACE_CrewInfo_dialog", "PLAIN", 1, false]; + +terminate (missionNamespace getVariable [QGVAR(hideCrewInfoHandle), scriptNull]); +GVAR(hideCrewInfoHandle) = 0 spawn { + sleep 2; + ("ACE_CrewInfo_CrewInfo" call BIS_fnc_rscLayer) cutFadeOut 2; +}; + +[_text] call FUNC(setText); diff --git a/TO_MERGE/agm/NameTags/functions/fn_drawNameTagIcon.sqf b/addons/nametags/functions/fnc_drawNameTagIcon.sqf similarity index 52% rename from TO_MERGE/agm/NameTags/functions/fn_drawNameTagIcon.sqf rename to addons/nametags/functions/fnc_drawNameTagIcon.sqf index fd9f66f635..f2a8a1f946 100644 --- a/TO_MERGE/agm/NameTags/functions/fn_drawNameTagIcon.sqf +++ b/addons/nametags/functions/fnc_drawNameTagIcon.sqf @@ -12,15 +12,17 @@ * None. */ +#include "script_component.hpp" + #define TEXTURES_RANKS [ \ - "", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\lieutenant_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\captain_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\major_gs.paa", \ - "\A3\Ui_f\data\GUI\Cfg\Ranks\colonel_gs.paa" \ + "", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\lieutenant_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\captain_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\major_gs.paa", \ + "\A3\Ui_f\data\GUI\Cfg\Ranks\colonel_gs.paa" \ ] private ["_player", "_target", "_alpha", "_heightOffset", "_height", "_position", "_color", "_name", "_rank", "_size"]; @@ -37,25 +39,25 @@ _position = visiblePositionASL _target; _position set [2, ((_target modelToWorld [0,0,0]) select 2) + _height + _heightOffset]; _color = if !(group _target == group _player) then { - [0.77, 0.51, 0.08, _alpha] + [0.77, 0.51, 0.08, _alpha] } else { - [[1, 1, 1, _alpha], [1, 0, 0, _alpha], [0, 1, 0, _alpha], [0, 0, 1, _alpha], [1, 1, 0, _alpha]] select (["MAIN", "RED", "GREEN", "BLUE", "YELLOW"] find (if (_target == _player) then {0} else {assignedTeam _target})) max 0 + [[1, 1, 1, _alpha], [1, 0, 0, _alpha], [0, 1, 0, _alpha], [0, 0, 1, _alpha], [1, 1, 0, _alpha]] select (["MAIN", "RED", "GREEN", "BLUE", "YELLOW"] find (if (_target == _player) then {0} else {assignedTeam _target})) max 0 }; -_name = [_target, true] call AGM_Core_fnc_getName; +_name = [_target, true] call EFUNC(common,getName); _rank = TEXTURES_RANKS select ((["PRIVATE", "CORPORAL", "SERGEANT", "LIEUTENANT", "CAPTAIN", "MAJOR", "COLONEL"] find rank _target) + 1); -_size = [0, 1] select (profileNamespace getVariable ["AGM_showPlayerRanks", true]); +_size = [0, 1] select (profileNamespace getVariable ["ACE_showPlayerRanks", true]); drawIcon3D [ - _rank, - _color, - _position, - _size, - _size, - 0, - _name, - 2, - 0.033, - "PuristaMedium" + _rank, + _color, + _position, + _size, + _size, + 0, + _name, + 2, + 0.033, + "PuristaMedium" ]; diff --git a/addons/nametags/functions/fnc_getVehicleData.sqf b/addons/nametags/functions/fnc_getVehicleData.sqf new file mode 100644 index 0000000000..5914bc1f7e --- /dev/null +++ b/addons/nametags/functions/fnc_getVehicleData.sqf @@ -0,0 +1,123 @@ +/* + 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 + ] +*/ + +#include "script_component.hpp" +#include "common.hpp"; + + +private ["_type", "_varName", "_data"]; + +_type = _this select 0; + +_varName = format ["AGM_CrewInfo_Cache_%1", _type]; +_data = + (uiNamespace getVariable _varName); + +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; + _path = _this select 1; + _role = CARGO; + + _simulationEmpty = 0; + _simulationLaserDesignate = 0; + _simulationOther = 0; + { + { + _magazine = configFile >> "CfgMagazines" >> _x; + _ammo = configFile >> "CfgAmmo" >> getText (_magazine >> "ammo"); + _simulation = getText (_ammo >> "simulation"); + + if(_simulation=="") then { + _simulationEmpty = _simulationEmpty + 1; + } else { + if(_simulation=="laserDesignate") then { + _simulationLaserDesignate = _simulationLaserDesignate + 1; + } else { + _simulationOther = _simulationOther + 1; + }; + }; + + } forEach getArray (configFile >> "CfgWeapons" >> _x >> "magazines"); + } forEach getArray (_config >> "weapons"); + + if(_simulationOther>0) then { + _role = GUNNER; + }; + if (_role == CARGO && {getNumber (_config >> "isCopilot") == 1}) then { + _role = COPILOT; + }; + if (_role == CARGO && {_simulationLaserDesignate>0 || getNumber (_config >> "primaryObserver") == 1}) then { + _role = COMMANDER; + }; + if (_role == CARGO && {getNumber (_config >> "isPersonTurret") == 1}) then { + _role = FFV; + }; + + _data pushBack [_path, _role]; + +}; + + +_fnc_addTurret = { + + private ["_config", "_path", "_count", "_offset", "_index", "_turretPath", "_turretConfig"]; + + _config = _this select 0; + _path = _this select 1; + + _config = _config >> "Turrets"; + _count = count _config; + + _offset = 0; + + for "_index" from 0 to (_count - 1) do { + _turretPath = _path + [_index - _offset]; + _turretConfig = _config select _index; + if (isClass _turretConfig) then { + [_turretConfig, _turretPath] call _fnc_addTurretUnit; + [_turretConfig, _turretPath] call _fnc_addTurret; + } else { + _offset = _offset + 1; + }; + + }; + +}; + + +_config = configFile >> "CfgVehicles" >> _type; +[_config, []] call _fnc_addTurret; + +_data = [_isAir, _data]; +uiNamespace setVariable [_varName, _data]; + +_data diff --git a/addons/nametags/functions/fnc_moduleNameTags.sqf b/addons/nametags/functions/fnc_moduleNameTags.sqf new file mode 100644 index 0000000000..b701a2db8c --- /dev/null +++ b/addons/nametags/functions/fnc_moduleNameTags.sqf @@ -0,0 +1,29 @@ +/* + * Author: CAA-Picard + * + * Initializes the name tags module. + * + * Arguments: + * Whatever the module provides. + * + * Return Value: + * None + */ + +#include "script_component.hpp" + +if !(isServer) exitWith {}; + +_logic = _this select 0; +_units = _this select 1; +_activated = _this select 2; + +if !(_activated) exitWith {}; + +GVAR(Module) = true; + +[_logic, QGVAR(PlayerNamesViewDistance), "PlayerNamesViewDistance" ] call EFUNC(common,readNumericParameterFromModule); +[_logic, QGVAR(ShowNamesForAI), "ShowNamesForAI" ] call EFUNC(common,readBooleanParameterFromModule); +[_logic, QGVAR(CrewInfoVisibility), "Visibility" ] call EFUNC(common,readNumericParameterFromModule); + +diag_log text "[ACE]: NameTags Module Initialized."; diff --git a/addons/nametags/functions/fnc_onMouseZChanged.sqf b/addons/nametags/functions/fnc_onMouseZChanged.sqf new file mode 100644 index 0000000000..8892f201bc --- /dev/null +++ b/addons/nametags/functions/fnc_onMouseZChanged.sqf @@ -0,0 +1,18 @@ +/* + Author: aeroson + + Description: + Callback for mouse wheel change + + Parameters: + None + + Returns: + Nothing +*/ + +#include "script_component.hpp" + +if(call FUNC(canShow)) then { + call FUNC(doShow); +}; diff --git a/addons/nametags/functions/fnc_setText.sqf b/addons/nametags/functions/fnc_setText.sqf new file mode 100644 index 0000000000..e7d1b748b1 --- /dev/null +++ b/addons/nametags/functions/fnc_setText.sqf @@ -0,0 +1,25 @@ +/* + Author: aeroson + + Description: + Sets the text on the dialog + + Parameters: + None + + Returns: + Nothing +*/ + +#include "script_component.hpp" + +#define TextIDC 11123 + +private["_text", "_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/script_component.hpp b/addons/nametags/functions/script_component.hpp new file mode 100644 index 0000000000..b8135e8ecd --- /dev/null +++ b/addons/nametags/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\nametags\script_component.hpp" diff --git a/addons/nametags/script_component.hpp b/addons/nametags/script_component.hpp new file mode 100644 index 0000000000..6cffb95618 --- /dev/null +++ b/addons/nametags/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT nametags +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_NAMETAGS + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_NAMETAGS + #define DEBUG_SETTINGS DEBUG_SETTINGS_NAMETAGS +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/TO_MERGE/agm/NameTags/stringtable.xml b/addons/nametags/stringtable.xml similarity index 91% rename from TO_MERGE/agm/NameTags/stringtable.xml rename to addons/nametags/stringtable.xml index a558b8986f..7d085b9d44 100644 --- a/TO_MERGE/agm/NameTags/stringtable.xml +++ b/addons/nametags/stringtable.xml @@ -1,8 +1,8 @@  - + - + Show Names Namen anzeigen Mostrar nombres @@ -12,7 +12,7 @@ Nevek mutatása Показать имена - + Show player names Spielernamen anzeigen Mostrar nombres de jugadores @@ -24,7 +24,7 @@ Mostra i nomi dei giocatori Показать имена игроков - + Show player name only on cursor (requires player names) Pokaż nazwę gracza tylko pod kursorem Mostrar nombres solo en el cursor (requiere Mostrar nombres de jugadores) @@ -36,7 +36,7 @@ Játékosok nevének mutatása (névcímke szükséges) Показать имена игроков только под курсором (требует имен игроков) - + Show player name only on keypress (requires player names) Spielernamen nur auf Tastendruck anzeigen (benötigt Spielernamen) Mostrar nombres solo al pulsar (requiere Mostrar nombres de jugadores) @@ -46,7 +46,7 @@ Játékosnevek mutatása gombnyomásra(névcíme szükséges) Показать имена игроков только по нажатию клавиши (требует имен игроков) - + Show player ranks (requires player names) Spielerränge anzeigen (benötig Spielernamen) Pokaż rangi graczy (wymaga nazw graczy) @@ -60,7 +60,7 @@ - + Show vehicle crew info Zeige Fahrzeugbesatzung Mostrar tripulantes @@ -69,4 +69,4 @@ Показать экипаж - \ No newline at end of file +