From a89b691ee65d2044579cb2c7ac5651d6a7b3713d Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 6 Jul 2019 13:08:18 +0200 Subject: [PATCH] Scripted optics updates (#1176) * add hideMagnification parameter for scripted optics * add disableTilt parameter for scripted optics * fix pip not updated when changing optics * disable debug --- addons/optics/XEH_preInit.sqf | 3 +++ addons/optics/fnc_animateScriptedOptic.sqf | 10 ++++++++-- addons/optics/fnc_updateOpticInfo.sqf | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/addons/optics/XEH_preInit.sqf b/addons/optics/XEH_preInit.sqf index a6478bfbf..a1f2188bb 100644 --- a/addons/optics/XEH_preInit.sqf +++ b/addons/optics/XEH_preInit.sqf @@ -34,6 +34,8 @@ GVAR(manualReticleNightSwitch) = false; GVAR(useReticleNight) = false; GVAR(reticleSafezoneSize) = RETICLE_SAFEZONE_DEFAULT_SIZE; GVAR(hidePeripheralVision) = false; +GVAR(hideMagnification) = false; +GVAR(disableTilt) = false; // Update optic info. ["weapon", { @@ -44,6 +46,7 @@ GVAR(hidePeripheralVision) = false; ["loadout", { params ["_unit"]; _unit call FUNC(updateOpticInfo); + _unit call FUNC(changePIPOpticClass); _unit call FUNC(changeCarryHandleOpticClass); }] call CBA_fnc_addPlayerEventHandler; diff --git a/addons/optics/fnc_animateScriptedOptic.sqf b/addons/optics/fnc_animateScriptedOptic.sqf index 30ad84ac5..b21e512d0 100644 --- a/addons/optics/fnc_animateScriptedOptic.sqf +++ b/addons/optics/fnc_animateScriptedOptic.sqf @@ -78,7 +78,7 @@ _ctrlMagnification ctrlSetText format [ [_zoom, 1, 1] call CBA_fnc_formatNumber ]; -_ctrlMagnification ctrlShow (_zoom >= 1); +_ctrlMagnification ctrlShow (_zoom >= 1 && {!GVAR(hideMagnification)}); private _positionMagnification = ctrlPosition _ctrlZeroing; _positionMagnification set [0, _positionMagnification#0 + ctrlTextWidth _ctrlZeroing]; @@ -116,7 +116,13 @@ _ctrlBody ctrlSetTextColor [1,1,1,_dayOpacity]; _ctrlBodyNight ctrlSetTextColor [1,1,1,_nightOpacity]; _ctrlBlackScope ctrlShow (GVAR(usePipOptics) && !isPipEnabled); -private _bank = call FUNC(gunBank); +// tilt while leaning +private _bank = 0; + +if (!GVAR(disableTilt)) then { + _bank = call FUNC(gunBank); +}; + _ctrlReticle ctrlSetAngle [_bank, 0.5, 0.5]; _ctrlBody ctrlSetAngle [_bank, 0.5, 0.5]; _ctrlBodyNight ctrlSetAngle [_bank, 0.5, 0.5]; diff --git a/addons/optics/fnc_updateOpticInfo.sqf b/addons/optics/fnc_updateOpticInfo.sqf index da8db29a3..d6ba36a55 100644 --- a/addons/optics/fnc_updateOpticInfo.sqf +++ b/addons/optics/fnc_updateOpticInfo.sqf @@ -111,6 +111,9 @@ GVAR(ppEffects) = getArray (_config >> "opticsPPEffects") apply { _ppEffect }; +GVAR(hideMagnification) = getNumber (_config >> "hideMagnification") != 0; +GVAR(disableTilt) = getNumber (_config >> "disableTilt") != 0; + [uiNamespace getVariable QGVAR(ScriptedOpticDisplay), false] call FUNC(loadScriptedOptic); //INFO_1("Updated optic info %1.",_optic);