Skip to content

Commit

Permalink
Add Feature Camera Player EH and Handling (#6573)
Browse files Browse the repository at this point in the history
* Switch to CBA Feature Camera handling

* Register ACE3's Feature Cameras

* Backwards compatiblity for old ace event

* Require CBA 3.9
  • Loading branch information
jonpas authored Oct 12, 2018
1 parent 0b2b72d commit f19a575
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion addons/advanced_throwing/functions/fnc_canPrepare.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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}} &&
Expand Down
20 changes: 6 additions & 14 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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, [], ""];
Expand Down
2 changes: 2 additions & 0 deletions addons/common/functions/fnc_isFeatureCameraActive.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion addons/goggles/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;



Expand Down
5 changes: 3 additions & 2 deletions addons/goggles/functions/fnc_externalCamera.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
2 changes: 2 additions & 0 deletions addons/huntir/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions addons/optics/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ 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"];
camDestroy GVAR(camera);
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;
2 changes: 2 additions & 0 deletions addons/spectator/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ if (hasInterface) then {
}
] call CBA_fnc_waitUntilAndExecute;
};

["ace_spectator", {GETMVAR(GVAR(isSet),false)}] call CBA_fnc_registerFeatureCamera;

0 comments on commit f19a575

Please sign in to comment.