Interaction Menu - Only compile self actions when needed (#6792)

* Interaction Menu - Only compile self actions when needed

* Update XEH_clientInit.sqf

* fix spellling

* format/comments

* Don't compile actions on headless servers

* Update addons/zeus/XEH_postInit.sqf

Co-Authored-By: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
PabstMirror 2019-01-31 19:25:16 -06:00 committed by GitHub
parent 639d3fdfa1
commit ff5eb34e10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 43 additions and 14 deletions

View File

@ -17,14 +17,6 @@ class Extended_PostInit_EventHandlers {
}; };
}; };
class Extended_InitPost_EventHandlers {
class All {
class GVAR(compileMenu) {
init = QUOTE(_this call FUNC(compileMenu);_this call FUNC(compileMenuSelfAction));
};
};
};
class Extended_DisplayLoad_EventHandlers { class Extended_DisplayLoad_EventHandlers {
class RscDiary { class RscDiary {
ADDON = QUOTE(call COMPILE_FILE(XEH_displayLoad)); ADDON = QUOTE(call COMPILE_FILE(XEH_displayLoad));

View File

@ -2,6 +2,29 @@
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
// Wait until player controls (man,vehicle or uav) a thing before compiling the menu
GVAR(controllableSelfActionsAdded) = [] call CBA_fnc_createNamespace;
DFUNC(newControllableObject) = {
params ["_object"];
private _type = typeOf _object;
TRACE_2("newControllableObject",_object,_type);
if (_type == "") exitWith {};
if (!(GVAR(controllableSelfActionsAdded) getVariable [_type, false])) then {
[_type] call FUNC(compileMenuSelfAction);
GVAR(controllableSelfActionsAdded) setVariable [_type, true];
[{
TRACE_1("sending newControllableObject event",_this);
// event for other systems to add self actions, running addActionToClass before this will cause compiling
[QGVAR(newControllableObject), _this] call CBA_fnc_localEvent;
}, [_type]] call CBA_fnc_execNextFrame; // delay event a frame to ensure postInit has run for all addons
};
};
["unit", {[_this select 0] call FUNC(newControllableObject)}, true] call CBA_fnc_addPlayerEventHandler;
["vehicle", {[_this select 1] call FUNC(newControllableObject)}, true] call CBA_fnc_addPlayerEventHandler;
["ACE_controlledUAV", {[_this select 0] call FUNC(newControllableObject)}] call CBA_fnc_addEventHandler;
GVAR(blockDefaultActions) = []; GVAR(blockDefaultActions) = [];
GVAR(cachedBuildingTypes) = []; GVAR(cachedBuildingTypes) = [];

View File

@ -8,6 +8,10 @@ PREP_RECOMPILE_END;
#include "initSettings.sqf" #include "initSettings.sqf"
if (!hasInterface) exitWith { ADDON = true; };
["All", "init", {_this call FUNC(compileMenu)}] call CBA_fnc_addClassEventHandler;
GVAR(ActNamespace) = [] call CBA_fnc_createNamespace; GVAR(ActNamespace) = [] call CBA_fnc_createNamespace;
GVAR(ActSelfNamespace) = [] call CBA_fnc_createNamespace; GVAR(ActSelfNamespace) = [] call CBA_fnc_createNamespace;

View File

@ -20,6 +20,7 @@
* Public: Yes * Public: Yes
*/ */
if (!hasInterface) exitWith { [] };
if (!params [["_objectType", "", [""]], ["_typeNum", 0, [0]], ["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith { if (!params [["_objectType", "", [""]], ["_typeNum", 0, [0]], ["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith {
ERROR("Bad Params"); ERROR("Bad Params");
[] []

View File

@ -19,6 +19,7 @@
* Public: Yes * Public: Yes
*/ */
if (!hasInterface) exitWith { [] };
if (!params [["_object", objNull, [objNull]], ["_typeNum", 0, [0]], ["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith { if (!params [["_object", objNull, [objNull]], ["_typeNum", 0, [0]], ["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith {
ERROR("Bad Params"); ERROR("Bad Params");
[] []

View File

@ -17,6 +17,7 @@
* Public: Yes * Public: Yes
*/ */
if (!hasInterface) exitWith { [] };
if (!params [["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith {ERROR("Bad Params"); []}; if (!params [["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith {ERROR("Bad Params"); []};
if ((_parentPath param [0, ""]) != "ACE_ZeusActions") exitWith {ERROR_1("Bad path %1 - should have ACE_ZeusActions as base", _parentPath); []}; if ((_parentPath param [0, ""]) != "ACE_ZeusActions") exitWith {ERROR_1("Bad path %1 - should have ACE_ZeusActions as base", _parentPath); []};
TRACE_2("addActionToZeus",_parentPath,_action); TRACE_2("addActionToZeus",_parentPath,_action);

View File

@ -28,6 +28,7 @@
// IGNORE_PRIVATE_WARNING(_actionName,_displayName,_icon,_statement,_condition,_insertChildren,_customParams,_position,_distance,_params,_modifierFunction); // IGNORE_PRIVATE_WARNING(_actionName,_displayName,_icon,_statement,_condition,_insertChildren,_customParams,_position,_distance,_params,_modifierFunction);
if (!hasInterface) exitWith { [] };
params [ params [
"_actionName", "_actionName",
"_displayName", "_displayName",

View File

@ -82,6 +82,11 @@ if (hasInterface) then {
[localize "str_a3_cfgvehicles_moduletasksetstate_f_arguments_state_values_created_0"] call EFUNC(common,displayTextStructured); [localize "str_a3_cfgvehicles_moduletasksetstate_f_arguments_state_values_created_0"] call EFUNC(common,displayTextStructured);
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
[QEGVAR(interact_menu,newControllableObject), {
params ["_type"];
if (!(_type isKindOf "CAManBase")) exitWith {};
TRACE_1("Adding zeus actions",_type);
private _action = [ private _action = [
QGVAR(create), QGVAR(create),
LLSTRING(CreateZeus), LLSTRING(CreateZeus),
@ -100,7 +105,7 @@ if (hasInterface) then {
&& {isNil QGVAR(zeus)} && {isNil QGVAR(zeus)}
} }
] call EFUNC(interact_menu,createAction); ] call EFUNC(interact_menu,createAction);
["CAManBase", 1, ["ACE_SelfActions"], _action, true] call EFUNC(interact_menu,addActionToClass); [_type, 1, ["ACE_SelfActions"], _action] call EFUNC(interact_menu,addActionToClass);
_action = [ _action = [
QGVAR(delete), QGVAR(delete),
@ -112,5 +117,6 @@ if (hasInterface) then {
}, },
{!(isNil QGVAR(zeus) || {isNull GVAR(zeus)})} {!(isNil QGVAR(zeus) || {isNull GVAR(zeus)})}
] call EFUNC(interact_menu,createAction); ] call EFUNC(interact_menu,createAction);
["CAManBase", 1, ["ACE_SelfActions"], _action, true] call EFUNC(interact_menu,addActionToClass); [_type, 1, ["ACE_SelfActions"], _action] call EFUNC(interact_menu,addActionToClass);
}] call CBA_fnc_addEventHandler;
}; };