From 82f3a57e22578883448c6c2980dd4aa7b3541acb Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 9 Dec 2017 00:08:30 +0100 Subject: [PATCH] Use ACRE2 add display passthrough keys API in spectator (#5735) * Use ACRE2 add display passthrough keys API * Assure backwards compatibility with older ACRE2 versions --- addons/spectator/XEH_PREP.hpp | 1 + .../functions/fnc_ui_handleKeyDown.sqf | 9 ------- .../spectator/functions/fnc_ui_handleLoad.sqf | 25 +++++++++++++++++++ addons/spectator/ui.hpp | 4 +-- 4 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 addons/spectator/functions/fnc_ui_handleLoad.sqf diff --git a/addons/spectator/XEH_PREP.hpp b/addons/spectator/XEH_PREP.hpp index fdcb6a22cb..dd651e0c1f 100644 --- a/addons/spectator/XEH_PREP.hpp +++ b/addons/spectator/XEH_PREP.hpp @@ -17,6 +17,7 @@ PREP(ui_handleChildDestroyed); PREP(ui_handleKeyDown); PREP(ui_handleKeyUp); PREP(ui_handleListClick); +PREP(ui_handleLoad); PREP(ui_handleMapClick); PREP(ui_handleMapDraw); PREP(ui_handleMouseButtonDblClick); diff --git a/addons/spectator/functions/fnc_ui_handleKeyDown.sqf b/addons/spectator/functions/fnc_ui_handleKeyDown.sqf index 696ba2e652..2ac7a049b7 100644 --- a/addons/spectator/functions/fnc_ui_handleKeyDown.sqf +++ b/addons/spectator/functions/fnc_ui_handleKeyDown.sqf @@ -197,13 +197,4 @@ if ((_key in (actionKeys "CuratorInterface")) && {!isNull (getAssignedCuratorLog true }; -// Handle acre spectate headset down (if present) -if ( - ["acre_sys_radio"] call EFUNC(common,isModLoaded) && - { [_key, [_shift, _ctrl, _alt]] isEqualTo ((["ACRE2", "HeadSet"] call CBA_fnc_getKeybind) select 5) } -) exitWith { - [] call acre_sys_core_fnc_toggleHeadset; - true -}; - false // default to unhandled diff --git a/addons/spectator/functions/fnc_ui_handleLoad.sqf b/addons/spectator/functions/fnc_ui_handleLoad.sqf new file mode 100644 index 0000000000..1afa5ce123 --- /dev/null +++ b/addons/spectator/functions/fnc_ui_handleLoad.sqf @@ -0,0 +1,25 @@ +/* + * Author: SilentSpike, Jonpas + * Function used to handle load event. + * + * Arguments: + * 0: Spectator display + * + * Return Value: + * None + * + * Example: + * _this call ace_spectator_fnc_ui_handleLoad + * + * Public: No + */ +#include "script_component.hpp" + +params ["_display"]; + +uiNamespace setVariable [QGVAR(display), _display]; + +// Handle ACRE2 Toggle Spectator (if present) +if (!isNil "acre_api_fnc_addDisplayPassthroughKeys") then { + [_display] call acre_api_fnc_addDisplayPassthroughKeys; +}; diff --git a/addons/spectator/ui.hpp b/addons/spectator/ui.hpp index b71dac3516..7a49c72a86 100644 --- a/addons/spectator/ui.hpp +++ b/addons/spectator/ui.hpp @@ -18,8 +18,8 @@ class GVAR(display) { enableSimulation = 1; movingEnable = 0; closeOnMissionEnd = 1; - - onLoad = QUOTE(with uiNameSpace do {GVAR(display) = _this select 0};); + + onLoad = QUOTE(_this call FUNC(ui_handleLoad)); onKeyDown = QUOTE(_this call FUNC(ui_handleKeyDown)); onKeyUp = QUOTE(_this call FUNC(ui_handleKeyUp));