2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-10-28 22:23:02 +00:00
|
|
|
/*
|
|
|
|
* Author: Jonpas
|
|
|
|
* Sets advanced visible element of the UI using displays and controls.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2016-06-02 12:32:39 +00:00
|
|
|
* 0: Element Name <STRING>
|
|
|
|
* 1: Show/Hide Element <BOOL>
|
2019-03-11 02:40:28 +00:00
|
|
|
* 2: Show Hint <BOOL> (default: false)
|
2016-03-08 17:40:23 +00:00
|
|
|
* 3: Force change even when disallowed <BOOL> (default: false)
|
2015-10-28 22:23:02 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2016-03-08 17:40:23 +00:00
|
|
|
* Successfully Set <BOOL>
|
2015-10-28 22:23:02 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2016-08-18 17:07:05 +00:00
|
|
|
* _successfullySet = ["ammoCount", true, false] call ace_ui_fnc_setAdvancedElement
|
2015-10-28 22:23:02 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2019-03-11 02:40:28 +00:00
|
|
|
params ["_element", "_show", ["_showHint", false, [true]], ["_force", false, [true]]];
|
2016-03-08 17:12:01 +00:00
|
|
|
|
2024-06-11 15:34:32 +00:00
|
|
|
_element = toLowerANSI _element;
|
|
|
|
|
|
|
|
private _cachedElement = GVAR(configCache) get _element;
|
2019-03-11 02:40:28 +00:00
|
|
|
if (isNil "_cachedElement") exitWith {TRACE_1("nil element",_this)};
|
2016-08-18 17:07:05 +00:00
|
|
|
|
2016-03-06 14:41:17 +00:00
|
|
|
if (!_force && {!GVAR(allowSelectiveUI)}) exitWith {
|
2019-03-11 02:40:28 +00:00
|
|
|
TRACE_1("not allowed",_this);
|
2016-06-02 12:32:39 +00:00
|
|
|
[LSTRING(Disallowed), 2] call EFUNC(common,displayTextStructured);
|
|
|
|
false
|
2016-03-06 14:41:17 +00:00
|
|
|
};
|
|
|
|
|
2016-08-18 17:07:05 +00:00
|
|
|
_cachedElement params ["_idd", "_elements", "_location", "_conditions"];
|
2016-06-02 12:32:39 +00:00
|
|
|
|
|
|
|
// Exit if main vehicle type condition not fitting
|
2019-03-11 02:40:28 +00:00
|
|
|
private _canUseWeaponOrInCargo = ACE_player call CBA_fnc_canUseWeapon || {-1 < vehicle ACE_player getCargoIndex ACE_player};
|
2023-07-28 21:44:14 +00:00
|
|
|
private _inUAVCamera = !isNull getConnectedUAVUnit player; // explictly using player
|
2019-03-11 02:40:28 +00:00
|
|
|
if (
|
2023-07-28 21:44:14 +00:00
|
|
|
(_canUseWeaponOrInCargo && {!_inUAVCamera} && {_location == VEHICLE_ONLY})
|
|
|
|
|| {(!_canUseWeaponOrInCargo || {_inUAVCamera}) && {_location == GROUND_ONLY}}
|
2019-03-11 02:40:28 +00:00
|
|
|
) exitWith {
|
|
|
|
TRACE_3("skip location",_this,_canUseWeaponOrInCargo,_location);
|
|
|
|
false
|
|
|
|
};
|
2016-06-02 12:32:39 +00:00
|
|
|
|
|
|
|
// Get setting from config API
|
|
|
|
{
|
2016-08-18 17:07:05 +00:00
|
|
|
if (!call (_x select 0)) exitWith {
|
2016-06-02 12:32:39 +00:00
|
|
|
// Display and print info which component forced the element except for default vehicle check
|
|
|
|
if (_showHint) then {
|
|
|
|
[LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured);
|
2016-10-02 10:55:31 +00:00
|
|
|
INFO_2("Attempted modification of a forced User Interface element '%1' by '%2'.",_element,_x select 1);
|
2016-06-02 12:32:39 +00:00
|
|
|
};
|
|
|
|
_show = false;
|
|
|
|
};
|
2023-07-28 21:44:14 +00:00
|
|
|
} forEach _conditions;
|
2016-06-02 12:32:39 +00:00
|
|
|
|
|
|
|
// Get setting from scripted API
|
|
|
|
if (!_force) then {
|
2024-06-11 15:34:32 +00:00
|
|
|
private _setElement = GVAR(elementsSet) get _element;
|
2016-08-18 17:07:05 +00:00
|
|
|
if (!isNil "_setElement") then {
|
|
|
|
_setElement params ["_sourceSet", "_showSet"];
|
2016-06-18 09:32:56 +00:00
|
|
|
if (_showHint) then {
|
|
|
|
[LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured);
|
2016-10-02 10:55:31 +00:00
|
|
|
INFO_2("Attempted modification of a forced User Interface element '%1' by '%2'.",_element,_sourceSet);
|
2016-06-02 12:32:39 +00:00
|
|
|
};
|
2016-06-18 09:32:56 +00:00
|
|
|
_show = _showSet;
|
2016-06-02 12:32:39 +00:00
|
|
|
};
|
2015-10-28 22:23:02 +00:00
|
|
|
};
|
2016-06-02 12:32:39 +00:00
|
|
|
|
2021-04-20 21:26:48 +00:00
|
|
|
private _displays = ((uiNamespace getVariable "IGUI_displays") + [findDisplay IDD_MISSION]) select {_idd == ctrlIDD _x};
|
2024-02-04 17:50:24 +00:00
|
|
|
private _fade = parseNumber !_show;
|
2015-10-28 22:23:02 +00:00
|
|
|
|
|
|
|
// Disable/Enable elements
|
2016-03-08 17:12:01 +00:00
|
|
|
private _success = false;
|
2015-10-28 22:23:02 +00:00
|
|
|
{
|
2016-03-06 11:50:16 +00:00
|
|
|
private _idc = _x;
|
2015-10-28 22:23:02 +00:00
|
|
|
|
|
|
|
// Loop through IGUI displays as they can be present several times for some reason
|
|
|
|
{
|
2021-04-20 21:26:48 +00:00
|
|
|
_success = true;
|
2015-10-28 22:23:02 +00:00
|
|
|
|
2021-04-20 21:26:48 +00:00
|
|
|
private _control = _x displayCtrl _idc;
|
|
|
|
if (ctrlFade _control == _fade) then {continue};
|
2016-03-08 17:12:01 +00:00
|
|
|
|
2021-04-20 21:26:48 +00:00
|
|
|
TRACE_4("Setting Element Visibility",_element,_fade,_idd,_idc);
|
|
|
|
|
|
|
|
_control ctrlSetFade _fade;
|
|
|
|
_control ctrlCommit 0;
|
2023-07-28 21:44:14 +00:00
|
|
|
} forEach _displays;
|
|
|
|
} forEach _elements;
|
2016-03-08 17:12:01 +00:00
|
|
|
|
|
|
|
_success
|