From ec58c0061ac3e1f0f13c46a7f7d59a06b003e28b Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Tue, 21 Jul 2015 20:19:54 +0100 Subject: [PATCH] Public functions to tweak available vision/camera modes --- addons/spectator/XEH_preInit.sqf | 2 + .../functions/fnc_updateCameraModes.sqf | 37 ++++++++++++++++ .../functions/fnc_updateVisionModes.sqf | 44 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 addons/spectator/functions/fnc_updateCameraModes.sqf create mode 100644 addons/spectator/functions/fnc_updateVisionModes.sqf diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index 7a3e3dbedb..112dcaf576 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -16,7 +16,9 @@ PREP(setCameraAttributes); PREP(setSpectator); PREP(transitionCamera); PREP(toggleInterface); +PREP(updateCameraModes); PREP(updateUnits); +PREP(updateVisionModes); // Permanent variables GVAR(availableModes) = [0,1,2]; diff --git a/addons/spectator/functions/fnc_updateCameraModes.sqf b/addons/spectator/functions/fnc_updateCameraModes.sqf new file mode 100644 index 0000000000..7048297551 --- /dev/null +++ b/addons/spectator/functions/fnc_updateCameraModes.sqf @@ -0,0 +1,37 @@ +/* + * Author: SilentSpike + * Adds or removes spectator camera modes from the selection available to the local player. + * Possible camera modes are: + * - 0: Freecam + * - 1: Internal + * - 2: External + * + * Arguments: + * 0: Camera modes to add + * 1: Camera modes to remove + * + * Return Value: + * Available camera modes + * + * Example: + * [[0], [1,2]] call ace_spectator_fnc_updateCameraModes + * + * Public: Yes + */ + +#include "script_component.hpp" + +params [["_addModes",[],[[]]], ["_removeModes",[],[[]]]]; + +// Restrict additions to only possible values +_addModes = _addModes arrayIntersect [0,1,2]; +_addModes sort true; + +// Remove and add new modes +GVAR(availableModes) = GVAR(availableModes) - _removeModes; + +GVAR(availableModes) append _addModes; +GVAR(availableModes) arrayIntersect GVAR(availableModes); +GVAR(availableModes) sort true; + +GVAR(availableModes) diff --git a/addons/spectator/functions/fnc_updateVisionModes.sqf b/addons/spectator/functions/fnc_updateVisionModes.sqf new file mode 100644 index 0000000000..4e8b02bce3 --- /dev/null +++ b/addons/spectator/functions/fnc_updateVisionModes.sqf @@ -0,0 +1,44 @@ +/* + * Author: SilentSpike + * Adds or removes spectator vision modes from the selection available to the local player. + * The default selection is [-2,-1,0,1]. + * Possible vision modes are: + * - -2: Normal + * - -1: Night vision + * - 0: White hot + * - 1: Black hot + * - 2: Light Green Hot / Darker Green cold + * - 3: Black Hot / Darker Green cold + * - 4: Light Red Hot /Darker Red Cold + * - 5: Black Hot / Darker Red Cold + * - 6: White Hot . Darker Red Col + * - 7: Thermal (Shade of Red and Green, Bodies are white) + * + * Arguments: + * 0: Vision modes to add + * 1: Vision modes to remove + * + * Return Value: + * Available vision modes + * + * Example: + * [[0], [1,2]] call ace_spectator_fnc_updateVisionModes + * + * Public: Yes + */ + +#include "script_component.hpp" + +params [["_addModes",[],[[]]], ["_removeModes",[],[[]]]]; + +// Restrict additions to only possible values +_addModes = _addModes arrayIntersect [-2,-1,0,1,2,3,4,5,6,7]; + +// Remove and add new modes +GVAR(availableVisions) = GVAR(availableVisions) - _removeModes; + +GVAR(availableVisions) append _addModes; +GVAR(availableVisions) arrayIntersect GVAR(availableVisions); +GVAR(availableVisions) sort true; + +GVAR(availableVisions)