Skip to content

Commit

Permalink
Merge pull request #1583 from johnb432/scripted-scope-1x-flickering-fix
Browse files Browse the repository at this point in the history
Optics - Fixed magnification text flickering at 1.0x zoom level
  • Loading branch information
PabstMirror committed Aug 29, 2023
2 parents 3b2b8a6 + 669eddd commit 6ce801b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions addons/optics/fnc_animateScriptedOptic.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ if (cameraView == "GUNNER") then {
// Add magnification to zeroing control.
private _zoom = 0.25 call CBA_fnc_getFov select 1;

// To avoid flickering of the magnification text, cache magnification and only modify magnification if change is big enough
if (abs (GVAR(magnificationCache) - _zoom) <= 0.005) then {
_zoom = GVAR(magnificationCache);
} else {
if (_zoom >= 1) then {
GVAR(magnificationCache) = _zoom;
};
};

_ctrlMagnification ctrlSetText format [
"(%1x)",
[_zoom, 1, 1] call CBA_fnc_formatNumber
Expand Down Expand Up @@ -130,10 +139,6 @@ _ctrlBodyNight ctrlSetAngle [_bank, 0.5, 0.5];
// zooming reticle
if (isNull (_display displayCtrl IDC_ENABLE_ZOOM)) exitWith {};

if (_zoom >= 1) then {
GVAR(magnificationCache) = _zoom;
};

GVAR(ReticleAdjust) set [2, _zoom];
private _reticleAdjust = linearConversion GVAR(ReticleAdjust);
private _sizeReticle = _reticleAdjust * _detailScaleFactor;
Expand Down

0 comments on commit 6ce801b

Please sign in to comment.