mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
#1984 - Always make sure ACE_MainActions exists
Also add debuging output when adding action with no parent
This commit is contained in:
parent
261cd42202
commit
93d2035fed
@ -4,6 +4,7 @@ ADDON = false;
|
|||||||
|
|
||||||
PREP(addActionToClass);
|
PREP(addActionToClass);
|
||||||
PREP(addActionToObject);
|
PREP(addActionToObject);
|
||||||
|
PREP(addMainAction);
|
||||||
PREP(compileMenu);
|
PREP(compileMenu);
|
||||||
PREP(compileMenuSelfAction);
|
PREP(compileMenuSelfAction);
|
||||||
PREP(compileMenuZeus);
|
PREP(compileMenuZeus);
|
||||||
|
@ -35,8 +35,15 @@ if((count _actionTrees) == 0) then {
|
|||||||
missionNamespace setVariable [_varName, _actionTrees];
|
missionNamespace setVariable [_varName, _actionTrees];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (_parentPath isEqualTo ["ACE_MainActions"]) then {
|
||||||
|
[_objectType, _typeNum] call FUNC(addMainAction);
|
||||||
|
};
|
||||||
|
|
||||||
_parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
|
_parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
|
||||||
if (isNil {_parentNode}) exitWith {};
|
if (isNil {_parentNode}) exitWith {
|
||||||
|
ERROR("Failed to add action");
|
||||||
|
diag_log text format ["action (%1) to parent %2 on object %3 [%4]", (_action select 0), _parentPath, _objectType, _typeNum];
|
||||||
|
};
|
||||||
|
|
||||||
// Add action node as children of the correct node of action tree
|
// Add action node as children of the correct node of action tree
|
||||||
(_parentNode select 1) pushBack [_action,[]];
|
(_parentNode select 1) pushBack [_action,[]];
|
||||||
|
@ -28,6 +28,10 @@ if((count _actionList) == 0) then {
|
|||||||
_object setVariable [_varName, _actionList];
|
_object setVariable [_varName, _actionList];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (_parentPath isEqualTo ["ACE_MainActions"]) then {
|
||||||
|
[(typeOf _object), _typeNum] call FUNC(addMainAction);
|
||||||
|
};
|
||||||
|
|
||||||
// Add action and parent path to the list of object actions
|
// Add action and parent path to the list of object actions
|
||||||
_actionList pushBack [_action, +_parentPath];
|
_actionList pushBack [_action, +_parentPath];
|
||||||
|
|
||||||
|
31
addons/interact_menu/functions/fnc_addMainAction.sqf
Normal file
31
addons/interact_menu/functions/fnc_addMainAction.sqf
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jonpas, PabstMirror
|
||||||
|
* Makes sure there is a ACE_MainActions on the object type
|
||||||
|
*
|
||||||
|
* Argument:
|
||||||
|
* 0: Object classname <STRING>
|
||||||
|
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ["Table", 0] call ace_interact_menu_fnc_addMainAction;
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
PARAMS_2(_objectType,_typeNum);
|
||||||
|
|
||||||
|
private["_actionTrees", "_mainAction", "_parentNode", "_varName"];
|
||||||
|
|
||||||
|
_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType];
|
||||||
|
_actionTrees = missionNamespace getVariable [_varName, []];
|
||||||
|
_parentNode = [_actionTrees, ["ACE_MainActions"]] call FUNC(findActionNode);
|
||||||
|
|
||||||
|
if (isNil {_parentNode}) then {
|
||||||
|
TRACE_2("No Main Action on object", _objectType, _typeNum);
|
||||||
|
_mainAction = ["ACE_MainActions", localize ELSTRING(interaction,MainAction), "", {}, {true}] call FUNC(createAction);
|
||||||
|
[_objectType, _typeNum, [], _mainAction] call EFUNC(interact_menu,addActionToClass);
|
||||||
|
};
|
@ -8,7 +8,7 @@
|
|||||||
* 1: Path <ARRAY>
|
* 1: Path <ARRAY>
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* Action node <ARRAY>.
|
* Action node <ARRAY> or <NIL> if not found
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [_actionTree, ["ACE_TapShoulderRight","VulcanPinchAction"]] call ace_interact_menu_fnc_findActionNode;
|
* [_actionTree, ["ACE_TapShoulderRight","VulcanPinchAction"]] call ace_interact_menu_fnc_findActionNode;
|
||||||
|
@ -53,15 +53,6 @@ _currentSlideshow = GVAR(slideshows); // Local variable in case GVAR gets change
|
|||||||
if (_duration == 0) then {
|
if (_duration == 0) then {
|
||||||
private ["_actionsObject", "_actionsClass", "_mainAction", "_slidesAction"];
|
private ["_actionsObject", "_actionsClass", "_mainAction", "_slidesAction"];
|
||||||
{
|
{
|
||||||
// Add MainAction if one does not already exist
|
|
||||||
_actionsObject = _x getVariable [QEGVAR(interact_menu,actions), []];
|
|
||||||
_actionsClass = missionNamespace getVariable [format [QEGVAR(interact_menu,Act_%1), typeOf _x], []];
|
|
||||||
if (count _actionsObject == 0 && {count _actionsClass == 0}) then {
|
|
||||||
_mainAction = ["ACE_MainActions", localize ELSTRING(interaction,MainAction), "", {}, {true}] call EFUNC(interact_menu,createAction);
|
|
||||||
[_x, 0, [], _mainAction] call EFUNC(interact_menu,addActionToObject);
|
|
||||||
TRACE_2("Adding ACE_MainActions",_actionsObject,_actionsClass);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add Slides sub-action and populate with images
|
// Add Slides sub-action and populate with images
|
||||||
_slidesAction = [QGVAR(Slides), localize LSTRING(Interaction), "", {}, {true}, {(_this select 2) call FUNC(addSlideActions)}, [_objects,_images,_names,_x,_currentSlideshow], [0,0,0], 2] call EFUNC(interact_menu,createAction);
|
_slidesAction = [QGVAR(Slides), localize LSTRING(Interaction), "", {}, {true}, {(_this select 2) call FUNC(addSlideActions)}, [_objects,_images,_names,_x,_currentSlideshow], [0,0,0], 2] call EFUNC(interact_menu,createAction);
|
||||||
[_x, 0, ["ACE_MainActions"], _slidesAction] call EFUNC(interact_menu,addActionToObject);
|
[_x, 0, ["ACE_MainActions"], _slidesAction] call EFUNC(interact_menu,addActionToObject);
|
||||||
|
Loading…
Reference in New Issue
Block a user