2018-09-17 19:19:29 +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
|
|
|
};
|
|
|
|
|
2016-08-18 17:07:05 +00:00
|
|
|
_element = toLower _element;
|
2016-03-08 17:42:37 +00:00
|
|
|
|
2016-08-18 17:07:05 +00:00
|
|
|
// Verify element is bound
|
|
|
|
private _cachedElement = GVAR(configCache) getVariable _element;
|
|
|
|
if (isNil "_cachedElement") 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
|
|
|
|
2016-08-18 17:07:05 +00:00
|
|
|
private _setElement = GVAR(elementsSet) getVariable _element;
|
|
|
|
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 {
|
2016-08-18 17:07:05 +00:00
|
|
|
GVAR(elementsSet) setVariable [_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);
|
|
|
|
GVAR(elementsSet) setVariable [_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
|