From 65c5e6e38eb8e54ff859b53b3f6853274fa2323d Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 14 Oct 2017 12:01:07 -0500 Subject: [PATCH] Add function to add curator actions (#5620) --- addons/interact_menu/XEH_PREP.hpp | 1 + .../functions/fnc_addActionToZeus.sqf | 45 +++++++++++++++++++ .../framework/interactionMenu-framework.md | 26 ++++++++++- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 addons/interact_menu/functions/fnc_addActionToZeus.sqf diff --git a/addons/interact_menu/XEH_PREP.hpp b/addons/interact_menu/XEH_PREP.hpp index 7ee668a583..840acbf10d 100644 --- a/addons/interact_menu/XEH_PREP.hpp +++ b/addons/interact_menu/XEH_PREP.hpp @@ -1,6 +1,7 @@ PREP(addActionToClass); PREP(addActionToObject); +PREP(addActionToZeus); PREP(addMainAction); PREP(compileMenu); PREP(compileMenuSelfAction); diff --git a/addons/interact_menu/functions/fnc_addActionToZeus.sqf b/addons/interact_menu/functions/fnc_addActionToZeus.sqf new file mode 100644 index 0000000000..66c1f29d08 --- /dev/null +++ b/addons/interact_menu/functions/fnc_addActionToZeus.sqf @@ -0,0 +1,45 @@ +/* + * Author: PabstMirror + * Insert an ACE action to zeus. + * Note: This function is NOT global. + * + * Arguments: + * 0: Parent path of the new action (e.g. ["ACE_ZeusActions"]) + * 1: Action + * + * Return Value: + * The entry full path, which can be used to add children entries . + * + * Example: + * [["ACE_ZeusActions"], zeusAction] call ace_interact_menu_fnc_addActionToZeus; + * + * Public: Yes + */ +#include "script_component.hpp" + +if (!params [["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith {ERROR("Bad Params"); []}; +if ((_parentPath param [0, ""]) != "ACE_ZeusActions") exitWith {ERROR_1("Bad path %1 - should have ACE_ZeusActions as base", _parentPath); []}; +TRACE_2("addActionToZeus",_parentPath,_action); + +private _currentPath = GVAR(ZeusActions); +private _pathValid = false; +{ + private _targetParent = _x; + _pathValid = false; + { + _x params ["_xAction", "_xSubActions"]; + TRACE_2("",_targetParent,_xAction); + if ((_xAction select 0) == _targetParent) exitWith { + _pathValid = true; + _currentPath = _xSubActions; + }; + } forEach _currentPath; +} forEach _parentPath; + +if (!_pathValid) exitWith {ERROR_1("Bad path %1", _parentPath); []}; + +TRACE_1("Adding Action",_currentPath); +_currentPath pushBack [_action, []]; + +// Return the full path +(_parentPath + [_action select 0]) diff --git a/docs/wiki/framework/interactionMenu-framework.md b/docs/wiki/framework/interactionMenu-framework.md index c77c03e785..44f4623ece 100644 --- a/docs/wiki/framework/interactionMenu-framework.md +++ b/docs/wiki/framework/interactionMenu-framework.md @@ -121,7 +121,19 @@ By default this function will not use inheritance, so actions will only be added */ ``` -### 2.4 Examples +### 2.4 fnc_addActionToZeus + +`ace_interact_menu_fnc_addActionToZeus` + +```cpp +/* + * Argument: + * 0: Parent path of the new action (Example: `["ACE_ZeusActions"]`) + * 1: Action + */ +``` + +### 2.5 Examples External: @@ -155,7 +167,17 @@ _action = ["CheckExtTank","Check External Tank","",{hint format ["Ext Tank: %1", ["Tank_F", 0, ["ACE_MainActions", "CheckFuel"], _action, true] call ace_interact_menu_fnc_addActionToClass; ``` -### 2.5 Advanced Example +Zeus: + +```cpp +_statement = { + playSound3D ["alarm.ogg", theBase] +}; +_action = ["myMissionEvent1","Mission Event: Play Base Alarm","",_statement,{true}] call ace_interact_menu_fnc_createAction; +[["ACE_ZeusActions"], _action] call ace_interact_menu_fnc_addActionToZeus; +``` + +### 2.6 Advanced Example This adds an interaction to a unit that allows passing items that the player is carrying.