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:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2016-06-18 09:32:56 +00:00
|
|
|
* ["ace_reload", true, "ace_ui_ammoCount", false] call ace_ui_fnc_setElementVisibility
|
2016-03-08 17:12:01 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
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-02 12:32:39 +00:00
|
|
|
// Verify element is bound
|
|
|
|
if (!isClass (configFile >> "ACE_UI" >> _element)) exitWith {
|
|
|
|
ACE_LOGWARNING_1("Element '%1' does not exist",_element);
|
|
|
|
};
|
|
|
|
|
2016-06-18 09:32:56 +00:00
|
|
|
if (_source == "" || {_element == ""}) exitWith {
|
|
|
|
ACE_LOGWARNING("Source or Element may not be empty strings!");
|
|
|
|
};
|
|
|
|
|
2016-03-08 17:42:37 +00:00
|
|
|
private _return = false;
|
|
|
|
|
2016-06-18 09:32:56 +00:00
|
|
|
private _setElement = [_element] call FUNC(findSetElement);
|
|
|
|
_setElement params ["_indexSet", "_sourceSet"];
|
|
|
|
|
2016-03-08 17:12:01 +00:00
|
|
|
if (_set) then {
|
2016-06-02 12:32:39 +00:00
|
|
|
// Exit if element has been set from another component, print warning if after interface initialization
|
2016-06-18 09:32:56 +00:00
|
|
|
if (_indexSet != -1) exitWith {
|
2016-06-02 12:32:39 +00:00
|
|
|
if (GVAR(interfaceInitialized)) then {
|
2016-06-18 09:32:56 +00:00
|
|
|
ACE_LOGWARNING_2("Element '%1' already set by %2",_element,_sourceSet);
|
2016-06-02 12:32:39 +00:00
|
|
|
};
|
|
|
|
};
|
2016-03-08 17:12:01 +00:00
|
|
|
|
2016-06-18 09:32:56 +00:00
|
|
|
TRACE_4("Setting element",_source,_element,_show,GVAR(elementsSet));
|
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-06-18 09:32:56 +00:00
|
|
|
GVAR(elementsSet) pushBack [_source, _element, _show];
|
2016-03-08 17:42:37 +00:00
|
|
|
_return = true;
|
2016-03-08 17:12:01 +00:00
|
|
|
};
|
|
|
|
} else {
|
2016-06-18 09:32:56 +00:00
|
|
|
if (_indexSet != -1) then {
|
|
|
|
TRACE_4("Unsetting element",_sourceSet,_element,_show,GVAR(elementsSet));
|
2016-03-08 17:12:01 +00:00
|
|
|
|
2016-06-18 09:32:56 +00:00
|
|
|
GVAR(elementsSet) deleteAt _indexSet;
|
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-03-08 17:42:37 +00:00
|
|
|
TRACE_2("Visibility set",_return,GVAR(elementsSet));
|
|
|
|
_return
|