diff --git a/addons/attach/CfgVehicles.hpp b/addons/attach/CfgVehicles.hpp index 9ae9dae7a2..744a0db2ad 100644 --- a/addons/attach/CfgVehicles.hpp +++ b/addons/attach/CfgVehicles.hpp @@ -5,7 +5,7 @@ class GVAR(AttachVehicle) { \ displayName = CSTRING(AttachDetach); \ condition = QUOTE(_this call FUNC(canAttach)); \ - insertChildren = QUOTE(_this call FUNC(getChildrenAttachActions)); \ + insertChildren = QUOTE(_this call FUNC(getChildrenActions)); \ exceptions[] = {"isNotSwimming"}; \ showDisabled = 0; \ icon = QPATHTOF(UI\attach_ca.paa); \ @@ -52,7 +52,7 @@ class CfgVehicles { class GVAR(Attach) { displayName = CSTRING(AttachDetach); condition = QUOTE(_this call FUNC(canAttach)); - insertChildren = QUOTE(_this call FUNC(getChildrenAttachActions)); + insertChildren = QUOTE(_this call FUNC(getChildrenActions)); exceptions[] = {"isNotDragging", "isNotSwimming"}; showDisabled = 0; icon = QPATHTOF(UI\attach_ca.paa); diff --git a/addons/attach/XEH_PREP.hpp b/addons/attach/XEH_PREP.hpp index 5dedc2254e..85915b4f45 100644 --- a/addons/attach/XEH_PREP.hpp +++ b/addons/attach/XEH_PREP.hpp @@ -1,9 +1,8 @@ - PREP(attach); PREP(canAttach); PREP(canDetach); PREP(detach); -PREP(getChildrenAttachActions); +PREP(getChildrenActions); PREP(handleGetIn); PREP(handleGetOut); PREP(handleKilled); diff --git a/addons/attach/functions/fnc_getChildrenActions.sqf b/addons/attach/functions/fnc_getChildrenActions.sqf new file mode 100644 index 0000000000..050eec4021 --- /dev/null +++ b/addons/attach/functions/fnc_getChildrenActions.sqf @@ -0,0 +1,48 @@ +/* + * Author: Garth de Wet (LH), PabstMirror, mharis001 + * Returns children actions for attachable items. + * + * Arguments: + * 0: Target + * 1: Player + * + * Return Value: + * Actions + * + * Example: + * [_target, _player] call ace_attach_fnc_getChildrenActions + * + * Public: No + */ +#include "script_component.hpp" + +params ["_target", "_player"]; +TRACE_2("params",_target,_player); + +private _cfgMagazines = configFile >> "CfgMagazines"; +private _cfgWeapons = configFile >> "CfgWeapons"; + +private _actions = []; + +private _magazines = magazines _player; +{ + private _config = _cfgMagazines >> _x; + if (getText (_config >> "ACE_Attachable") != "") then { + private _displayName = getText (_config >> "displayName"); + private _picture = getText (_config >> "picture"); + private _action = [_x, _displayName, _picture, {[{_this call FUNC(attach)}, _this] call CBA_fnc_execNextFrame}, {true}, {}, _x] call EFUNC(interact_menu,createAction); + _actions pushBack [_action, [], _target]; + }; +} forEach (_magazines arrayIntersect _magazines); + +{ + private _config = _cfgWeapons >> _x; + if (getText (_config >> "ACE_Attachable") != "") then { + private _displayName = getText (_config >> "displayName"); + private _picture = getText (_config >> "picture"); + private _action = [_x, _displayName, _picture, {[{_this call FUNC(attach)}, _this] call CBA_fnc_execNextFrame}, {true}, {}, _x] call EFUNC(interact_menu,createAction); + _actions pushBack [_action, [], _target]; + }; +} forEach ([_player, false] call CBA_fnc_uniqueUnitItems); + +_actions diff --git a/addons/attach/functions/fnc_getChildrenAttachActions.sqf b/addons/attach/functions/fnc_getChildrenAttachActions.sqf deleted file mode 100644 index c9bec90aac..0000000000 --- a/addons/attach/functions/fnc_getChildrenAttachActions.sqf +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Author: Garth de Wet (LH), PabstMirror - * Show the ammo counts for a static weapon. - * Called from "insertChildren" on interact_menu - * - * Arguments: - * 0: Target - * 1: Player - * - * Return Value: - * ChildActiosn - * - * Example: - * [player, player] call ace_attach_fnc_getChildrenAttachActions - * - * Public: No - */ -#include "script_component.hpp" - -params ["_target","_player"]; -TRACE_2("params",_target,_player); - -private _listed = []; -private _actions = []; - -{ - if !(_x in _listed) then { - _listed pushBack _x; - private _item = ConfigFile >> "CfgMagazines" >> _x; - if (getText (_item >> "ACE_Attachable") != "") then { - private _displayName = getText(_item >> "displayName"); - private _picture = getText(_item >> "picture"); - private _action = [_x, _displayName, _picture, {[{_this call FUNC(attach)}, _this] call CBA_fnc_execNextFrame}, {true}, {}, [_x]] call EFUNC(interact_menu,createAction); - _actions pushBack [_action, [], _target]; - }; - }; -} forEach (magazines _player); - -{ - if !(_x in _listed) then { - _listed pushBack _x; - private _item = ConfigFile >> "CfgWeapons" >> _x; - if (getText (_item >> "ACE_Attachable") != "") then { - private _displayName = getText(_item >> "displayName"); - private _picture = getText(_item >> "picture"); - private _action = [_x, _displayName, _picture, {[{_this call FUNC(attach)}, _this] call CBA_fnc_execNextFrame}, {true}, {}, [_x]] call EFUNC(interact_menu,createAction); - _actions pushBack [_action, [], _target]; - }; - }; -} forEach (items _player); - -_actions