ACE3/addons/interaction/functions/fnc_openMenuSelectUI.sqf

58 lines
1.3 KiB
Plaintext
Raw Normal View History

/*
* Author: commy2
* Opens menu select UI
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Vehicle <OBJECT>
*
* Return value:
* None
*
* Example:
* [unit, vehicle] call ace_interaction_fnc_openMenuSelectUI
*
* Public: No
*/
2015-01-11 23:13:47 +00:00
#include "script_component.hpp"
2015-01-11 19:32:51 +00:00
2015-05-09 20:14:00 +00:00
PARAMS_2(_unit,_vehicle);
2015-01-11 19:32:51 +00:00
2015-05-09 20:14:00 +00:00
private ["_cargo", "_actions"];
2015-01-11 19:32:51 +00:00
2015-05-09 20:14:00 +00:00
// Allow interaction with all cargo slots and all FFV slots
2015-01-13 05:14:27 +00:00
_cargo = [_vehicle, ["cargo", "ffv"], true] call EFUNC(common,getVehicleCrew);
2015-01-11 19:32:51 +00:00
2015-05-09 20:14:00 +00:00
// You can only interact if you are in cargo or FFV yourself. exit otherwise
2015-01-11 19:32:51 +00:00
if !(_unit in _cargo) exitWith {};
2015-01-11 23:13:47 +00:00
GVAR(InteractionMenu_Crew) = _cargo;
2015-01-11 19:32:51 +00:00
2015-05-09 20:14:00 +00:00
// Prepare: add header and "OK" button to select menu
2015-05-28 19:59:04 +00:00
_actions = [localize LSTRING(InteractionMenu), localize LSTRING(Interact)] call FUNC(prepareSelectMenu);
2015-01-11 19:32:51 +00:00
2015-05-09 20:14:00 +00:00
// Prepare: add all cargo units as options to select menu
2015-01-11 19:32:51 +00:00
{
if (_x != _unit) then {
_actions = [
_actions,
[_x] call EFUNC(common,getName),
QUOTE(PATHTOF(UI\dot_ca.paa)),
_forEachIndex
] call FUNC(addSelectableItem);
};
2015-01-11 19:32:51 +00:00
} forEach _cargo;
2015-05-09 20:14:00 +00:00
// Open select menu
2015-01-11 19:32:51 +00:00
[
_actions,
{
call FUNC(hideMenu);
[0, GVAR(InteractionMenu_Crew) select _this, ""] spawn FUNC(showMenu);
GVAR(InteractionMenu_Crew) = nil;
},
{
call FUNC(hideMenu);
}
2015-01-11 23:13:47 +00:00
] call FUNC(openSelectMenu);