2015-07-21 19:19:54 +00:00
|
|
|
/*
|
|
|
|
* Author: SilentSpike
|
|
|
|
* Adds or removes spectator camera modes from the selection available to the local player.
|
|
|
|
* Possible camera modes are:
|
2015-07-21 21:49:17 +00:00
|
|
|
* - 0: Free
|
2017-08-12 13:25:48 +00:00
|
|
|
* - 1: First person
|
|
|
|
* - 2: Follow
|
|
|
|
*
|
|
|
|
* Default selection is [0,1,2]
|
2015-07-21 19:19:54 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Camera modes to add <ARRAY>
|
|
|
|
* 1: Camera modes to remove <ARRAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Available camera modes <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [[0], [1,2]] call ace_spectator_fnc_updateCameraModes
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2017-04-15 14:32:05 +00:00
|
|
|
if !(EGVAR(common,settingsInitFinished)) exitWith {
|
|
|
|
EGVAR(common,runAtSettingsInitialized) pushBack [DFUNC(updateCameraModes),_this];
|
|
|
|
};
|
|
|
|
|
2015-07-21 19:19:54 +00:00
|
|
|
params [["_addModes",[],[[]]], ["_removeModes",[],[[]]]];
|
2015-07-21 20:51:32 +00:00
|
|
|
private ["_newModes","_currentModes"];
|
|
|
|
|
|
|
|
_currentModes = GVAR(availableModes);
|
2015-07-21 19:19:54 +00:00
|
|
|
|
|
|
|
// Restrict additions to only possible values
|
2017-08-12 13:25:48 +00:00
|
|
|
_newModes = _addModes arrayIntersect ALL_MODES;
|
2015-07-21 20:51:32 +00:00
|
|
|
_newModes append (_currentModes - _removeModes);
|
|
|
|
|
2015-07-27 17:32:21 +00:00
|
|
|
_newModes = _newModes arrayIntersect _newModes;
|
2015-07-21 20:51:32 +00:00
|
|
|
_newModes sort true;
|
2015-07-21 19:19:54 +00:00
|
|
|
|
2015-07-21 20:51:32 +00:00
|
|
|
// Can't become an empty array
|
|
|
|
if (_newModes isEqualTo []) then {
|
2017-08-12 13:25:48 +00:00
|
|
|
WARNING("Cannot remove all spectator camera modes");
|
2015-07-21 20:51:32 +00:00
|
|
|
} else {
|
|
|
|
GVAR(availableModes) = _newModes;
|
|
|
|
};
|
2015-07-21 19:19:54 +00:00
|
|
|
|
2015-07-21 20:51:32 +00:00
|
|
|
// Update camera in case of change
|
2017-08-12 13:25:48 +00:00
|
|
|
if !(isNil QGVAR(camera)) then {
|
|
|
|
// If mode was free and no longer available, find a focus
|
2017-08-17 11:50:43 +00:00
|
|
|
if (!(MODE_FREE in _newModes) && {GVAR(camMode) == MODE_FREE} && {isNull GVAR(camTarget)}) then {
|
2017-08-12 13:25:48 +00:00
|
|
|
[true] call FUNC(setFocus);
|
|
|
|
};
|
|
|
|
|
|
|
|
[GVAR(camMode)] call FUNC(cam_setCameraMode);
|
2015-07-21 20:51:32 +00:00
|
|
|
};
|
2015-07-21 19:19:54 +00:00
|
|
|
|
2015-07-21 20:51:32 +00:00
|
|
|
_newModes
|