diff --git a/addons/accessory/XEH_preInitClient.sqf b/addons/accessory/XEH_preInitClient.sqf index bc5436088..31b03fab4 100644 --- a/addons/accessory/XEH_preInitClient.sqf +++ b/addons/accessory/XEH_preInitClient.sqf @@ -2,7 +2,7 @@ #include "XEH_PREP.sqf" -["CBA Accessory Functions", "MRT_SwitchItemNextClass_R", [LSTRING(railNext), LSTRING(railNext_tooltip)], {[1, "next"] call FUNC(switchAttachment)}, {}, [38, [false, true, false]]] call CBA_fnc_addKeybind; //default ctrl + L -["CBA Accessory Functions", "MRT_SwitchItemPrevClass_R", [LSTRING(railPrev), LSTRING(railPrev_tooltip)], {[1, "prev"] call FUNC(switchAttachment)}, {}, [38, [true, false, false]]] call CBA_fnc_addKeybind; //default shift + L -["CBA Accessory Functions", "MRT_SwitchItemNextClass_O", [LSTRING(opticNext), LSTRING(opticNext_tooltip)], {[2, "next"] call FUNC(switchAttachment)}, {}, [181, [false, true, false]]] call CBA_fnc_addKeybind; //default ctlr + NUM-/ -["CBA Accessory Functions", "MRT_SwitchItemPrevClass_O", [LSTRING(opticPrev), LSTRING(opticPrev_tooltip)], {[2, "prev"] call FUNC(switchAttachment)}, {}, [181, [true, false, false]]] call CBA_fnc_addKeybind; //default shift + NUM-/ +[ELSTRING(common,WeaponsCategory), "MRT_SwitchItemNextClass_R", [LSTRING(railNext), LSTRING(railNext_tooltip)], {[1, "next"] call FUNC(switchAttachment)}, {}, [38, [false, true, false]]] call CBA_fnc_addKeybind; //default ctrl + L +[ELSTRING(common,WeaponsCategory), "MRT_SwitchItemPrevClass_R", [LSTRING(railPrev), LSTRING(railPrev_tooltip)], {[1, "prev"] call FUNC(switchAttachment)}, {}, [38, [true, false, false]]] call CBA_fnc_addKeybind; //default shift + L +[ELSTRING(common,WeaponsCategory), "MRT_SwitchItemNextClass_O", [LSTRING(opticNext), LSTRING(opticNext_tooltip)], {[2, "next"] call FUNC(switchAttachment)}, {}, [181, [false, true, false]]] call CBA_fnc_addKeybind; //default ctlr + NUM-/ +[ELSTRING(common,WeaponsCategory), "MRT_SwitchItemPrevClass_O", [LSTRING(opticPrev), LSTRING(opticPrev_tooltip)], {[2, "prev"] call FUNC(switchAttachment)}, {}, [181, [true, false, false]]] call CBA_fnc_addKeybind; //default shift + NUM-/ 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 5f67d1e6a..a6478bfbf 100644 --- a/addons/optics/XEH_preInit.sqf +++ b/addons/optics/XEH_preInit.sqf @@ -12,6 +12,8 @@ if (configProperties [configFile >> "CBA_PIPItems"] isEqualTo [] && { if (!hasInterface) exitWith {}; +#include "initKeybinds.sqf" + QGVAR(pauseOpticLayer) cutText ["", "PLAIN"]; GVAR(camera) = objNull; @@ -28,6 +30,10 @@ GVAR(OpticReticleDetailTextures) = []; GVAR(OpticBodyTexture) = ""; 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 1e459b011..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; @@ -89,6 +90,12 @@ _ctrlMagnification ctrlCommit 0; private _dayOpacity = AMBIENT_BRIGHTNESS; private _nightOpacity = [1,0] select (_dayOpacity == 1); +private _useReticleNight = GVAR(useReticleNight); + +if (!GVAR(manualReticleNightSwitch)) then { + _useReticleNight = _dayOpacity < 0.5; +}; + // Apply lighting and make layers visible. private _texture = ""; private _detailScaleFactor = 1; @@ -97,7 +104,7 @@ private _detailScaleFactor = 1; _x params ["_zoomX", "_textureX", "_detailScaleFactorX", "_textureXNight"]; if (_zoom > _zoomX) then { - _texture = [_textureX, _textureXNight] select (_dayOpacity < 0.5); + _texture = [_textureX, _textureXNight] select _useReticleNight; _detailScaleFactor = _detailScaleFactorX; }; } forEach GVAR(OpticReticleDetailTextures); @@ -118,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 089065585..b09aaf954 100644 --- a/addons/optics/fnc_updateOpticInfo.sqf +++ b/addons/optics/fnc_updateOpticInfo.sqf @@ -73,6 +73,16 @@ if (GVAR(OpticBodyTextureNight) isEqualTo "") then { GVAR(OpticBodyTextureNight) = GVAR(OpticBodyTexture); }; +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/initKeybinds.sqf b/addons/optics/initKeybinds.sqf new file mode 100644 index 000000000..94d58581d --- /dev/null +++ b/addons/optics/initKeybinds.sqf @@ -0,0 +1,27 @@ +[ + ELSTRING(common,WeaponsCategory), + QGVAR(ManualReticleNightSwitch), + [LSTRING(manual_reticle_switch), LSTRING(manual_reticle_switch_tooltip)], + { + if (GVAR(manualReticleNightSwitch)) then { + GVAR(useReticleNight) = !GVAR(useReticleNight); + + // play sound + private _unit = call CBA_fnc_currentUnit; + private _position = _unit modelToWorldVisualWorld (_unit selectionPosition "RightHand"); + + SOUND_RETICLE_SWITCH params ["_filename", ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]]; + + // add file extension .wss as default + if !(toLower (_filename select [count _filename - 4]) in [".wav", ".ogg", ".wss"]) then { + _filename = format ["%1.wss", _filename]; + }; + + playSound3D [_filename, objNull, false, _position, _volume, _soundPitch, _distance]; + + true + } else {false}; + }, + {}, + [DIK_NUMPAD0, [false, false, false]] +] call CBA_fnc_addKeybind; diff --git a/addons/optics/script_component.hpp b/addons/optics/script_component.hpp index 2a3b1a1d4..fb0d12c64 100644 --- a/addons/optics/script_component.hpp +++ b/addons/optics/script_component.hpp @@ -17,10 +17,15 @@ #define DEBUG_SYNCHRONOUS #include "\x\cba\addons\main\script_macros.hpp" +#include "\a3\ui_f\hpp\defineDIKCodes.inc" + #define PARSE(value) (call compile format ["%1", value]) #define AMBIENT_BRIGHTNESS (sunOrMoon * sunOrMoon * (1 - overcast * 0.25) + moonIntensity / 5 * (1 - overcast) min 1) // idea by Falke #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 #define IDC_BODY 4001 @@ -40,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 diff --git a/addons/optics/stringtable.xml b/addons/optics/stringtable.xml index 31cd69d26..d70a5b914 100644 --- a/addons/optics/stringtable.xml +++ b/addons/optics/stringtable.xml @@ -15,5 +15,13 @@ Używaj optyki typu Obraz w obrazie (PIP) Usa ottiche on Picture-in-Picture + + Toggle Reticle + Absehen umschalten + + + Manually switch the reticle of the optic. + Absehen der Optik manuell umschalten. +