diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index 487f1c017f..9d50eb0a1c 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -7,6 +7,7 @@ PREP(addClassAction); PREP(compileMenu); PREP(compileMenuSelfAction); PREP(collectActiveActionTree); +PREP(createAction); PREP(keyDown); PREP(keyDownSelfAction); PREP(keyUp); diff --git a/addons/interact_menu/functions/fnc_addAction.sqf b/addons/interact_menu/functions/fnc_addAction.sqf index c7dd6ecab3..ef3c2196e6 100644 --- a/addons/interact_menu/functions/fnc_addAction.sqf +++ b/addons/interact_menu/functions/fnc_addAction.sqf @@ -14,6 +14,8 @@ * 7: Condition * 8: Distance * 9: Other parameters (Optional) + * 10: Insert children code (Optional) + * 11: Action parameters (Optional) * * Return value: * The entry full path, which can be used to remove the entry, or add children entries . @@ -27,7 +29,7 @@ EXPLODE_9_PVT(_this,_object,_typeNum,_fullPath,_displayName,_icon,_position,_statement,_condition,_distance); -private ["_varName","_actions","_params","_entry"]; +private ["_varName","_actions","_params","_insertChildren","_parameters","_entry"]; _varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum; _actions = _object getVariable [_varName, []]; @@ -40,6 +42,16 @@ if (count _this > 9) then { _params = _this select 9; }; +_insertChildren = {}; +if (count _this > 10) then { + _insertChildren = _this select 10; +}; + +_parameters = []; +if (count _this > 11) then { + _parameters = _this select 11; +}; + _entry = [ [ _displayName, @@ -49,7 +61,9 @@ _entry = [ _condition, _distance, _params, - + _fullPath + + _fullPath, + _insertChildren, + _parameters ], [] ]; diff --git a/addons/interact_menu/functions/fnc_addClassAction.sqf b/addons/interact_menu/functions/fnc_addClassAction.sqf index 4931328af2..a389b5bd8b 100644 --- a/addons/interact_menu/functions/fnc_addClassAction.sqf +++ b/addons/interact_menu/functions/fnc_addClassAction.sqf @@ -14,6 +14,8 @@ * 7: Condition * 8: Distance * 9: Other parameters (Optional) + * 10: Insert children code (Optional) + * 11: Action parameters (Optional) * * Return value: * The entry full path, which can be used to remove the entry, or add children entries . @@ -34,7 +36,7 @@ if (_typeNum == 0) then { [_objectType] call FUNC(compileMenuSelfAction); }; -private ["_varName","_actions","_params","_entry", "_parentLevel", "_foundParentLevel", "_fnc_findFolder"]; +private ["_varName","_actions","_params","_insertChildren","_parameters","_entry", "_parentLevel", "_foundParentLevel", "_fnc_findFolder"]; _varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType]; _actions = missionNamespace getVariable [_varName, []]; @@ -47,6 +49,16 @@ if (count _this > 9) then { _params = _this select 9; }; +_insertChildren = {}; +if (count _this > 10) then { + _insertChildren = _this select 10; +}; + +_parameters = []; +if (count _this > 11) then { + _parameters = _this select 11; +}; + // Search the class action trees and find where to insert the entry _parentLevel = _actions; _foundParentLevel = false; @@ -84,7 +96,9 @@ _entry = [ _condition, _distance, _params, - + _fullPath + + _fullPath, + _insertChildren, + _parameters ], [] ]; diff --git a/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf b/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf index 7e8da46014..ca6dadd44f 100644 --- a/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf +++ b/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf @@ -22,12 +22,17 @@ _target = _object; _player = ACE_player; // Return nothing if the action itself is not active -if !([_target, ACE_player] call (_origActionData select 4)) exitWith { +if !([_target, ACE_player, _origActionData select 9] call (_origActionData select 4)) exitWith { [] }; _activeChildren = []; +// If there's a statement to dynamically insert children then execute it +if (count _origActionData > 8 && {!({} isEqualTo (_origActionData select 8))}) then { + _activeChildren = [_target, ACE_player, _origActionData select 9] call (_origActionData select 8); +}; + // Collect children class actions { _action = [_object, _x] call FUNC(collectActiveActionTree); @@ -64,9 +69,12 @@ _activeChildren = []; // If the original action has no statement, and no children, don't display it +/* if ((count _activeChildren) == 0 && ((_origActionData select 3) isEqualTo {})) exitWith { // @todo: Account for showDisabled? [] }; +*/ +//diag_log [_origActionData, _activeChildren, _object]; [_origActionData, _activeChildren, _object] diff --git a/addons/interact_menu/functions/fnc_compileMenu.sqf b/addons/interact_menu/functions/fnc_compileMenu.sqf index e6a2744f03..46e74fb220 100644 --- a/addons/interact_menu/functions/fnc_compileMenu.sqf +++ b/addons/interact_menu/functions/fnc_compileMenu.sqf @@ -27,7 +27,7 @@ if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {}; private "_recurseFnc"; _recurseFnc = { private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled", - "_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_fullPath"]; + "_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_fullPath", "_insertChildren"]; EXPLODE_2_PVT(_this,_actionsCfg,_parentPath); _actions = []; @@ -46,7 +46,9 @@ _recurseFnc = { if (_condition == "") then {_condition = "true"}; // Add canInteract (including exceptions) and canInteractWith to condition - _condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EGVAR(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")]; + _condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")]; + + _insertChildren = compile (getText (_entryCfg >> "insertChildren")); _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0; _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0; @@ -68,7 +70,9 @@ _recurseFnc = { _condition, _distance, [_showDisabled,_enableInside,_canCollapse,_runOnHover], - _fullPath + _fullPath, + _insertChildren, + [] ], _children ]; diff --git a/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf b/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf index 81f4a25ef1..5c613caec2 100644 --- a/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf +++ b/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf @@ -27,7 +27,7 @@ if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {}; private "_recurseFnc"; _recurseFnc = { private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled", - "_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_fullPath"]; + "_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_fullPath", "_insertChildren"]; EXPLODE_2_PVT(_this,_actionsCfg,_parentPath); _actions = []; @@ -43,7 +43,9 @@ _recurseFnc = { if (_condition == "") then {_condition = "true"}; // Add canInteract (including exceptions) and canInteractWith to condition - _condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, objNull, %1)] call EGVAR(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")]; + _condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, objNull, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")]; + + _insertChildren = compile (getText (_entryCfg >> "insertChildren")); _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0; _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0; @@ -65,7 +67,9 @@ _recurseFnc = { _condition, 10, //distace [_showDisabled,_enableInside,_canCollapse,_runOnHover], - _fullPath + _fullPath, + _insertChildren, + [] ], _children ]; @@ -89,7 +93,9 @@ _actions = [ { true }, 10, [false,true,false], - ["ACE_SelfActions"] + ["ACE_SelfActions"], + {}, + [] ], [_actionsCfg, ["ACE_SelfActions"]] call _recurseFnc ] diff --git a/addons/interact_menu/functions/fnc_createAction.sqf b/addons/interact_menu/functions/fnc_createAction.sqf new file mode 100644 index 0000000000..e7d53dab03 --- /dev/null +++ b/addons/interact_menu/functions/fnc_createAction.sqf @@ -0,0 +1,63 @@ +/* + * Author: CAA-Picard + * Creates an isolated ACE action + * Note: This function is NOT global. + * + * Argument: + * 0: Action name + * 1: Name of the action shown in the menu + * 2: Icon + * 3: Position (Position or Selection Name) or + * 4: Statement + * 5: Condition + * 6: Distance + * 7: Other parameters (Optional) + * 8: Insert children code (Optional) + * 9: Action parameters (Optional) + * + * Return value: + * Action + * + * Example: + * [[VulcanPinch"],"Vulcan Pinch","",[0,0,0],{_target setDamage 1;},{true},100,{},[parameters]] call ace_interact_menu_fnc_addAction; + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_7_PVT(_this,_fullPath,_displayName,_icon,_position,_statement,_condition,_distance); + +private ["_actions","_params","_insertChildren","_parameters","_entry"]; + +_params = [false,false,false,false]; +if (count _this > 7) then { + _params = _this select 7; +}; + +_insertChildren = {}; +if (count _this > 8) then { + _insertChildren = _this select 8; +}; + +_parameters = []; +if (count _this > 9) then { + _parameters = _this select 9; +}; + +_entry = [ + [ + _displayName, + _icon, + _position, + _statement, + _condition, + _distance, + _params, + + _fullPath, + _insertChildren, + _parameters + ], + [] + ]; + +_entry diff --git a/addons/interact_menu/functions/fnc_keyUp.sqf b/addons/interact_menu/functions/fnc_keyUp.sqf index 716d6dafd8..fe60c438b6 100644 --- a/addons/interact_menu/functions/fnc_keyUp.sqf +++ b/addons/interact_menu/functions/fnc_keyUp.sqf @@ -16,7 +16,7 @@ if(GVAR(actionSelected)) then { this = GVAR(selectedTarget); _player = ACE_Player; _target = GVAR(selectedTarget); - [GVAR(selectedTarget), ACE_player] call GVAR(selectedStatement); + [GVAR(selectedTarget), ACE_player, (GVAR(selectedAction) select 0) select 9] call GVAR(selectedStatement); }; if (GVAR(keyDown)) then { diff --git a/addons/interact_menu/functions/fnc_keyUpSelfAction.sqf b/addons/interact_menu/functions/fnc_keyUpSelfAction.sqf index 6346696d53..4603479e87 100644 --- a/addons/interact_menu/functions/fnc_keyUpSelfAction.sqf +++ b/addons/interact_menu/functions/fnc_keyUpSelfAction.sqf @@ -20,7 +20,7 @@ if(GVAR(actionSelected)) then { this = GVAR(selectedTarget); _player = ACE_Player; _target = GVAR(selectedTarget); - [GVAR(selectedTarget), ACE_player] call GVAR(selectedStatement); + [GVAR(selectedTarget), ACE_player, (GVAR(selectedAction) select 0) select 9] call GVAR(selectedStatement); }; if (GVAR(keyDownSelfAction)) then {