diff --git a/addons/common/RscInfoType.hpp b/addons/common/RscInfoType.hpp index e5af2454cb..32bc0b698f 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/fcs/ACE_UI.hpp b/addons/fcs/ACE_UI.hpp new file mode 100644 index 0000000000..ca35779f36 --- /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 1d7c263f1e..a38cee5d7d 100644 --- a/addons/fcs/config.cpp +++ b/addons/fcs/config.cpp @@ -14,6 +14,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 0000000000..6dae3e5147 --- /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/config.cpp b/addons/reload/config.cpp index 940820ccba..1e97fa70f1 100644 --- a/addons/reload/config.cpp +++ b/addons/reload/config.cpp @@ -14,11 +14,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/reload/script_component.hpp b/addons/reload/script_component.hpp index 09993faaa4..eece5acec7 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 89ddc8d35d..e6c3e5e496 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); @@ -85,7 +83,7 @@ class ACE_Settings { displayName = CSTRING(AmmoCount); description = CSTRING(RequiresSoldierVehicleWeaponInfo); typeName = "BOOL"; - value = 0; + value = 1; isClientSettable = 1; }; class GVAR(magCount) { @@ -122,14 +120,12 @@ class ACE_Settings { }; class GVAR(weaponLowerInfoBackground) { category = CSTRING(Category); - displayName = CSTRING(WeaponLowerInfoBackground); //todo + displayName = CSTRING(WeaponLowerInfoBackground); description = CSTRING(RequiresSoldierVehicleWeaponInfo); typeName = "BOOL"; 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); @@ -149,6 +143,88 @@ class ACE_Settings { isClientSettable = 1; }; + // 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); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(gunnerMagCount) { + category = CSTRING(Category); + displayName = CSTRING(GunnerMagCount); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + 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); + description = CSTRING(RequiresSoldierVehicleWeaponInfo); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + // Vehicle class GVAR(vehicleName) { category = CSTRING(Category); @@ -206,12 +282,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/ACE_UI.hpp b/addons/ui/ACE_UI.hpp new file mode 100644 index 0000000000..008d97db9b --- /dev/null +++ b/addons/ui/ACE_UI.hpp @@ -0,0 +1,180 @@ +#define ANYWHERE 0 +#define GROUND_ONLY 1 +#define VEHICLE_ONLY 2 + +class ACE_UI { + class weaponName { + idd = 300; + elements[] = {118}; + location = GROUND_ONLY; + class conditions {}; + }; + class weaponNameBackground { + idd = 300; + elements[] = {1001, 1008}; + location = GROUND_ONLY; + class conditions {}; + }; + class firingMode { + idd = 300; + elements[] = {187, 1203}; + location = GROUND_ONLY; + class conditions {}; + }; + class ammoType { + idd = 300; + elements[] = {155}; + location = GROUND_ONLY; + class conditions {}; + }; + class ammoCount { + idd = 300; + elements[] = {184}; + location = GROUND_ONLY; + class conditions {}; + }; + class magCount { + idd = 300; + elements[] = {185}; + location = GROUND_ONLY; + class conditions {}; + }; + class throwableName { + idd = 300; + elements[] = {152}; + location = GROUND_ONLY; + class conditions {}; + }; + class throwableCount { + idd = 300; + elements[] = {151}; + location = GROUND_ONLY; + class conditions {}; + }; + class zeroing { + idd = 300; + elements[] = {168}; + location = GROUND_ONLY; + class conditions {}; + }; + class weaponLowerInfoBackground { + idd = 300; + elements[] = {1202}; + location = GROUND_ONLY; + class conditions {}; + }; + class staminaBar { + idd = 305; + elements[] = {193}; + location = GROUND_ONLY; + class conditions {}; + }; + class stance { + idd = 303; + elements[] = {188, 1201}; + location = GROUND_ONLY; + class conditions {}; + }; + class gunnerWeaponName { + idd = 300; + elements[] = {118}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class gunnerWeaponNameBackground { + idd = 300; + elements[] = {1001, 1008}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class gunnerFiringMode { + idd = 300; + elements[] = {187, 1203}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class gunnerAmmoType { + idd = 300; + elements[] = {155}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class gunnerAmmoCount { + idd = 300; + elements[] = {184}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class gunnerMagCount { + idd = 300; + elements[] = {185}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class gunnerLaunchableName { + idd = 300; + elements[] = {152}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class gunnerLaunchableCount { + idd = 300; + elements[] = {151}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class gunnerZeroing { + idd = 300; + elements[] = {168}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class gunnerWeaponLowerInfoBackground { + idd = 300; + elements[] = {1202}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class vehicleName { + idd = 300; + elements[] = {120}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class vehicleNameBackground { + idd = 300; + elements[] = {1000, 1013}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class vehicleFuelBar { + idd = 300; + elements[] = {113, 1202}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class vehicleSpeed { + idd = 300; + elements[] = {121, 1004, 1006}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class vehicleAltitude { + idd = 300; + elements[] = {122, 1005, 1014}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class vehicleDamage { + idd = 300; + elements[] = {111}; + location = VEHICLE_ONLY; + class conditions {}; + }; + class vehicleInfoBackground { + idd = 300; + elements[] = {1200}; + location = VEHICLE_ONLY; + class conditions {}; + }; +}; diff --git a/addons/ui/CfgVehicles.hpp b/addons/ui/CfgVehicles.hpp index 391b3627eb..0b1cc9b2a9 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); @@ -75,7 +73,7 @@ class CfgVehicles { displayName = CSTRING(AmmoCount); description = CSTRING(RequiresSoldierVehicleWeaponInfo); typeName = "BOOL"; - defaultValue = 0; + defaultValue = 1; }; class magCount { displayName = CSTRING(MagCount); @@ -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); @@ -124,6 +118,68 @@ class CfgVehicles { defaultValue = 1; }; + // 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 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); + typeName = "BOOL"; + defaultValue = 1; + }; + // Vehicle class vehicleName { displayName = CSTRING(VehicleName); @@ -167,12 +223,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/XEH_clientInit.sqf b/addons/ui/XEH_clientInit.sqf index d228696fc0..72a754a28e 100644 --- a/addons/ui/XEH_clientInit.sqf +++ b/addons/ui/XEH_clientInit.sqf @@ -13,28 +13,27 @@ 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); - } 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 + if (!GVAR(interfaceInitialized)) then { + ["InterfaceInitialized", []] call EFUNC(common,localEvent); + GVAR(interfaceInitialized) = true; + }; }] call EFUNC(common,addEventHandler); // On changing settings ["SettingChanged", { params ["_name"]; - // Selective UI Basic if (_name in ELEMENTS_BASIC) then { [false] call FUNC(setElements); + } else { + [_name select [7], missionNamespace getVariable _name, true] call FUNC(setAdvancedElement); }; - - // Selective UI Advanced - { - _x params ["_idd", "_elements", "_elementName"]; - - if (_name == _elementName) then { - [_idd, _elements, _elementName] call FUNC(setAdvancedElement); - TRACE_2("Setting Changed",_name,_elementName); - }; - } forEach ELEMENTS_ADVANCED; }] call EFUNC(common,addEventHandler); }] call EFUNC(common,addEventHandler); diff --git a/addons/ui/XEH_preInit.sqf b/addons/ui/XEH_preInit.sqf index 4a5638fc03..8646227653 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/config.cpp b/addons/ui/config.cpp index 84b7f7001c..0b680ca136 100644 --- a/addons/ui/config.cpp +++ b/addons/ui/config.cpp @@ -16,6 +16,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_moduleInit.sqf b/addons/ui/functions/fnc_moduleInit.sqf index 10f18f94f3..6bfe29392f 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,16 @@ 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(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); [_logic, QGVAR(vehicleFuelBar), "vehicleFuelBar"] call EFUNC(common,readSettingFromModule); @@ -51,6 +62,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/functions/fnc_setAdvancedElement.sqf b/addons/ui/functions/fnc_setAdvancedElement.sqf index 2ef88d5868..3f087d8974 100644 --- a/addons/ui/functions/fnc_setAdvancedElement.sqf +++ b/addons/ui/functions/fnc_setAdvancedElement.sqf @@ -3,33 +3,65 @@ * Sets advanced visible element of the UI using displays and controls. * * Arguments: - * 0: Element IDD - * 1: Element IDCs - * 2: Show/Hide Element OR Element ACE Settings Variable + * 0: Element Name + * 1: Show/Hide Element + * 2: Show Hint * 3: 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]] ]; - -if (_elementInfo in GVAR(elementsSet)) exitWith {}; +params ["_element", "_show", ["_showHint", false, [true]], ["_force", false, [true]] ]; if (!_force && {!GVAR(allowSelectiveUI)}) exitWith { - [LSTRING(Disallowed), 2] call EFUNC(common,displayTextStructured) + [LSTRING(Disallowed), 2] call EFUNC(common,displayTextStructured); + false }; -// Get show/hide boolean from mission namespace if it's a string -if (typeName _show == "STRING") then { - _show = missionNamespace getVariable _show; +private _config = configFile >> "ACE_UI" >> _element; + +// Exit if main vehicle type condition not fitting +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"); + +// 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; // Disable/Enable elements @@ -40,7 +72,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 b019c4c081..8fbe4cf294 100644 --- a/addons/ui/functions/fnc_setElementVisibility.sqf +++ b/addons/ui/functions/fnc_setElementVisibility.sqf @@ -3,16 +3,15 @@ * Setter for toggling advanced element visibility. * * 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) + * 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 */ @@ -20,30 +19,43 @@ params [ ["_set", true, [true]], - ["_idd", 0, [0]], - ["_elements", [], [[]]], - ["_show", false, [true, ""]] + ["_element", "", [""]], + ["_show", false, [true]] ]; +// Verify element is bound +if (!isClass (configFile >> "ACE_UI" >> _element)) exitWith { + ACE_LOGWARNING_1("Element '%1' does not exist",_element); +}; + 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 ([_element, _show] in GVAR(elementsSet) || {[_element, !_show] in GVAR(elementsSet)}) exitWith { + if (GVAR(interfaceInitialized)) then { + ACE_LOGWARNING_2("Element '%1' already set in %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, false, true] call FUNC(setAdvancedElement); if (_success) then { - GVAR(elementsSet) pushBack [_idd, _elements]; + GVAR(elementsSet) pushBack [_element, _show]; _return = true; }; } else { - if ([_idd, _elements] in GVAR(elementsSet)) then { - TRACE_4("Setting element",_idd,_elements,_show,GVAR(elementsSet)); - [_idd, _elements, _show] call FUNC(setAdvancedElement); + if ([_element, _show] in GVAR(elementsSet) || {[_element, !_show] in GVAR(elementsSet)}) then { + TRACE_3("Unsetting element",_element,_show,GVAR(elementsSet)); - private _index = GVAR(elementsSet) find [_idd, _elements]; + private _index = GVAR(elementsSet) find [_element, _show]; + if (_index == -1) then { + _index = GVAR(elementsSet) find [_element, !_show]; + }; GVAR(elementsSet) deleteAt _index; + + [_element, _show, false, true] call FUNC(setAdvancedElement); _return = true; }; }; diff --git a/addons/ui/functions/fnc_setElements.sqf b/addons/ui/functions/fnc_setElements.sqf index 64b716ee29..877489aba4 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 a7410a49b8..d57697867c 100644 --- a/addons/ui/script_component.hpp +++ b/addons/ui/script_component.hpp @@ -17,51 +17,26 @@ #include "\z\ace\addons\main\script_macros.hpp" -// Elements +// Basic 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) -#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)] \ -] - - /* RscUnitInfo = 300 -------------------- -118 (Weapon Name) -+ 1001 (Weapon Name Background 1/2) -+ 1008 (Weapon Name Background 2/2) +118 (Weapon Name / Gunner Weapon Name) ++ 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) -184 (Ammo Count) - disabled in config by ace_reload -185 (Magazine Count) -152 (Grenade/Flare Type) -151 (Grenade/Flare Count) -1202 (Lower Weapon Info Background) -168 (Zeroing) +155 (Ammo Type / Gunner Ammo Type) +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) @@ -80,8 +55,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 74cd89e93b..61dcc18ee7 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -87,6 +87,36 @@ 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 Launchable Type + + + Gunner Launchable Count + + + Gunner Zeroing + + + Gunner Weapon Lower Info Background + Vehicle Name Název vozidla @@ -115,17 +145,16 @@ Vehicle Info Background Info o vozidle v pozadí - - Vehicle Gunner Weapon - Střelcova zbraň ve vozidle - - Requires Soldier/Vehicle/Weapons Information. + Requires Soldier/Vehicle/Weapon Information. Vyžaduje informace o Vojákovi/Vozidlu/Zbrani 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 +