From e00723039b0d7d1e2101ed527c0f7aa1e3b0c9bb Mon Sep 17 00:00:00 2001 From: zharf Date: Sat, 17 Nov 2018 05:30:46 +0200 Subject: [PATCH] Nametags - Adjustable colors settings (#6641) * Move hard coded nametag team colors to settings Also made the default colors lighter to make them easier to read * Added myself to contributors * Fixed Nametag to Name Tag * Optimized array copying * Moved team color settings to color subcategory and used vanilla localization strings * Split a long line into a more readable multiline solution --- AUTHORS.txt | 1 + addons/nametags/ACE_Settings.hpp | 6 +- addons/nametags/XEH_preInit.sqf | 2 + .../functions/fnc_drawNameTagIcon.sqf | 12 +++- addons/nametags/initSettings.sqf | 56 +++++++++++++++++++ 5 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 addons/nametags/initSettings.sqf diff --git a/AUTHORS.txt b/AUTHORS.txt index c3c4d7f12e..05db46c820 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -65,6 +65,7 @@ Drill Dudakov aka [OMCB]Kaban Drofseh Dslyecxi +Eclipser ElTyranos eRazeri evromalarkey diff --git a/addons/nametags/ACE_Settings.hpp b/addons/nametags/ACE_Settings.hpp index 702cba07cd..5b5d7b79cc 100644 --- a/addons/nametags/ACE_Settings.hpp +++ b/addons/nametags/ACE_Settings.hpp @@ -1,10 +1,6 @@ class ACE_Settings { class GVAR(defaultNametagColor) { - value[] = {0.77, 0.51, 0.08, 1}; - typeName = "COLOR"; - isClientSettable = 1; - displayName = CSTRING(DefaultNametagColor); - category = CSTRING(Module_DisplayName); + movedToSQF = 1; }; class GVAR(showPlayerNames) { value = 1; diff --git a/addons/nametags/XEH_preInit.sqf b/addons/nametags/XEH_preInit.sqf index b47cf6628d..9361d05015 100644 --- a/addons/nametags/XEH_preInit.sqf +++ b/addons/nametags/XEH_preInit.sqf @@ -6,4 +6,6 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; +#include "initSettings.sqf" + ADDON = true; diff --git a/addons/nametags/functions/fnc_drawNameTagIcon.sqf b/addons/nametags/functions/fnc_drawNameTagIcon.sqf index 093496cfb8..61a8a1b930 100644 --- a/addons/nametags/functions/fnc_drawNameTagIcon.sqf +++ b/addons/nametags/functions/fnc_drawNameTagIcon.sqf @@ -57,10 +57,18 @@ _fnc_parameters = { private _color = [1, 1, 1, _alpha]; if ((group _target) != (group _player)) then { _color = +GVAR(defaultNametagColor); //Make a copy, then multiply both alpha values (allows client to decrease alpha in settings) - _color set [3, (_color select 3) * _alpha]; } else { - _color = [[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 ([assignedTeam _target] param [0, "MAIN"])) max 0); + _color = +([ + GVAR(nametagColorMain), + GVAR(nametagColorRed), + GVAR(nametagColorGreen), + GVAR(nametagColorBlue), + GVAR(nametagColorYellow) + ] select ( + (["MAIN", "RED", "GREEN", "BLUE", "YELLOW"] find ([assignedTeam _target] param [0, "MAIN"])) max 0 + )); }; + _color set [3, (_color select 3) * _alpha]; private _scale = [0.333, 0.5, 0.666, 0.83333, 1] select GVAR(tagSize); diff --git a/addons/nametags/initSettings.sqf b/addons/nametags/initSettings.sqf new file mode 100644 index 0000000000..b2cf482ce1 --- /dev/null +++ b/addons/nametags/initSettings.sqf @@ -0,0 +1,56 @@ +// CBA Settings [ADDON: ace_nametags]: + +[ + QGVAR(defaultNametagColor), "COLOR", + [LSTRING(DefaultNametagColor)], + [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize "str_a3_rscdisplaygameoptions_buttongui"], + [0.77, 0.51, 0.08, 1], + false, // isGlobal + {[QGVAR(defaultNametagColor), _this] call EFUNC(common,cbaSettings_settingChanged)} +] call CBA_settings_fnc_init; + +[ + QGVAR(nametagColorMain), "COLOR", + ["str_team_main"], + [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize "str_a3_rscdisplaygameoptions_buttongui"], + [1.00, 1.00, 1.00, 1], + false, // isGlobal + {[QGVAR(nametagColorMain), _this] call EFUNC(common,cbaSettings_settingChanged)} +] call CBA_settings_fnc_init; + +[ + QGVAR(nametagColorRed), "COLOR", + ["str_team_red"], + [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize "str_a3_rscdisplaygameoptions_buttongui"], + [1.00, 0.67, 0.67, 1], + false, // isGlobal + {[QGVAR(nametagColorRed), _this] call EFUNC(common,cbaSettings_settingChanged)} +] call CBA_settings_fnc_init; + +[ + QGVAR(nametagColorGreen), "COLOR", + ["str_team_green"], + [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize "str_a3_rscdisplaygameoptions_buttongui"], + [0.67, 1.00, 0.67, 1], + false, // isGlobal + {[QGVAR(nametagColorGreen), _this] call EFUNC(common,cbaSettings_settingChanged)} +] call CBA_settings_fnc_init; + +[ + QGVAR(nametagColorBlue), "COLOR", + ["str_team_blue"], + [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize "str_a3_rscdisplaygameoptions_buttongui"], + [0.67, 0.67, 1.00, 1], + false, // isGlobal + {[QGVAR(nametagColorBlue), _this] call EFUNC(common,cbaSettings_settingChanged)} +] call CBA_settings_fnc_init; + +[ + QGVAR(nametagColorYellow), + "COLOR", + ["str_team_yellow"], + [format ["ACE %1", localize LSTRING(Module_DisplayName)], localize "str_a3_rscdisplaygameoptions_buttongui"], + [1.00, 1.00, 0.67, 1], + false, // isGlobal + {[QGVAR(nametagColorYellow), _this] call EFUNC(common,cbaSettings_settingChanged)} +] call CBA_settings_fnc_init;