From 89fb57fdcf147e3c7a89459c37248f47e48adb55 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Wed, 21 Apr 2021 01:26:48 +0400 Subject: [PATCH] User Interface - Add setting for Development Build watermark (#8140) Co-authored-by: jonpas --- addons/ui/ACE_UI.hpp | 104 ++++++++++-------- addons/ui/XEH_clientInit.sqf | 11 +- addons/ui/XEH_preInit.sqf | 2 + .../ui/functions/fnc_setAdvancedElement.sqf | 16 +-- addons/ui/initSettings.sqf | 9 ++ addons/ui/script_component.hpp | 1 + addons/ui/stringtable.xml | 4 + 7 files changed, 88 insertions(+), 59 deletions(-) create mode 100644 addons/ui/initSettings.sqf diff --git a/addons/ui/ACE_UI.hpp b/addons/ui/ACE_UI.hpp index 7bf395da57..4fbf7038ef 100644 --- a/addons/ui/ACE_UI.hpp +++ b/addons/ui/ACE_UI.hpp @@ -1,174 +1,182 @@ class ACE_UI { + class devWatermark { + idd = IDD_MISSION; + elements[] = {11400}; + location = ANYWHERE; + class conditions { + isDevelopmentBranch = QUOTE(productVersion select 4 == 'Development'); + }; + }; class weaponName { - idd = 300; - elements[] = {118}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_WEAPON}; location = GROUND_ONLY; class conditions {}; }; class weaponNameBackground { - idd = 300; + idd = IDD_UNITINFO; elements[] = {1001, 1008}; location = GROUND_ONLY; class conditions {}; }; class firingMode { - idd = 300; - elements[] = {187, 1203}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_WEAPON_MODE_TEXTURE, 1203}; location = GROUND_ONLY; class conditions {}; }; class ammoType { - idd = 300; - elements[] = {155}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_WEAPON_AMMO}; location = GROUND_ONLY; class conditions {}; }; class ammoCount { - idd = 300; - elements[] = {184}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_AMMOCOUNT}; location = GROUND_ONLY; class conditions {}; }; class magCount { - idd = 300; - elements[] = {185}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_MAGCOUNT}; location = GROUND_ONLY; class conditions {}; }; class throwableName { - idd = 300; + idd = IDD_UNITINFO; elements[] = {152}; location = GROUND_ONLY; class conditions {}; }; class throwableCount { - idd = 300; + idd = IDD_UNITINFO; elements[] = {151}; location = GROUND_ONLY; class conditions {}; }; class zeroing { - idd = 300; - elements[] = {168}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_WEAPON_ELEVATION}; location = GROUND_ONLY; class conditions {}; }; class weaponLowerInfoBackground { - idd = 300; + idd = IDD_UNITINFO; elements[] = {1202}; location = GROUND_ONLY; class conditions {}; }; class staminaBar { - idd = 305; - elements[] = {193}; + idd = IDD_STAMINA_BAR; + elements[] = {IDC_IGUI_STAMINA_BAR}; location = GROUND_ONLY; class conditions {}; }; class stance { - idd = 303; - elements[] = {188, 1201}; + idd = IDD_STANCEINFO; + elements[] = {IDC_IGUI_STANCE_INDICATOR, 1201}; location = GROUND_ONLY; class conditions {}; }; class gunnerWeaponName { - idd = 300; - elements[] = {118}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_WEAPON}; location = VEHICLE_ONLY; class conditions {}; }; class gunnerWeaponNameBackground { - idd = 300; + idd = IDD_UNITINFO; elements[] = {1001, 1008}; location = VEHICLE_ONLY; class conditions {}; }; class gunnerFiringMode { - idd = 300; - elements[] = {187, 1203}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_WEAPON_MODE_TEXTURE, 1203}; location = VEHICLE_ONLY; class conditions {}; }; class gunnerAmmoType { - idd = 300; - elements[] = {155}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_WEAPON_AMMO}; location = VEHICLE_ONLY; class conditions {}; }; class gunnerAmmoCount { - idd = 300; - elements[] = {184}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_AMMOCOUNT}; location = VEHICLE_ONLY; class conditions {}; }; class gunnerMagCount { - idd = 300; - elements[] = {185}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_MAGCOUNT}; location = VEHICLE_ONLY; class conditions {}; }; class gunnerLaunchableName { - idd = 300; + idd = IDD_UNITINFO; elements[] = {152}; location = VEHICLE_ONLY; class conditions {}; }; class gunnerLaunchableCount { - idd = 300; + idd = IDD_UNITINFO; elements[] = {151}; location = VEHICLE_ONLY; class conditions {}; }; class gunnerZeroing { - idd = 300; - elements[] = {168}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_WEAPON_ELEVATION}; location = VEHICLE_ONLY; class conditions {}; }; class gunnerWeaponLowerInfoBackground { - idd = 300; + idd = IDD_UNITINFO; elements[] = {1202}; location = VEHICLE_ONLY; class conditions {}; }; class vehicleName { - idd = 300; - elements[] = {120}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_VEHICLE}; location = VEHICLE_ONLY; class conditions {}; }; class vehicleNameBackground { - idd = 300; + idd = IDD_UNITINFO; elements[] = {1000, 1013}; location = VEHICLE_ONLY; class conditions {}; }; class vehicleFuelBar { - idd = 300; - elements[] = {113, 1202}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_VALUE_FUEL, 1202}; location = VEHICLE_ONLY; class conditions {}; }; class vehicleSpeed { - idd = 300; - elements[] = {121, 1004, 1006}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_SPEED, 1004, 1006}; location = VEHICLE_ONLY; class conditions {}; }; class vehicleAltitude { - idd = 300; - elements[] = {122, 1005, 1014}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_ALT, 1005, 1014}; location = VEHICLE_ONLY; class conditions {}; }; class vehicleDamage { - idd = 300; - elements[] = {111}; + idd = IDD_UNITINFO; + elements[] = {IDC_IGUI_HITZONES}; location = VEHICLE_ONLY; class conditions {}; }; class vehicleInfoBackground { - idd = 300; + idd = IDD_UNITINFO; elements[] = {1200}; location = VEHICLE_ONLY; class conditions {}; diff --git a/addons/ui/XEH_clientInit.sqf b/addons/ui/XEH_clientInit.sqf index 5cfa322b0d..dfef530fcf 100644 --- a/addons/ui/XEH_clientInit.sqf +++ b/addons/ui/XEH_clientInit.sqf @@ -33,16 +33,19 @@ GVAR(elementsSet) = call CBA_fnc_createNamespace; }] call CBA_fnc_addEventHandler; // On changing settings - ["ace_settingChanged", { - params ["_name"]; + ["CBA_SettingChanged", { + params ["_name", "_value"]; + + private _delimPos = count QUOTE(DOUBLES(ADDON,)); + if (_name select [0, _delimPos] != QUOTE(DOUBLES(ADDON,))) exitWith {}; if (_name in ELEMENTS_BASIC) then { [true] call FUNC(setElements); } else { - private _nameNoPrefix = toLower (_name select [7]); + private _nameNoPrefix = toLower (_name select [_delimPos]); private _cachedElement = GVAR(configCache) getVariable _nameNoPrefix; if (!isNil "_cachedElement") then { - [_nameNoPrefix, missionNamespace getVariable _name, true] call FUNC(setAdvancedElement); + [_nameNoPrefix, _value, true] call FUNC(setAdvancedElement); }; }; }] call CBA_fnc_addEventHandler; diff --git a/addons/ui/XEH_preInit.sqf b/addons/ui/XEH_preInit.sqf index b937d5d81c..8fe8c38b0d 100644 --- a/addons/ui/XEH_preInit.sqf +++ b/addons/ui/XEH_preInit.sqf @@ -8,4 +8,6 @@ PREP_RECOMPILE_END; GVAR(interfaceInitialized) = false; +#include "initSettings.sqf" + ADDON = true; diff --git a/addons/ui/functions/fnc_setAdvancedElement.sqf b/addons/ui/functions/fnc_setAdvancedElement.sqf index 4e2ececf6c..96453f1cfb 100644 --- a/addons/ui/functions/fnc_setAdvancedElement.sqf +++ b/addons/ui/functions/fnc_setAdvancedElement.sqf @@ -66,6 +66,7 @@ if (!_force) then { }; }; +private _displays = ((uiNamespace getVariable "IGUI_displays") + [findDisplay IDD_MISSION]) select {_idd == ctrlIDD _x}; private _fade = [1, 0] select _show; // Disable/Enable elements @@ -75,15 +76,16 @@ private _success = false; // Loop through IGUI displays as they can be present several times for some reason { - if (_idd == ctrlIDD _x) then { - TRACE_4("Setting Element Visibility",_element,_fade,_idd,_idc); + _success = true; - (_x displayCtrl _idc) ctrlSetFade _fade; - (_x displayCtrl _idc) ctrlCommit 0; + private _control = _x displayCtrl _idc; + if (ctrlFade _control == _fade) then {continue}; - _success = true; - }; - } count (uiNamespace getVariable "IGUI_displays"); + TRACE_4("Setting Element Visibility",_element,_fade,_idd,_idc); + + _control ctrlSetFade _fade; + _control ctrlCommit 0; + } count _displays; nil } count _elements; diff --git a/addons/ui/initSettings.sqf b/addons/ui/initSettings.sqf new file mode 100644 index 0000000000..eebda7e2e4 --- /dev/null +++ b/addons/ui/initSettings.sqf @@ -0,0 +1,9 @@ +if (productVersion select 4 == 'Development') then { + [ + QGVAR(devWatermark), + "CHECKBOX", + LSTRING(devWatermark), + "ACE " + LLSTRING(Category), + true + ] call CBA_fnc_addSetting; +}; diff --git a/addons/ui/script_component.hpp b/addons/ui/script_component.hpp index 11b0d08715..d98691e0de 100644 --- a/addons/ui/script_component.hpp +++ b/addons/ui/script_component.hpp @@ -16,6 +16,7 @@ #include "\z\ace\addons\main\script_macros.hpp" +#include "\a3\ui_f\hpp\defineResincl.inc" // Basic Elements #define ELEMENTS_BASIC [QGVAR(soldierVehicleWeaponInfo), QGVAR(vehicleRadar), QGVAR(vehicleCompass), QGVAR(commandMenu), QGVAR(groupBar)] diff --git a/addons/ui/stringtable.xml b/addons/ui/stringtable.xml index 423f5e07a8..3f6b0483ce 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -156,6 +156,10 @@ Barra de grupo Grup Göstergesi + + Development Build Watermark + Водяной знак Development Build + Weapon Name Název zbraně