From e9af0864541bf4e7343daa2e4b62305a3d7daa7b Mon Sep 17 00:00:00 2001 From: mharis001 <34453221+mharis001@users.noreply.github.com> Date: Sat, 28 Apr 2018 18:23:44 -0400 Subject: [PATCH] Interaction Menu - Add ability to change selector color (#6292) * Add selector color changing * Setup colors once at init --- addons/interact_menu/XEH_clientInit.sqf | 17 ++++++++--------- addons/interact_menu/XEH_preInit.sqf | 2 ++ addons/interact_menu/functions/fnc_render.sqf | 2 +- .../functions/fnc_renderSelector.sqf | 4 ++-- addons/interact_menu/initSettings.sqf | 9 +++++++++ addons/interact_menu/stringtable.xml | 3 +++ 6 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 addons/interact_menu/initSettings.sqf diff --git a/addons/interact_menu/XEH_clientInit.sqf b/addons/interact_menu/XEH_clientInit.sqf index dbe9d548cd..d6d5cd065c 100644 --- a/addons/interact_menu/XEH_clientInit.sqf +++ b/addons/interact_menu/XEH_clientInit.sqf @@ -1,4 +1,3 @@ -//XEH_clientInit.sqf #include "script_component.hpp" if (!hasInterface) exitWith {}; @@ -10,16 +9,16 @@ GVAR(cachedBuildingActionPairs) = []; GVAR(ParsedTextCached) = []; -["ace_settingChanged", { - params ["_name"]; - if (({_x == _name} count [QGVAR(colorTextMax), QGVAR(colorTextMin), QGVAR(colorShadowMax), QGVAR(colorShadowMin), QGVAR(textSize), QGVAR(shadowSetting)]) == 1) then { - [] call FUNC(setupTextColors); - }; -}] call CBA_fnc_addEventHandler; - ["ace_settingsInitialized", { - //Setup text/shadow/size/color settings matrix + // Setup text/shadow/size/color settings matrix [] call FUNC(setupTextColors); + // Setting changed added here so color setup happens once at init + ["ace_settingChanged", { + params ["_name"]; + if (_name in [QGVAR(colorTextMax), QGVAR(colorTextMin), QGVAR(colorShadowMax), QGVAR(colorShadowMin), QGVAR(textSize), QGVAR(shadowSetting)]) then { + [] call FUNC(setupTextColors); + }; + }] call CBA_fnc_addEventHandler; // Install the render EH on the main display addMissionEventHandler ["Draw3D", {call FUNC(render)}]; }] call CBA_fnc_addEventHandler; diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index 817693c93c..a05eac1bb5 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -6,6 +6,8 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; +#include "initSettings.sqf" + GVAR(ActNamespace) = [] call CBA_fnc_createNamespace; GVAR(ActSelfNamespace) = [] call CBA_fnc_createNamespace; diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf index 1c3ed50c92..47ddcf938d 100644 --- a/addons/interact_menu/functions/fnc_render.sqf +++ b/addons/interact_menu/functions/fnc_render.sqf @@ -28,7 +28,7 @@ if (GVAR(openedMenuType) >= 0) then { // Render all available nearby interactions call FUNC(renderActionPoints); - // Draw the red selector only when there's no cursor + // Draw the selector only when there's no cursor if !(uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then { [[0.5,0.5], "\a3\ui_f\data\IGUI\Cfg\Cursors\selected_ca.paa"] call FUNC(renderSelector); }; diff --git a/addons/interact_menu/functions/fnc_renderSelector.sqf b/addons/interact_menu/functions/fnc_renderSelector.sqf index c2fe5f932c..2acc66c8eb 100644 --- a/addons/interact_menu/functions/fnc_renderSelector.sqf +++ b/addons/interact_menu/functions/fnc_renderSelector.sqf @@ -30,10 +30,10 @@ if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then { private _ctrl = GVAR(iconCtrls) select GVAR(iconCount); private _pos = if (GVAR(UseListMenu)) then { - [_ctrl, GVAR(iconCount), format ["", _icon]] call FUNC(ctrlSetParsedTextCached); + [_ctrl, GVAR(iconCount), format ["", _icon, GVAR(selectorColorHex)]] call FUNC(ctrlSetParsedTextCached); [(_sPos select 0)-(0.014*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.05*SafeZoneW, 0.035*SafeZoneW] } else { - [_ctrl, GVAR(iconCount), format ["", _icon]] call FUNC(ctrlSetParsedTextCached); + [_ctrl, GVAR(iconCount), format ["", _icon, GVAR(selectorColorHex)]] call FUNC(ctrlSetParsedTextCached); [(_sPos select 0)-(0.050*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.1*SafeZoneW, 0.035*SafeZoneW] }; diff --git a/addons/interact_menu/initSettings.sqf b/addons/interact_menu/initSettings.sqf new file mode 100644 index 0000000000..45c9fdbd3b --- /dev/null +++ b/addons/interact_menu/initSettings.sqf @@ -0,0 +1,9 @@ +[ + QGVAR(selectorColor), + "COLOR", + localize LSTRING(SelectorColor), + format ["ACE %1", localize LSTRING(Category_InteractionMenu)], + [1, 0, 0], + false, + {GVAR(selectorColorHex) = _this call BIS_fnc_colorRGBtoHTML} // Stored in Hex to avoid constant conversion +] call CBA_settings_fnc_init; diff --git a/addons/interact_menu/stringtable.xml b/addons/interact_menu/stringtable.xml index a05dcee3e4..ed961e4ead 100644 --- a/addons/interact_menu/stringtable.xml +++ b/addons/interact_menu/stringtable.xml @@ -446,5 +446,8 @@ 使選單的動畫速度更快,並減少子選項顯現出來的時間 상호 작용을 표시하기 위해 메뉴 애니메이션을 빠르게 만들고 마우스를 가져 오는 데 필요한 시간을 줄입니다. + + Selector Color +