2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-02-02 08:35:17 +00:00
|
|
|
* Author: Garth 'L-H' de Wet
|
|
|
|
* Opens the UI for explosive placement selection
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player] call ACE_Explosives_fnc_openPlaceUI;
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-13 21:21:31 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
private ["_unit","_mags", "_item", "_index", "_actions"];
|
|
|
|
_unit = _this select 0;
|
2015-01-12 09:48:26 +00:00
|
|
|
call FUNC(place_Cancel);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
_mags = magazines _unit;
|
|
|
|
_list = [];
|
|
|
|
_itemCount = [];
|
|
|
|
{
|
|
|
|
_item = ConfigFile >> "CfgMagazines" >> _x;
|
2015-01-12 09:48:26 +00:00
|
|
|
if (getNumber(_item >> "ACE_Placeable") == 1) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_index = _list find _item;
|
|
|
|
if (_index != -1) then {
|
|
|
|
_itemCount set [_index, (_itemCount select _index) + 1];
|
|
|
|
} else {
|
|
|
|
_list pushBack _item;
|
|
|
|
_itemCount pushBack 1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach _mags;
|
2015-01-12 09:48:26 +00:00
|
|
|
_actions = [localize "STR_ACE_Explosives_PlaceMenu", localize "STR_ACE_Explosives_Place"]
|
2015-01-15 19:13:12 +00:00
|
|
|
call EFUNC(interaction,prepareSelectMenu);
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
|
|
|
_actions = [
|
|
|
|
_actions,
|
|
|
|
format [getText(_x >> "displayName") + " (%1)", _itemCount select _foreachIndex],
|
|
|
|
getText(_x >> "picture"),
|
|
|
|
configName _x
|
2015-01-15 19:13:12 +00:00
|
|
|
] call EFUNC(interaction,AddSelectableItem);
|
2015-01-11 16:42:31 +00:00
|
|
|
} foreach _list;
|
|
|
|
|
|
|
|
[
|
|
|
|
_actions,
|
|
|
|
{
|
2015-01-12 09:48:26 +00:00
|
|
|
[_this] call FUNC(openTriggerSelectionUI);
|
2015-01-11 16:42:31 +00:00
|
|
|
},
|
|
|
|
{
|
2015-01-15 19:13:12 +00:00
|
|
|
call EFUNC(interaction,hideMenu);
|
|
|
|
if !(profileNamespace getVariable [EGVAR(interaction,AutoCloseMenu), false]) then {
|
|
|
|
"ACE_Explosives" call EFUNC(interaction,openMenuSelf);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
}
|
2015-01-15 19:13:12 +00:00
|
|
|
] call EFUNC(interaction,openSelectMenu);
|