ACE3/addons/cargo/functions/fnc_onMenuOpen.sqf

49 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2015-08-16 20:41:35 +00:00
* Handle the UI data display.
2015-08-10 21:07:47 +00:00
*
* Arguments:
2015-08-16 20:41:35 +00:00
* 0: Display <DISPLAY>
2015-08-10 21:07:47 +00:00
*
2016-06-18 09:50:41 +00:00
* Return Value:
2015-08-10 21:07:47 +00:00
* None
*
2015-08-16 20:41:35 +00:00
* Example:
* [display] call ace_cargo_fnc_onMenuOpen
*
2015-08-10 21:07:47 +00:00
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
2015-08-16 20:41:35 +00:00
params ["_display"];
uiNamespace setVariable [QGVAR(menuDisplay), _display];
2015-08-10 21:07:47 +00:00
[{
disableSerialization;
2016-01-19 03:53:48 +00:00
private _display = uiNamespace getVariable QGVAR(menuDisplay);
2015-08-16 20:41:35 +00:00
if (isnil "_display") exitWith {
2015-08-10 21:07:47 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
2016-01-19 03:53:48 +00:00
if (isNull GVAR(interactionVehicle) || {ACE_player distance GVAR(interactionVehicle) >= 10}) exitWith {
2015-08-10 21:07:47 +00:00
closeDialog 0;
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
2016-01-19 03:53:48 +00:00
private _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
private _ctrl = _display displayCtrl 100;
private _label = _display displayCtrl 2;
2015-08-10 21:07:47 +00:00
lbClear _ctrl;
{
2016-01-19 03:53:48 +00:00
private _class = if (_x isEqualType "") then {_x} else {typeOf _x};
_ctrl lbAdd (getText(configfile >> "CfgVehicles" >> _class >> "displayName"));
true
} count _loaded;
2015-08-10 21:07:47 +00:00
2015-08-14 20:46:51 +00:00
_label ctrlSetText format[localize LSTRING(labelSpace), [GVAR(interactionVehicle)] call DFUNC(getCargoSpaceLeft)];
2015-08-10 21:07:47 +00:00
}, 0, []] call CBA_fnc_addPerFrameHandler;