2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-03-08 17:12:01 +00:00
|
|
|
/*
|
|
|
|
* Author: Jonpas
|
2016-03-08 17:40:23 +00:00
|
|
|
* Setter for toggling advanced element visibility.
|
2016-03-08 17:12:01 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2016-06-18 09:32:56 +00:00
|
|
|
* 0: Source <STRING>
|
|
|
|
* 1: Set/Unset <BOOL>
|
|
|
|
* 2: Element Name <STRING>
|
|
|
|
* 3: Show/Hide Element <BOOL> (default: false)
|
2016-03-08 17:12:01 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2016-08-18 17:07:05 +00:00
|
|
|
* Successfully Modified <BOOL>
|
2016-03-08 17:12:01 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2016-08-18 17:07:05 +00:00
|
|
|
* _successfullyModified = ["ace_reload", true, "ammoCount", false] call ace_ui_fnc_setElementVisibility
|
2016-03-08 17:12:01 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
params [
|
2016-06-18 09:32:56 +00:00
|
|
|
["_source", "", [""]],
|
2016-03-08 17:12:01 +00:00
|
|
|
["_set", true, [true]],
|
2016-06-02 12:32:39 +00:00
|
|
|
["_element", "", [""]],
|
|
|
|
["_show", false, [true]]
|
2016-03-08 17:12:01 +00:00
|
|
|
];
|
|
|
|
|
2016-06-18 09:32:56 +00:00
|
|
|
if (_source == "" || {_element == ""}) exitWith {
|
2016-10-02 10:55:31 +00:00
|
|
|
WARNING("Source or Element may not be empty strings!");
|
2016-06-18 09:32:56 +00:00
|
|
|
};
|
|
|
|
|
2024-03-07 21:08:13 +00:00
|
|
|
_element = toLowerANSI _element;
|
2016-03-08 17:42:37 +00:00
|
|
|
|
2016-08-18 17:07:05 +00:00
|
|
|
// Verify element is bound
|
2024-06-11 15:34:32 +00:00
|
|
|
if !(_element in GVAR(configCache)) exitWith {
|
2016-10-02 10:55:31 +00:00
|
|
|
WARNING_2("Element '%1' does not exist - modification by '%2' failed.",_element,_source);
|
2016-08-18 17:07:05 +00:00
|
|
|
};
|
2016-06-18 09:32:56 +00:00
|
|
|
|
2024-06-11 15:34:32 +00:00
|
|
|
private _setElement = GVAR(elementsSet) get _element;
|
2016-08-18 17:07:05 +00:00
|
|
|
private _return = false;
|
2016-03-08 17:12:01 +00:00
|
|
|
|
2016-08-18 17:07:05 +00:00
|
|
|
if (isNil "_setElement") then {
|
|
|
|
TRACE_3("Setting element",_source,_element,_show);
|
2016-06-02 12:32:39 +00:00
|
|
|
private _success = [_element, _show, false, true] call FUNC(setAdvancedElement);
|
2016-03-08 17:12:01 +00:00
|
|
|
|
|
|
|
if (_success) then {
|
2024-06-11 15:34:32 +00:00
|
|
|
GVAR(elementsSet) set [_element, [_source, _show]];
|
2016-03-08 17:42:37 +00:00
|
|
|
_return = true;
|
2016-03-08 17:12:01 +00:00
|
|
|
};
|
|
|
|
} else {
|
2016-08-18 17:07:05 +00:00
|
|
|
_setElement params ["_sourceSet"];
|
2016-03-08 17:12:01 +00:00
|
|
|
|
2016-08-18 17:07:05 +00:00
|
|
|
if (_set) then {
|
|
|
|
if (GVAR(interfaceInitialized)) then {
|
2016-10-02 10:55:31 +00:00
|
|
|
WARNING_3("Element '%1' already set by '%2' - modification by '%3' failed.",_element,_sourceSet,_source);
|
2016-08-18 17:07:05 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
TRACE_3("Unsetting element",_sourceSet,_element,_show);
|
2024-06-11 15:34:32 +00:00
|
|
|
GVAR(elementsSet) set [_element, nil];
|
2016-06-02 12:32:39 +00:00
|
|
|
|
|
|
|
[_element, _show, false, true] call FUNC(setAdvancedElement);
|
2016-03-08 17:42:37 +00:00
|
|
|
_return = true;
|
2016-03-08 17:12:01 +00:00
|
|
|
};
|
|
|
|
};
|
2016-03-08 17:40:23 +00:00
|
|
|
|
2016-08-18 17:07:05 +00:00
|
|
|
TRACE_2("Visibility set",_element,_return);
|
2016-03-08 17:42:37 +00:00
|
|
|
_return
|