Add brightness control when NV effects disabled (#5913)

* Add brightness control when NV effects disabled

* Add initial ajust and commit. Add comment to math

* Fix math comment

* Change initial level to -3
This commit is contained in:
Dystopian 2017-12-17 22:09:41 +03:00 committed by PabstMirror
parent af09fc652a
commit 1385f12542
3 changed files with 23 additions and 4 deletions

View File

@ -26,11 +26,17 @@ GVAR(ppEffectCCMuzzleFlash) = -1;
["ace_settingsInitialized", {
TRACE_3("settingsInitialized",GVAR(disableNVGsWithSights),GVAR(fogScaling),GVAR(effectScaling));
// Disable ALL effects if ace_nightvision_effectScaling is zero
if (GVAR(effectScaling) == 0) exitWith {};
["visionMode", LINKFUNC(onVisionModeChanged), false] call CBA_fnc_addPlayerEventHandler;
// handle only brightness if effects are disabled
if (GVAR(effectScaling) == 0) exitWith {
GVAR(ppEffectNVGBrightness) = ppEffectCreate ["ColorCorrections", 1236];
GVAR(ppEffectNVGBrightness) ppEffectForceInNVG true;
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, (-3+3)/5 + 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
};
["loadout", LINKFUNC(onLoadoutChanged), true] call CBA_fnc_addPlayerEventHandler;
["visionMode", LINKFUNC(onVisionModeChanged), false] call CBA_fnc_addPlayerEventHandler;
["cameraView", LINKFUNC(onCameraViewChanged), true] call CBA_fnc_addPlayerEventHandler;
["vehicle", LINKFUNC(refreshGoggleType), false] call CBA_fnc_addPlayerEventHandler;
["turret", LINKFUNC(refreshGoggleType), true] call CBA_fnc_addPlayerEventHandler;

View File

@ -19,7 +19,8 @@
params ["_player", "_changeInBrightness"];
TRACE_2("changeNVGBrightness",_player,_changeInBrightness);
private _brightness = _player getVariable [QGVAR(NVGBrightness), 0];
private _areEffectsDisabled = GVAR(effectScaling) == 0;
private _brightness = _player getVariable [QGVAR(NVGBrightness), [0, -3] select _areEffectsDisabled];
_brightness = ((_brightness + _changeInBrightness) min 0) max -6;
@ -28,5 +29,12 @@ _player setVariable [QGVAR(NVGBrightness), _brightness, false];
[format [(localize LSTRING(NVGBrightness)), _brightness]] call EFUNC(common,displayTextStructured);
playSound "ACE_Sound_Click";
// handle only brightness if effects are disabled
if (_areEffectsDisabled) exitWith {
// here we take (-6; 0) _brightness range and alter it to (0.4; 1.6)
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, (_brightness+3)/5 + 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
};
// Trigger full ppEffects update next time run in the PFEH:
GVAR(nextEffectsUpdate) = -1;

View File

@ -19,6 +19,11 @@
params ["_unit", "_visionMode"];
TRACE_2("onVisionModeChanged",_unit,_visionMode);
// handle only brightness if effects are disabled
if (GVAR(effectScaling) == 0) exitWith {
GVAR(ppEffectNVGBrightness) ppEffectEnable (_visionMode == 1);
};
// Start PFEH when entering night vision mode:
if (_visionMode == 1) then {
if (GVAR(PFID) == -1) then {