diff --git a/addons/nightvision/ACE_Settings.hpp b/addons/nightvision/ACE_Settings.hpp new file mode 100644 index 0000000000..d6d52bab10 --- /dev/null +++ b/addons/nightvision/ACE_Settings.hpp @@ -0,0 +1,8 @@ +class ACE_Settings { + class GVAR(disableNVGsWithSights) { + displayName = CSTRING(DisableNVGsWithSights_DisplayName); + description = CSTRING(DisableNVGsWithSights_description); + typeName = "BOOL"; + value = 1; + }; +}; diff --git a/addons/nightvision/CfgVehicles.hpp b/addons/nightvision/CfgVehicles.hpp index 84e7105f0b..8b489ad64f 100644 --- a/addons/nightvision/CfgVehicles.hpp +++ b/addons/nightvision/CfgVehicles.hpp @@ -14,4 +14,28 @@ class CfgVehicles { MACRO_ADDITEM(ACE_NVG_Wide,6); }; }; + + class ACE_Module; + class GVAR(ModuleSettings): ACE_Module { + scope = 2; + displayName = CSTRING(Module_DisplayName); + icon = QUOTE(PATHTOF(UI\Icon_Module_ca.paa)); + category = "ACE"; + function = QUOTE(FUNC(initModule)); + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + author = "BaerMitUmlaut"; + class Arguments { + class disableNVGsWithSights { + displayName = CSTRING(DisableNVGsWithSights_DisplayName); + description = CSTRING(DisableNVGsWithSights_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + }; + class ModuleDescription { + description = CSTRING(Module_Description); + }; + }; }; diff --git a/addons/nightvision/UI/Icon_Module_ca.paa b/addons/nightvision/UI/Icon_Module_ca.paa new file mode 100644 index 0000000000..556adaf30c Binary files /dev/null and b/addons/nightvision/UI/Icon_Module_ca.paa differ diff --git a/addons/nightvision/XEH_postInitClient.sqf b/addons/nightvision/XEH_postInitClient.sqf index 2839f6e5f9..e7c1ec9bc5 100644 --- a/addons/nightvision/XEH_postInitClient.sqf +++ b/addons/nightvision/XEH_postInitClient.sqf @@ -30,9 +30,15 @@ GVAR(ppEffectMuzzleFlash) ppEffectCommit 0; // Setup the event handlers ["playerInventoryChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); -["playerVisionModeChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); +["playerVisionModeChanged", { + _this call FUNC(updatePPEffects); + _this call FUNC(onVisionModeChanged); +}] call EFUNC(common,addEventHandler); ["zeusDisplayChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); -["cameraViewChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); +["cameraViewChanged", { + _this call FUNC(updatePPEffects); + _this call FUNC(onCameraViewChanged); +}] call EFUNC(common,addEventHandler); ["playerVehicleChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); ["playerTurretChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler); diff --git a/addons/nightvision/XEH_preInit.sqf b/addons/nightvision/XEH_preInit.sqf index 27f8ea7d48..ed02b9524e 100644 --- a/addons/nightvision/XEH_preInit.sqf +++ b/addons/nightvision/XEH_preInit.sqf @@ -4,6 +4,9 @@ ADDON = false; PREP(blending); PREP(changeNVGBrightness); +PREP(initModule); +PREP(onCameraViewChanged); +PREP(onVisionModeChanged); PREP(updatePPEffects); ADDON = true; diff --git a/addons/nightvision/config.cpp b/addons/nightvision/config.cpp index 4e6aa2e39a..1edeca6e5b 100644 --- a/addons/nightvision/config.cpp +++ b/addons/nightvision/config.cpp @@ -15,3 +15,4 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" +#include "ACE_Settings.hpp" diff --git a/addons/nightvision/functions/fnc_initModule.sqf b/addons/nightvision/functions/fnc_initModule.sqf new file mode 100644 index 0000000000..6831a29edf --- /dev/null +++ b/addons/nightvision/functions/fnc_initModule.sqf @@ -0,0 +1,21 @@ +/* + * Author: BaerMitUmlaut + * Initializes the settings for the disable NVGs in sight module. + * + * Arguments: + * 0: Module + * + * Return Value: + * None + * + * Example: + * [_module] call ace_nightvision_fnc_initModule + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_module"]; + +[_module, QGVAR(disableNVGsWithSights), "disableNVGsWithSights"] call EFUNC(common,readSettingFromModule); diff --git a/addons/nightvision/functions/fnc_onCameraViewChanged.sqf b/addons/nightvision/functions/fnc_onCameraViewChanged.sqf new file mode 100644 index 0000000000..5384d6924c --- /dev/null +++ b/addons/nightvision/functions/fnc_onCameraViewChanged.sqf @@ -0,0 +1,38 @@ +/* + * Author: BaerMitUmlaut + * Disables/re-enables NVGs when the player starts/stops aiming down his sight. + * + * Arguments: + * 0: Unit + * 1: New camera view + * + * Return Value: + * None + * + * Example: + * [player, "GUNNER"] call ace_nightvision_fnc_onCameraViewChanged + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_unit", "_cameraView"]; + +if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then { + if ((vehicle _unit == _unit) + || {isTurnedOut _unit} + || {!([_unit] call EFUNC(common,hasHatch)) + && {[_unit] call EFUNC(common,getTurretIndex) in ([vehicle _unit] call EFUNC(common,getTurretsFFV))} + }) then { + if ((_cameraView == "GUNNER") && {currentVisionMode _unit == 1}) then { + _unit action ["NVGogglesOff", _unit]; + _unit setVariable [QGVAR(reenableNVGs), true]; + } else { + if (_unit getVariable [QGVAR(reenableNVGs), false] && {_cameraView != "GUNNER"}) then { + _unit action ["NVGoggles", _unit]; + _unit setVariable [QGVAR(reenableNVGs), false]; + }; + }; + }; +}; diff --git a/addons/nightvision/functions/fnc_onVisionModeChanged.sqf b/addons/nightvision/functions/fnc_onVisionModeChanged.sqf new file mode 100644 index 0000000000..64f77a69bc --- /dev/null +++ b/addons/nightvision/functions/fnc_onVisionModeChanged.sqf @@ -0,0 +1,32 @@ +/* + * Author: BaerMitUmlaut + * Disables turning on NVGs while the player aims down his sight. + * + * Arguments: + * 0: Unit + * 1: New vision mode + * + * Return Value: + * None + * + * Example: + * [player, 1] call ace_nightvision_fnc_onVisionModeChanged + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_unit", "_visionMode"]; + +if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then { + if ((vehicle _unit == _unit) + || {isTurnedOut _unit} + || {!([_unit] call EFUNC(common,hasHatch)) + && {[_unit] call EFUNC(common,getTurretIndex) in ([vehicle _unit] call EFUNC(common,getTurretsFFV))} + }) then { + if ((cameraView == "GUNNER") && {_visionMode > 0}) then { + _unit action ["NVGogglesOff", _unit]; + }; + }; +}; diff --git a/addons/nightvision/stringtable.xml b/addons/nightvision/stringtable.xml index 050945d5d8..b6e35147f9 100644 --- a/addons/nightvision/stringtable.xml +++ b/addons/nightvision/stringtable.xml @@ -133,5 +133,21 @@ Diminuir Luminosidade do EVN Riduci la luminosità dell'NVG + + Nightvision + Nachtsicht + + + Settings for night vision. + Einstellungen für Nachtsichtgeräte. + + + Disable NVGs in scope + Deakt. NVGs mit Visier + + + Blocks the usage of night vision goggles whilst aiming down the sight. + Blockiert das Benutzen von Nachtsichtbrillen beim Benutzen des Visiers. + - \ No newline at end of file + diff --git a/extras/assets/icons/Icon_Module_png/Icon_Module_Nightvision_ca.png b/extras/assets/icons/Icon_Module_png/Icon_Module_Nightvision_ca.png new file mode 100644 index 0000000000..975a4126f3 Binary files /dev/null and b/extras/assets/icons/Icon_Module_png/Icon_Module_Nightvision_ca.png differ