From 5108ffe20c1256aea63d99bff0c1eae6a89f7699 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 25 Jun 2016 19:16:26 -0500 Subject: [PATCH] Add goggles setting for level of effects Can chose between none, tint/colorCC/ and full dust/dirt/rain/rotorwash --- addons/goggles/ACE_Settings.hpp | 12 +- addons/goggles/CfgEventHandlers.hpp | 8 - addons/goggles/XEH_postInit.sqf | 225 ++++++++++-------- .../functions/fnc_applyGlassesEffect.sqf | 14 +- .../goggles/functions/fnc_externalCamera.sqf | 2 +- addons/goggles/functions/fnc_handleKilled.sqf | 19 +- .../functions/fnc_removeGlassesEffect.sqf | 8 +- addons/goggles/stringtable.xml | 9 + 8 files changed, 160 insertions(+), 137 deletions(-) diff --git a/addons/goggles/ACE_Settings.hpp b/addons/goggles/ACE_Settings.hpp index a78c2866e0..659a10b4e3 100644 --- a/addons/goggles/ACE_Settings.hpp +++ b/addons/goggles/ACE_Settings.hpp @@ -1,11 +1,11 @@ class ACE_Settings { - /*class GVAR(enable) { // @todo - value = 0; - typeName = "BOOL"; - isClientSettable = 1; - displayName = CSTRING(enable); - };*/ + class GVAR(effects) { + displayName = CSTRING(effects_displayName); + typeName = "SCALAR"; + value = 2; + values[] = {ECSTRING(common,Disabled), CSTRING(effects_tintOnly), CSTRING(enabled_tintAndEffects)}; + }; class GVAR(showInThirdPerson) { value = 0; typeName = "BOOL"; diff --git a/addons/goggles/CfgEventHandlers.hpp b/addons/goggles/CfgEventHandlers.hpp index 578b4ebebb..99cbf2f8ad 100644 --- a/addons/goggles/CfgEventHandlers.hpp +++ b/addons/goggles/CfgEventHandlers.hpp @@ -24,11 +24,3 @@ class Extended_Killed_EventHandlers { }; }; }; - -class Extended_Explosion_EventHandlers { - class CAManBase { - class ADDON { - clientExplosion = QUOTE(if (local (_this select 0)) then {_this call FUNC(handleExplosion)}); - }; - }; -}; diff --git a/addons/goggles/XEH_postInit.sqf b/addons/goggles/XEH_postInit.sqf index ea610afff0..b7b5de9e1b 100644 --- a/addons/goggles/XEH_postInit.sqf +++ b/addons/goggles/XEH_postInit.sqf @@ -3,6 +3,7 @@ if (!hasInterface) exitWith {}; ["ACE3 Common", QGVAR(wipeGlasses), localize LSTRING(WipeGlasses), { + if (GVAR(effects) != 2) exitWith {false}; //Can only wipe if full effects setting is set if (!(GETVAR(ace_player,ACE_isUnconscious,false))) exitWith { call FUNC(clearGlasses); true @@ -12,126 +13,142 @@ if (!hasInterface) exitWith {}; {false}, [20, [true, true, false]], false] call CBA_fnc_addKeybind; -// make sure to stack effect layers in correct order -GVAR(GogglesEffectsLayer) = QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer; -GVAR(GogglesLayer) = QGVAR(GogglesLayer) call BIS_fnc_RSCLayer; -if (isNil QGVAR(UsePP)) then { - GVAR(UsePP) = true; -}; +["ace_settingsInitialized", { + TRACE_2("ace_settingsInitialized eh",GVAR(effects),GVAR(showInThirdPerson)); -// init pp effects -GVAR(PostProcess) = ppEffectCreate ["ColorCorrections", 1995]; -GVAR(PostProcessEyes) = ppEffectCreate ["ColorCorrections", 1992]; -GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [1, 1, 1, 0]]; -GVAR(PostProcessEyes) ppEffectCommit 0; -GVAR(PostProcessEyes) ppEffectEnable false; + if (GVAR(effects) == 0) exitWith {}; -GVAR(EffectsActive) = false; + // ---Add the TINT Effect--- + + // make sure to stack effect layers in correct order + GVAR(GogglesEffectsLayer) = QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer; + GVAR(GogglesLayer) = QGVAR(GogglesLayer) call BIS_fnc_RSCLayer; -SETGLASSES(ace_player,GLASSESDEFAULT); - -GVAR(FrameEvent) = [false, [false, 20]]; -GVAR(PostProcessEyes_Enabled) = false; -GVAR(DustHandler) = -1; -GVAR(RainDrops) = objNull; -GVAR(RainActive) = false; -GVAR(RainLastLevel) = 0; -GVAR(surfaceCache) = ""; -GVAR(surfaceCacheIsDust) = false; - -// init GlassesChanged eventhandler -GVAR(OldGlasses) = ""; - -["loadout", { - params ["_unit"]; - - private _currentGlasses = goggles _unit; - - if (GVAR(OldGlasses) != _currentGlasses) then { - ["ace_glassesChanged", [_unit, _currentGlasses]] call CBA_fnc_localEvent; - GVAR(OldGlasses) = _currentGlasses; + if (isNil QGVAR(UsePP)) then { + GVAR(UsePP) = true; }; -}] call CBA_fnc_addPlayerEventHandler; -// add glasses eventhandlers -["ace_glassesChanged", { - params ["_unit", "_glasses"]; + // init GlassesChanged eventhandler + GVAR(OldGlasses) = ""; + ["loadout", { + params ["_unit"]; - SETGLASSES(_unit,GLASSESDEFAULT); + private _currentGlasses = goggles _unit; - if (call FUNC(ExternalCamera)) exitWith {call FUNC(RemoveGlassesEffect)}; + if (GVAR(OldGlasses) != _currentGlasses) then { + ["ace_glassesChanged", [_unit, _currentGlasses]] call CBA_fnc_localEvent; + GVAR(OldGlasses) = _currentGlasses; + }; + }] call CBA_fnc_addPlayerEventHandler; - if ([_unit] call FUNC(isGogglesVisible)) then { - _glasses call FUNC(applyGlassesEffect); - } else { - call FUNC(removeGlassesEffect); + + // init pp effects + GVAR(PostProcess) = ppEffectCreate ["ColorCorrections", 1995]; + GVAR(EffectsActive) = false; + + // check goggles + private _fnc_checkGoggles = { + params ["_unit"]; + + if (GVAR(EffectsActive)) then { + if (call FUNC(externalCamera) || {!([_unit] call FUNC(isGogglesVisible))}) then { + call FUNC(removeGlassesEffect); + }; + } else { + if (!(call FUNC(externalCamera)) && {[_unit] call FUNC(isGogglesVisible)}) then { + [goggles _unit] call FUNC(applyGlassesEffect); + }; + }; }; -}] call CBA_fnc_addEventHandler; -["ace_glassesCracked", { - params ["_unit"]; + ["cameraView", _fnc_checkGoggles] call CBA_fnc_addPlayerEventHandler; + ["ace_activeCameraChanged", _fnc_checkGoggles] call CBA_fnc_addEventHandler; - _unit setVariable ["ACE_EyesDamaged", true]; - GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0.5, 0.5, 0.5, 0.5], [1, 1, 1, 0]]; - GVAR(PostProcessEyes) ppEffectCommit 0; - GVAR(PostProcessEyes) ppEffectEnable true; + // add glasses eventhandlers + ["ace_glassesChanged", { + params ["_unit", "_glasses"]; - [{ - GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 0]]; - GVAR(PostProcessEyes) ppEffectCommit 5; + SETGLASSES(_unit,GLASSESDEFAULT); - [{ - params ["_unit"]; + if (call FUNC(ExternalCamera)) exitWith {call FUNC(RemoveGlassesEffect)}; - GVAR(PostProcessEyes) ppEffectEnable false; - - _unit setVariable ["ACE_EyesDamaged", false]; - - }, _this, 5] call CBA_fnc_waitAndExecute; - - }, _unit, 25] call CBA_fnc_waitAndExecute; - -}] call CBA_fnc_addEventHandler; - -// check goggles -private _fnc_checkGoggles = { - params ["_unit"]; - - if (GVAR(EffectsActive)) then { - if (call FUNC(externalCamera) || {!([_unit] call FUNC(isGogglesVisible))}) then { + if ([_unit] call FUNC(isGogglesVisible)) then { + _glasses call FUNC(applyGlassesEffect); + } else { call FUNC(removeGlassesEffect); }; - } else { - if (!(call FUNC(externalCamera)) && {[_unit] call FUNC(isGogglesVisible)}) then { - [goggles _unit] call FUNC(applyGlassesEffect); - }; + }] call CBA_fnc_addEventHandler; + + + // // ---Add the Dust/Dirt/Rain Effects--- + if (GVAR(effects) == 2) then { + + // Register fire event handler + ["ace_firedPlayer", DFUNC(handleFired)] call CBA_fnc_addEventHandler; + + //Add Explosion XEH + ["CAManBase", "explosion", FUNC(handleExplosion)] call CBA_fnc_addClassEventHandler; + + GVAR(PostProcessEyes) = ppEffectCreate ["ColorCorrections", 1992]; + GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [1, 1, 1, 0]]; + GVAR(PostProcessEyes) ppEffectCommit 0; + GVAR(PostProcessEyes) ppEffectEnable false; + GVAR(PostProcessEyes_Enabled) = false; + + GVAR(FrameEvent) = [false, [false, 20]]; + GVAR(DustHandler) = -1; + GVAR(RainDrops) = objNull; + GVAR(RainActive) = false; + GVAR(RainLastLevel) = 0; + GVAR(surfaceCache) = ""; + GVAR(surfaceCacheIsDust) = false; + + ["ace_glassesCracked", { + params ["_unit"]; + + _unit setVariable ["ACE_EyesDamaged", true]; + + GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0.5, 0.5, 0.5, 0.5], [1, 1, 1, 0]]; + GVAR(PostProcessEyes) ppEffectCommit 0; + GVAR(PostProcessEyes) ppEffectEnable true; + + [{ + GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 0]]; + GVAR(PostProcessEyes) ppEffectCommit 5; + + [{ + params ["_unit"]; + + GVAR(PostProcessEyes) ppEffectEnable false; + + _unit setVariable ["ACE_EyesDamaged", false]; + + }, _this, 5] call CBA_fnc_waitAndExecute; + + }, _unit, 25] call CBA_fnc_waitAndExecute; + + }] call CBA_fnc_addEventHandler; + + // goggles effects main PFH + [{ + BEGIN_COUNTER(goggles); + + // rain + call FUNC(applyRainEffect); + + // auto remove effects under water + if (GVAR(EffectsActive) && {underwater ACE_player} && {[goggles ACE_player] call FUNC(isDivingGoggles)}) then { + call FUNC(removeRainEffect); + call FUNC(removeDirtEffect); + call FUNC(removeDustEffect); + }; + + // rotor wash effect + call FUNC(applyRotorWashEffect); + + END_COUNTER(goggles); + }, 0.5, []] call CBA_fnc_addPerFrameHandler; }; -}; - -["cameraView", _fnc_checkGoggles] call CBA_fnc_addPlayerEventHandler; -["ace_activeCameraChanged", _fnc_checkGoggles] call CBA_fnc_addEventHandler; - -// goggles effects main PFH -[{ - BEGIN_COUNTER(goggles); - - // rain - call FUNC(applyRainEffect); - - // auto remove effects under water - if (GVAR(EffectsActive) && {underwater ACE_player} && {[goggles ACE_player] call FUNC(isDivingGoggles)}) then { - call FUNC(removeRainEffect); - call FUNC(removeDirtEffect); - call FUNC(removeDustEffect); - }; - - // rotor wash effect - call FUNC(applyRotorWashEffect); - - END_COUNTER(goggles); -}, 0.5, []] call CBA_fnc_addPerFrameHandler; - -// Register fire event handler -["ace_firedPlayer", DFUNC(handleFired)] call CBA_fnc_addEventHandler; +}] call CBA_fnc_addEventHandler; diff --git a/addons/goggles/functions/fnc_applyGlassesEffect.sqf b/addons/goggles/functions/fnc_applyGlassesEffect.sqf index 7be010ef9c..71a5b3b84c 100644 --- a/addons/goggles/functions/fnc_applyGlassesEffect.sqf +++ b/addons/goggles/functions/fnc_applyGlassesEffect.sqf @@ -46,13 +46,15 @@ if (_imagePath != "") then { (GLASSDISPLAY displayCtrl 10650) ctrlSetText _imagePath; }; -if (GETDIRT) then { - call FUNC(applyDirtEffect); -}; +if (GVAR(effects) == 2) then { + if (GETDIRT) then { + call FUNC(applyDirtEffect); + }; -if (GETDUSTT(DACTIVE)) then { - SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2)); - call FUNC(applyDustEffect); + if (GETDUSTT(DACTIVE)) then { + SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2)); + call FUNC(applyDustEffect); + }; }; GVAR(EffectsActive) = true; diff --git a/addons/goggles/functions/fnc_externalCamera.sqf b/addons/goggles/functions/fnc_externalCamera.sqf index 06c6cec407..9e7eed3efe 100644 --- a/addons/goggles/functions/fnc_externalCamera.sqf +++ b/addons/goggles/functions/fnc_externalCamera.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" // Handle the ThreeDen Editor Camera -if ((!isNil {is3DEN}) && {is3DEN}) exitWith {true}; +if (is3DEN) exitWith {true}; if (GVAR(showInThirdPerson)) then { cameraView in ["GROUP"] || EFUNC(common,isFeatureCameraActive) diff --git a/addons/goggles/functions/fnc_handleKilled.sqf b/addons/goggles/functions/fnc_handleKilled.sqf index e8e207c478..b9af2e075b 100644 --- a/addons/goggles/functions/fnc_handleKilled.sqf +++ b/addons/goggles/functions/fnc_handleKilled.sqf @@ -15,20 +15,21 @@ params ["_unit"]; if (_unit != ACE_player) exitWith {true}; - -GVAR(PostProcessEyes) ppEffectEnable false; - -SETGLASSES(_unit,GLASSESDEFAULT); +if (GVAR(effects) == 0) exitWith {true}; call FUNC(removeGlassesEffect); -GVAR(EffectsActive) = false; +if (GVAR(effects) == 2) then { + GVAR(PostProcessEyes) ppEffectEnable false; -_unit setVariable ["ACE_EyesDamaged", false]; + SETGLASSES(_unit,GLASSESDEFAULT); -if (GVAR(DustHandler) != -1) then { - [GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler; + _unit setVariable ["ACE_EyesDamaged", false]; + + if (GVAR(DustHandler) != -1) then { + [GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler; + }; + GVAR(DustHandler) = -1; }; -GVAR(DustHandler) = -1; true diff --git a/addons/goggles/functions/fnc_removeGlassesEffect.sqf b/addons/goggles/functions/fnc_removeGlassesEffect.sqf index 658daf1d32..c27d8684e8 100644 --- a/addons/goggles/functions/fnc_removeGlassesEffect.sqf +++ b/addons/goggles/functions/fnc_removeGlassesEffect.sqf @@ -22,6 +22,8 @@ if (!isNull (GLASSDISPLAY)) then { GLASSDISPLAY closeDisplay 0; }; -call FUNC(removeDirtEffect); -call FUNC(removeRainEffect); -call FUNC(removeDustEffect); +if (GVAR(effects) == 2) then { + call FUNC(removeDirtEffect); + call FUNC(removeRainEffect); + call FUNC(removeDustEffect); +}; diff --git a/addons/goggles/stringtable.xml b/addons/goggles/stringtable.xml index ce337760d7..31dd10dbf1 100644 --- a/addons/goggles/stringtable.xml +++ b/addons/goggles/stringtable.xml @@ -25,5 +25,14 @@ Limpar Ă“culos Pulisci gli occhiali + + Goggle Effects + + + Tint + + + Tint + Effects + \ No newline at end of file