mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Refactoring of interact_menu:
- Reordering of action members - Removed full path from actions, so they can be mounted under different paths if needed - Added api for creating actions - Api for adding actions for objects or classes
This commit is contained in:
parent
49cdf6512e
commit
84bf44e026
@ -2,22 +2,24 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(addAction);
|
||||
PREP(addClassAction);
|
||||
PREP(addActionToClass);
|
||||
PREP(addActionToObject);
|
||||
PREP(compileMenu);
|
||||
PREP(compileMenuSelfAction);
|
||||
PREP(collectActiveActionTree);
|
||||
PREP(createAction);
|
||||
PREP(findActionNode);
|
||||
PREP(keyDown);
|
||||
PREP(keyDownSelfAction);
|
||||
PREP(keyUp);
|
||||
PREP(keyUpSelfAction);
|
||||
PREP(removeAction);
|
||||
PREP(removeClassAction);
|
||||
PREP(removeActionFromClass);
|
||||
PREP(removeActionFromObject);
|
||||
PREP(render);
|
||||
PREP(renderIcon);
|
||||
PREP(renderBaseMenu);
|
||||
PREP(renderIcon);
|
||||
PREP(renderMenu);
|
||||
PREP(splitPath);
|
||||
|
||||
GVAR(keyDown) = false;
|
||||
GVAR(keyDownSelfAction) = false;
|
||||
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Author: commy2, NouberNou and CAA-Picard
|
||||
* Add an ACE action to an object, under a certain config path
|
||||
* Note: This function is NOT global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Object the action should be assigned to <OBJECT>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Full path of the new action <ARRAY>
|
||||
* 3: Name of the action shown in the menu <STRING>
|
||||
* 4: Icon <STRING>
|
||||
* 5: Position (Position or Selection Name) <POSITION> or <STRING>
|
||||
* 6: Statement <CODE>
|
||||
* 7: Condition <CODE>
|
||||
* 8: Distance <NUMBER>
|
||||
* 9: Other parameters <ARRAY> (Optional)
|
||||
* 10: Insert children code <CODE> (Optional)
|
||||
* 11: Action parameters <ANY> (Optional)
|
||||
*
|
||||
* Return value:
|
||||
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
|
||||
*
|
||||
* Example:
|
||||
* [cursorTarget,0,["ACE_TapShoulderRight","VulcanPinch"],"Vulcan Pinch","",[0,0,0],{_target setDamage 1;},{true},100] call ace_interact_menu_fnc_addAction;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_9_PVT(_this,_object,_typeNum,_fullPath,_displayName,_icon,_position,_statement,_condition,_distance);
|
||||
|
||||
private ["_varName","_actions","_params","_insertChildren","_parameters","_entry"];
|
||||
|
||||
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
|
||||
_actions = _object getVariable [_varName, []];
|
||||
if((count _actions) == 0) then {
|
||||
_object setVariable [_varName, _actions];
|
||||
};
|
||||
|
||||
_params = [false,false,false,false];
|
||||
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,
|
||||
_icon,
|
||||
_position,
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
_params,
|
||||
+ _fullPath,
|
||||
_insertChildren,
|
||||
_parameters
|
||||
],
|
||||
[]
|
||||
];
|
||||
|
||||
_actions pushBack _entry;
|
||||
|
||||
_fullPath
|
45
addons/interact_menu/functions/fnc_addActionToClass.sqf
Normal file
45
addons/interact_menu/functions/fnc_addActionToClass.sqf
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Insert an ACE action to a class, under a certain path
|
||||
* Note: This function is NOT global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: TypeOf of the class <STRING>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Parent path of the new action <ARRAY>
|
||||
* 3: Action <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
|
||||
*
|
||||
* Example:
|
||||
* [typeOf cursorTarget, 0, ["ACE_TapShoulderRight"],VulcanPinchAction] call ace_interact_menu_fnc_addActionToClass;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_4_PVT(_this,_objectType,_typeNum,_parentPath,_action);
|
||||
|
||||
// Ensure the config menu was compiled first
|
||||
if (_typeNum == 0) then {
|
||||
[_objectType] call FUNC(compileMenu);
|
||||
} else {
|
||||
[_objectType] call FUNC(compileMenuSelfAction);
|
||||
};
|
||||
|
||||
private ["_varName","_actionTrees", "_parentNode"];
|
||||
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
|
||||
_actionTrees = missionNamespace getVariable [_varName, []];
|
||||
if((count _actionTrees) == 0) then {
|
||||
missionNamespace setVariable [_varName, _actionTrees];
|
||||
};
|
||||
|
||||
_parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
|
||||
if (isNil {_parentNode}) exitWith {};
|
||||
|
||||
// Add action node as children of the correct node of action tree
|
||||
(_parentNode select 1) pushBack [_action,[]];
|
||||
|
||||
// Return the full path
|
||||
(+ _parentPath) pushBack (_action select 0)
|
35
addons/interact_menu/functions/fnc_addActionToObject.sqf
Normal file
35
addons/interact_menu/functions/fnc_addActionToObject.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Insert an ACE action to an object, under a certain config path
|
||||
* Note: This function is NOT global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Object the action should be assigned to <OBJECT>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Parent path of the new action <ARRAY>
|
||||
* 3: Action <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
|
||||
*
|
||||
* Example:
|
||||
* [typeOf cursorTarget, 0, ["ACE_TapShoulderRight"],VulcanPinchAction] call ace_interact_menu_fnc_addActionToClass;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_4_PVT(_this,_object,_typeNum,_parentPath,_action);
|
||||
|
||||
private ["_varName","_actionList"];
|
||||
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
|
||||
_actionList = _object getVariable [_varName, []];
|
||||
if((count _actionList) == 0) then {
|
||||
_object setVariable [_varName, _actionList];
|
||||
};
|
||||
|
||||
// Add action and parent path to the list of object actions
|
||||
_actionList pushBack [_action, +_parentPath];
|
||||
|
||||
// Return the full path
|
||||
(+ _parentPath) pushBack (_action select 0)
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Add an ACE action to a class, under a certain path
|
||||
* Note: This function is NOT global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: TypeOf of the class <STRING>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Full path of the new action <ARRAY>
|
||||
* 3: Name of the action shown in the menu <STRING>
|
||||
* 4: Icon <STRING>
|
||||
* 5: Position (Position or Selection Name) <POSITION> or <STRING>
|
||||
* 6: Statement <CODE>
|
||||
* 7: Condition <CODE>
|
||||
* 8: Distance <NUMBER>
|
||||
* 9: Other parameters <ARRAY> (Optional)
|
||||
* 10: Insert children code <CODE> (Optional)
|
||||
* 11: Action parameters <ANY> (Optional)
|
||||
*
|
||||
* Return value:
|
||||
* The entry full path, which can be used to remove the entry, or add children entries <ARRAY>.
|
||||
*
|
||||
* Example:
|
||||
* [typeOf cursorTarget, 0,["ACE_TapShoulderRight","VulcanPinch"],"Vulcan Pinch","",[0,0,0],{_target setDamage 1;},{true},100] call ace_interact_menu_fnc_addClassAction;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_9_PVT(_this,_objectType,_typeNum,_fullPath,_displayName,_icon,_position,_statement,_condition,_distance);
|
||||
|
||||
// Ensure the config menu was compiled first
|
||||
if (_typeNum == 0) then {
|
||||
[_objectType] call FUNC(compileMenu);
|
||||
} else {
|
||||
[_objectType] call FUNC(compileMenuSelfAction);
|
||||
};
|
||||
|
||||
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, []];
|
||||
if((count _actions) == 0) then {
|
||||
missionNamespace setVariable [_varName, _actions];
|
||||
};
|
||||
|
||||
_params = [false,false,false,false];
|
||||
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;
|
||||
|
||||
_fnc_findFolder = {
|
||||
EXPLODE_3_PVT(_this,_fullPath,_level,_classActions);
|
||||
|
||||
if (count _fullPath == _level + 1) then {
|
||||
_parentLevel = _classActions;
|
||||
_foundParentLevel = true;
|
||||
};
|
||||
|
||||
if (_foundParentLevel) exitWith {};
|
||||
|
||||
{
|
||||
EXPLODE_2_PVT(_x,_actionData,_actionChildren);
|
||||
if (((_actionData select 7) select _level) isEqualTo (_fullPath select _level)) exitWith {
|
||||
// The action should go somewhere in here
|
||||
[_fullPath, _level + 1, _actionChildren] call _fnc_findFolder;
|
||||
};
|
||||
} forEach _classActions;
|
||||
};
|
||||
|
||||
[_fullPath, 0, _actions] call _fnc_findFolder;
|
||||
|
||||
// Exit if there's no entry point to insert this action
|
||||
if (!_foundParentLevel) exitWith {};
|
||||
|
||||
_entry = [
|
||||
[
|
||||
_displayName,
|
||||
_icon,
|
||||
_position,
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
_params,
|
||||
+ _fullPath,
|
||||
_insertChildren,
|
||||
_parameters
|
||||
],
|
||||
[]
|
||||
];
|
||||
|
||||
_parentLevel pushBack _entry;
|
||||
|
||||
_fullPath
|
@ -5,6 +5,7 @@
|
||||
* Argument:
|
||||
* 0: Object <OBJECT>
|
||||
* 1: Original action tree <ARRAY>
|
||||
* 2: Parent path <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* Active children <ARRAY>
|
||||
@ -13,29 +14,32 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_object,_origAction);
|
||||
EXPLODE_3_PVT(_this,_object,_origAction,_parentPath);
|
||||
EXPLODE_2_PVT(_origAction,_origActionData,_origActionChildren);
|
||||
|
||||
private ["_resultingAction","_target","_player","_activeChildren","_action","_actionData","_x"];
|
||||
private ["_target","_player","_fullPath","_activeChildren","_action","_actionData","_x"];
|
||||
|
||||
_target = _object;
|
||||
_player = ACE_player;
|
||||
|
||||
// Return nothing if the action itself is not active
|
||||
if !([_target, ACE_player, _origActionData select 9] call (_origActionData select 4)) exitWith {
|
||||
if !([_target, ACE_player, _origActionData select 6] 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);
|
||||
if !({} isEqualTo (_origActionData select 5)) then {
|
||||
_activeChildren = [_target, ACE_player, _origActionData select 6] call (_origActionData select 5);
|
||||
};
|
||||
|
||||
_fullPath = +_parentPath;
|
||||
_fullPath pushBack (_origActionData select 0);
|
||||
|
||||
// Collect children class actions
|
||||
{
|
||||
_action = [_object, _x] call FUNC(collectActiveActionTree);
|
||||
_action = [_object, _x, _fullPath] call FUNC(collectActiveActionTree);
|
||||
if ((count _action) > 0) then {
|
||||
_activeChildren pushBack _action;
|
||||
};
|
||||
@ -43,26 +47,15 @@ if (count _origActionData > 8 && {!({} isEqualTo (_origActionData select 8))}) t
|
||||
|
||||
// Collect children object actions
|
||||
{
|
||||
_action = _x;
|
||||
_actionData = _action select 0;
|
||||
EXPLODE_2_PVT(_x,_actionData,_pPath);
|
||||
|
||||
// Check if the action is children of the original action
|
||||
if ((count (_actionData select 7)) == (count (_origActionData select 7) + 1)) then {
|
||||
if (count _pPath == count _fullPath &&
|
||||
{_pPath isEqualTo _fullPath}) then {
|
||||
|
||||
// Compare parent path to see if it's a suitable child
|
||||
private "_isChild";
|
||||
_isChild = true;
|
||||
{
|
||||
if !(_x isEqualTo ((_actionData select 7) select _forEachIndex)) exitWith {
|
||||
_isChild = false;
|
||||
};
|
||||
} forEach (_origActionData select 7);
|
||||
|
||||
if (_isChild) then {
|
||||
_action = [_object, _action] call FUNC(collectActiveActionTree);
|
||||
if ((count _action) > 0) then {
|
||||
_activeChildren pushBack _action;
|
||||
};
|
||||
_action = [_object, _action, _fullPath] call FUNC(collectActiveActionTree);
|
||||
if ((count _action) > 0) then {
|
||||
_activeChildren pushBack _action;
|
||||
};
|
||||
};
|
||||
} forEach GVAR(objectActions);
|
||||
@ -75,5 +68,4 @@ if ((count _activeChildren) == 0 && ((_origActionData select 3) isEqualTo {})) e
|
||||
};
|
||||
|
||||
|
||||
//diag_log [_origActionData, _activeChildren, _object];
|
||||
[_origActionData, _activeChildren, _object]
|
||||
|
@ -27,8 +27,8 @@ 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", "_insertChildren"];
|
||||
EXPLODE_2_PVT(_this,_actionsCfg,_parentPath);
|
||||
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren"];
|
||||
EXPLODE_1_PVT(_this,_actionsCfg);
|
||||
_actions = [];
|
||||
|
||||
for "_i" from 0 to (count _actionsCfg) - 1 do {
|
||||
@ -55,24 +55,21 @@ _recurseFnc = {
|
||||
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
|
||||
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
|
||||
|
||||
_fullPath = (+ _parentPath);
|
||||
_fullPath pushBack (configName _entryCfg);
|
||||
|
||||
_condition = compile _condition;
|
||||
_children = [_entryCfg, _fullPath] call _recurseFnc;
|
||||
_children = [_entryCfg] call _recurseFnc;
|
||||
|
||||
_entry = [
|
||||
[
|
||||
configName _entryCfg,
|
||||
_displayName,
|
||||
_icon,
|
||||
_selection,
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
|
||||
_fullPath,
|
||||
_insertChildren,
|
||||
[]
|
||||
[],
|
||||
_selection,
|
||||
_distance,
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover]
|
||||
],
|
||||
_children
|
||||
];
|
||||
@ -85,20 +82,22 @@ _recurseFnc = {
|
||||
private "_actionsCfg";
|
||||
_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions";
|
||||
|
||||
missionNamespace setVariable [_actionsVarName, [_actionsCfg, []] call _recurseFnc];
|
||||
missionNamespace setVariable [_actionsVarName, [_actionsCfg] call _recurseFnc];
|
||||
|
||||
/*
|
||||
[
|
||||
[
|
||||
[
|
||||
"MyAction",
|
||||
"My Action",
|
||||
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
|
||||
[0,0,0],
|
||||
{ (_this select 0) setVelocity [0,0,10]; },
|
||||
{ true },
|
||||
{},
|
||||
[],
|
||||
[0,0,0],
|
||||
1,
|
||||
[false,false,false]
|
||||
["ACE_MainActions","TeamManagement","MyAction"]
|
||||
],
|
||||
[children actions]
|
||||
]
|
||||
|
@ -27,8 +27,8 @@ 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", "_insertChildren"];
|
||||
EXPLODE_2_PVT(_this,_actionsCfg,_parentPath);
|
||||
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren"];
|
||||
EXPLODE_1_PVT(_this,_actionsCfg);
|
||||
_actions = [];
|
||||
|
||||
for "_i" from 0 to (count _actionsCfg) - 1 do {
|
||||
@ -52,24 +52,21 @@ _recurseFnc = {
|
||||
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
|
||||
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
|
||||
|
||||
_fullPath = (+ _parentPath);
|
||||
_fullPath pushBack (configName _entryCfg);
|
||||
|
||||
_condition = compile _condition;
|
||||
_children = [_entryCfg, _fullPath] call _recurseFnc;
|
||||
_children = [_entryCfg] call _recurseFnc;
|
||||
|
||||
_entry = [
|
||||
[
|
||||
configName _entryCfg,
|
||||
_displayName,
|
||||
_icon,
|
||||
[0,0,0],
|
||||
_statement,
|
||||
_condition,
|
||||
10, //distace
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover],
|
||||
_fullPath,
|
||||
_insertChildren,
|
||||
[]
|
||||
[],
|
||||
[0,0,0],
|
||||
10, //distace
|
||||
[_showDisabled,_enableInside,_canCollapse,_runOnHover]
|
||||
],
|
||||
_children
|
||||
];
|
||||
@ -86,18 +83,18 @@ _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions";
|
||||
_actions = [
|
||||
[
|
||||
[
|
||||
"ACE_SelfActions",
|
||||
"Self Actions",
|
||||
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
|
||||
"Spine3",
|
||||
{ true },
|
||||
{ true },
|
||||
10,
|
||||
[false,true,false],
|
||||
["ACE_SelfActions"],
|
||||
{},
|
||||
[]
|
||||
{ true },
|
||||
{},
|
||||
[],
|
||||
"Spine3",
|
||||
10,
|
||||
[false,true,false]
|
||||
],
|
||||
[_actionsCfg, ["ACE_SelfActions"]] call _recurseFnc
|
||||
[_actionsCfg] call _recurseFnc
|
||||
]
|
||||
];
|
||||
|
||||
|
@ -7,57 +7,68 @@
|
||||
* 0: Action name <STRING>
|
||||
* 1: Name of the action shown in the menu <STRING>
|
||||
* 2: Icon <STRING>
|
||||
* 3: Position (Position or Selection Name) <POSITION> or <STRING>
|
||||
* 4: Statement <CODE>
|
||||
* 5: Condition <CODE>
|
||||
* 6: Distance <NUMBER>
|
||||
* 7: Other parameters <ARRAY> (Optional)
|
||||
* 8: Insert children code <CODE> (Optional)
|
||||
* 9: Action parameters <ANY> (Optional)
|
||||
* 3: Statement <CODE>
|
||||
* 4: Condition <CODE>
|
||||
* 5: Insert children code <CODE> (Optional)
|
||||
* 6: Action parameters <ANY> (Optional)
|
||||
* 7: Position (Position or Selection Name) <POSITION> or <STRING> (Optional)
|
||||
* 8: Distance <NUMBER> (Optional)
|
||||
* 9: Other parameters <ARRAY> (Optional)
|
||||
*
|
||||
* Return value:
|
||||
* Action
|
||||
* Action <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [[VulcanPinch"],"Vulcan Pinch","",[0,0,0],{_target setDamage 1;},{true},100,{},[parameters]] call ace_interact_menu_fnc_addAction;
|
||||
* [VulcanPinch","Vulcan Pinch",{_target setDamage 1;},{true},{},[parameters], [0,0,0], 100] call ace_interact_menu_fnc_createAction;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_7_PVT(_this,_fullPath,_displayName,_icon,_position,_statement,_condition,_distance);
|
||||
EXPLODE_5_PVT(_this,_actionName,_displayName,_icon,_statement,_condition);
|
||||
|
||||
private ["_actions","_params","_insertChildren","_parameters","_entry"];
|
||||
private ["_insertChildren","_customParams","_position","_distance","_params"];
|
||||
|
||||
_params = [false,false,false,false];
|
||||
if (count _this > 7) then {
|
||||
_params = _this select 7;
|
||||
_insertChildren = if (count _this > 5) then {
|
||||
_this select 5
|
||||
} else {
|
||||
{}
|
||||
};
|
||||
|
||||
_insertChildren = {};
|
||||
if (count _this > 8) then {
|
||||
_insertChildren = _this select 8;
|
||||
_customParams = if (count _this > 6) then {
|
||||
_this select 6
|
||||
} else {
|
||||
[]
|
||||
};
|
||||
|
||||
_parameters = [];
|
||||
if (count _this > 9) then {
|
||||
_parameters = _this select 9;
|
||||
_position = if (count _this > 7) then {
|
||||
_this select 7
|
||||
} else {
|
||||
[0,0,0]
|
||||
};
|
||||
|
||||
_entry = [
|
||||
[
|
||||
_displayName,
|
||||
_icon,
|
||||
_position,
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
_params,
|
||||
+ _fullPath,
|
||||
_insertChildren,
|
||||
_parameters
|
||||
],
|
||||
[]
|
||||
];
|
||||
_distance = if (count _this > 8) then {
|
||||
_this select 8
|
||||
} else {
|
||||
2
|
||||
};
|
||||
|
||||
_entry
|
||||
_params = if (count _this > 9) then {
|
||||
_this select 9
|
||||
} else {
|
||||
[false,false,false,false]
|
||||
};
|
||||
|
||||
[
|
||||
_actionName,
|
||||
_displayName,
|
||||
_icon,
|
||||
_statement,
|
||||
_condition,
|
||||
|
||||
_insertChildren,
|
||||
_customParams,
|
||||
_position,
|
||||
_distance,
|
||||
_params
|
||||
]
|
||||
|
56
addons/interact_menu/functions/fnc_findActionNode.sqf
Normal file
56
addons/interact_menu/functions/fnc_findActionNode.sqf
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Return action point from path
|
||||
* Note: This function is NOT global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: List of Action Tree <ARRAY>
|
||||
* 1: Path <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* Action node <ARRAY>.
|
||||
*
|
||||
* Example:
|
||||
* [_actionTree, ["ACE_TapShoulderRight","VulcanPinchAction"]] call ace_interact_menu_fnc_findActionNode;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_actionTreeList,_parentPath);
|
||||
|
||||
private ["_parentNode", "_foundParentNode", "_fnc_findFolder"];
|
||||
|
||||
// Hack to make this work on the root node too
|
||||
if (count _parentPath == 0) exitWith {
|
||||
[[],_actionTreeList]
|
||||
};
|
||||
|
||||
// Search the class action trees and find where to insert the entry
|
||||
_parentNode = [[],_actionTreeList];
|
||||
_foundParentNode = false;
|
||||
|
||||
_fnc_findFolder = {
|
||||
EXPLODE_3_PVT(_this,_parentPath,_level,_actionNode);
|
||||
|
||||
{
|
||||
EXPLODE_2_PVT(_x,_actionData,_actionChildren);
|
||||
if ((_actionData select 0) isEqualTo (_parentPath select _level)) exitWith {
|
||||
|
||||
if (count _parentPath == _level + 1) exitWith {
|
||||
_parentNode = _x;
|
||||
_foundParentNode = true;
|
||||
};
|
||||
|
||||
// The action should go somewhere in here
|
||||
[_parentPath, _level + 1, _x] call _fnc_findFolder;
|
||||
};
|
||||
} forEach (_actionNode select 1);
|
||||
};
|
||||
|
||||
[_parentPath, 0, [[],_actionTreeList]] call _fnc_findFolder;
|
||||
|
||||
// Exit if there's no entry point to insert this action
|
||||
if (!_foundParentNode) exitWith {};
|
||||
|
||||
_parentNode
|
@ -16,7 +16,7 @@ if(GVAR(actionSelected)) then {
|
||||
this = GVAR(selectedTarget);
|
||||
_player = ACE_Player;
|
||||
_target = GVAR(selectedTarget);
|
||||
[GVAR(selectedTarget), ACE_player, (GVAR(selectedAction) select 0) select 9] call GVAR(selectedStatement);
|
||||
[GVAR(selectedTarget), ACE_player, (GVAR(selectedAction) select 0) select 6] call GVAR(selectedStatement);
|
||||
};
|
||||
|
||||
if (GVAR(keyDown)) then {
|
||||
|
@ -20,7 +20,7 @@ if(GVAR(actionSelected)) then {
|
||||
this = GVAR(selectedTarget);
|
||||
_player = ACE_Player;
|
||||
_target = GVAR(selectedTarget);
|
||||
[GVAR(selectedTarget), ACE_player, (GVAR(selectedAction) select 0) select 9] call GVAR(selectedStatement);
|
||||
[GVAR(selectedTarget), ACE_player, (GVAR(selectedAction) select 0) select 6] call GVAR(selectedStatement);
|
||||
};
|
||||
|
||||
if (GVAR(keyDownSelfAction)) then {
|
||||
|
39
addons/interact_menu/functions/fnc_removeActionFromClass.sqf
Normal file
39
addons/interact_menu/functions/fnc_removeActionFromClass.sqf
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Removes an action from a class
|
||||
*
|
||||
* Argument:
|
||||
* 0: TypeOf of the class <STRING>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Full path of the new action <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [typeOf cursorTarget, 0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeActionFromClass;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_3_PVT(_this,_objectType,_typeNum,_fullPath);
|
||||
|
||||
private ["_res","_varName","_actionTrees"];
|
||||
_res = _fullPath call FUNC(splitPath);
|
||||
EXPLODE_2_PVT(_res,_parentPath,_actionName);
|
||||
|
||||
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
|
||||
_actionTrees = missionNamespace getVariable [_varName, []];
|
||||
|
||||
_parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
|
||||
if (isNil {_parentNode}) exitWith {};
|
||||
|
||||
// Iterate through children of the father
|
||||
{
|
||||
if (((_x select 0) select 0) == _actionName) exitWith {
|
||||
(_parentNode select 1) deleteAt _forEachIndex;
|
||||
};
|
||||
} forEach (_parentNode select 1);
|
||||
|
||||
_parentLevel deleteAt _actionIndex;
|
@ -1,30 +1,33 @@
|
||||
/*
|
||||
* Author: commy2, NouberNou and CAA-Picard
|
||||
* Remove an action from an object
|
||||
*
|
||||
* Argument:
|
||||
* 0: Object the action is assigned to <OBJECT>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Full path of the action to remove <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [cursorTarget,0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeAction;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_3_PVT(_this,_object,_typeNum,_fullPath);
|
||||
|
||||
private ["_varName","_actions"];
|
||||
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
|
||||
_actions = _object getVariable [_varName, []];
|
||||
|
||||
{
|
||||
if (((_x select 0) select 7) isEqualTo _fullPath) exitWith {
|
||||
_actions deleteAt _forEachIndex;
|
||||
};
|
||||
} forEach _actions;
|
||||
/*
|
||||
* Author: commy2, NouberNou and CAA-Picard
|
||||
* Removes an action from an object
|
||||
*
|
||||
* Argument:
|
||||
* 0: Object the action is assigned to <OBJECT>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Full path of the action to remove <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [cursorTarget,0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeActionFromObject;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_3_PVT(_this,_object,_typeNum,_fullPath);
|
||||
|
||||
private ["_res","_varName","_actionList"];
|
||||
_res = _fullPath call FUNC(splitPath);
|
||||
EXPLODE_2_PVT(_res,_parentPath,_actionName);
|
||||
|
||||
_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
|
||||
_actionList = _object getVariable [_varName, []];
|
||||
{
|
||||
if (((_x select 0) select 0) isEqualTo _actionName &&
|
||||
{(_x select 1) isEqualTo _parentPath}) exitWith {
|
||||
_actionList deleteAt _forEachIndex;
|
||||
};
|
||||
} forEach _actionList;
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Removes a class action from a class
|
||||
* Note: This function is NOT global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: TypeOf of the class <STRING>
|
||||
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||
* 2: Full path of the new action <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [typeOf cursorTarget, 0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeClassAction;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_3_PVT(_this,_objectType,_typeNum,_fullPath);
|
||||
|
||||
private ["_varName","_actions","_parentLevel", "_actionIndex", "_foundAction", "_fnc_findFolder"];
|
||||
|
||||
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
|
||||
_actions = missionNamespace getVariable [_varName, []];
|
||||
|
||||
// Search the class action trees and find where to insert the entry
|
||||
_parentLevel = _actions;
|
||||
_actionIndex = -1;
|
||||
_foundAction = false;
|
||||
|
||||
_fnc_findFolder = {
|
||||
EXPLODE_3_PVT(_this,_fullPath,_level,_classActions);
|
||||
|
||||
if (count _fullPath == _level + 1) then {
|
||||
_parentLevel = _classActions;
|
||||
};
|
||||
|
||||
{
|
||||
EXPLODE_2_PVT(_x,_actionData,_actionChildren);
|
||||
if (((_actionData select 7) select _level) isEqualTo (_fullPath select _level)) exitWith {
|
||||
if (_level + 1 == count _fullPath) exitWith {
|
||||
_actionIndex = _forEachIndex;
|
||||
_foundAction = true;
|
||||
};
|
||||
[_fullPath, _level + 1, _actionChildren] call _fnc_findFolder;
|
||||
};
|
||||
if (_foundAction) exitWith {};
|
||||
} forEach _classActions;
|
||||
};
|
||||
|
||||
[_fullPath, 0, _actions] call _fnc_findFolder;
|
||||
|
||||
// Exit if the action was not found
|
||||
if (!_foundAction) exitWith {};
|
||||
|
||||
_entry = [
|
||||
[
|
||||
_displayName,
|
||||
_icon,
|
||||
_position,
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
_params,
|
||||
+ _fullPath
|
||||
],
|
||||
[]
|
||||
];
|
||||
|
||||
_parentLevel deleteAt _actionIndex;
|
@ -41,17 +41,17 @@ if (GVAR(keyDown)) then {
|
||||
|
||||
// Iterate through object actions, find base level actions and render them if appropiate
|
||||
_actionsVarName = format [QGVAR(Act_%1), typeOf _target];
|
||||
GVAR(objectActions) = _target getVariable [QGVAR(actions), []];
|
||||
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
|
||||
{
|
||||
_action = _x;
|
||||
// Only render them directly if they are base level actions
|
||||
if (count ((_action select 0) select 7) == 1) then {
|
||||
if (count (_x select 1) == 0) then {
|
||||
// Try to render the menu
|
||||
_action = [_x,[]];
|
||||
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
||||
_numInteractions = _numInteractions + 1;
|
||||
};
|
||||
};
|
||||
} forEach GVAR(objectActions);
|
||||
} forEach GVAR(objectActionList);
|
||||
|
||||
// Iterate through base level class actions and render them if appropiate
|
||||
_classActions = missionNamespace getVariable [_actionsVarName, []];
|
||||
@ -80,7 +80,7 @@ if (GVAR(keyDown)) then {
|
||||
|
||||
// Iterate through object actions, find base level actions and render them if appropiate
|
||||
_actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
|
||||
GVAR(objectActions) = _target getVariable [QGVAR(selfActions), []];
|
||||
GVAR(objectActionList) = _target getVariable [QGVAR(selfActions), []];
|
||||
/*
|
||||
{
|
||||
_action = _x;
|
||||
@ -88,7 +88,7 @@ if (GVAR(keyDown)) then {
|
||||
if (count (_action select 7) == 1) then {
|
||||
[_target, _action, 0, [180, 360]] call FUNC(renderMenu);
|
||||
};
|
||||
} forEach GVAR(objectActions);
|
||||
} forEach GVAR(objectActionList);
|
||||
*/
|
||||
|
||||
// Iterate through base level class actions and render them if appropiate
|
||||
@ -171,12 +171,12 @@ if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
|
||||
|
||||
// Execute the current action if it's run on hover
|
||||
private "_runOnHover";
|
||||
_runOnHover = ((GVAR(selectedAction) select 0) select 6) select 3;
|
||||
_runOnHover = ((GVAR(selectedAction) select 0) select 9) select 3;
|
||||
if (_runOnHover) 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 6] call GVAR(selectedStatement);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Argument:
|
||||
* 0: Object <OBJECT>
|
||||
* 1: Action data <ARRAY>
|
||||
* 1: Action node <ARRAY>
|
||||
* 2: 3D position <ARRAY> (Optional)
|
||||
*
|
||||
* Return value:
|
||||
@ -16,25 +16,25 @@
|
||||
|
||||
private ["_distance","_pos","_weaponDir","_ref","_cameraPos","_sPos","_activeActionTree"];
|
||||
|
||||
EXPLODE_2_PVT(_this,_object,_baseAction);
|
||||
EXPLODE_1_PVT(_baseAction,_actionData);
|
||||
EXPLODE_2_PVT(_this,_object,_baseActionNode);
|
||||
EXPLODE_1_PVT(_baseActionNode,_actionData);
|
||||
|
||||
_distance = _actionData select 5;
|
||||
_distance = _actionData select 8;
|
||||
|
||||
// Obtain a 3D position for the action
|
||||
if((count _this) > 2) then {
|
||||
_pos = _this select 2;
|
||||
} else {
|
||||
if(typeName (_actionData select 2) == "ARRAY") then {
|
||||
_pos = _object modelToWorld (_actionData select 2);
|
||||
if(typeName (_actionData select 7) == "ARRAY") then {
|
||||
_pos = _object modelToWorld (_actionData select 7);
|
||||
} else {
|
||||
if ((_actionData select 2) == "weapon") then {
|
||||
if ((_actionData select 7) == "weapon") then {
|
||||
// Craft a suitable position for weapon interaction
|
||||
_weaponDir = _object weaponDirection currentWeapon _object;
|
||||
_ref = _weaponDir call EFUNC(common,createOrthonormalReference);
|
||||
_pos = (_object modelToWorld (_object selectionPosition "righthand")) vectorAdd ((_ref select 2) vectorMultiply 0.1);
|
||||
} else {
|
||||
_pos = _object modelToWorld (_object selectionPosition (_actionData select 2));
|
||||
_pos = _object modelToWorld (_object selectionPosition (_actionData select 7));
|
||||
};
|
||||
};
|
||||
// Compensate for movement during the frame to get rid of jittering
|
||||
@ -59,9 +59,9 @@ if ((_sPos select 1) < safeZoneY || (_sPos select 1) > safeZoneY + safeZon
|
||||
|
||||
// Collect active tree
|
||||
private "_uid";
|
||||
_uid = format [QGVAR(ATCache_%1), (_actionData select 7) select 0];
|
||||
_uid = format [QGVAR(ATCache_%1), _actionData select 0];
|
||||
_activeActionTree = [
|
||||
[_object, _baseAction],
|
||||
[_object, _baseActionNode, []],
|
||||
DFUNC(collectActiveActionTree),
|
||||
_object, _uid, 0.2
|
||||
] call EFUNC(common,cachedCall);
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_menuInSelectedPath", "_localPath", "_path", "_menuDepth", "_currentRenderDepth", "_x", "_offset", "_newPos", "_forEachIndex"];
|
||||
private ["_menuInSelectedPath", "_path", "_menuDepth", "_currentRenderDepth", "_x", "_offset", "_newPos", "_forEachIndex"];
|
||||
|
||||
EXPLODE_4_PVT(_this,_parentPath,_action,_pos,_angles);
|
||||
EXPLODE_3_PVT(_action,_actionData,_activeChildren,_actionObject);
|
||||
@ -24,9 +24,8 @@ EXPLODE_2_PVT(_angles,_centerAngle,_maxAngleSpan);
|
||||
_menuDepth = (count GVAR(menuDepthPath));
|
||||
|
||||
// Store path to action
|
||||
_localPath = _actionData select 7;
|
||||
_path = +_parentPath;
|
||||
_path pushBack [_localPath select ((count _localPath) - 1), _actionObject];
|
||||
_path pushBack [_actionData select 0,_actionObject];
|
||||
|
||||
// Check if the menu is on the selected path
|
||||
_menuInSelectedPath = true;
|
||||
@ -49,7 +48,7 @@ if(!_menuInSelectedPath) then { //_menuDepth > 0 &&
|
||||
_color = format ["#%1FFFFFF", [255 * 0.75] call EFUNC(common,toHex)];
|
||||
};
|
||||
};
|
||||
[_actionData select 0, _color, _pos, 1, 1, 0, _actionData select 1, 0.5, 0.025, "TahomaB"] call FUNC(renderIcon);
|
||||
[_actionData select 1, _color, _pos, 1, 1, 0, _actionData select 2, 0.5, 0.025, "TahomaB"] call FUNC(renderIcon);
|
||||
|
||||
// Add the action to current options
|
||||
GVAR(currentOptions) pushBack [_this, _pos, _path];
|
||||
|
23
addons/interact_menu/functions/fnc_splitPath.sqf
Normal file
23
addons/interact_menu/functions/fnc_splitPath.sqf
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Take full path and split it between parent path and action name
|
||||
*
|
||||
* Argument:
|
||||
* Full path of the action to remove <ARRAY>
|
||||
*
|
||||
* Return value:
|
||||
* 0: Parent path <ARRAY>
|
||||
* 1: Action name <STRING>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_parentPath","_actionName"];
|
||||
_parentPath = [];
|
||||
for "_i" from 0 to (count _this) - 1 do {
|
||||
_parentPath pushBack (_this select _i);
|
||||
};
|
||||
_actionName = _this select ((count _this) - 1);
|
||||
|
||||
[_parentPath, _actionName]
|
Loading…
Reference in New Issue
Block a user