ACE3/addons/ui/functions/fnc_setElementVisibility.sqf
Grim e06c6f7835
General - Replace toLower with toLowerANSI where applicable (#9790)
* General - Replace toLower with toLowerANSI where applicable

* whoops

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Update addons/repair/functions/fnc_setHitPointDamage.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/repair/dev/draw_showRepairInfo.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/tagging/XEH_preStart.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/vehicle_damage/functions/fnc_handleCookoff.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/tagging/XEH_preStart.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* comparment -> compartment

* Update fnc_showHud.sqf

* Update fnc_registerObjects.sqf

* Update addons/common/functions/fnc_cbaSettings_settingChanged.sqf

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-03-07 22:08:13 +01:00

69 lines
1.8 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: Jonpas
* Setter for toggling advanced element visibility.
*
* Arguments:
* 0: Source <STRING>
* 1: Set/Unset <BOOL>
* 2: Element Name <STRING>
* 3: Show/Hide Element <BOOL> (default: false)
*
* Return Value:
* Successfully Modified <BOOL>
*
* Example:
* _successfullyModified = ["ace_reload", true, "ammoCount", false] call ace_ui_fnc_setElementVisibility
*
* Public: Yes
*/
params [
["_source", "", [""]],
["_set", true, [true]],
["_element", "", [""]],
["_show", false, [true]]
];
if (_source == "" || {_element == ""}) exitWith {
WARNING("Source or Element may not be empty strings!");
};
_element = toLowerANSI _element;
// Verify element is bound
private _cachedElement = GVAR(configCache) getVariable _element;
if (isNil "_cachedElement") exitWith {
WARNING_2("Element '%1' does not exist - modification by '%2' failed.",_element,_source);
};
private _setElement = GVAR(elementsSet) getVariable _element;
private _return = false;
if (isNil "_setElement") then {
TRACE_3("Setting element",_source,_element,_show);
private _success = [_element, _show, false, true] call FUNC(setAdvancedElement);
if (_success) then {
GVAR(elementsSet) setVariable [_element, [_source, _show]];
_return = true;
};
} else {
_setElement params ["_sourceSet"];
if (_set) then {
if (GVAR(interfaceInitialized)) then {
WARNING_3("Element '%1' already set by '%2' - modification by '%3' failed.",_element,_sourceSet,_source);
};
} else {
TRACE_3("Unsetting element",_sourceSet,_element,_show);
GVAR(elementsSet) setVariable [_element, nil];
[_element, _show, false, true] call FUNC(setAdvancedElement);
_return = true;
};
};
TRACE_2("Visibility set",_element,_return);
_return