From 5a2f1c06db091ec4975838dbc1e082bd20f63a42 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 20 May 2016 19:08:16 +0200 Subject: [PATCH 1/7] Improve selective UI API, Disable ammo count when reload component is loaded, Fix stance UI --- addons/common/RscInfoType.hpp | 4 ++ addons/reload/XEH_postInit.sqf | 5 ++ addons/reload/config.cpp | 2 +- addons/reload/script_component.hpp | 2 +- addons/ui/ACE_Settings.hpp | 4 +- addons/ui/CfgVehicles.hpp | 2 +- addons/ui/XEH_clientInit.sqf | 19 +++++++- addons/ui/XEH_preInit.sqf | 1 + .../ui/functions/fnc_setAdvancedElement.sqf | 14 +++--- .../ui/functions/fnc_setElementVisibility.sqf | 47 ++++++++++++++----- addons/ui/functions/fnc_setElements.sqf | 4 -- addons/ui/script_component.hpp | 2 +- addons/ui/stringtable.xml | 5 +- 13 files changed, 80 insertions(+), 31 deletions(-) diff --git a/addons/common/RscInfoType.hpp b/addons/common/RscInfoType.hpp index e5af2454cbc..32bc0b698f8 100644 --- a/addons/common/RscInfoType.hpp +++ b/addons/common/RscInfoType.hpp @@ -111,4 +111,8 @@ class RscInGameUI { class RscStaminaBar { onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscStaminaBar"",'IGUI')] call (uinamespace getvariable 'BIS_fnc_initDisplay'); uiNamespace setVariable [ARR_2(QUOTE(QGVAR(dlgStaminaBar)),_this select 0)]); }; + + class RscStanceInfo { + onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscStanceInfo"",'IGUI')] call (uinamespace getvariable 'BIS_fnc_initDisplay'); [ARR_2('infoDisplayChanged', [ARR_2(_this select 0, 'Stance')])] call FUNC(localEvent);); + }; }; diff --git a/addons/reload/XEH_postInit.sqf b/addons/reload/XEH_postInit.sqf index 16f3d9b40ef..724375e48fb 100644 --- a/addons/reload/XEH_postInit.sqf +++ b/addons/reload/XEH_postInit.sqf @@ -62,3 +62,8 @@ if (!hasInterface) exitWith {}; _receiver addMagazine _magazine; }] call EFUNC(common,addEventhandler); + +// Hide ammo UI indicator +["InterfaceInitialized", { + [true, QEGVAR(ui,ammoCount), false] call EFUNC(ui,setElementVisibility); +}] call EFUNC(common,addEventhandler); diff --git a/addons/reload/config.cpp b/addons/reload/config.cpp index 86ba809a934..7706ada5ce2 100644 --- a/addons/reload/config.cpp +++ b/addons/reload/config.cpp @@ -5,7 +5,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_interaction"}; + requiredAddons[] = {"ace_interaction", "ace_ui"}; author[] = {"commy2","KoffeinFlummi","esteldunedain"}; authorUrl = "https://github.com/commy2/"; VERSION_CONFIG; diff --git a/addons/reload/script_component.hpp b/addons/reload/script_component.hpp index 09993faaa4c..eece5acec75 100644 --- a/addons/reload/script_component.hpp +++ b/addons/reload/script_component.hpp @@ -14,4 +14,4 @@ #define DEBUG_SETTINGS DEBUG_ENABLED_RELOAD #endif -#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/addons/ui/ACE_Settings.hpp b/addons/ui/ACE_Settings.hpp index 89ddc8d35d8..9b96fc23cbf 100644 --- a/addons/ui/ACE_Settings.hpp +++ b/addons/ui/ACE_Settings.hpp @@ -85,7 +85,7 @@ class ACE_Settings { displayName = CSTRING(AmmoCount); description = CSTRING(RequiresSoldierVehicleWeaponInfo); typeName = "BOOL"; - value = 0; + value = 1; isClientSettable = 1; }; class GVAR(magCount) { @@ -122,7 +122,7 @@ class ACE_Settings { }; class GVAR(weaponLowerInfoBackground) { category = CSTRING(Category); - displayName = CSTRING(WeaponLowerInfoBackground); //todo + displayName = CSTRING(WeaponLowerInfoBackground); description = CSTRING(RequiresSoldierVehicleWeaponInfo); typeName = "BOOL"; value = 1; diff --git a/addons/ui/CfgVehicles.hpp b/addons/ui/CfgVehicles.hpp index 391b3627eb7..984d868600f 100644 --- a/addons/ui/CfgVehicles.hpp +++ b/addons/ui/CfgVehicles.hpp @@ -75,7 +75,7 @@ class CfgVehicles { displayName = CSTRING(AmmoCount); description = CSTRING(RequiresSoldierVehicleWeaponInfo); typeName = "BOOL"; - defaultValue = 0; + defaultValue = 1; }; class magCount { displayName = CSTRING(MagCount); diff --git a/addons/ui/XEH_clientInit.sqf b/addons/ui/XEH_clientInit.sqf index d228696fc0c..6ff380f1d6c 100644 --- a/addons/ui/XEH_clientInit.sqf +++ b/addons/ui/XEH_clientInit.sqf @@ -13,8 +13,15 @@ if (!hasInterface) exitWith {}; // Defaults must be set in this EH to make sure controls are activated and advanced settings can be modified private _force = [true, false] select (GVAR(allowSelectiveUI)); { - [_x select 0, _x select 1, _x select 2, _force] call FUNC(setAdvancedElement); + [_x select 0, _x select 1, missionNamespace getVariable (_x select 2), _force] call FUNC(setAdvancedElement); } forEach ELEMENTS_ADVANCED; + + // Execute local event for when it's safe to modify UI through this API + // infoDisplayChanged can execute multiple times, make sure it only happens once + if (!GVAR(interfaceInitialized)) then { + ["InterfaceInitialized", []] call EFUNC(common,localEvent); + GVAR(interfaceInitialized) = true; + }; }] call EFUNC(common,addEventHandler); // On changing settings @@ -30,8 +37,16 @@ if (!hasInterface) exitWith {}; { _x params ["_idd", "_elements", "_elementName"]; + // Get show/hide boolean from mission namespace + private _show = missionNamespace getVariable _elementName; + + // Get show/hide boolean from a set element if set via API + if ([_idd, _elements, !(missionNamespace getVariable _elementName)] in GVAR(elementsSet)) then { + [LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured); + }; + if (_name == _elementName) then { - [_idd, _elements, _elementName] call FUNC(setAdvancedElement); + [_idd, _elements, _show] call FUNC(setAdvancedElement); TRACE_2("Setting Changed",_name,_elementName); }; } forEach ELEMENTS_ADVANCED; diff --git a/addons/ui/XEH_preInit.sqf b/addons/ui/XEH_preInit.sqf index 4a5638fc03e..8646227653c 100644 --- a/addons/ui/XEH_preInit.sqf +++ b/addons/ui/XEH_preInit.sqf @@ -5,5 +5,6 @@ ADDON = false; #include "XEH_PREP.hpp" GVAR(elementsSet) = []; +GVAR(interfaceInitialized) = false; ADDON = true; diff --git a/addons/ui/functions/fnc_setAdvancedElement.sqf b/addons/ui/functions/fnc_setAdvancedElement.sqf index 2ef88d58688..126871df6ec 100644 --- a/addons/ui/functions/fnc_setAdvancedElement.sqf +++ b/addons/ui/functions/fnc_setAdvancedElement.sqf @@ -5,7 +5,7 @@ * Arguments: * 0: Element IDD * 1: Element IDCs - * 2: Show/Hide Element OR Element ACE Settings Variable + * 2: Show/Hide Element * 3: Force change even when disallowed (default: false) * * Return Value: @@ -20,16 +20,16 @@ params ["_idd", "_elements", "_show", ["_force", false, [true]] ]; -if (_elementInfo in GVAR(elementsSet)) exitWith {}; - if (!_force && {!GVAR(allowSelectiveUI)}) exitWith { - [LSTRING(Disallowed), 2] call EFUNC(common,displayTextStructured) + [LSTRING(Disallowed), 2] call EFUNC(common,displayTextStructured); }; -// Get show/hide boolean from mission namespace if it's a string -if (typeName _show == "STRING") then { - _show = missionNamespace getVariable _show; +// Get show/hide boolean from a set element if set via API +// Inversion only needed if inverted, otherwise parameter can be used directly as it is the same +if ([_idd, _elements, !_show] in GVAR(elementsSet)) then { + _show = !_show; }; + _show = [1, 0] select _show; // Disable/Enable elements diff --git a/addons/ui/functions/fnc_setElementVisibility.sqf b/addons/ui/functions/fnc_setElementVisibility.sqf index b019c4c0811..4ee7d820015 100644 --- a/addons/ui/functions/fnc_setElementVisibility.sqf +++ b/addons/ui/functions/fnc_setElementVisibility.sqf @@ -4,15 +4,17 @@ * * Arguments: * 0: Set/Unset (default: true) - * 1: Element IDD (default: 0) - * 2: Element IDCs (default: []) - * 3: Show/Hide Element OR Element ACE Settings Variable (default: false) + * 1: Element Info OR Element Name (default: "") + * 0: Element Info IDD (default: 0) + * 1: Element Info IDCs (default: []) + * 2: Show/Hide Element (default: false) * * Return Value: * None * * Example: * [true, 300, [188], false] call ace_ui_fnc_setElementVisibility + * [true, "ace_ui_ammoCount", false] call ace_ui_fnc_setElementVisibility * * Public: Yes */ @@ -20,30 +22,53 @@ params [ ["_set", true, [true]], - ["_idd", 0, [0]], - ["_elements", [], [[]]], - ["_show", false, [true, ""]] + ["_element", "", ["", []]], + ["_show", false, [true]] ]; +// Get IDD and Elements from setting name +private _idd = 0; +private _elements = []; +if (_element isEqualType "") then { + private _elementInfo = ELEMENTS_ADVANCED select {_x select 2 == _element}; + if (_elementInfo isEqualTo []) exitWith { + ACE_LOGWARNING_1("Element setting name does not exist (Element: %1)",_element); + }; + _idd = (_elementInfo select 0) select 0; + _elements = (_elementInfo select 0) select 1; +} else { + _idd = _element select 0; + _elements = _element select 1; +}; + private _return = false; if (_set) then { - if ([_idd, _elements] in GVAR(elementsSet)) exitWith { TRACE_3("Element already set",_idd,_elements,GVAR(elementsSet)); }; + // Exit if element has been set from another component, print warning if after interface initialization + if ([_idd, _elements] in GVAR(elementsSet)) exitWith { + if (GVAR(interfaceInitialized)) then { + ACE_LOGWARNING_3("Element already set (IDD: %1, Elements: %2, Elements Set: %3",_idd,_elements,GVAR(elementsSet)); + }; + }; TRACE_4("Setting element",_idd,_elements,_show,GVAR(elementsSet)); private _success = [_idd, _elements, _show] call FUNC(setAdvancedElement); if (_success) then { - GVAR(elementsSet) pushBack [_idd, _elements]; + GVAR(elementsSet) pushBack [_idd, _elements, _show]; _return = true; }; } else { - if ([_idd, _elements] in GVAR(elementsSet)) then { + if ([_idd, _elements, _show] in GVAR(elementsSet) || {[_idd, _elements, !_show] in GVAR(elementsSet)}) then { TRACE_4("Setting element",_idd,_elements,_show,GVAR(elementsSet)); - [_idd, _elements, _show] call FUNC(setAdvancedElement); - private _index = GVAR(elementsSet) find [_idd, _elements]; + private _index = GVAR(elementsSet) find [_idd, _elements, _show]; + if (_index == -1) then { + _index = GVAR(elementsSet) find [_idd, _elements, !_show]; + }; GVAR(elementsSet) deleteAt _index; + + [_idd, _elements, _show] call FUNC(setAdvancedElement); _return = true; }; }; diff --git a/addons/ui/functions/fnc_setElements.sqf b/addons/ui/functions/fnc_setElements.sqf index 64b716ee297..877489aba4e 100644 --- a/addons/ui/functions/fnc_setElements.sqf +++ b/addons/ui/functions/fnc_setElements.sqf @@ -19,10 +19,6 @@ if (isArray (missionConfigFile >> "showHUD")) exitWith {}; params [ ["_force", false, [true]] ]; -if (!_force && {!GVAR(allowSelectiveUI)}) exitWith { - [LSTRING(Disallowed), 2] call EFUNC(common,displayTextStructured); -}; - ["ui", [ true, GVAR(soldierVehicleWeaponInfo), diff --git a/addons/ui/script_component.hpp b/addons/ui/script_component.hpp index a7410a49b84..43dd210ab52 100644 --- a/addons/ui/script_component.hpp +++ b/addons/ui/script_component.hpp @@ -56,7 +56,7 @@ RscUnitInfo = 300 + 1203 (Firing Mode Background) 155 (Ammo Type) -184 (Ammo Count) - disabled in config by ace_reload +184 (Ammo Count) - disabled by default if ace_reload is loaded 185 (Magazine Count) 152 (Grenade/Flare Type) 151 (Grenade/Flare Count) diff --git a/addons/ui/stringtable.xml b/addons/ui/stringtable.xml index 74cd89e93b4..4261635a854 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -127,5 +127,8 @@ Modifying User Interface is disabled. Změna uživatelského rozhraní je zakázána. + + Cannot modify a forced User Interface element. + - \ No newline at end of file + From 26ee74c919db537bc7c314036e22f21329106062 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 24 May 2016 17:07:25 +0200 Subject: [PATCH 2/7] Upgrade Selective UI framework for controls that share IDCs for gunner and soldier --- addons/ui/ACE_Settings.hpp | 10 ++++ addons/ui/CfgVehicles.hpp | 8 ++++ addons/ui/XEH_clientInit.sqf | 21 +++------ addons/ui/functions/fnc_moduleInit.sqf | 4 +- .../ui/functions/fnc_setAdvancedElement.sqf | 24 ++++++---- .../ui/functions/fnc_setElementVisibility.sqf | 46 +++++++------------ addons/ui/script_component.hpp | 45 +++++++++--------- addons/ui/stringtable.xml | 2 + 8 files changed, 86 insertions(+), 74 deletions(-) diff --git a/addons/ui/ACE_Settings.hpp b/addons/ui/ACE_Settings.hpp index 9b96fc23cbf..8bce027afad 100644 --- a/addons/ui/ACE_Settings.hpp +++ b/addons/ui/ACE_Settings.hpp @@ -149,6 +149,16 @@ class ACE_Settings { isClientSettable = 1; }; + // Gunner + class GVAR(gunnerAmmoCount) { + category = CSTRING(Category); + displayName = CSTRING(GunnerAmmoCount); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + // Vehicle class GVAR(vehicleName) { category = CSTRING(Category); diff --git a/addons/ui/CfgVehicles.hpp b/addons/ui/CfgVehicles.hpp index 984d868600f..1982ad4fbca 100644 --- a/addons/ui/CfgVehicles.hpp +++ b/addons/ui/CfgVehicles.hpp @@ -124,6 +124,14 @@ class CfgVehicles { defaultValue = 1; }; + // Gunner + class gunnerAmmoCount { + displayName = CSTRING(GunnerAmmoCount); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; + // Vehicle class vehicleName { displayName = CSTRING(VehicleName); diff --git a/addons/ui/XEH_clientInit.sqf b/addons/ui/XEH_clientInit.sqf index 6ff380f1d6c..eaf2520cc93 100644 --- a/addons/ui/XEH_clientInit.sqf +++ b/addons/ui/XEH_clientInit.sqf @@ -13,7 +13,7 @@ if (!hasInterface) exitWith {}; // Defaults must be set in this EH to make sure controls are activated and advanced settings can be modified private _force = [true, false] select (GVAR(allowSelectiveUI)); { - [_x select 0, _x select 1, missionNamespace getVariable (_x select 2), _force] call FUNC(setAdvancedElement); + [_x select 3, missionNamespace getVariable (_x select 3), _force] call FUNC(setAdvancedElement); } forEach ELEMENTS_ADVANCED; // Execute local event for when it's safe to modify UI through this API @@ -31,25 +31,18 @@ if (!hasInterface) exitWith {}; // Selective UI Basic if (_name in ELEMENTS_BASIC) then { [false] call FUNC(setElements); - }; - - // Selective UI Advanced - { - _x params ["_idd", "_elements", "_elementName"]; - + } else { // Selective UI Advanced // Get show/hide boolean from mission namespace - private _show = missionNamespace getVariable _elementName; + private _show = missionNamespace getVariable _name; // Get show/hide boolean from a set element if set via API - if ([_idd, _elements, !(missionNamespace getVariable _elementName)] in GVAR(elementsSet)) then { + if ([_name, !_show] in GVAR(elementsSet)) exitWith { [LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured); }; - if (_name == _elementName) then { - [_idd, _elements, _show] call FUNC(setAdvancedElement); - TRACE_2("Setting Changed",_name,_elementName); - }; - } forEach ELEMENTS_ADVANCED; + [_name, _show] call FUNC(setAdvancedElement); + TRACE_2("Setting Changed",_name,_show); + }; }] call EFUNC(common,addEventHandler); }] call EFUNC(common,addEventHandler); diff --git a/addons/ui/functions/fnc_moduleInit.sqf b/addons/ui/functions/fnc_moduleInit.sqf index 10f18f94f30..cfdb29e79d1 100644 --- a/addons/ui/functions/fnc_moduleInit.sqf +++ b/addons/ui/functions/fnc_moduleInit.sqf @@ -18,12 +18,13 @@ params ["_logic", "_units", "_activated"]; if (!_activated) exitWith {}; +[_logic, QGVAR(allowSelectiveUI), "allowSelectiveUI"] call EFUNC(common,readSettingFromModule); + // Basic if (isArray (missionConfigFile >> "showHUD")) then { // HUD visibility is hardcoded in mission config and showHUD command is overriden ACE_LOGINFO("User Interface Module Failed to Initialize Basic settings - showHUD overriden in mission config!"); } else { - [_logic, QGVAR(allowSelectiveUI), "allowSelectiveUI"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(soldierVehicleWeaponInfo), "soldierVehicleWeaponInfo"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleRadar), "vehicleRadar"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleCompass), "vehicleCompass"] call EFUNC(common,readSettingFromModule); @@ -44,6 +45,7 @@ if (isArray (missionConfigFile >> "showHUD")) then { [_logic, QGVAR(weaponLowerInfoBackground), "weaponLowerInfoBackground"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(stance), "stance"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(staminaBar), "staminaBar"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerAmmoCount), "gunnerAmmoCount"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleName), "vehicleName"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleNameBackground), "vehicleNameBackground"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleFuelBar), "vehicleFuelBar"] call EFUNC(common,readSettingFromModule); diff --git a/addons/ui/functions/fnc_setAdvancedElement.sqf b/addons/ui/functions/fnc_setAdvancedElement.sqf index 126871df6ec..187e5230abf 100644 --- a/addons/ui/functions/fnc_setAdvancedElement.sqf +++ b/addons/ui/functions/fnc_setAdvancedElement.sqf @@ -3,30 +3,38 @@ * Sets advanced visible element of the UI using displays and controls. * * Arguments: - * 0: Element IDD - * 1: Element IDCs - * 2: Show/Hide Element - * 3: Force change even when disallowed (default: false) + * 0: Element Name + * 1: Show/Hide Element + * 2: Force change even when disallowed (default: false) * * Return Value: * Successfully Set * * Example: - * [303, [188], true, false] call ace_ui_fnc_setAdvancedElement + * ["ace_ui_ammoCount", true, false] call ace_ui_fnc_setAdvancedElement * * Public: No */ #include "script_component.hpp" -params ["_idd", "_elements", "_show", ["_force", false, [true]] ]; +params ["_element", "_show", ["_force", false, [true]] ]; if (!_force && {!GVAR(allowSelectiveUI)}) exitWith { [LSTRING(Disallowed), 2] call EFUNC(common,displayTextStructured); }; +private _elementInfo = ELEMENTS_ADVANCED select {_x select 3 == _element}; +(_elementInfo select 0) params ["_idd", "_elements", "_selectiveType"]; + +private _inVehicle = ACE_player != vehicle ACE_player; +TRACE_2("Type",_inVehicle,_selectiveType); + +// Exit if selective type not applicable to current vehicle +if ((_inVehicle && {_selectiveType == 1}) || (!_inVehicle && {_selectiveType == 2})) exitWith {}; + // Get show/hide boolean from a set element if set via API // Inversion only needed if inverted, otherwise parameter can be used directly as it is the same -if ([_idd, _elements, !_show] in GVAR(elementsSet)) then { +if ([_element, !_show] in GVAR(elementsSet)) then { _show = !_show; }; @@ -40,7 +48,7 @@ private _success = false; // Loop through IGUI displays as they can be present several times for some reason { if (_idd == ctrlIDD _x) then { - TRACE_3("Setting Element Visibility",_show,_idd,_idc); + //TRACE_3("Setting Element Visibility",_show,_idd,_idc); (_x displayCtrl _idc) ctrlSetFade _show; (_x displayCtrl _idc) ctrlCommit 0; diff --git a/addons/ui/functions/fnc_setElementVisibility.sqf b/addons/ui/functions/fnc_setElementVisibility.sqf index 4ee7d820015..6ee3eb257d2 100644 --- a/addons/ui/functions/fnc_setElementVisibility.sqf +++ b/addons/ui/functions/fnc_setElementVisibility.sqf @@ -3,17 +3,14 @@ * Setter for toggling advanced element visibility. * * Arguments: - * 0: Set/Unset (default: true) - * 1: Element Info OR Element Name (default: "") - * 0: Element Info IDD (default: 0) - * 1: Element Info IDCs (default: []) + * 0: Set/Unset + * 1: Element Name * 2: Show/Hide Element (default: false) * * Return Value: * None * * Example: - * [true, 300, [188], false] call ace_ui_fnc_setElementVisibility * [true, "ace_ui_ammoCount", false] call ace_ui_fnc_setElementVisibility * * Public: Yes @@ -22,53 +19,44 @@ params [ ["_set", true, [true]], - ["_element", "", ["", []]], + ["_element", "", [""]], ["_show", false, [true]] ]; -// Get IDD and Elements from setting name -private _idd = 0; -private _elements = []; -if (_element isEqualType "") then { - private _elementInfo = ELEMENTS_ADVANCED select {_x select 2 == _element}; - if (_elementInfo isEqualTo []) exitWith { - ACE_LOGWARNING_1("Element setting name does not exist (Element: %1)",_element); - }; - _idd = (_elementInfo select 0) select 0; - _elements = (_elementInfo select 0) select 1; -} else { - _idd = _element select 0; - _elements = _element select 1; +// Verify element is bound +private _elementInfo = ELEMENTS_ADVANCED select {_x select 3 == _element}; +if (_elementInfo isEqualTo []) exitWith { + ACE_LOGWARNING_1("Element setting name does not exist (Element: %1)",_element); }; private _return = false; if (_set) then { // Exit if element has been set from another component, print warning if after interface initialization - if ([_idd, _elements] in GVAR(elementsSet)) exitWith { + if ([_element, _show] in GVAR(elementsSet) || {[_element, !_show] in GVAR(elementsSet)}) exitWith { if (GVAR(interfaceInitialized)) then { - ACE_LOGWARNING_3("Element already set (IDD: %1, Elements: %2, Elements Set: %3",_idd,_elements,GVAR(elementsSet)); + ACE_LOGWARNING_2("Element already set (Element: %1, Elements Set: %2",_element,GVAR(elementsSet)); }; }; - TRACE_4("Setting element",_idd,_elements,_show,GVAR(elementsSet)); - private _success = [_idd, _elements, _show] call FUNC(setAdvancedElement); + TRACE_3("Setting element",_element,_show,GVAR(elementsSet)); + private _success = [_element, _show, true] call FUNC(setAdvancedElement); if (_success) then { - GVAR(elementsSet) pushBack [_idd, _elements, _show]; + GVAR(elementsSet) pushBack [_element, _show]; _return = true; }; } else { - if ([_idd, _elements, _show] in GVAR(elementsSet) || {[_idd, _elements, !_show] in GVAR(elementsSet)}) then { - TRACE_4("Setting element",_idd,_elements,_show,GVAR(elementsSet)); + if ([_element, _show] in GVAR(elementsSet) || {[_element, !_show] in GVAR(elementsSet)}) then { + TRACE_3("Setting element",_element,_show,GVAR(elementsSet)); - private _index = GVAR(elementsSet) find [_idd, _elements, _show]; + private _index = GVAR(elementsSet) find [_element, _show]; if (_index == -1) then { - _index = GVAR(elementsSet) find [_idd, _elements, !_show]; + _index = GVAR(elementsSet) find [_element, !_show]; }; GVAR(elementsSet) deleteAt _index; - [_idd, _elements, _show] call FUNC(setAdvancedElement); + [_element, _show, true] call FUNC(setAdvancedElement); _return = true; }; }; diff --git a/addons/ui/script_component.hpp b/addons/ui/script_component.hpp index 43dd210ab52..6c97bebb287 100644 --- a/addons/ui/script_component.hpp +++ b/addons/ui/script_component.hpp @@ -20,28 +20,29 @@ // Elements #define ELEMENTS_BASIC [QGVAR(soldierVehicleWeaponInfo), QGVAR(vehicleRadar), QGVAR(vehicleCompass), QGVAR(commandMenu), QGVAR(groupBar)] -// IDD, IDC, Element (must be string to compare to changed setting name) +// IDD, IDCs, Element (must be string to compare to changed setting name), Selective Type (0-both, 1-ground, 2-vehicle) #define ELEMENTS_ADVANCED [ \ - [300, [118], QGVAR(weaponName)], \ - [300, [1001, 1008], QGVAR(weaponNameBackground)], \ - [300, [187, 1203], QGVAR(firingMode)], \ - [300, [155], QGVAR(ammoType)], \ - [300, [184], QGVAR(ammoCount)], \ - [300, [185], QGVAR(magCount)], \ - [300, [152], QGVAR(throwableName)], \ - [300, [151], QGVAR(throwableCount)], \ - [300, [1202], QGVAR(weaponLowerInfoBackground)], \ - [300, [168], QGVAR(zeroing)], \ - [305, [193], QGVAR(staminaBar)], \ - [303, [188, 1201], QGVAR(stance)], \ - [300, [120], QGVAR(vehicleName)], \ - [300, [1000, 1013], QGVAR(vehicleNameBackground)], \ - [300, [113, 1202], QGVAR(vehicleFuelBar)], \ - [300, [121, 1004, 1006], QGVAR(vehicleSpeed)], \ - [300, [122, 1005, 1014], QGVAR(vehicleAltitude)], \ - [300, [111], QGVAR(vehicleDamage)], \ - [300, [1200], QGVAR(vehicleInfoBackground)], \ - [300, [150], QGVAR(vehicleGunnerWeapon)] \ + [300, [118], 0, QGVAR(weaponName)], \ + [300, [1001, 1008], 0, QGVAR(weaponNameBackground)], \ + [300, [187, 1203], 0, QGVAR(firingMode)], \ + [300, [155], 0, QGVAR(ammoType)], \ + [300, [184], 1, QGVAR(ammoCount)], \ + [300, [185], 0, QGVAR(magCount)], \ + [300, [152], 0, QGVAR(throwableName)], \ + [300, [151], 0, QGVAR(throwableCount)], \ + [300, [1202], 0, QGVAR(weaponLowerInfoBackground)], \ + [300, [168], 0, QGVAR(zeroing)], \ + [305, [193], 1, QGVAR(staminaBar)], \ + [303, [188, 1201], 1, QGVAR(stance)], \ + [300, [184], 2, QGVAR(gunnerAmmoCount)], \ + [300, [120], 2, QGVAR(vehicleName)], \ + [300, [1000, 1013], 2, QGVAR(vehicleNameBackground)], \ + [300, [113, 1202], 2, QGVAR(vehicleFuelBar)], \ + [300, [121, 1004, 1006], 2, QGVAR(vehicleSpeed)], \ + [300, [122, 1005, 1014], 2, QGVAR(vehicleAltitude)], \ + [300, [111], 2, QGVAR(vehicleDamage)], \ + [300, [1200], 2, QGVAR(vehicleInfoBackground)], \ + [300, [150], 2, QGVAR(vehicleGunnerWeapon)] \ ] @@ -56,7 +57,7 @@ RscUnitInfo = 300 + 1203 (Firing Mode Background) 155 (Ammo Type) -184 (Ammo Count) - disabled by default if ace_reload is loaded +184 (Ammo Count / Gunner Ammo Count) - disabled by default if ace_reload is loaded 185 (Magazine Count) 152 (Grenade/Flare Type) 151 (Grenade/Flare Count) diff --git a/addons/ui/stringtable.xml b/addons/ui/stringtable.xml index 4261635a854..b00e6d9c484 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -59,6 +59,8 @@ Ammo Count Počet munice + + Gunner Ammo Count Magazine Count From a3d08672e4e0950132635047e0aba1dc867b85df Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 24 May 2016 17:35:45 +0200 Subject: [PATCH 3/7] Separate more soldier and gunner settings sharing same IDCs, Remove vehicle gunner weapon which has no effect anymore --- addons/ui/ACE_Settings.hpp | 64 ++++++++++++++++++++------ addons/ui/CfgVehicles.hpp | 50 ++++++++++++++------ addons/ui/functions/fnc_moduleInit.sqf | 7 ++- addons/ui/script_component.hpp | 34 ++++++++------ addons/ui/stringtable.xml | 27 ++++++++--- 5 files changed, 132 insertions(+), 50 deletions(-) diff --git a/addons/ui/ACE_Settings.hpp b/addons/ui/ACE_Settings.hpp index 8bce027afad..85554e0a710 100644 --- a/addons/ui/ACE_Settings.hpp +++ b/addons/ui/ACE_Settings.hpp @@ -45,7 +45,7 @@ class ACE_Settings { }; // ADVANCED - // Upper Weapon Info + // Soldier class GVAR(weaponName) { category = CSTRING(Category); displayName = CSTRING(WeaponName); @@ -70,8 +70,6 @@ class ACE_Settings { value = 1; isClientSettable = 1; }; - - // Lower Weapon Info class GVAR(ammoType) { category = CSTRING(Category); displayName = CSTRING(AmmoType); @@ -128,8 +126,6 @@ class ACE_Settings { value = 1; isClientSettable = 1; }; - - // Stance class GVAR(stance) { category = CSTRING(Category); displayName = CSTRING(Stance); @@ -138,8 +134,6 @@ class ACE_Settings { value = 1; isClientSettable = 1; }; - - // Stamina Bar class GVAR(staminaBar) { category = CSTRING(Category); displayName = CSTRING(StaminaBar); @@ -150,6 +144,38 @@ class ACE_Settings { }; // Gunner + class GVAR(gunnerWeaponName) { + category = CSTRING(Category); + displayName = CSTRING(GunnerWeaponName); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(gunnerWeaponNameBackground) { + category = CSTRING(Category); + displayName = CSTRING(GunnerWeaponNameBackground); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(gunnerFiringMode) { + category = CSTRING(Category); + displayName = CSTRING(GunnerFiringMode); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(gunnerAmmoType) { + category = CSTRING(Category); + displayName = CSTRING(GunnerAmmoType); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; class GVAR(gunnerAmmoCount) { category = CSTRING(Category); displayName = CSTRING(GunnerAmmoCount); @@ -158,6 +184,22 @@ class ACE_Settings { value = 1; isClientSettable = 1; }; + class GVAR(gunnerMagCount) { + category = CSTRING(Category); + displayName = CSTRING(GunnerMagCount); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(gunnerWeaponLowerInfoBackground) { + category = CSTRING(Category); + displayName = CSTRING(GunnerWeaponLowerInfoBackground); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; // Vehicle class GVAR(vehicleName) { @@ -216,12 +258,4 @@ class ACE_Settings { value = 1; isClientSettable = 1; }; - class GVAR(vehicleGunnerWeapon) { - category = CSTRING(Category); - displayName = CSTRING(VehicleGunnerWeapon); - description = CSTRING(RequiresSoldierVehicleWeaponInfo); - typeName = "BOOL"; - value = 1; - isClientSettable = 1; - }; }; diff --git a/addons/ui/CfgVehicles.hpp b/addons/ui/CfgVehicles.hpp index 1982ad4fbca..31b50f05abe 100644 --- a/addons/ui/CfgVehicles.hpp +++ b/addons/ui/CfgVehicles.hpp @@ -44,7 +44,7 @@ class CfgVehicles { }; // ADVANCED - // Upper Weapon Info + // Soldier class weaponName { displayName = CSTRING(WeaponName); description = CSTRING(RequiresSoldierVehicleWeaponInfo); @@ -63,8 +63,6 @@ class CfgVehicles { typeName = "BOOL"; defaultValue = 1; }; - - // Lower Weapon Info class ammoType { displayName = CSTRING(AmmoType); description = CSTRING(RequiresSoldierVehicleWeaponInfo); @@ -107,16 +105,12 @@ class CfgVehicles { typeName = "BOOL"; defaultValue = 1; }; - - // Stance class stance { displayName = CSTRING(Stance); description = CSTRING(RequiresSoldierVehicleWeaponInfo); typeName = "BOOL"; defaultValue = 1; }; - - // Stamina Bar class staminaBar { displayName = CSTRING(StaminaBar); description = CSTRING(RequiresSoldierVehicleWeaponInfo); @@ -125,12 +119,48 @@ class CfgVehicles { }; // Gunner + class gunnerWeaponName { + displayName = CSTRING(GunnerWeaponName); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; + class gunnerWeaponNameBackground { + displayName = CSTRING(GunnerWeaponNameBackground); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; + class gunnerFiringMode { + displayName = CSTRING(GunnerFiringMode); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; + class gunnerAmmoType { + displayName = CSTRING(GunnerAmmoType); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; class gunnerAmmoCount { displayName = CSTRING(GunnerAmmoCount); description = CSTRING(RequiresSoldierVehicleWeaponInfo); typeName = "BOOL"; defaultValue = 1; }; + class gunnerMagCount { + displayName = CSTRING(GunnerMagCount); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; + class gunnerWeaponLowerInfoBackground { + displayName = CSTRING(GunnerWeaponLowerInfoBackground); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; // Vehicle class vehicleName { @@ -175,12 +205,6 @@ class CfgVehicles { typeName = "BOOL"; defaultValue = 1; }; - class vehicleGunnerWeapon { - displayName = CSTRING(VehicleGunnerWeapon); - description = CSTRING(RequiresSoldierVehicleWeaponInfo); - typeName = "BOOL"; - defaultValue = 1; - }; }; class ModuleDescription { description = CSTRING(ModuleDescription); diff --git a/addons/ui/functions/fnc_moduleInit.sqf b/addons/ui/functions/fnc_moduleInit.sqf index cfdb29e79d1..51d851ca085 100644 --- a/addons/ui/functions/fnc_moduleInit.sqf +++ b/addons/ui/functions/fnc_moduleInit.sqf @@ -45,7 +45,13 @@ if (isArray (missionConfigFile >> "showHUD")) then { [_logic, QGVAR(weaponLowerInfoBackground), "weaponLowerInfoBackground"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(stance), "stance"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(staminaBar), "staminaBar"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerWeaponName), "gunnerWeaponName"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerWeaponNameBackground), "gunnerWeaponNameBackground"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerFiringMode), "gunnerFiringMode"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerAmmoType), "gunnerAmmoType"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(gunnerAmmoCount), "gunnerAmmoCount"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerMagCount), "gunnerMagCount"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerWeaponLowerInfoBackground), "gunnerWeaponLowerInfoBackground"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleName), "vehicleName"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleNameBackground), "vehicleNameBackground"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleFuelBar), "vehicleFuelBar"] call EFUNC(common,readSettingFromModule); @@ -53,6 +59,5 @@ if (isArray (missionConfigFile >> "showHUD")) then { [_logic, QGVAR(vehicleAltitude), "vehicleAltitude"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleDamage), "vehicleDamage"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleInfoBackground), "vehicleInfoBackground"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(vehicleGunnerWeapon), "vehicleGunnerWeapon"] call EFUNC(common,readSettingFromModule); ACE_LOGINFO_1("User Interface Module Initialized. Allow client modifications: %1",GVAR(allowSelectiveUI)); diff --git a/addons/ui/script_component.hpp b/addons/ui/script_component.hpp index 6c97bebb287..a5edaf5329d 100644 --- a/addons/ui/script_component.hpp +++ b/addons/ui/script_component.hpp @@ -17,46 +17,52 @@ #include "\z\ace\addons\main\script_macros.hpp" -// Elements +// Basic Elements #define ELEMENTS_BASIC [QGVAR(soldierVehicleWeaponInfo), QGVAR(vehicleRadar), QGVAR(vehicleCompass), QGVAR(commandMenu), QGVAR(groupBar)] +// Advanced Elements bindings // IDD, IDCs, Element (must be string to compare to changed setting name), Selective Type (0-both, 1-ground, 2-vehicle) #define ELEMENTS_ADVANCED [ \ - [300, [118], 0, QGVAR(weaponName)], \ - [300, [1001, 1008], 0, QGVAR(weaponNameBackground)], \ - [300, [187, 1203], 0, QGVAR(firingMode)], \ - [300, [155], 0, QGVAR(ammoType)], \ + [300, [118], 1, QGVAR(weaponName)], \ + [300, [1001, 1008], 1, QGVAR(weaponNameBackground)], \ + [300, [187, 1203], 1, QGVAR(firingMode)], \ + [300, [155], 1, QGVAR(ammoType)], \ [300, [184], 1, QGVAR(ammoCount)], \ - [300, [185], 0, QGVAR(magCount)], \ - [300, [152], 0, QGVAR(throwableName)], \ - [300, [151], 0, QGVAR(throwableCount)], \ - [300, [1202], 0, QGVAR(weaponLowerInfoBackground)], \ + [300, [185], 1, QGVAR(magCount)], \ + [300, [152], 1, QGVAR(throwableName)], \ + [300, [151], 1, QGVAR(throwableCount)], \ + [300, [1202], 1, QGVAR(weaponLowerInfoBackground)], \ [300, [168], 0, QGVAR(zeroing)], \ [305, [193], 1, QGVAR(staminaBar)], \ [303, [188, 1201], 1, QGVAR(stance)], \ + [300, [118], 2, QGVAR(gunnerWeaponName)], \ + [300, [1001, 1008], 2, QGVAR(gunnerWeaponNameBackground)], \ + [300, [187, 1203], 2, QGVAR(gunnerFiringMode)], \ + [300, [155], 2, QGVAR(gunnerAmmoType)], \ [300, [184], 2, QGVAR(gunnerAmmoCount)], \ + [300, [185], 2, QGVAR(gunnerMagCount)], \ + [300, [1202], 2, QGVAR(gunnerWeaponLowerInfoBackground)], \ [300, [120], 2, QGVAR(vehicleName)], \ [300, [1000, 1013], 2, QGVAR(vehicleNameBackground)], \ [300, [113, 1202], 2, QGVAR(vehicleFuelBar)], \ [300, [121, 1004, 1006], 2, QGVAR(vehicleSpeed)], \ [300, [122, 1005, 1014], 2, QGVAR(vehicleAltitude)], \ [300, [111], 2, QGVAR(vehicleDamage)], \ - [300, [1200], 2, QGVAR(vehicleInfoBackground)], \ - [300, [150], 2, QGVAR(vehicleGunnerWeapon)] \ + [300, [1200], 2, QGVAR(vehicleInfoBackground)] \ ] /* RscUnitInfo = 300 -------------------- -118 (Weapon Name) +118 (Weapon Name / Gunner Weapon Name) + 1001 (Weapon Name Background 1/2) + 1008 (Weapon Name Background 2/2) 187 (Firing Mode) + 1203 (Firing Mode Background) -155 (Ammo Type) +155 (Ammo Type / Gunner Ammo Type) 184 (Ammo Count / Gunner Ammo Count) - disabled by default if ace_reload is loaded 185 (Magazine Count) 152 (Grenade/Flare Type) @@ -81,8 +87,6 @@ RscUnitInfo = 300 111 (Vehicle Damage) 1200 (Vehicle Info Background) -150 (Vehicle Gunner Weapon) - RscStanceInfo = 303 -------------------- diff --git a/addons/ui/stringtable.xml b/addons/ui/stringtable.xml index b00e6d9c484..c1295db2a71 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -59,8 +59,6 @@ Ammo Count Počet munice - - Gunner Ammo Count Magazine Count @@ -89,6 +87,27 @@ Stamina Bar Panel výdrže + + Gunner Weapon Name + + + Gunner Weapon Name Background + + + Gunner Firing Mode + + + Gunner Ammo Type + + + Gunner Ammo Count + + + Gunner Magazine Count + + + Gunner Weapon Lower Info Background + Vehicle Name Název vozidla @@ -117,10 +136,6 @@ Vehicle Info Background Info o vozidle v pozadí - - Vehicle Gunner Weapon - Střelcova zbraň ve vozidle - Requires Soldier/Vehicle/Weapons Information. Vyžaduje informace o Vojákovi/Vozidlu/Zbrani From 6ab753248363b9246ff2f94b4e48b5bc5c9b93bf Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 24 May 2016 18:19:23 +0200 Subject: [PATCH 4/7] Separate more soldier and gunner IDC sharing elements, Fix typo, Fix API setting not being respected in case where selective type is not the same on load --- addons/ui/ACE_Settings.hpp | 24 +++++++++++++++++++ addons/ui/CfgVehicles.hpp | 18 ++++++++++++++ addons/ui/functions/fnc_moduleInit.sqf | 3 +++ .../ui/functions/fnc_setAdvancedElement.sqf | 3 ++- addons/ui/script_component.hpp | 5 +++- addons/ui/stringtable.xml | 11 ++++++++- 6 files changed, 61 insertions(+), 3 deletions(-) diff --git a/addons/ui/ACE_Settings.hpp b/addons/ui/ACE_Settings.hpp index 85554e0a710..e6c3e5e4960 100644 --- a/addons/ui/ACE_Settings.hpp +++ b/addons/ui/ACE_Settings.hpp @@ -192,6 +192,30 @@ class ACE_Settings { value = 1; isClientSettable = 1; }; + class GVAR(gunnerLaunchableName) { + category = CSTRING(Category); + displayName = CSTRING(gunnerLaunchableName); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(gunnerLaunchableCount) { + category = CSTRING(Category); + displayName = CSTRING(gunnerLaunchableCount); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(gunnerZeroing) { + category = CSTRING(Category); + displayName = CSTRING(GunnerZeroing); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; class GVAR(gunnerWeaponLowerInfoBackground) { category = CSTRING(Category); displayName = CSTRING(GunnerWeaponLowerInfoBackground); diff --git a/addons/ui/CfgVehicles.hpp b/addons/ui/CfgVehicles.hpp index 31b50f05abe..0b1cc9b2a99 100644 --- a/addons/ui/CfgVehicles.hpp +++ b/addons/ui/CfgVehicles.hpp @@ -155,6 +155,24 @@ class CfgVehicles { typeName = "BOOL"; defaultValue = 1; }; + class gunnerLaunchableName { + displayName = CSTRING(gunnerLaunchableName); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; + class gunnerLaunchableCount { + displayName = CSTRING(gunnerLaunchableCount); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; + class gunnerZeroing { + displayName = CSTRING(GunnerZeroing); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + defaultValue = 1; + }; class gunnerWeaponLowerInfoBackground { displayName = CSTRING(GunnerWeaponLowerInfoBackground); description = CSTRING(RequiresSoldierVehicleWeaponInfo); diff --git a/addons/ui/functions/fnc_moduleInit.sqf b/addons/ui/functions/fnc_moduleInit.sqf index 51d851ca085..6bfe29392f2 100644 --- a/addons/ui/functions/fnc_moduleInit.sqf +++ b/addons/ui/functions/fnc_moduleInit.sqf @@ -51,6 +51,9 @@ if (isArray (missionConfigFile >> "showHUD")) then { [_logic, QGVAR(gunnerAmmoType), "gunnerAmmoType"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(gunnerAmmoCount), "gunnerAmmoCount"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(gunnerMagCount), "gunnerMagCount"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerLaunchableName), "gunnerLaunchableName"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerLaunchableCount), "gunnerLaunchableCount"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(gunnerZeroing), "gunnerZeroing"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(gunnerWeaponLowerInfoBackground), "gunnerWeaponLowerInfoBackground"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleName), "vehicleName"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(vehicleNameBackground), "vehicleNameBackground"] call EFUNC(common,readSettingFromModule); diff --git a/addons/ui/functions/fnc_setAdvancedElement.sqf b/addons/ui/functions/fnc_setAdvancedElement.sqf index 187e5230abf..b9d98d15cd0 100644 --- a/addons/ui/functions/fnc_setAdvancedElement.sqf +++ b/addons/ui/functions/fnc_setAdvancedElement.sqf @@ -21,6 +21,7 @@ params ["_element", "_show", ["_force", false, [true]] ]; if (!_force && {!GVAR(allowSelectiveUI)}) exitWith { [LSTRING(Disallowed), 2] call EFUNC(common,displayTextStructured); + false }; private _elementInfo = ELEMENTS_ADVANCED select {_x select 3 == _element}; @@ -30,7 +31,7 @@ private _inVehicle = ACE_player != vehicle ACE_player; TRACE_2("Type",_inVehicle,_selectiveType); // Exit if selective type not applicable to current vehicle -if ((_inVehicle && {_selectiveType == 1}) || (!_inVehicle && {_selectiveType == 2})) exitWith {}; +if (!_force && {(_inVehicle && {_selectiveType == 1}) || (!_inVehicle && {_selectiveType == 2})}) exitWith {false}; // Get show/hide boolean from a set element if set via API // Inversion only needed if inverted, otherwise parameter can be used directly as it is the same diff --git a/addons/ui/script_component.hpp b/addons/ui/script_component.hpp index a5edaf5329d..20a21c3a435 100644 --- a/addons/ui/script_component.hpp +++ b/addons/ui/script_component.hpp @@ -31,8 +31,8 @@ [300, [185], 1, QGVAR(magCount)], \ [300, [152], 1, QGVAR(throwableName)], \ [300, [151], 1, QGVAR(throwableCount)], \ + [300, [168], 1, QGVAR(zeroing)], \ [300, [1202], 1, QGVAR(weaponLowerInfoBackground)], \ - [300, [168], 0, QGVAR(zeroing)], \ [305, [193], 1, QGVAR(staminaBar)], \ [303, [188, 1201], 1, QGVAR(stance)], \ [300, [118], 2, QGVAR(gunnerWeaponName)], \ @@ -41,6 +41,9 @@ [300, [155], 2, QGVAR(gunnerAmmoType)], \ [300, [184], 2, QGVAR(gunnerAmmoCount)], \ [300, [185], 2, QGVAR(gunnerMagCount)], \ + [300, [152], 2, QGVAR(gunnerLaunchableName)], \ + [300, [151], 2, QGVAR(gunnerLaunchableCount)], \ + [300, [168], 2, QGVAR(gunnerZeroing)], \ [300, [1202], 2, QGVAR(gunnerWeaponLowerInfoBackground)], \ [300, [120], 2, QGVAR(vehicleName)], \ [300, [1000, 1013], 2, QGVAR(vehicleNameBackground)], \ diff --git a/addons/ui/stringtable.xml b/addons/ui/stringtable.xml index c1295db2a71..61dcc18ee78 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -105,6 +105,15 @@ Gunner Magazine Count + + Gunner Launchable Type + + + Gunner Launchable Count + + + Gunner Zeroing + Gunner Weapon Lower Info Background @@ -137,7 +146,7 @@ Info o vozidle v pozadí - Requires Soldier/Vehicle/Weapons Information. + Requires Soldier/Vehicle/Weapon Information. Vyžaduje informace o Vojákovi/Vozidlu/Zbrani From 185187a93f069004e9ca9e73a7f1fa2537425237 Mon Sep 17 00:00:00 2001 From: jonpas Date: Wed, 25 May 2016 01:31:37 +0200 Subject: [PATCH 5/7] Rework Selective UI using ACE_UI config, Cleanup, Add ACE_UI to FCS component to mark it (is already disabled due to other necessary settings for FCS to function) --- addons/fcs/ACE_UI.hpp | 7 + addons/fcs/config.cpp | 1 + addons/reload/ACE_UI.hpp | 7 + addons/reload/XEH_postInit.sqf | 5 - addons/reload/config.cpp | 7 +- addons/ui/ACE_UI.hpp | 177 ++++++++++++++++++ addons/ui/XEH_clientInit.sqf | 19 +- addons/ui/config.cpp | 1 + .../ui/functions/fnc_setAdvancedElement.sqf | 45 +++-- .../ui/functions/fnc_setElementVisibility.sqf | 13 +- addons/ui/script_component.hpp | 55 +----- 11 files changed, 249 insertions(+), 88 deletions(-) create mode 100644 addons/fcs/ACE_UI.hpp create mode 100644 addons/reload/ACE_UI.hpp create mode 100644 addons/ui/ACE_UI.hpp diff --git a/addons/fcs/ACE_UI.hpp b/addons/fcs/ACE_UI.hpp new file mode 100644 index 00000000000..ca35779f366 --- /dev/null +++ b/addons/fcs/ACE_UI.hpp @@ -0,0 +1,7 @@ +class ACE_UI { + class gunnerZeroing { + class conditions { + ADDON = "false"; + }; + }; +}; diff --git a/addons/fcs/config.cpp b/addons/fcs/config.cpp index 12edf02ba3d..ddeb5f91d08 100644 --- a/addons/fcs/config.cpp +++ b/addons/fcs/config.cpp @@ -13,6 +13,7 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" +#include "ACE_UI.hpp" #include "CfgAmmo.hpp" #include "CfgMagazines.hpp" diff --git a/addons/reload/ACE_UI.hpp b/addons/reload/ACE_UI.hpp new file mode 100644 index 00000000000..6dae3e5147e --- /dev/null +++ b/addons/reload/ACE_UI.hpp @@ -0,0 +1,7 @@ +class ACE_UI { + class ammoCount { + class conditions { + ADDON = "false"; + }; + }; +}; diff --git a/addons/reload/XEH_postInit.sqf b/addons/reload/XEH_postInit.sqf index 724375e48fb..16f3d9b40ef 100644 --- a/addons/reload/XEH_postInit.sqf +++ b/addons/reload/XEH_postInit.sqf @@ -62,8 +62,3 @@ if (!hasInterface) exitWith {}; _receiver addMagazine _magazine; }] call EFUNC(common,addEventhandler); - -// Hide ammo UI indicator -["InterfaceInitialized", { - [true, QEGVAR(ui,ammoCount), false] call EFUNC(ui,setElementVisibility); -}] call EFUNC(common,addEventhandler); diff --git a/addons/reload/config.cpp b/addons/reload/config.cpp index 7706ada5ce2..33154cb5f46 100644 --- a/addons/reload/config.cpp +++ b/addons/reload/config.cpp @@ -5,7 +5,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_interaction", "ace_ui"}; + requiredAddons[] = {"ace_interaction"}; author[] = {"commy2","KoffeinFlummi","esteldunedain"}; authorUrl = "https://github.com/commy2/"; VERSION_CONFIG; @@ -13,11 +13,8 @@ class CfgPatches { }; #include "CfgVehicles.hpp" - #include "CfgMagazines.hpp" - #include "CfgEventHandlers.hpp" - #include "CfgActions.hpp" - #include "ACE_Settings.hpp" +#include "ACE_UI.hpp" diff --git a/addons/ui/ACE_UI.hpp b/addons/ui/ACE_UI.hpp new file mode 100644 index 00000000000..9442c10da30 --- /dev/null +++ b/addons/ui/ACE_UI.hpp @@ -0,0 +1,177 @@ +// IDD, elements[]s, Element (must be string to compare to changed setting name), Selective Type (0-both, 1-ground, 2-vehicle) +class ACE_UI { + class weaponName { + idd = 300; + elements[] = {118}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class weaponNameBackground { + idd = 300; + elements[] = {1001, 1008}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class firingMode { + idd = 300; + elements[] = {187, 1203}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class ammoType { + idd = 300; + elements[] = {155}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class ammoCount { + idd = 300; + elements[] = {184}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class magCount { + idd = 300; + elements[] = {185}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class throwableName { + idd = 300; + elements[] = {152}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class throwableCount { + idd = 300; + elements[] = {151}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class zeroing { + idd = 300; + elements[] = {168}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class weaponLowerInfoBackground { + idd = 300; + elements[] = {1202}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class staminaBar { + idd = 305; + elements[] = {193}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class stance { + idd = 303; + elements[] = {188, 1201}; + condition = QUOTE(ACE_player == vehicle ACE_player); + class conditions {}; + }; + class gunnerWeaponName { + idd = 300; + elements[] = {118}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class gunnerWeaponNameBackground { + idd = 300; + elements[] = {1001, 1008}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class gunnerFiringMode { + idd = 300; + elements[] = {187, 1203}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class gunnerAmmoType { + idd = 300; + elements[] = {155}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class gunnerAmmoCount { + idd = 300; + elements[] = {184}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class gunnerMagCount { + idd = 300; + elements[] = {185}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class gunnerLaunchableName { + idd = 300; + elements[] = {152}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class gunnerLaunchableCount { + idd = 300; + elements[] = {151}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class gunnerZeroing { + idd = 300; + elements[] = {168}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class gunnerWeaponLowerInfoBackground { + idd = 300; + elements[] = {1202}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class vehicleName { + idd = 300; + elements[] = {120}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class vehicleNameBackground { + idd = 300; + elements[] = {1000, 1013}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class vehicleFuelBar { + idd = 300; + elements[] = {113, 1202}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class vehicleSpeed { + idd = 300; + elements[] = {121, 1004, 1006}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class vehicleAltitude { + idd = 300; + elements[] = {122, 1005, 1014}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class vehicleDamage { + idd = 300; + elements[] = {111}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; + class vehicleInfoBackground { + idd = 300; + elements[] = {1200}; + condition = QUOTE(ACE_player != vehicle ACE_player); + class conditions {}; + }; +}; diff --git a/addons/ui/XEH_clientInit.sqf b/addons/ui/XEH_clientInit.sqf index eaf2520cc93..72a754a28e2 100644 --- a/addons/ui/XEH_clientInit.sqf +++ b/addons/ui/XEH_clientInit.sqf @@ -13,8 +13,9 @@ if (!hasInterface) exitWith {}; // Defaults must be set in this EH to make sure controls are activated and advanced settings can be modified private _force = [true, false] select (GVAR(allowSelectiveUI)); { - [_x select 3, missionNamespace getVariable (_x select 3), _force] call FUNC(setAdvancedElement); - } forEach ELEMENTS_ADVANCED; + private _name = configName _x; + [_name, missionNamespace getVariable (format [QGVAR(%1), _name]), false, _force] call FUNC(setAdvancedElement); + } forEach ("true" configClasses (configFile >> "ACE_UI")); // Execute local event for when it's safe to modify UI through this API // infoDisplayChanged can execute multiple times, make sure it only happens once @@ -28,20 +29,10 @@ if (!hasInterface) exitWith {}; ["SettingChanged", { params ["_name"]; - // Selective UI Basic if (_name in ELEMENTS_BASIC) then { [false] call FUNC(setElements); - } else { // Selective UI Advanced - // Get show/hide boolean from mission namespace - private _show = missionNamespace getVariable _name; - - // Get show/hide boolean from a set element if set via API - if ([_name, !_show] in GVAR(elementsSet)) exitWith { - [LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured); - }; - - [_name, _show] call FUNC(setAdvancedElement); - TRACE_2("Setting Changed",_name,_show); + } else { + [_name select [7], missionNamespace getVariable _name, true] call FUNC(setAdvancedElement); }; }] call EFUNC(common,addEventHandler); diff --git a/addons/ui/config.cpp b/addons/ui/config.cpp index d6fbed61ae3..8558059cc32 100644 --- a/addons/ui/config.cpp +++ b/addons/ui/config.cpp @@ -15,6 +15,7 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" #include "ACE_Settings.hpp" +#include "ACE_UI.hpp" #include "RscChat.hpp" #include "RscVignette.hpp" diff --git a/addons/ui/functions/fnc_setAdvancedElement.sqf b/addons/ui/functions/fnc_setAdvancedElement.sqf index b9d98d15cd0..f4560c044e6 100644 --- a/addons/ui/functions/fnc_setAdvancedElement.sqf +++ b/addons/ui/functions/fnc_setAdvancedElement.sqf @@ -5,7 +5,8 @@ * Arguments: * 0: Element Name * 1: Show/Hide Element - * 2: Force change even when disallowed (default: false) + * 2: Show Hint + * 3: Force change even when disallowed (default: false) * * Return Value: * Successfully Set @@ -17,26 +18,46 @@ */ #include "script_component.hpp" -params ["_element", "_show", ["_force", false, [true]] ]; +params ["_element", "_show", ["_showHint", false, [true]], ["_force", false, [true]] ]; if (!_force && {!GVAR(allowSelectiveUI)}) exitWith { [LSTRING(Disallowed), 2] call EFUNC(common,displayTextStructured); false }; -private _elementInfo = ELEMENTS_ADVANCED select {_x select 3 == _element}; -(_elementInfo select 0) params ["_idd", "_elements", "_selectiveType"]; +private _config = configFile >> "ACE_UI" >> _element; -private _inVehicle = ACE_player != vehicle ACE_player; -TRACE_2("Type",_inVehicle,_selectiveType); +// Exit if main vehicle type condition not fitting +if (!call compile (getText (_config >> "condition"))) exitWith {false}; -// Exit if selective type not applicable to current vehicle -if (!_force && {(_inVehicle && {_selectiveType == 1}) || (!_inVehicle && {_selectiveType == 2})}) exitWith {false}; +private _idd = getNumber (_config >> "idd"); +private _elements = getArray (_config >> "elements"); -// Get show/hide boolean from a set element if set via API -// Inversion only needed if inverted, otherwise parameter can be used directly as it is the same -if ([_element, !_show] in GVAR(elementsSet)) then { - _show = !_show; +// Get setting from config API +{ + private _condition = call compile (getText _x); + if !(_condition) exitWith { + TRACE_2("Condition False",_element,_x); + // Display and print info which component forced the element except for default vehicle check + if (_showHint) then { + [LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured); + }; + _show = false; + }; +} forEach (configProperties [_config >> "conditions"]); + +// Get setting from scripted API +if (!_force) then { + private _index = GVAR(elementsSet) find [_element, _show]; + if (_index == -1) then { + _index = GVAR(elementsSet) find [_element, !_show]; + if (_index != -1) then { + if (_showHint) then { + [LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured); + }; + _show = ((GVAR(elementsSet)) select _index) select 1; + }; + }; }; _show = [1, 0] select _show; diff --git a/addons/ui/functions/fnc_setElementVisibility.sqf b/addons/ui/functions/fnc_setElementVisibility.sqf index 6ee3eb257d2..8fbe4cf2941 100644 --- a/addons/ui/functions/fnc_setElementVisibility.sqf +++ b/addons/ui/functions/fnc_setElementVisibility.sqf @@ -24,9 +24,8 @@ params [ ]; // Verify element is bound -private _elementInfo = ELEMENTS_ADVANCED select {_x select 3 == _element}; -if (_elementInfo isEqualTo []) exitWith { - ACE_LOGWARNING_1("Element setting name does not exist (Element: %1)",_element); +if (!isClass (configFile >> "ACE_UI" >> _element)) exitWith { + ACE_LOGWARNING_1("Element '%1' does not exist",_element); }; private _return = false; @@ -35,12 +34,12 @@ if (_set) then { // Exit if element has been set from another component, print warning if after interface initialization if ([_element, _show] in GVAR(elementsSet) || {[_element, !_show] in GVAR(elementsSet)}) exitWith { if (GVAR(interfaceInitialized)) then { - ACE_LOGWARNING_2("Element already set (Element: %1, Elements Set: %2",_element,GVAR(elementsSet)); + ACE_LOGWARNING_2("Element '%1' already set in %2",_element,GVAR(elementsSet)); }; }; TRACE_3("Setting element",_element,_show,GVAR(elementsSet)); - private _success = [_element, _show, true] call FUNC(setAdvancedElement); + private _success = [_element, _show, false, true] call FUNC(setAdvancedElement); if (_success) then { GVAR(elementsSet) pushBack [_element, _show]; @@ -48,7 +47,7 @@ if (_set) then { }; } else { if ([_element, _show] in GVAR(elementsSet) || {[_element, !_show] in GVAR(elementsSet)}) then { - TRACE_3("Setting element",_element,_show,GVAR(elementsSet)); + TRACE_3("Unsetting element",_element,_show,GVAR(elementsSet)); private _index = GVAR(elementsSet) find [_element, _show]; if (_index == -1) then { @@ -56,7 +55,7 @@ if (_set) then { }; GVAR(elementsSet) deleteAt _index; - [_element, _show, true] call FUNC(setAdvancedElement); + [_element, _show, false, true] call FUNC(setAdvancedElement); _return = true; }; }; diff --git a/addons/ui/script_component.hpp b/addons/ui/script_component.hpp index 20a21c3a435..d57697867c2 100644 --- a/addons/ui/script_component.hpp +++ b/addons/ui/script_component.hpp @@ -20,58 +20,23 @@ // Basic Elements #define ELEMENTS_BASIC [QGVAR(soldierVehicleWeaponInfo), QGVAR(vehicleRadar), QGVAR(vehicleCompass), QGVAR(commandMenu), QGVAR(groupBar)] -// Advanced Elements bindings -// IDD, IDCs, Element (must be string to compare to changed setting name), Selective Type (0-both, 1-ground, 2-vehicle) -#define ELEMENTS_ADVANCED [ \ - [300, [118], 1, QGVAR(weaponName)], \ - [300, [1001, 1008], 1, QGVAR(weaponNameBackground)], \ - [300, [187, 1203], 1, QGVAR(firingMode)], \ - [300, [155], 1, QGVAR(ammoType)], \ - [300, [184], 1, QGVAR(ammoCount)], \ - [300, [185], 1, QGVAR(magCount)], \ - [300, [152], 1, QGVAR(throwableName)], \ - [300, [151], 1, QGVAR(throwableCount)], \ - [300, [168], 1, QGVAR(zeroing)], \ - [300, [1202], 1, QGVAR(weaponLowerInfoBackground)], \ - [305, [193], 1, QGVAR(staminaBar)], \ - [303, [188, 1201], 1, QGVAR(stance)], \ - [300, [118], 2, QGVAR(gunnerWeaponName)], \ - [300, [1001, 1008], 2, QGVAR(gunnerWeaponNameBackground)], \ - [300, [187, 1203], 2, QGVAR(gunnerFiringMode)], \ - [300, [155], 2, QGVAR(gunnerAmmoType)], \ - [300, [184], 2, QGVAR(gunnerAmmoCount)], \ - [300, [185], 2, QGVAR(gunnerMagCount)], \ - [300, [152], 2, QGVAR(gunnerLaunchableName)], \ - [300, [151], 2, QGVAR(gunnerLaunchableCount)], \ - [300, [168], 2, QGVAR(gunnerZeroing)], \ - [300, [1202], 2, QGVAR(gunnerWeaponLowerInfoBackground)], \ - [300, [120], 2, QGVAR(vehicleName)], \ - [300, [1000, 1013], 2, QGVAR(vehicleNameBackground)], \ - [300, [113, 1202], 2, QGVAR(vehicleFuelBar)], \ - [300, [121, 1004, 1006], 2, QGVAR(vehicleSpeed)], \ - [300, [122, 1005, 1014], 2, QGVAR(vehicleAltitude)], \ - [300, [111], 2, QGVAR(vehicleDamage)], \ - [300, [1200], 2, QGVAR(vehicleInfoBackground)] \ -] - - /* RscUnitInfo = 300 -------------------- 118 (Weapon Name / Gunner Weapon Name) -+ 1001 (Weapon Name Background 1/2) -+ 1008 (Weapon Name Background 2/2) ++ 1001 (Weapon Name Background 1/2 / Gunner Weapon Name Background 1/2) ++ 1008 (Weapon Name Background 2/2 / Gunner Weapon Name Background 2/2) -187 (Firing Mode) -+ 1203 (Firing Mode Background) +187 (Firing Mode / Gunner Firing Mode) ++ 1203 (Firing Mode Background / Gunner Firing Mode Background) 155 (Ammo Type / Gunner Ammo Type) -184 (Ammo Count / Gunner Ammo Count) - disabled by default if ace_reload is loaded -185 (Magazine Count) -152 (Grenade/Flare Type) -151 (Grenade/Flare Count) -1202 (Lower Weapon Info Background) -168 (Zeroing) +184 (Ammo Count / Gunner Ammo Count) +185 (Magazine Count / Gunner Magazine Count) +152 (Grenade/Flare Type / Launchable Type) +151 (Grenade/Flare Count / Launchable Count) +1202 (Lower Weapon Info Background / Gunner Lower Weapon Info Background) +168 (Zeroing / Gunner Zeroing) 120 (Vehicle Name) From 6fa31df3713c973021fbf51acd874e06ef6be42b Mon Sep 17 00:00:00 2001 From: jonpas Date: Wed, 25 May 2016 15:26:05 +0200 Subject: [PATCH 6/7] Do location check in function, Rename condition to location, change to number --- addons/ui/ACE_UI.hpp | 60 +++++++++---------- .../ui/functions/fnc_setAdvancedElement.sqf | 4 +- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/addons/ui/ACE_UI.hpp b/addons/ui/ACE_UI.hpp index 9442c10da30..c150322219b 100644 --- a/addons/ui/ACE_UI.hpp +++ b/addons/ui/ACE_UI.hpp @@ -1,177 +1,177 @@ -// IDD, elements[]s, Element (must be string to compare to changed setting name), Selective Type (0-both, 1-ground, 2-vehicle) +// Location (0-both, 1-ground, 2-vehicle) class ACE_UI { class weaponName { idd = 300; elements[] = {118}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class weaponNameBackground { idd = 300; elements[] = {1001, 1008}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class firingMode { idd = 300; elements[] = {187, 1203}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class ammoType { idd = 300; elements[] = {155}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class ammoCount { idd = 300; elements[] = {184}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class magCount { idd = 300; elements[] = {185}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class throwableName { idd = 300; elements[] = {152}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class throwableCount { idd = 300; elements[] = {151}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class zeroing { idd = 300; elements[] = {168}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class weaponLowerInfoBackground { idd = 300; elements[] = {1202}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class staminaBar { idd = 305; elements[] = {193}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class stance { idd = 303; elements[] = {188, 1201}; - condition = QUOTE(ACE_player == vehicle ACE_player); + location = 1; class conditions {}; }; class gunnerWeaponName { idd = 300; elements[] = {118}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class gunnerWeaponNameBackground { idd = 300; elements[] = {1001, 1008}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class gunnerFiringMode { idd = 300; elements[] = {187, 1203}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class gunnerAmmoType { idd = 300; elements[] = {155}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class gunnerAmmoCount { idd = 300; elements[] = {184}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class gunnerMagCount { idd = 300; elements[] = {185}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class gunnerLaunchableName { idd = 300; elements[] = {152}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class gunnerLaunchableCount { idd = 300; elements[] = {151}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class gunnerZeroing { idd = 300; elements[] = {168}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class gunnerWeaponLowerInfoBackground { idd = 300; elements[] = {1202}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class vehicleName { idd = 300; elements[] = {120}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class vehicleNameBackground { idd = 300; elements[] = {1000, 1013}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class vehicleFuelBar { idd = 300; elements[] = {113, 1202}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class vehicleSpeed { idd = 300; elements[] = {121, 1004, 1006}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class vehicleAltitude { idd = 300; elements[] = {122, 1005, 1014}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class vehicleDamage { idd = 300; elements[] = {111}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; class vehicleInfoBackground { idd = 300; elements[] = {1200}; - condition = QUOTE(ACE_player != vehicle ACE_player); + location = 2; class conditions {}; }; }; diff --git a/addons/ui/functions/fnc_setAdvancedElement.sqf b/addons/ui/functions/fnc_setAdvancedElement.sqf index f4560c044e6..3f087d89748 100644 --- a/addons/ui/functions/fnc_setAdvancedElement.sqf +++ b/addons/ui/functions/fnc_setAdvancedElement.sqf @@ -28,7 +28,9 @@ if (!_force && {!GVAR(allowSelectiveUI)}) exitWith { private _config = configFile >> "ACE_UI" >> _element; // Exit if main vehicle type condition not fitting -if (!call compile (getText (_config >> "condition"))) exitWith {false}; +private _location = getNumber (_config >> "location"); // (0-both, 1-ground, 2-vehicle) +private _currentLocation = ACE_player == vehicle ACE_player; +if ((_currentLocation && _location == 2) || (!_currentLocation && _location == 1)) exitWith {false}; private _idd = getNumber (_config >> "idd"); private _elements = getArray (_config >> "elements"); From 2e5f48d5e629d53734f681e47afa99c7b66a97e7 Mon Sep 17 00:00:00 2001 From: jonpas Date: Thu, 2 Jun 2016 14:23:51 +0200 Subject: [PATCH 7/7] Use macros in ACE_UI location --- addons/ui/ACE_UI.hpp | 63 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/addons/ui/ACE_UI.hpp b/addons/ui/ACE_UI.hpp index c150322219b..008d97db9b2 100644 --- a/addons/ui/ACE_UI.hpp +++ b/addons/ui/ACE_UI.hpp @@ -1,177 +1,180 @@ -// Location (0-both, 1-ground, 2-vehicle) +#define ANYWHERE 0 +#define GROUND_ONLY 1 +#define VEHICLE_ONLY 2 + class ACE_UI { class weaponName { idd = 300; elements[] = {118}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class weaponNameBackground { idd = 300; elements[] = {1001, 1008}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class firingMode { idd = 300; elements[] = {187, 1203}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class ammoType { idd = 300; elements[] = {155}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class ammoCount { idd = 300; elements[] = {184}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class magCount { idd = 300; elements[] = {185}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class throwableName { idd = 300; elements[] = {152}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class throwableCount { idd = 300; elements[] = {151}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class zeroing { idd = 300; elements[] = {168}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class weaponLowerInfoBackground { idd = 300; elements[] = {1202}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class staminaBar { idd = 305; elements[] = {193}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class stance { idd = 303; elements[] = {188, 1201}; - location = 1; + location = GROUND_ONLY; class conditions {}; }; class gunnerWeaponName { idd = 300; elements[] = {118}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class gunnerWeaponNameBackground { idd = 300; elements[] = {1001, 1008}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class gunnerFiringMode { idd = 300; elements[] = {187, 1203}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class gunnerAmmoType { idd = 300; elements[] = {155}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class gunnerAmmoCount { idd = 300; elements[] = {184}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class gunnerMagCount { idd = 300; elements[] = {185}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class gunnerLaunchableName { idd = 300; elements[] = {152}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class gunnerLaunchableCount { idd = 300; elements[] = {151}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class gunnerZeroing { idd = 300; elements[] = {168}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class gunnerWeaponLowerInfoBackground { idd = 300; elements[] = {1202}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class vehicleName { idd = 300; elements[] = {120}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class vehicleNameBackground { idd = 300; elements[] = {1000, 1013}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class vehicleFuelBar { idd = 300; elements[] = {113, 1202}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class vehicleSpeed { idd = 300; elements[] = {121, 1004, 1006}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class vehicleAltitude { idd = 300; elements[] = {122, 1005, 1014}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class vehicleDamage { idd = 300; elements[] = {111}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; class vehicleInfoBackground { idd = 300; elements[] = {1200}; - location = 2; + location = VEHICLE_ONLY; class conditions {}; }; };