ACE3/addons/cargo/functions/fnc_onMenuOpen.sqf

50 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
*
* Return value:
* 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
[{
private ["_display","_loaded", "_ctrl", "_class", "_label"];
2015-08-10 21:07:47 +00:00
disableSerialization;
2015-08-16 20:41:35 +00:00
_display = uiNamespace getVariable QGVAR(menuDisplay);
if (isnil "_display") exitWith {
2015-08-10 21:07:47 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
2015-08-16 20:41:35 +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;
};
2015-08-16 20:41:35 +00:00
_loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
2015-08-10 21:07:47 +00:00
_ctrl = _display displayCtrl 100;
_label = _display displayCtrl 2;
lbClear _ctrl;
{
_class = if (typeName _x == "STRING") 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;