From 7746dbcc75dce85d88a38c55a8b290ca0934d0fa Mon Sep 17 00:00:00 2001 From: mharis001 <34453221+mharis001@users.noreply.github.com> Date: Fri, 5 Jun 2020 21:13:10 -0400 Subject: [PATCH] Spectator - Add display loaded and unloaded events (#7720) --- .../spectator/functions/fnc_ui_handleLoad.sqf | 2 ++ .../functions/fnc_ui_handleUnload.sqf | 20 +++++++++++++++++++ addons/spectator/ui.hpp | 1 + docs/wiki/framework/spectator-framework.md | 8 +++++--- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 addons/spectator/functions/fnc_ui_handleUnload.sqf diff --git a/addons/spectator/functions/fnc_ui_handleLoad.sqf b/addons/spectator/functions/fnc_ui_handleLoad.sqf index bcaf90a699..74564dcd9b 100644 --- a/addons/spectator/functions/fnc_ui_handleLoad.sqf +++ b/addons/spectator/functions/fnc_ui_handleLoad.sqf @@ -19,6 +19,8 @@ params ["_display"]; uiNamespace setVariable [QGVAR(display), _display]; +[QGVAR(displayLoaded), _display] call CBA_fnc_localEvent; + // Handle ACRE2 Toggle Spectator (if present) if (!isNil "acre_api_fnc_addDisplayPassthroughKeys") then { [_display] call acre_api_fnc_addDisplayPassthroughKeys; diff --git a/addons/spectator/functions/fnc_ui_handleUnload.sqf b/addons/spectator/functions/fnc_ui_handleUnload.sqf new file mode 100644 index 0000000000..8d9f92a262 --- /dev/null +++ b/addons/spectator/functions/fnc_ui_handleUnload.sqf @@ -0,0 +1,20 @@ +#include "script_component.hpp" +/* + * Author: mharis001 + * Function used to handle unload event. + * + * Arguments: + * 0: Spectator display + * + * Return Value: + * None + * + * Example: + * _this call ace_spectator_fnc_ui_handleUnload + * + * Public: No + */ + +params ["_display"]; + +[QGVAR(displayUnloaded), _display] call CBA_fnc_localEvent; diff --git a/addons/spectator/ui.hpp b/addons/spectator/ui.hpp index 7a49c72a86..8ffd1b5ebd 100644 --- a/addons/spectator/ui.hpp +++ b/addons/spectator/ui.hpp @@ -20,6 +20,7 @@ class GVAR(display) { closeOnMissionEnd = 1; onLoad = QUOTE(_this call FUNC(ui_handleLoad)); + onUnload = QUOTE(_this call FUNC(ui_handleUnload)); onKeyDown = QUOTE(_this call FUNC(ui_handleKeyDown)); onKeyUp = QUOTE(_this call FUNC(ui_handleKeyUp)); diff --git a/docs/wiki/framework/spectator-framework.md b/docs/wiki/framework/spectator-framework.md index 36c2d628f6..1ea3ec0918 100644 --- a/docs/wiki/framework/spectator-framework.md +++ b/docs/wiki/framework/spectator-framework.md @@ -51,6 +51,8 @@ Note that these settings govern the default spectator behaviour. Through the use Event Name | Passed Parameter(s) | Locality | Description ---------- | ----------- | ------------------- | -------- `ace_spectatorSet` | [_isSpectator, _player] | Global | Player's spectator status was changed +`ace_spectator_displayLoaded` | _display | Local | Spectator display was loaded +`ace_spectator_displayUnloaded` | _display | Local | Spectator display was unloaded ## 4. Scripting @@ -94,7 +96,7 @@ Note that this function takes local effect, so only the local player will see th * Example: * [allPlayers, [player]] call ace_spectator_fnc_updateUnits ``` - + ### 4.3 Add/Remove sides available to spectate `ace_spectator_fnc_updateSides` @@ -117,7 +119,7 @@ Note that this function takes local effect, so only the local player will see th ### 4.4 Add/Remove available camera modes `ace_spectator_fnc_updateCameraModes` -You can change the spectator camera modes available at any point during the mission and independently on different machines with this function (e.g. if you only want one side of players to have a free camera). Remember that the **Camera modes** setting will change which modes are available to everyone by default - changes with this function will override that. +You can change the spectator camera modes available at any point during the mission and independently on different machines with this function (e.g. if you only want one side of players to have a free camera). Remember that the **Camera modes** setting will change which modes are available to everyone by default - changes with this function will override that. Note that this function takes local effect, so only the local player will experience these changes. @@ -141,7 +143,7 @@ Note that this function takes local effect, so only the local player will experi ### 4.5 Add/Remove available vision modes `ace_spectator_fnc_updateVisionModes` -You can change the spectator vision modes available at any point during the mission and independently on different machines with this function (e.g. if you only want one side of players to have night vision). Remember that the **Vision modes** setting will change which modes are available to everyone by default (if thermal is enabled via the setting then both black and white hot are available) - changes with this function will override that. +You can change the spectator vision modes available at any point during the mission and independently on different machines with this function (e.g. if you only want one side of players to have night vision). Remember that the **Vision modes** setting will change which modes are available to everyone by default (if thermal is enabled via the setting then both black and white hot are available) - changes with this function will override that. Note that this function takes local effect, so only the local player will experience these changes.