mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Remove debug, added scripted add/remove actions.
This commit is contained in:
parent
6a04408a74
commit
84f404ae84
@ -12,6 +12,8 @@ PREP(rotateVectLine);
|
||||
PREP(keyDown);
|
||||
PREP(keyUp);
|
||||
PREP(compileMenu);
|
||||
PREP(addAction);
|
||||
PREP(removeAction);
|
||||
|
||||
GVAR(toRender) = [];
|
||||
|
||||
@ -46,4 +48,6 @@ GVAR(iconCount) = 0;
|
||||
|
||||
GVAR(objectActionsHash) = HASH_CREATE;
|
||||
|
||||
GVAR(uidCounter) = 0;
|
||||
|
||||
ADDON = true;
|
51
addons/interact_menu/functions/fnc_addAction.sqf
Normal file
51
addons/interact_menu/functions/fnc_addAction.sqf
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Add an ACE action to an object. Note: This function is NOT global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Object the action should be assigned to (Object)
|
||||
* 1: Name of the action shown in the menu (String)
|
||||
* 2: Icon (String)
|
||||
* 3: Position (Position or Selection Name)
|
||||
* 4: Statement (Code)
|
||||
* 5: Condition (Code)
|
||||
* 6: Distance (Number)
|
||||
*
|
||||
* Return value:
|
||||
* The entry array, which can be used to remove the entry, or add children entries.
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_object", "_displayName", "_icon", "_position", "_statement", "_condition", "_distance", "_actions", "_entry"];
|
||||
_object = _this select 0;
|
||||
_displayName = _this select 1;
|
||||
_icon = _this select 2;
|
||||
_position = _this select 3;
|
||||
_statement = _this select 4;
|
||||
_condition = _this select 5;
|
||||
_distance = _this select 6;
|
||||
|
||||
_actions = [];
|
||||
if(IS_OBJECT(_object)) then {
|
||||
_actions = _object getVariable [QUOTE(GVAR(actionData)), []];
|
||||
} else {
|
||||
if(IS_ARRAY(_object)) then {
|
||||
_actions = _object select 6;
|
||||
};
|
||||
};
|
||||
|
||||
_entry = [
|
||||
_displayName,
|
||||
_icon,
|
||||
_position,
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
[],
|
||||
GVAR(uidCounter)
|
||||
];
|
||||
GVAR(uidCounter) = GVAR(uidCounter) + 1;
|
||||
_actions pushBack _entry;
|
||||
|
||||
_entry;
|
@ -1,6 +1,6 @@
|
||||
//fnc_compileMenu.sqf
|
||||
#include "script_component.hpp";
|
||||
diag_log text format["COMPILE ACTIONS: %1", _this];
|
||||
// diag_log text format["COMPILE ACTIONS: %1", _this];
|
||||
|
||||
_object = _this select 0;
|
||||
_objectType = typeOf _object;
|
||||
@ -55,7 +55,7 @@ _recurseFnc = {
|
||||
_enableInside = getNumber (_entryCfg >> "enableInside");
|
||||
|
||||
_condition = compile _condition;
|
||||
diag_log text format["_condition: %1", _condition];
|
||||
// diag_log text format["_condition: %1", _condition];
|
||||
_children = [];
|
||||
if(isArray (_entryCfg >> "subMenu")) then {
|
||||
_subMenuDef = getArray (_entryCfg >> "subMenu");
|
||||
@ -70,9 +70,10 @@ _recurseFnc = {
|
||||
_statement,
|
||||
_condition,
|
||||
_distance,
|
||||
_children
|
||||
_children,
|
||||
GVAR(uidCounter)
|
||||
];
|
||||
|
||||
GVAR(uidCounter) = GVAR(uidCounter) + 1;
|
||||
_actions pushBack _entry;
|
||||
};
|
||||
};
|
||||
@ -88,8 +89,10 @@ _actions = [[
|
||||
{ true },
|
||||
{ true },
|
||||
5,
|
||||
_actions
|
||||
]];
|
||||
|
||||
_actions,
|
||||
GVAR(uidCounter)
|
||||
]
|
||||
];
|
||||
GVAR(uidCounter) = GVAR(uidCounter) + 1;
|
||||
|
||||
_object setVariable [QUOTE(GVAR(actionData)), _actions];
|
@ -18,7 +18,7 @@ if(!GVAR(keyDown)) then {
|
||||
_target = _actionObject;
|
||||
_player = ACE_player;
|
||||
_active = [_target, ACE_player] call (_actionItem select 4);
|
||||
player sideChat format["_active: %1 %2", _actionItem select 0, _active];
|
||||
// player sideChat format["_active: %1 %2", _actionItem select 0, _active];
|
||||
if(_active) then {
|
||||
_renderItem = +_actionItem;
|
||||
_renderItem set[4, true];
|
||||
|
51
addons/interact_menu/functions/fnc_removeAction.sqf
Normal file
51
addons/interact_menu/functions/fnc_removeAction.sqf
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Add an ACE action to an object. Note: This function is global.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Object the action should be assigned to (Object)
|
||||
* 1: Entry to remove (Array or Number)
|
||||
*
|
||||
* Return value:
|
||||
* ID of the action (used to remove it later).
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
_object = _this select 0;
|
||||
_entry = _this select 1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(!IS_OBJECT(_object)) exitWith {false};
|
||||
|
||||
_actions = _object getVariable [QUOTE(GVAR(actionData)), []];
|
||||
if(IS_ARRAY(_entry)) then {
|
||||
_entry = _entry select 7;
|
||||
};
|
||||
|
||||
_found = false;
|
||||
_searchFnc = {
|
||||
private ["_actions", "_entry"];
|
||||
_actions = _this select 0;
|
||||
_entry = _this select 1;
|
||||
{
|
||||
if((_x select 7) == _entry) then {
|
||||
_actions set[_forEachIndex, "aceactiondelete"];
|
||||
_actions = _actions - ["aceactiondelete"];
|
||||
_found = true;
|
||||
} else {
|
||||
if(!_found && {count (_x select 6) > 0}) then {
|
||||
_childActions = [(_x select 6), _entry] call _searchFnc;
|
||||
_x set[6, _childActions];
|
||||
};
|
||||
};
|
||||
} forEach _actions;
|
||||
_actions;
|
||||
};
|
||||
_actions = [_actions, _entry] call _searchFnc;
|
||||
_object setVariable [QUOTE(GVAR(actionData)), _actions];
|
||||
|
||||
_found;
|
@ -37,14 +37,13 @@ if(_cursorScreenPos distance _pos <= _distance) then {
|
||||
_currentRenderDepth = GVAR(renderDepth);
|
||||
GVAR(renderDepth) = GVAR(renderDepth) + 1;
|
||||
if(_index == (GVAR(menuDepthPath) select (GVAR(renderDepth)-1))) then {
|
||||
_radialOffset = 0;
|
||||
{
|
||||
_radialOffset = 0;
|
||||
{
|
||||
// if(_index != (GVAR(menuDepthPath) select (GVAR(renderDepth)))) then {
|
||||
this = _object;
|
||||
_target = _object;
|
||||
_player = ACE_player;
|
||||
_active = [_object, ACE_player] call (_x select 4);
|
||||
diag_log text format["_active: %1: %2", (_x select 0), _active];
|
||||
if(_active) then {
|
||||
_offset = [GVAR(vecLineMap), (270*(GVAR(renderDepth)%2))-(_radialOffset*45)] call FUNC(rotateVectLine);
|
||||
_newPos = [
|
||||
@ -57,7 +56,7 @@ if(_cursorScreenPos distance _pos <= _distance) then {
|
||||
_radialOffset = _radialOffset + 1;
|
||||
};
|
||||
// };
|
||||
} forEach (_actionData select 6);
|
||||
} forEach (_actionData select 6);
|
||||
};
|
||||
GVAR(renderDepth) = GVAR(renderDepth) - 1;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user