diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index 72e8e7249e..6d13067aba 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -5,6 +5,7 @@ ADDON = false; PREP(addAction); PREP(compileMenu); PREP(compileMenuSelfAction); +PREP(collectActiveChildren); PREP(keyDown); PREP(keyDownSelfAction); PREP(keyUp); diff --git a/addons/interact_menu/functions/fnc_collectActiveChildren.sqf b/addons/interact_menu/functions/fnc_collectActiveChildren.sqf new file mode 100644 index 0000000000..c258516f00 --- /dev/null +++ b/addons/interact_menu/functions/fnc_collectActiveChildren.sqf @@ -0,0 +1,58 @@ +/* + * Author: CAA-Picard + * For a given action, collect all active children + * + * Argument: + * 0: Object + * 1: Action data + * + * Return value: + * Active children + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_2_PVT(_this,_object,_parentAction); + +private ["_activeChildren","_target","_player","_action"]; + +_activeChildren = []; + +_target = _object; +_player = ACE_player; + +// Collect children class actions +{ + _action = _x; + + if([_object, ACE_player] call (_action select 4)) then { + _activeChildren pushBack _action; + }; +} forEach (_parentAction select 6); + +// Collect children object actions +{ + _action = _x; + + // Check if the action is children of the selected menu + if ((count (_action select 8)) == (count (_parentAction select 8) + 1)) then { + + // Compare parent path to see if it's a suitable child + private "_isChild"; + _isChild = true; + { + if !(_x isEqualTo ((_action select 8) select _forEachIndex)) exitWith { + _isChild = false; + }; + } forEach (_parentAction select 8); + + if (_isChild) then { + if ([_target, ACE_player] call (_action select 4)) then { + _activeChildren pushBack _action; + }; + }; + }; +} forEach GVAR(objectActions); + +_activeChildren diff --git a/addons/interact_menu/functions/fnc_renderMenu.sqf b/addons/interact_menu/functions/fnc_renderMenu.sqf index ec836c1be3..547b2a5a80 100644 --- a/addons/interact_menu/functions/fnc_renderMenu.sqf +++ b/addons/interact_menu/functions/fnc_renderMenu.sqf @@ -95,42 +95,7 @@ if !(_menuInSelectedPath) exitWith {true}; // Collect all active children actions private "_activeChildren"; -_activeChildren = []; -// Collect children class actions -{ - _target = _object; - _player = ACE_player; - _active = [_object, ACE_player] call (_x select 4); - if(_active) then { - _activeChildren pushBack _x; - }; -} forEach (_actionData select 6); - -// Collect children object actions -{ - _actionItem = _x; - - // Check if the action is children of the selected menu - if ((count (_actionItem select 8)) == (count _path)) then { - // Compare parent path to see if it's a suitable child - private "_isChild"; - _isChild = true; - for "_i" from 0 to (count (_actionItem select 8)) - 2 do { - if !(((_actionItem select 8) select _i) isEqualTo (_path select (_i + 1))) exitWith { - _isChild = false; - }; - }; - if (_isChild) exitWith { - _target = _object; - _player = ACE_player; - _active = [_target, ACE_player] call (_actionItem select 4); - - if (_active) then { - _activeChildren pushBack _actionItem; - }; - }; - }; -} forEach GVAR(objectActions); +_activeChildren = [_object,_actionData] call FUNC(collectActiveChildren); private ["_angleSpan","_angle"]; _angleSpan = _maxAngleSpan min (55 * ((count _activeChildren) - 1)); @@ -139,7 +104,6 @@ if (_angleSpan >= 305) then { }; _angle = _centerAngle - _angleSpan / 2; - { _target = _object; _player = ACE_player;