ACE3/addons/ui/functions/fnc_setElementVisibility.sqf
Dedmen Miller e2ac18a05d [WIP] Fix script errors reporting wrong line numbers (#6407)
* advanced_ballistics

* advanced_fatigue

* advanced_throwing

* ai

* aircraft

* arsenal

* atragmx

* attach

* backpacks

* ballistics

* captives

* cargo

* chemlights

* common

* concertina_wire

* cookoff

* dagr

* disarming

* disposable

* dogtags

* dragging

* explosives

* fastroping

* fcs

* finger

* frag

* gestures

* gforces

* goggles

* grenades

* gunbag

* hearing

* hitreactions

* huntir

* interact_menu

* interaction

* inventory

* kestrel4500

* laser

* laserpointer

* logistics_uavbattery

* logistics_wirecutter

* magazinerepack

* map

* map_gestures

* maptools

* markers

* medical

* medical_ai

* medical_blood

* medical_menu

* microdagr

* minedetector

* missileguidance

* missionmodules

* mk6mortar

* modules

* movement

* nametags

* nightvision

* nlaw

* optics

* optionsmenu

* overheating

* overpressure

* parachute

* pylons

* quickmount

* rangecard

* rearm

* recoil

* refuel

* reload

* reloadlaunchers

* repair

* respawn

* safemode

* sandbag

* scopes

* slideshow

* spectator

* spottingscope

* switchunits

* tacticalladder

* tagging

* trenches

* tripod

* ui

* vector

* vehiclelock

* vehicles

* viewdistance

* weaponselect

* weather

* winddeflection

* yardage450

* zeus

* arsenal defines.hpp

* optionals

* DEBUG_MODE_FULL 1

* DEBUG_MODE_FULL 2

* Manual fixes

* Add SQF Validator check for #include after block comment

* explosives fnc_openTimerUI

* fix uniqueItems
2018-09-17 14:19:29 -05: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 = toLower _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