From f43e88ff25222e1e70bd555fc06f2649cd1b5909 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 21 Feb 2016 22:16:12 +0100 Subject: [PATCH] replace zeusDisplayChanged with DisplayLoad event --- addons/captives/CfgEventHandlers.hpp | 8 ++++++++ addons/captives/XEH_postInit.sqf | 1 - .../functions/fnc_handleZeusDisplayChanged.sqf | 17 ++++++----------- addons/common/XEH_postInit.sqf | 11 ----------- addons/nightvision/CfgEventHandlers.hpp | 15 ++++++++++++++- addons/nightvision/XEH_postInitClient.sqf | 2 +- .../functions/fnc_updatePPEffects.sqf | 10 +++++++++- 7 files changed, 38 insertions(+), 26 deletions(-) diff --git a/addons/captives/CfgEventHandlers.hpp b/addons/captives/CfgEventHandlers.hpp index 4d12dc10c4..59351119c3 100644 --- a/addons/captives/CfgEventHandlers.hpp +++ b/addons/captives/CfgEventHandlers.hpp @@ -1,3 +1,4 @@ + class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preInit)); @@ -9,6 +10,13 @@ class Extended_PostInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; + +class Extended_DisplayUnload_EventHandlers { + class RscDisplayCurator { + ADDON = QUOTE(call FUNC(handleZeusDisplayChanged)); + }; +}; + //release escorted captive when entering a vehicle class Extended_GetIn_EventHandlers { class All { diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf index 8f7109b81f..144d3efb9a 100644 --- a/addons/captives/XEH_postInit.sqf +++ b/addons/captives/XEH_postInit.sqf @@ -18,7 +18,6 @@ if (isServer) then { }]; }; -["zeusDisplayChanged", {_this call FUNC(handleZeusDisplayChanged)}] call EFUNC(common,addEventHandler); ["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); ["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler); ["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler); diff --git a/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf b/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf index ef8aedbbe1..433c1fc259 100644 --- a/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf +++ b/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf @@ -17,15 +17,10 @@ */ #include "script_component.hpp" -params ["_unit","_zeusIsOpen"]; - -//set showHUD based on unit status: -if (!_zeusIsOpen) then { - if ((_unit getVariable [QGVAR(isHandcuffed), false]) || {_unit getVariable [QGVAR(isSurrendering), false]}) then { - TRACE_1("Player Change (showHUD false)",_unit); - ["captive", [false, false, false, false, false, false, false, false]] call EFUNC(common,showHud); - } else { - TRACE_1("Player Change (showHUD true)",_unit); - ["captive", []] call EFUNC(common,showHud); //same as showHud true; - }; +if ((ACE_player getVariable [QGVAR(isHandcuffed), false]) || {ACE_player getVariable [QGVAR(isSurrendering), false]}) then { + TRACE_1("Player Change (showHUD false)",ACE_player); + ["captive", [false, false, false, false, false, false, false, false]] call EFUNC(common,showHud); +} else { + TRACE_1("Player Change (showHUD true)",ACE_player); + ["captive", []] call EFUNC(common,showHud); //same as showHud true; }; diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index b5647cd186..8bda027d1f 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -316,17 +316,6 @@ enableCamShake true; // Set up numerous eventhanders for player controlled units ////////////////////////////////////////////////// -//CBA has events for zeus's display onLoad and onUnload (Need to delay a frame for display to be ready) -private _zeusDisplayChangedFNC = { - [{ - private _data = !(isNull findDisplay 312); - ["zeusDisplayChanged", [ACE_player, _data]] call FUNC(localEvent); - }, []] call FUNC(execNextFrame); -}; -["CBA_curatorOpened", _zeusDisplayChangedFNC] call CBA_fnc_addEventHandler; -["CBA_curatorClosed", _zeusDisplayChangedFNC] call CBA_fnc_addEventHandler; - - // default variables GVAR(OldPlayerVehicle) = vehicle objNull; GVAR(OldPlayerTurret) = [objNull] call FUNC(getTurretIndex); diff --git a/addons/nightvision/CfgEventHandlers.hpp b/addons/nightvision/CfgEventHandlers.hpp index 49b87fb4fd..1e30aab27a 100644 --- a/addons/nightvision/CfgEventHandlers.hpp +++ b/addons/nightvision/CfgEventHandlers.hpp @@ -1,3 +1,4 @@ + class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preInit) ); @@ -6,6 +7,18 @@ class Extended_PreInit_EventHandlers { class Extended_PostInit_EventHandlers { class ADDON { - clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient) ); + clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient)); + }; +}; + +class Extended_DisplayLoad_EventHandlers { + class RscDisplayCurator { + ADDON = QUOTE(_this call FUNC(updatePPEffects)); + }; +}; + +class Extended_DisplayUnload_EventHandlers { + class RscDisplayCurator { + ADDON = QUOTE(displayNull call FUNC(updatePPEffects)); // emulate zeus display being deleted }; }; diff --git a/addons/nightvision/XEH_postInitClient.sqf b/addons/nightvision/XEH_postInitClient.sqf index 1f73b12e93..17cb92f9cc 100644 --- a/addons/nightvision/XEH_postInitClient.sqf +++ b/addons/nightvision/XEH_postInitClient.sqf @@ -34,7 +34,7 @@ GVAR(ppEffectMuzzleFlash) ppEffectCommit 0; _this call FUNC(updatePPEffects); _this call FUNC(onVisionModeChanged); }] call EFUNC(common,addEventHandler); -["zeusDisplayChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); + ["cameraViewChanged", { _this call FUNC(updatePPEffects); _this call FUNC(onCameraViewChanged); diff --git a/addons/nightvision/functions/fnc_updatePPEffects.sqf b/addons/nightvision/functions/fnc_updatePPEffects.sqf index 72cd6cbd0d..9bf8321353 100644 --- a/addons/nightvision/functions/fnc_updatePPEffects.sqf +++ b/addons/nightvision/functions/fnc_updatePPEffects.sqf @@ -17,12 +17,20 @@ if (!hasInterface) exitWith {}; +disableSerialization; + +params [["_display", displayNull]]; + +if !(_display isEqualType displayNull) then { + _display = displayNull; +}; + private ["_currentVehicle", "_grainSetting", "_blurSetting", "_radBlurSetting", "_config", "_hmd", "_cameraView", "_turret"]; _currentVehicle = vehicle ACE_player; // If the Zeus display is on or the player has no nightvision -if ((!isNull findDisplay 312) || ((currentVisionMode ACE_player) != 1)) exitWith { +if (ctrlIDD _display == 312 || currentVisionMode ACE_player != 1) exitWith { GVAR(ppEffectFilmGrain) ppEffectEnable false; GVAR(ppEffectBlur) ppEffectEnable false; GVAR(ppEffectRadialBlur) ppEffectEnable false;