diff --git a/addons/optics/RscInGameUI.hpp b/addons/optics/RscInGameUI.hpp index 54ed3bcd2..f173cf52b 100644 --- a/addons/optics/RscInGameUI.hpp +++ b/addons/optics/RscInGameUI.hpp @@ -49,16 +49,16 @@ class RscInGameUI { // It will ONLY effect tripple head users, as (safeZoneX == safeZoneXAbs) for everyone else. class TrippleHeadLeft: RscText { idc = IDC_BLACK_LEFT; - x = "safeZoneXAbs"; - y = "safeZoneY"; - w = "(safeZoneX - safeZoneXAbs) * ((getResolution select 4)/(16/3))"; - h = "safeZoneH"; + x = safezoneXAbs; + y = safezoneY; + w = THIRD_SCREEN_WIDTH; + h = safezoneH; colorBackground[] = {0,0,0,1}; }; class TrippleHeadRight: TrippleHeadLeft { idc = IDC_BLACK_RIGHT; - x = "safeZoneXAbs + safeZoneWAbs - (safeZoneX - safeZoneXAbs) * ((getResolution select 4)/(16/3))"; + x = safezoneXAbs + safezoneWAbs - THIRD_SCREEN_WIDTH; }; class Magnification: CA_Zeroing { @@ -87,10 +87,10 @@ class RscInGameUI { class ReticleSafeZone: RscControlsGroupNoScrollbars { idc = IDC_RETICLE_SAFEZONE; - x = RETICLE_SAFEZONE_LEFT; - y = RETICLE_SAFEZONE_TOP; - w = RETICLE_SAFEZONE_WIDTH; - h = RETICLE_SAFEZONE_HEIGHT; + x = RETICLE_SAFEZONE_DEFAULT_LEFT; + y = RETICLE_SAFEZONE_DEFAULT_TOP; + w = RETICLE_SAFEZONE_DEFAULT_WIDTH; + h = RETICLE_SAFEZONE_DEFAULT_HEIGHT; class controls { class Reticle: Reticle {}; diff --git a/addons/optics/XEH_preInit.sqf b/addons/optics/XEH_preInit.sqf index 39b7a445e..a6478bfbf 100644 --- a/addons/optics/XEH_preInit.sqf +++ b/addons/optics/XEH_preInit.sqf @@ -32,6 +32,8 @@ GVAR(OpticBodyTextureNight) = ""; GVAR(ppEffects) = []; GVAR(manualReticleNightSwitch) = false; GVAR(useReticleNight) = false; +GVAR(reticleSafezoneSize) = RETICLE_SAFEZONE_DEFAULT_SIZE; +GVAR(hidePeripheralVision) = false; // Update optic info. ["weapon", { diff --git a/addons/optics/fnc_animateScriptedOptic.sqf b/addons/optics/fnc_animateScriptedOptic.sqf index d8784bcb7..3d07a3957 100644 --- a/addons/optics/fnc_animateScriptedOptic.sqf +++ b/addons/optics/fnc_animateScriptedOptic.sqf @@ -31,6 +31,7 @@ private _ctrlBodyNight = _display displayCtrl IDC_BODY_NIGHT; private _ctrlBlackScope = _display displayCtrl IDC_BLACK_SCOPE; private _ctrlBlackLeft = _display displayCtrl IDC_BLACK_LEFT; private _ctrlBlackRight = _display displayCtrl IDC_BLACK_RIGHT; +private _ctrlReticleSafezone = _display displayCtrl IDC_RETICLE_SAFEZONE; private _ctrlZeroing = _display displayCtrl 168; private _ctrlMagnification = _display displayCtrl IDC_MAGNIFICATION; @@ -124,12 +125,12 @@ if (_zoom >= 1) then { GVAR(ReticleAdjust) set [2, _zoom]; private _reticleAdjust = linearConversion GVAR(ReticleAdjust); - private _sizeReticle = _reticleAdjust * _detailScaleFactor; +ctrlPosition _ctrlReticleSafezone params ["_reticleSafeZonePositionLeft", "_reticleSafeZonePositionTop"]; private _positionReticle = [ - POS_X(_sizeReticle) - RETICLE_SAFEZONE_LEFT, - POS_Y(_sizeReticle) - RETICLE_SAFEZONE_TOP, + POS_X(_sizeReticle) - _reticleSafeZonePositionLeft, + POS_Y(_sizeReticle) - _reticleSafeZonePositionTop, POS_W(_sizeReticle), POS_H(_sizeReticle) ]; diff --git a/addons/optics/fnc_animateScriptedOpticRecoil.sqf b/addons/optics/fnc_animateScriptedOpticRecoil.sqf index fbf04f549..32c5c93d1 100644 --- a/addons/optics/fnc_animateScriptedOpticRecoil.sqf +++ b/addons/optics/fnc_animateScriptedOpticRecoil.sqf @@ -34,6 +34,7 @@ private _ctrlBodyNight = _display displayCtrl IDC_BODY_NIGHT; private _ctrlBlackScope = _display displayCtrl IDC_BLACK_SCOPE; private _ctrlBlackLeft = _display displayCtrl IDC_BLACK_LEFT; private _ctrlBlackRight = _display displayCtrl IDC_BLACK_RIGHT; +private _ctrlReticleSafezone = _display displayCtrl IDC_RETICLE_SAFEZONE; // Reduce the reticle movement as the player drops into lower, supported stances. private _recoilCoef = SCOPE_RECOIL_COEF; @@ -60,21 +61,18 @@ private _sizeBody = GVAR(OpticBodyTextureSize); // Create and commit recoil effect. private _reticleAdjust = 1; -private _reticleSafeZoneOffsetLeft = 0; -private _reticleSafeZoneOffsetTop = 0; +ctrlPosition _ctrlReticleSafezone params ["_reticleSafeZonePositionLeft", "_reticleSafeZonePositionTop"]; -if (!isNull (_display displayCtrl IDC_RETICLE_SAFEZONE)) then { +if (!isNull _ctrlReticleSafezone) then { _reticleAdjust = linearConversion GVAR(ReticleAdjust); - _reticleSafeZoneOffsetLeft = - RETICLE_SAFEZONE_LEFT; - _reticleSafeZoneOffsetTop = - RETICLE_SAFEZONE_TOP; }; private _detailScaleFactor = _display getVariable [QGVAR(DetailScaleFactor), 1]; private _size = _reticleAdjust * _detailScaleFactor + _recoilScope; private _positionReticle = [ - POS_X(_size + _reticleShiftX) + _reticleSafeZoneOffsetLeft, - POS_Y(_size + _reticleShiftY) + _reticleSafeZoneOffsetTop, + POS_X(_size + _reticleShiftX) - _reticleSafeZonePositionLeft, + POS_Y(_size + _reticleShiftY) - _reticleSafeZonePositionTop, POS_W(_size), POS_H(_size) ]; @@ -101,8 +99,8 @@ _ctrlBodyNight ctrlCommit 0; private _sizeReticle = _reticleAdjust * _detailScaleFactor; _positionReticle = [ - POS_X(_sizeReticle) + _reticleSafeZoneOffsetLeft, - POS_Y(_sizeReticle) + _reticleSafeZoneOffsetTop, + POS_X(_sizeReticle) - _reticleSafeZonePositionLeft, + POS_Y(_sizeReticle) - _reticleSafeZonePositionTop, POS_W(_sizeReticle), POS_H(_sizeReticle) ]; diff --git a/addons/optics/fnc_loadScriptedOptic.sqf b/addons/optics/fnc_loadScriptedOptic.sqf index e45834840..d1a982ec5 100644 --- a/addons/optics/fnc_loadScriptedOptic.sqf +++ b/addons/optics/fnc_loadScriptedOptic.sqf @@ -7,6 +7,7 @@ Description: Parameters: _display - CBA weapon info display + _init - Begin draw script, true when called from onLoad event Returns: Nothing. @@ -20,9 +21,9 @@ Author: commy2 ---------------------------------------------------------------------------- */ -params [["_display", displayNull], ["_initDisplay", false]]; +params [["_display", displayNull], ["_init", false]]; -if (_initDisplay) then { +if (_init) then { private _unit = call CBA_fnc_currentUnit; _unit call FUNC(updateOpticInfo); @@ -35,6 +36,7 @@ private _ctrlBodyNight = _display displayCtrl IDC_BODY_NIGHT; private _ctrlBlackScope = _display displayCtrl IDC_BLACK_SCOPE; private _ctrlBlackLeft = _display displayCtrl IDC_BLACK_LEFT; private _ctrlBlackRight = _display displayCtrl IDC_BLACK_RIGHT; +private _ctrlReticleSafezone = _display displayCtrl IDC_RETICLE_SAFEZONE; private _ctrlMagnification = _display displayCtrl IDC_MAGNIFICATION; _ctrlRedDot ctrlShow false; @@ -72,7 +74,28 @@ _ctrlBodyNight ctrlSetText GVAR(OpticBodyTextureNight); _ctrlBodyNight ctrlSetPosition _bodyPosition; _ctrlBodyNight ctrlCommit 0; -if (_initDisplay) then { +_ctrlReticleSafezone ctrlSetPosition [ + POS_X(GVAR(reticleSafezoneSize)), + POS_Y(GVAR(reticleSafezoneSize)), + POS_W(GVAR(reticleSafezoneSize)), + POS_H(GVAR(reticleSafezoneSize)) +]; +_ctrlReticleSafezone ctrlCommit 0; + +private _width = THIRD_SCREEN_WIDTH; + +if (GVAR(hidePeripheralVision)) then { + _width = 0.5 - (_bodyPosition select 2)/2 - safezoneXAbs; +}; + +_ctrlBlackLeft ctrlSetPositionW _width; +_ctrlBlackLeft ctrlCommit 0; + +_ctrlBlackRight ctrlSetPositionW _width; +_ctrlBlackRight ctrlSetPositionX (safezoneXAbs + safezoneWAbs - _width); +_ctrlBlackRight ctrlCommit 0; + +if (_init) then { [missionNamespace, "Draw3D", { if (isNull _thisArgs) exitWith { removeMissionEventHandler ["Draw3D", _thisId]; diff --git a/addons/optics/fnc_updateOpticInfo.sqf b/addons/optics/fnc_updateOpticInfo.sqf index 1733173f6..b09aaf954 100644 --- a/addons/optics/fnc_updateOpticInfo.sqf +++ b/addons/optics/fnc_updateOpticInfo.sqf @@ -75,6 +75,14 @@ if (GVAR(OpticBodyTextureNight) isEqualTo "") then { GVAR(manualReticleNightSwitch) = getNumber (_config >> "manualReticleNightSwitch") != 0; +GVAR(reticleSafezoneSize) = RETICLE_SAFEZONE_DEFAULT_SIZE; + +if (isNumber (_config >> "reticleSafezoneSize")) then { + GVAR(reticleSafezoneSize) = getNumber (_config >> "reticleSafezoneSize"); +}; + +GVAR(hidePeripheralVision) = getNumber (_config >> "hidePeripheralVision") != 0; + // zeroing distances configProperties [configFile >> "CfgWeapons" >> _optic >> "ItemInfo" >> "OpticsModes"] findIf { GVAR(ZeroingDistances) = getArray (_x >> "discreteDistance"); diff --git a/addons/optics/script_component.hpp b/addons/optics/script_component.hpp index 15a5dd28e..fb0d12c64 100644 --- a/addons/optics/script_component.hpp +++ b/addons/optics/script_component.hpp @@ -24,6 +24,7 @@ #define WEAPON_MAGAZINES(unit,weapon) (weaponsItems (unit) select {_x select 0 == (weapon)} param [0, []] select {_x isEqualType []}) #define SOUND_RETICLE_SWITCH ["A3\Sounds_F\arsenal\weapons\UGL\Firemode_ugl",0.31622776,1,5] +#define THIRD_SCREEN_WIDTH ((safezoneX - safezoneXAbs) * ((getResolution select 4)/(16/3))) // control ids #define IDC_RETICLE 4000 @@ -44,11 +45,11 @@ #define POS_X(size) (0.5 - 0.5 * POS_W(size)) #define POS_Y(size) (0.5 - 0.5 * POS_H(size)) -#define RETICLE_SAFEZONE_SIZE 0.84 -#define RETICLE_SAFEZONE_WIDTH POS_W(RETICLE_SAFEZONE_SIZE) -#define RETICLE_SAFEZONE_HEIGHT POS_H(RETICLE_SAFEZONE_SIZE) -#define RETICLE_SAFEZONE_LEFT POS_X(RETICLE_SAFEZONE_SIZE) -#define RETICLE_SAFEZONE_TOP POS_Y(RETICLE_SAFEZONE_SIZE) +#define RETICLE_SAFEZONE_DEFAULT_SIZE 0.84 +#define RETICLE_SAFEZONE_DEFAULT_WIDTH POS_W(RETICLE_SAFEZONE_DEFAULT_SIZE) +#define RETICLE_SAFEZONE_DEFAULT_HEIGHT POS_H(RETICLE_SAFEZONE_DEFAULT_SIZE) +#define RETICLE_SAFEZONE_DEFAULT_LEFT POS_X(RETICLE_SAFEZONE_DEFAULT_SIZE) +#define RETICLE_SAFEZONE_DEFAULT_TOP POS_Y(RETICLE_SAFEZONE_DEFAULT_SIZE) // scope animation config #define SCOPE_RECOIL_COEF 1