From 4ff01967b6b553ad55b8360aa210617e0a035839 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 12 Oct 2018 14:59:40 +0200 Subject: [PATCH] Add Feature Camera Player EH and Handling (#6573) * Switch to CBA Feature Camera handling * Register ACE3's Feature Cameras * Backwards compatiblity for old ace event * Require CBA 3.9 --- .../functions/fnc_canPrepare.sqf | 2 +- addons/common/XEH_postInit.sqf | 20 ++++++------------- .../functions/fnc_isFeatureCameraActive.sqf | 2 ++ addons/goggles/XEH_postInit.sqf | 2 +- .../goggles/functions/fnc_externalCamera.sqf | 5 +++-- addons/huntir/XEH_postInit.sqf | 2 ++ addons/main/script_mod.hpp | 2 +- addons/optics/XEH_postInit.sqf | 12 +++++------ addons/spectator/XEH_postInit.sqf | 2 ++ 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/addons/advanced_throwing/functions/fnc_canPrepare.sqf b/addons/advanced_throwing/functions/fnc_canPrepare.sqf index c3fdce974f..87c6a7843c 100644 --- a/addons/advanced_throwing/functions/fnc_canPrepare.sqf +++ b/addons/advanced_throwing/functions/fnc_canPrepare.sqf @@ -31,7 +31,7 @@ GVAR(enabled) && {_unit getVariable [QGVAR(lastThrownTime), CBA_missionTime - 3] < CBA_missionTime - 2} && // Prevent throwing in quick succession #endif -{!(call EFUNC(common,isFeatureCameraActive))} && +{(call CBA_fnc_getActiveFeatureCamera) isEqualTo ""} && {[_unit, objNull, ["isNotInside", "isNotSwimming", "isNotSitting"/*, "isNotOnLadder"*/]] call EFUNC(common,canInteractWith)} && // Ladder needs positioning fixes on throw {_unit call CBA_fnc_canUseWeapon} && // Disable in non-FFV seats due to surface detection issues {"" == currentWeapon _unit || {currentWeapon _unit != secondaryWeapon _unit}} && diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index ce6126cba7..2ced174f30 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -266,21 +266,13 @@ TRACE_1("adding unit playerEH to set ace_player",isNull cba_events_oldUnit); GVAR(uniqueItemsCache) = nil; }] call CBA_fnc_addPlayerEventHandler; +// Backwards compatiblity for old ace event GVAR(OldIsCamera) = false; - -[{ - BEGIN_COUNTER(stateChecker); - - // "activeCameraChanged" event - private _data = call FUNC(isfeatureCameraActive); - if !(_data isEqualTo GVAR(OldIsCamera)) then { - // Raise ACE event locally - GVAR(OldIsCamera) = _data; - ["ace_activeCameraChanged", [ACE_player, _data]] call CBA_fnc_localEvent; - }; - - END_COUNTER(stateChecker); -}, 0.5, []] call CBA_fnc_addPerFrameHandler; +["featureCamera", { + params ["_player", "_cameraName"]; + GVAR(OldIsCamera) = _cameraName != ""; + ["ace_activeCameraChanged", [_player, GVAR(OldIsCamera)]] call CBA_fnc_localEvent; +}, true] call CBA_fnc_addPlayerEventHandler; // Add event handler for UAV control change ACE_controlledUAV = [objNull, objNull, [], ""]; diff --git a/addons/common/functions/fnc_isFeatureCameraActive.sqf b/addons/common/functions/fnc_isFeatureCameraActive.sqf index 00e3db699a..24ea0667be 100644 --- a/addons/common/functions/fnc_isFeatureCameraActive.sqf +++ b/addons/common/functions/fnc_isFeatureCameraActive.sqf @@ -24,6 +24,8 @@ * Public: Yes */ +ACE_DEPRECATED(QFUNC(isFeatureCameraActive),"3.14.0","CBA_fnc_getActiveFeatureCamera"); + !( isNull curatorCamera && // Curator {!GETMVAR(EGVAR(spectator,isSet),false)} && // ACE Spectator diff --git a/addons/goggles/XEH_postInit.sqf b/addons/goggles/XEH_postInit.sqf index 9927a165f1..a1a7c53460 100644 --- a/addons/goggles/XEH_postInit.sqf +++ b/addons/goggles/XEH_postInit.sqf @@ -80,7 +80,7 @@ if (!hasInterface) exitWith {}; }; ["cameraView", _fnc_checkGoggles] call CBA_fnc_addPlayerEventHandler; - ["ace_activeCameraChanged", _fnc_checkGoggles] call CBA_fnc_addEventHandler; + ["featureCamera", _fnc_checkGoggles] call CBA_fnc_addPlayerEventHandler; diff --git a/addons/goggles/functions/fnc_externalCamera.sqf b/addons/goggles/functions/fnc_externalCamera.sqf index c251ef1f49..99a268f2ef 100644 --- a/addons/goggles/functions/fnc_externalCamera.sqf +++ b/addons/goggles/functions/fnc_externalCamera.sqf @@ -18,8 +18,9 @@ // Handle the ThreeDen Editor Camera if (is3DEN) exitWith {true}; +private _isFeatureCamera = call CBA_fnc_getFeatureCameraActive != ""; if (GVAR(showInThirdPerson)) then { - cameraView in ["GROUP"] || EFUNC(common,isFeatureCameraActive) + cameraView in ["GROUP"] || _isFeatureCamera } else { - cameraView in ["EXTERNAL", "GROUP"] || EFUNC(common,isFeatureCameraActive) + cameraView in ["EXTERNAL", "GROUP"] || _isFeatureCamera }; diff --git a/addons/huntir/XEH_postInit.sqf b/addons/huntir/XEH_postInit.sqf index 5ad798a62d..1f6a39056b 100644 --- a/addons/huntir/XEH_postInit.sqf +++ b/addons/huntir/XEH_postInit.sqf @@ -11,3 +11,5 @@ GVAR(ELEVAT) = 0.01; // Register fire event handler // Don't run for non players, as they are too dumb to launch huntirs anyway ["ace_firedPlayer", DFUNC(handleFired)] call CBA_fnc_addEventHandler; + +["ace_huntir", {!GETMVAR(GVAR(stop),true)}] call CBA_fnc_registerFeatureCamera; diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index 65aa94f8fa..372be82530 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -10,7 +10,7 @@ // MINIMAL required version for the Mod. Components can specify others.. #define REQUIRED_VERSION 1.84 -#define REQUIRED_CBA_VERSION {3,8,0} +#define REQUIRED_CBA_VERSION {3,9,0} #ifdef COMPONENT_BEAUTIFIED #define COMPONENT_NAME QUOTE(ACE3 - COMPONENT_BEAUTIFIED) diff --git a/addons/optics/XEH_postInit.sqf b/addons/optics/XEH_postInit.sqf index 2c02e72638..abb97e5b5d 100644 --- a/addons/optics/XEH_postInit.sqf +++ b/addons/optics/XEH_postInit.sqf @@ -13,11 +13,11 @@ GVAR(camera) = objNull; }; }] call CBA_fnc_addEventHandler; -// camera has to be re-created every time another camera is created. Otherwise r2t is either black or transparent. @todo Add popular custom cameras to the event in ACE_common. -["ace_activeCameraChanged", { - params ["", "_isfeatureCameraActive"]; - TRACE_1("ace_activeCameraChanged",_isfeatureCameraActive); - if (!_isfeatureCameraActive) then { +// camera has to be re-created every time another camera is created. Otherwise r2t is either black or transparent.. +["featureCamera", { + params ["_player", "_featureCamera"]; + TRACE_1("featureCamera",_featureCamera); + if (_featureCamera isEqualTo "") then { // Destroy the camera, and it will be re-created in the onDrawScope2d helper if (!isNull GVAR(camera)) then { GVAR(camera) cameraEffect ["TERMINATE", "BACK"]; @@ -25,7 +25,7 @@ GVAR(camera) = objNull; TRACE_1("destroying pip camera for restart",GVAR(camera)); }; }; -}] call CBA_fnc_addEventHandler; +}] call CBA_fnc_addPlayerEventHandler; // Register fire event handler ["ace_firedPlayer", DFUNC(handleFired)] call CBA_fnc_addEventHandler; diff --git a/addons/spectator/XEH_postInit.sqf b/addons/spectator/XEH_postInit.sqf index 715dbe1c3d..a02f36ae67 100644 --- a/addons/spectator/XEH_postInit.sqf +++ b/addons/spectator/XEH_postInit.sqf @@ -34,3 +34,5 @@ if (hasInterface) then { } ] call CBA_fnc_waitUntilAndExecute; }; + +["ace_spectator", {GETMVAR(GVAR(isSet),false)}] call CBA_fnc_registerFeatureCamera;