mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
4c995d4c5c
* Improve selective UI API, Disable ammo count when reload component is loaded, Fix stance UI * Upgrade Selective UI framework for controls that share IDCs for gunner and soldier * Separate more soldier and gunner settings sharing same IDCs, Remove vehicle gunner weapon which has no effect anymore * 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 * 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) * Do location check in function, Rename condition to location, change to number * Use macros in ACE_UI location
65 lines
1.8 KiB
Plaintext
65 lines
1.8 KiB
Plaintext
/*
|
|
* Author: Jonpas
|
|
* Setter for toggling advanced element visibility.
|
|
*
|
|
* Arguments:
|
|
* 0: Set/Unset <BOOL>
|
|
* 1: Element Name <ARRAY/STRING>
|
|
* 2: Show/Hide Element <BOOL> (default: false)
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [true, "ace_ui_ammoCount", false] call ace_ui_fnc_setElementVisibility
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
#include "script_component.hpp"
|
|
|
|
params [
|
|
["_set", true, [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 {
|
|
// 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_3("Setting element",_element,_show,GVAR(elementsSet));
|
|
private _success = [_element, _show, false, true] call FUNC(setAdvancedElement);
|
|
|
|
if (_success) then {
|
|
GVAR(elementsSet) pushBack [_element, _show];
|
|
_return = true;
|
|
};
|
|
} else {
|
|
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 [_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;
|
|
};
|
|
};
|
|
|
|
TRACE_2("Visibility set",_return,GVAR(elementsSet));
|
|
_return
|