mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added addClassAction and removeClassAction functions
This commit is contained in:
parent
3dfef439e5
commit
8c7a51eac7
@ -3,6 +3,7 @@
|
||||
ADDON = false;
|
||||
|
||||
PREP(addAction);
|
||||
PREP(addClassAction);
|
||||
PREP(compileMenu);
|
||||
PREP(compileMenuSelfAction);
|
||||
PREP(collectActiveActionTree);
|
||||
@ -11,6 +12,7 @@ PREP(keyDownSelfAction);
|
||||
PREP(keyUp);
|
||||
PREP(keyUpSelfAction);
|
||||
PREP(removeAction);
|
||||
PREP(removeClassAction);
|
||||
PREP(render);
|
||||
PREP(renderIcon);
|
||||
PREP(renderBaseMenu);
|
||||
|
87
addons/interact_menu/functions/fnc_addClassAction.sqf
Normal file
87
addons/interact_menu/functions/fnc_addClassAction.sqf
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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)
|
||||
*
|
||||
* 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);
|
||||
|
||||
private ["_varName","_actions","_params","_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;
|
||||
};
|
||||
|
||||
// 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
|
||||
],
|
||||
[]
|
||||
];
|
||||
|
||||
_parentLevel pushBack _entry;
|
||||
|
||||
_fullPath
|
72
addons/interact_menu/functions/fnc_removeClassAction.sqf
Normal file
72
addons/interact_menu/functions/fnc_removeClassAction.sqf
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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;
|
Loading…
Reference in New Issue
Block a user