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>
|
|
|
|
* 2: Show Hint <BOOL>
|
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-06-02 12:32:39 +00:00
|
|
|
* ["ace_ui_ammoCount", true, false] call ace_ui_fnc_setAdvancedElement
|
2015-10-28 22:23:02 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-06-02 12:32:39 +00:00
|
|
|
params ["_element", "_show", ["_showHint", false, [true]], ["_force", false, [true]] ];
|
2016-03-08 17:12:01 +00:00
|
|
|
|
2016-03-06 14:41:17 +00:00
|
|
|
if (!_force && {!GVAR(allowSelectiveUI)}) exitWith {
|
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-06-02 12:32:39 +00:00
|
|
|
private _config = configFile >> "ACE_UI" >> _element;
|
|
|
|
|
|
|
|
// Exit if main vehicle type condition not fitting
|
|
|
|
private _location = getNumber (_config >> "location"); // (0-both, 1-ground, 2-vehicle)
|
2016-06-05 12:02:55 +00:00
|
|
|
private _canUseWeapon = ACE_player call CBA_fnc_canUseWeapon;
|
|
|
|
if ((_canUseWeapon && _location == 2) || (!_canUseWeapon && _location == 1)) exitWith {false};
|
2016-06-02 12:32:39 +00:00
|
|
|
|
|
|
|
private _idd = getNumber (_config >> "idd");
|
|
|
|
private _elements = getArray (_config >> "elements");
|
|
|
|
|
|
|
|
// Get setting from config API
|
|
|
|
{
|
|
|
|
private _condition = call compile (getText _x);
|
|
|
|
if !(_condition) exitWith {
|
|
|
|
// 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-06-18 09:32:56 +00:00
|
|
|
ACE_LOGINFO_2("Attempted modification of a forced User Interface element '%1' by '%2'",_element,configName _x);
|
2016-06-02 12:32:39 +00:00
|
|
|
};
|
|
|
|
_show = false;
|
|
|
|
};
|
|
|
|
} forEach (configProperties [_config >> "conditions"]);
|
|
|
|
|
|
|
|
// Get setting from scripted API
|
|
|
|
if (!_force) then {
|
2016-06-18 09:32:56 +00:00
|
|
|
private _setElement = [_element] call FUNC(findSetElement);
|
|
|
|
_setElement params ["_indexSet", "_sourceSet", "_showSet"];
|
|
|
|
|
|
|
|
if (_indexSet != -1) then {
|
|
|
|
if (_showHint) then {
|
|
|
|
[LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured);
|
|
|
|
ACE_LOGINFO_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
|
|
|
|
2015-10-28 22:23:02 +00:00
|
|
|
_show = [1, 0] select _show;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
{
|
|
|
|
if (_idd == ctrlIDD _x) then {
|
2016-06-02 12:32:39 +00:00
|
|
|
//TRACE_3("Setting Element Visibility",_show,_idd,_idc);
|
2015-10-28 22:23:02 +00:00
|
|
|
|
|
|
|
(_x displayCtrl _idc) ctrlSetFade _show;
|
|
|
|
(_x displayCtrl _idc) ctrlCommit 0;
|
2016-03-08 17:12:01 +00:00
|
|
|
|
|
|
|
_success = true;
|
2015-10-28 22:23:02 +00:00
|
|
|
};
|
|
|
|
} forEach (uiNamespace getVariable "IGUI_displays");
|
|
|
|
} forEach _elements;
|
2016-03-08 17:12:01 +00:00
|
|
|
|
|
|
|
_success
|