From 3ee3c5de5a8646700b4bb5e5a0913ad5147ffb90 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 22 Feb 2019 18:54:07 -0600 Subject: [PATCH] Interact Menu - Cache config actions for CAManBase (#6818) * Interact Menu - Cache config actions for CaManBase * Update addons/interact_menu/functions/fnc_compileMenu.sqf Co-Authored-By: PabstMirror * Update addons/interact_menu/XEH_preInit.sqf Co-Authored-By: PabstMirror * Apply suggestions from code review Co-Authored-By: PabstMirror --- addons/interact_menu/XEH_preInit.sqf | 4 ++++ addons/interact_menu/functions/fnc_compileMenu.sqf | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index 1524ccb504..08fa9701cd 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -15,6 +15,10 @@ if (!hasInterface) exitWith { ADDON = true; }; GVAR(ActNamespace) = [] call CBA_fnc_createNamespace; GVAR(ActSelfNamespace) = [] call CBA_fnc_createNamespace; +// Compile actions for CAManBase now and use for all mans types +["CAManBase"] call FUNC(compileMenu); +GVAR(cacheManActions) = +(GVAR(ActNamespace) getVariable ["CAManBase", []]); // copy + // Event handlers for all interact menu controls DFUNC(handleMouseMovement) = { if (GVAR(cursorKeepCentered)) then { diff --git a/addons/interact_menu/functions/fnc_compileMenu.sqf b/addons/interact_menu/functions/fnc_compileMenu.sqf index 94c63795ff..2f68d490b8 100644 --- a/addons/interact_menu/functions/fnc_compileMenu.sqf +++ b/addons/interact_menu/functions/fnc_compileMenu.sqf @@ -26,6 +26,15 @@ private _namespace = GVAR(ActNamespace); // Exit if the action menu is already compiled for this class if !(isNil {_namespace getVariable _objectType}) exitWith {}; +if ((_objectType isKindOf "CAManBase") && {!isNil QGVAR(cacheManActions)}) exitWith { + _namespace setVariable [_objectType, +GVAR(cacheManActions)]; // copy +}; + +if ((getNumber (configFile >> "CfgVehicles" >> _objectType >> "isPlayableLogic")) == 1) exitWith { + TRACE_1("skipping playable logic",_objectType); + _namespace setVariable [_objectType, []]; +}; + private _recurseFnc = { params ["_actionsCfg", "_parentDistance"]; private _actions = []; @@ -106,11 +115,6 @@ private _recurseFnc = { _actions }; -if ((getNumber (configFile >> "CfgVehicles" >> _objectType >> "isPlayableLogic")) == 1) exitWith { - TRACE_1("skipping playable logic",_objectType); - _namespace setVariable [_objectType, []]; -}; - private _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions"; TRACE_1("Building ACE_Actions",_objectType);