2023-09-12 18:58:10 +00:00
#include "..\script_component.hpp"
2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2023-11-17 23:07:28 +00:00
* Handles 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:
2023-11-17 23:07:28 +00:00
* display call ace_cargo_fnc_onMenuOpen
2015-08-16 20:41:35 +00:00
*
2015-08-10 21:07:47 +00:00
* Public: No
*/
disableSerialization;
2015-08-16 20:41:35 +00:00
params ["_display"];
uiNamespace setVariable [QGVAR(menuDisplay), _display];
2015-08-10 21:07:47 +00:00
2016-08-27 08:14:54 +00:00
if (GVAR(interactionParadrop)) then {
2023-11-17 23:07:28 +00:00
(_display displayCtrl 12) ctrlSetText LLSTRING(paradropButton);
2016-08-27 08:14:54 +00:00
};
2024-02-07 12:16:18 +00:00
// Disable deploy option if paradropping or in Zeus
(_display displayCtrl 13) ctrlEnable (GVAR(enableDeploy) && !GVAR(interactionParadrop) && {isNull curatorCamera});
2015-08-10 21:07:47 +00:00
[{
2023-11-17 23:07:28 +00:00
params ["_vehicle", "_pfhID"];
2015-08-10 21:07:47 +00:00
disableSerialization;
2023-11-17 23:07:28 +00:00
2016-01-19 03:53:48 +00:00
private _display = uiNamespace getVariable QGVAR(menuDisplay);
2023-11-17 23:07:28 +00:00
if (isNil "_display") exitWith {
GVAR(interactionParadrop) = nil;
_pfhID call CBA_fnc_removePerFrameHandler;
2015-08-10 21:07:47 +00:00
};
2023-11-17 23:07:28 +00:00
// Close menu if in invalid state
if (
2024-02-07 12:16:18 +00:00
!alive ACE_player ||
{!alive _vehicle} ||
2023-11-17 23:07:28 +00:00
{locked _vehicle >= 2} ||
{!(_vehicle getVariable [QGVAR(hasCargo), true])} || // if the cargo menu could be opened, the vehicle has QGVAR(hasCargo) in its config or the variable is set using FUNC(setSpace)
2023-11-21 23:44:08 +00:00
{
2024-02-07 12:16:18 +00:00
isNull curatorCamera && // if in Zeus, ignore the checks that follow
2023-11-21 23:44:08 +00:00
{([ACE_player, _vehicle] call EFUNC(interaction,getInteractionDistance)) >= MAX_LOAD_DISTANCE} &&
{(vehicle ACE_player) != _vehicle}
}
2023-11-17 23:07:28 +00:00
) exitWith {
2015-08-10 21:07:47 +00:00
closeDialog 0;
2023-11-17 23:07:28 +00:00
GVAR(interactionParadrop) = nil;
_pfhID call CBA_fnc_removePerFrameHandler;
2015-08-10 21:07:47 +00:00
};
2016-01-19 03:53:48 +00:00
private _ctrl = _display displayCtrl 100;
private _label = _display displayCtrl 2;
2015-08-10 21:07:47 +00:00
2023-11-17 23:07:28 +00:00
// Remove previous entries
2015-08-10 21:07:47 +00:00
lbClear _ctrl;
2023-11-17 23:07:28 +00:00
// Display item names
private _displayName = "";
private _itemSize = 0;
private _index = -1;
2023-11-21 01:46:16 +00:00
private _damageStr = "0%";
private _damage = 0;
2023-11-17 23:07:28 +00:00
2015-08-10 21:07:47 +00:00
{
2023-11-17 23:07:28 +00:00
_displayName = [_x, true] call FUNC(getNameItem);
_itemSize = _x call FUNC(getSizeItem);
2023-11-21 01:46:16 +00:00
_damage = if (_x isEqualType "") then {0} else {damage _x};
_damageStr = ((_damage * 100) toFixed 0) + "%";
2023-11-17 23:07:28 +00:00
if (_itemSize >= 0) then {
_index = if (GVAR(interactionParadrop)) then {
2023-11-21 01:46:16 +00:00
_ctrl lbAdd format ["%1. %2 (%3s)", _forEachIndex + 1, _displayName, GVAR(paradropTimeCoefficent) * _itemSize]
2023-11-17 23:07:28 +00:00
} else {
2023-11-21 01:46:16 +00:00
_ctrl lbAdd format ["%1. %2", _forEachIndex + 1, _displayName]
2023-11-17 23:07:28 +00:00
};
2023-11-21 01:46:16 +00:00
private _tooltip = format ["%1\n%2", format [LLSTRING(sizeMenu), _itemSize], format ["%1: %2", localize "str_a3_normaldamage1", _damageStr]];
_ctrl lbSetTooltip [_index, _tooltip];
2017-05-05 19:02:59 +00:00
} else {
2023-11-17 23:07:28 +00:00
// If item has a size < 0, it means it's not loadable
_index = _ctrl lbAdd _displayName;
2017-05-05 19:02:59 +00:00
2023-11-17 23:07:28 +00:00
_ctrl lbSetTooltip [_index, LLSTRING(unloadingImpossible)];
_ctrl lbSetColor [_index, [1, 0, 0, 1]]; // set text to red
_ctrl lbSetSelectColor [_index, [1, 0, 0, 1]];
};
} forEach (_vehicle getVariable [QGVAR(loaded), []]);
2015-08-10 21:07:47 +00:00
2023-11-17 23:07:28 +00:00
_label ctrlSetText format [LLSTRING(labelSpace), (_vehicle call FUNC(getCargoSpaceLeft)) max 0];
}, 0, GVAR(interactionVehicle)] call CBA_fnc_addPerFrameHandler;