ACE3/addons/attach/functions/fnc_openAttachUI.sqf

64 lines
1.6 KiB
Plaintext
Raw Normal View History

2015-01-11 20:39:49 +00:00
#include "script_component.hpp"
/*
Author: Garth de Wet (LH)
Description:
Opens the UI for attaching objects.
Parameters:
0: OBJECT - unit
Returns:
Nothing
Example:
2015-01-13 23:00:31 +00:00
[player] call ACE_Attach_fnc_openAttachUI;
2015-01-11 20:39:49 +00:00
*/
private ["_unit", "_actions", "_attachables", "_item"];
_unit = _this select 0;
_listed = [];
_attachables = magazines _unit;
2015-01-13 23:00:31 +00:00
_actions = [localize "STR_ACE_Attach_AttachDetach", localize "STR_ACE_Attach_Attach"] call EFUNC(interaction,prepareSelectMenu);
2015-01-11 20:39:49 +00:00
{
if !(_x in _listed) then {
_item = ConfigFile >> "CfgMagazines" >> _x;
2015-01-13 23:00:31 +00:00
if (getNumber (_item >> "ACE_Attachable") == 1) then {
2015-01-11 20:39:49 +00:00
_actions = [
_actions,
getText(_item >> "displayName"),
getText(_item >> "picture"),
_x
] call EFUNC(interaction,addSelectableItem);
};
_listed pushBack _x;
};
} forEach _attachables;
_attachables = items _unit;
{
if !(_x in _listed) then {
_item = ConfigFile >> "CfgWeapons" >> _x;
2015-01-13 23:00:31 +00:00
if (getNumber (_item >> "ACE_Attachable") == 1) then {
2015-01-11 20:39:49 +00:00
_actions = [
_actions,
getText(_item >> "displayName"),
getText(_item >> "picture"),
_x
] call EFUNC(interaction,addSelectableItem);
};
_listed pushBack _x;
};
} forEach _attachables;
[
_actions,
{
2015-01-13 23:00:31 +00:00
[ACE_player, _this] call FUNC(attach);
2015-01-11 20:39:49 +00:00
call EFUNC(interaction,hideMenu);
},
{
call EFUNC(interaction,hideMenu);
2015-01-13 15:38:21 +00:00
if !(profileNamespace getVariable [QEGVAR(interaction,AutoCloseMenu), false]) then {"Default" call EFUNC(interaction,openMenuSelf)};
2015-01-11 20:39:49 +00:00
}
] call EFUNC(interaction,openSelectMenu);