From 386fee4694eb6744ea8bce34edf09e4888ca2649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Thu, 19 Mar 2015 13:31:45 -0300 Subject: [PATCH] Replace place list menu by dynamically created actions --- addons/explosives/CfgVehicles.hpp | 3 +- addons/explosives/XEH_preInit.sqf | 2 +- .../functions/fnc_addExplosiveActions.sqf | 55 +++++++++++++++++++ .../explosives/functions/fnc_openPlaceUI.sqf | 55 ------------------- 4 files changed, 58 insertions(+), 57 deletions(-) create mode 100644 addons/explosives/functions/fnc_addExplosiveActions.sqf delete mode 100644 addons/explosives/functions/fnc_openPlaceUI.sqf diff --git a/addons/explosives/CfgVehicles.hpp b/addons/explosives/CfgVehicles.hpp index e62b31aa56..99f884c0ab 100644 --- a/addons/explosives/CfgVehicles.hpp +++ b/addons/explosives/CfgVehicles.hpp @@ -26,7 +26,8 @@ class CfgVehicles { class ACE_Place { displayName = $STR_ACE_Explosives_Place; condition = QUOTE((vehicle _player == _player) and {[_player] call FUNC(hasExplosives)}); - statement = QUOTE([_player] call FUNC(openPlaceUI);); + statement = ""; + insertChildren = QUOTE([_player] call FUNC(addExplosiveActions);); exceptions[] = {"ACE_Interaction_isNotSwimming"}; showDisabled = 1; icon = PATHTOF(UI\Place_Explosive_ca.paa); diff --git a/addons/explosives/XEH_preInit.sqf b/addons/explosives/XEH_preInit.sqf index 3747151d16..c306a1f2f2 100644 --- a/addons/explosives/XEH_preInit.sqf +++ b/addons/explosives/XEH_preInit.sqf @@ -19,6 +19,7 @@ ADDON = false; PREP(addCellphoneIED); PREP(addClacker); +PREP(addExplosiveActions); PREP(addToSpeedDial); PREP(canDefuse); PREP(canDetonate); @@ -37,7 +38,6 @@ PREP(getPlacedExplosives); PREP(getSpeedDialExplosive); PREP(openDetonateUI); -PREP(openPlaceUI); PREP(openTransmitterUI); PREP(openTimerSetUI); PREP(openTriggerSelectionUI); diff --git a/addons/explosives/functions/fnc_addExplosiveActions.sqf b/addons/explosives/functions/fnc_addExplosiveActions.sqf new file mode 100644 index 0000000000..6cdc611329 --- /dev/null +++ b/addons/explosives/functions/fnc_addExplosiveActions.sqf @@ -0,0 +1,55 @@ +/* + * Author: Garth 'L-H' de Wet and CAA-Picard + * + * + * Arguments: + * 0: Unit + * + * Return Value: + * Actions + * + * Public: No + */ +#include "script_component.hpp" +private ["_mags", "_item", "_index", "_actions"]; + +EXPLODE_1_PVT(_this,_unit); + +_mags = magazines _unit; +_list = []; +_itemCount = []; +{ + _item = ConfigFile >> "CfgMagazines" >> _x; + if (getNumber(_item >> "ACE_Placeable") == 1) then { + _index = _list find _item; + if (_index != -1) then { + _itemCount set [_index, (_itemCount select _index) + 1]; + } else { + _list pushBack _item; + _itemCount pushBack 1; + }; + }; +} forEach _mags; + +_children = []; + +{ + _action = [ + [format ["Explosive_%1", _forEachIndex]], + format [getText(_x >> "displayName") + " (%1)", _itemCount select _foreachIndex], + getText(_x >> "picture"), + "", + {(_this select 2) call FUNC(openTriggerSelectionUI)}, + {true}, + 2, + [false,false,false,false], + {}, + [configName _x] + ] call EFUNC(interact_menu,createAction); + + _action pushBack _unit; + _children pushBack _action + +} foreach _list; + +_children diff --git a/addons/explosives/functions/fnc_openPlaceUI.sqf b/addons/explosives/functions/fnc_openPlaceUI.sqf deleted file mode 100644 index 6eb2d478bf..0000000000 --- a/addons/explosives/functions/fnc_openPlaceUI.sqf +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Author: Garth 'L-H' de Wet - * Opens the UI for explosive placement selection - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [player] call ACE_Explosives_fnc_openPlaceUI; - * - * Public: No - */ -#include "script_component.hpp" -private ["_unit","_mags", "_item", "_index", "_actions"]; -_unit = _this select 0; -call FUNC(place_Cancel); - -_mags = magazines _unit; -_list = []; -_itemCount = []; -{ - _item = ConfigFile >> "CfgMagazines" >> _x; - if (getNumber(_item >> "ACE_Placeable") == 1) then { - _index = _list find _item; - if (_index != -1) then { - _itemCount set [_index, (_itemCount select _index) + 1]; - } else { - _list pushBack _item; - _itemCount pushBack 1; - }; - }; -} forEach _mags; -_actions = [localize "STR_ACE_Explosives_PlaceMenu", localize "STR_ACE_Explosives_Place"] - call EFUNC(interaction,prepareSelectMenu); -{ - _actions = [ - _actions, - format [getText(_x >> "displayName") + " (%1)", _itemCount select _foreachIndex], - getText(_x >> "picture"), - configName _x - ] call EFUNC(interaction,AddSelectableItem); -} foreach _list; - -[ - _actions, - { - [_this] call FUNC(openTriggerSelectionUI); - }, - { - call EFUNC(interaction,hideMenu); - } -] call EFUNC(interaction,openSelectMenu);