ACE3/addons/cargo/functions/fnc_startUnload.sqf

49 lines
1.2 KiB
Plaintext
Raw Normal View History

2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2015-08-16 20:41:35 +00:00
* Start unload action.
2015-08-10 21:07:47 +00:00
*
* Arguments:
* None
*
* Return value:
* None
*
2015-08-16 20:41:35 +00:00
* Example:
* [] call ace_cargo_fnc_startUnload
*
2015-08-10 21:07:47 +00:00
* Public: No
*/
#include "script_component.hpp"
2015-08-14 20:01:14 +00:00
private ["_display", "_loaded", "_ctrl", "_selected", "_item"];
2015-08-16 20:41:35 +00:00
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-16 20:41:35 +00:00
_loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
if (count _loaded == 0) exitWith {};
2015-08-10 21:07:47 +00:00
_ctrl = _display displayCtrl 100;
_selected = (lbCurSel _ctrl) max 0;
2015-08-16 20:41:35 +00:00
if (count _loaded <= _selected) exitWith {};
2015-08-10 21:07:47 +00:00
_item = _loaded select _selected;
// Start progress bar
private ["_size", "_itemClass", "_displayName"];
if ([_item, GVAR(interactionVehicle)] call FUNC(canUnloadItem)) then {
_size = [_item] call FUNC(getSizeItem);
[5 * _size, [_item, GVAR(interactionVehicle)], "UnloadCargo", {}, localize LSTRING(UnloadingItem)] call EFUNC(common,progressBar);
} else {
_itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
_displayName = getText (configFile >> "CfgVehicles" >> _itemClass >> "displayName");
["displayTextStructured", [[LSTRING(UnloadingFailed), _displayName], 3.0]] call EFUNC(common,localEvent);
};