diff --git a/addons/nametags/XEH_PREP.hpp b/addons/nametags/XEH_PREP.hpp index 93a8ff6626..5d99258d27 100644 --- a/addons/nametags/XEH_PREP.hpp +++ b/addons/nametags/XEH_PREP.hpp @@ -8,3 +8,4 @@ PREP(moduleNameTags); PREP(onDraw3d); PREP(setText); PREP(updateSettings); +PREP(setFactionRankIcons); diff --git a/addons/nametags/XEH_postInit.sqf b/addons/nametags/XEH_postInit.sqf index bebe840b47..22c787b3f2 100644 --- a/addons/nametags/XEH_postInit.sqf +++ b/addons/nametags/XEH_postInit.sqf @@ -5,6 +5,10 @@ if (!hasInterface) exitWith {}; +if (isNil QGVAR(factionRanks)) then { + GVAR(factionRanks) = [] call CBA_fnc_createNamespace; +}; + GVAR(showNamesTime) = -10; // Add keybinds diff --git a/addons/nametags/functions/fnc_drawNameTagIcon.sqf b/addons/nametags/functions/fnc_drawNameTagIcon.sqf index a58dc606f4..a765f1b802 100644 --- a/addons/nametags/functions/fnc_drawNameTagIcon.sqf +++ b/addons/nametags/functions/fnc_drawNameTagIcon.sqf @@ -37,7 +37,12 @@ _fnc_parameters = { _size = 1; } else { if (_drawRank && {rank _target != ""}) then { - _icon = format["\A3\Ui_f\data\GUI\Cfg\Ranks\%1_gs.paa", toLower rank _target]; + _icon = GVAR(factionRanks) getVariable faction _target; + if (!isNil "_icon") then { + _icon = _icon param [ALL_RANKS find rank _target, ""]; + } else { + _icon = format ["\A3\Ui_f\data\GUI\Cfg\Ranks\%1_gs.paa", rank _target]; + }; _size = 1; }; }; diff --git a/addons/nametags/functions/fnc_setFactionRankIcons.sqf b/addons/nametags/functions/fnc_setFactionRankIcons.sqf new file mode 100644 index 0000000000..905e1137fe --- /dev/null +++ b/addons/nametags/functions/fnc_setFactionRankIcons.sqf @@ -0,0 +1,37 @@ +/* + * Author: commy2 + * Sets a custom set of icons for a specified faction. + * + * Arguments: + * 0: Faction + * 1: Rank Icons + * + * Return Value: + * Successful? + * + * Example: + * ["BLU_F", [ + * "\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" + * ] call ace_nametags_fnc_setFactionRankIcons + * + * Public: Yes + */ +#include "script_component.hpp" + +if (isNil QGVAR(factionRanks)) then { + GVAR(factionRanks) = [] call CBA_fnc_createNamespace; +}; + +params [["_faction", "", [""]], ["_icons", [], [[]], [7]]]; + +if !(_faction != "" && {_icons isEqualTypeAll ""}) exitWith {false}; + +GVAR(factionRanks) setVariable [_faction, _icons]; + +true diff --git a/addons/nametags/script_component.hpp b/addons/nametags/script_component.hpp index a4cdaeeb9d..fff9a31de3 100644 --- a/addons/nametags/script_component.hpp +++ b/addons/nametags/script_component.hpp @@ -22,3 +22,5 @@ #define ICON_NAME_RANK 2 #define ICON_NAME_SPEAK 3 #define ICON_SPEAK 4 + +#define ALL_RANKS ["PRIVATE", "CORPORAL", "SERGEANT", "LIEUTENANT", "CAPTAIN", "MAJOR", "COLONEL"]