From 319596ddcbf5f1c8087f41ef3c06900995af831a Mon Sep 17 00:00:00 2001 From: Andreas G <13819164+agaertner@users.noreply.github.com> Date: Wed, 10 Apr 2024 02:22:48 +0200 Subject: [PATCH 1/2] feat: mute when game is muted --- .../GameIntegration/AudioIntegration.cs | 24 +++++++++++++------ .../GameServices/OverlayService.Designer.cs | 18 ++++++++++++++ .../GameServices/OverlayService.de.resx | 6 +++++ .../GameServices/OverlayService.fr.resx | 6 +++++ .../Strings/GameServices/OverlayService.resx | 9 ++++--- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/Blish HUD/GameServices/GameIntegration/AudioIntegration.cs b/Blish HUD/GameServices/GameIntegration/AudioIntegration.cs index 9e021852f..771f1bf92 100644 --- a/Blish HUD/GameServices/GameIntegration/AudioIntegration.cs +++ b/Blish HUD/GameServices/GameIntegration/AudioIntegration.cs @@ -21,6 +21,7 @@ public enum Devices { private const string APPLICATION_SETTINGS = "OverlayConfiguration"; private const string USEGAMEVOLUME_SETTINGS = "GameVolume"; + private const string MUTEIFNOGAMEAUDIO_SETTINGS = "MuteIfNoGameAudio"; private const string VOLUME_SETTINGS = "Volume"; private const string DEVICE_SETTINGS = "OutputDevice"; private const int CHECK_INTERVAL = 250; @@ -32,8 +33,9 @@ public enum Devices { private SettingEntry _useGameVolume; private SettingEntry _deviceSetting; private SettingEntry _volumeSetting; + private SettingEntry _muteIfNoGameAudio; - private readonly AudioEndpointNotificationReceiver _audioEndpointNotificationReceiver; + private readonly AudioEndpointNotificationReceiver _audioEndpointNotificationReceiver; private readonly List<(MMDevice AudioDevice, AudioMeterInformation MeterInformation)> _gw2AudioDevices = new List<(MMDevice AudioDevice, AudioMeterInformation MeterInformation)>(); private double _timeSinceCheck = 0; @@ -62,8 +64,16 @@ internal AudioIntegration(GameIntegrationService service) : base(service) { public override void Load() { var audioSettings = GameService.Settings.RegisterRootSettingCollection(APPLICATION_SETTINGS); - _useGameVolume = audioSettings.DefineSetting(USEGAMEVOLUME_SETTINGS, true, () => Strings.GameServices.OverlayService.Setting_UseGameVolume_DisplayName, () => Strings.GameServices.OverlayService.Setting_UseGameVolume_Description); - _volumeSetting = audioSettings.DefineSetting(VOLUME_SETTINGS, MAX_VOLUME / 2, () => Strings.GameServices.OverlayService.Setting_Volume_DisplayName, () => Strings.GameServices.OverlayService.Setting_Volume_Description); + _useGameVolume = audioSettings.DefineSetting(USEGAMEVOLUME_SETTINGS, true, + () => Strings.GameServices.OverlayService.Setting_UseGameVolume_DisplayName, + () => Strings.GameServices.OverlayService.Setting_UseGameVolume_Description); + _volumeSetting = audioSettings.DefineSetting(VOLUME_SETTINGS, MAX_VOLUME / 2, + () => Strings.GameServices.OverlayService.Setting_Volume_DisplayName, + () => Strings.GameServices.OverlayService.Setting_Volume_Description); + _muteIfNoGameAudio = audioSettings.DefineSetting(MUTEIFNOGAMEAUDIO_SETTINGS, true, + () => Strings.GameServices.OverlayService.Setting_MuteIfNoGameAudio_DisplayName, + () => Strings.GameServices.OverlayService.Setting_MuteIfNoGameAudio_Description); + _volumeSetting.SetRange(0.0f, MAX_VOLUME); _deviceSetting = audioSettings.DefineSetting(DEVICE_SETTINGS, Devices.Gw2OutputDevice, () => Strings.GameServices.OverlayService.Setting_AudioDevice_DisplayName, () => Strings.GameServices.OverlayService.Setting_AudioDevice_Description + " (This setting is temporarily disabled in this version)"); @@ -124,11 +134,11 @@ public override void Update(GameTime gameTime) { } private float GetVolume() { - if (_useGameVolume.Value) { - return CalculateAverageVolume(); + float gameVol = CalculateAverageVolume(); + if (_muteIfNoGameAudio.Value && gameVol < 0.0001f) { + return 0; } - - return _volumeSetting.Value; + return _useGameVolume.Value ? gameVol : _volumeSetting.Value; } private float CalculateAverageVolume() { diff --git a/Blish HUD/Strings/GameServices/OverlayService.Designer.cs b/Blish HUD/Strings/GameServices/OverlayService.Designer.cs index 879e91ae6..f48f7224e 100644 --- a/Blish HUD/Strings/GameServices/OverlayService.Designer.cs +++ b/Blish HUD/Strings/GameServices/OverlayService.Designer.cs @@ -521,6 +521,24 @@ internal static string Setting_InteractKey_DisplayName { } } + /// + /// Looks up a localized string similar to When enabled, Blish HUD will mute itself when the game does not emit any sound either.. + /// + internal static string Setting_MuteIfNoGameAudio_Description { + get { + return ResourceManager.GetString("Setting_MuteIfNoGameAudio_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mute when Game is muted.. + /// + internal static string Setting_MuteIfNoGameAudio_DisplayName { + get { + return ResourceManager.GetString("Setting_MuteIfNoGameAudio_DisplayName", resourceCulture); + } + } + /// /// Looks up a localized string similar to When enabled, Blish HUD will be shown in the taskbar while running.. /// diff --git a/Blish HUD/Strings/GameServices/OverlayService.de.resx b/Blish HUD/Strings/GameServices/OverlayService.de.resx index 169c41702..a4afb33a4 100644 --- a/Blish HUD/Strings/GameServices/OverlayService.de.resx +++ b/Blish HUD/Strings/GameServices/OverlayService.de.resx @@ -262,4 +262,10 @@ Für die beste Erfahrung auf die selbe Taste wie im Spiel setzen. Neue Beta-Version verfügbar + + Wenn aktiviert, schaltet Blish HUD die Lautstärke stumm, wenn das Spiel ebenfalls keinen Ton ausgibt. + + + Stummschalten, wenn Guild Wars 2 stummgeschaltet wird. + \ No newline at end of file diff --git a/Blish HUD/Strings/GameServices/OverlayService.fr.resx b/Blish HUD/Strings/GameServices/OverlayService.fr.resx index c1913f70d..a38a0de9f 100644 --- a/Blish HUD/Strings/GameServices/OverlayService.fr.resx +++ b/Blish HUD/Strings/GameServices/OverlayService.fr.resx @@ -260,4 +260,10 @@ Guild Wars 2 et Blish HUD. Nouvelle version bêta disponible + + + + + + \ No newline at end of file diff --git a/Blish HUD/Strings/GameServices/OverlayService.resx b/Blish HUD/Strings/GameServices/OverlayService.resx index cb2d4fee5..6e1c9a263 100644 --- a/Blish HUD/Strings/GameServices/OverlayService.resx +++ b/Blish HUD/Strings/GameServices/OverlayService.resx @@ -302,16 +302,13 @@ WARNING: Prerelease modules or Blish HUD versions may be unstable. By enabling The majority of Blish HUD's feedback, development, and other discussions take place in our - Discord - channel. - @@ -324,4 +321,10 @@ participate in the conversation? New Prerelease Available + + When enabled, Blish HUD will mute itself when the game does not emit any sound either. + + + Mute when Game is muted. + \ No newline at end of file From ae771908972e4c9e35fb8526ea5a60e539164aec Mon Sep 17 00:00:00 2001 From: Andreas G <13819164+agaertner@users.noreply.github.com> Date: Wed, 10 Apr 2024 02:29:24 +0200 Subject: [PATCH 2/2] feat(fr): add French translation --- Blish HUD/Strings/GameServices/OverlayService.fr.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Blish HUD/Strings/GameServices/OverlayService.fr.resx b/Blish HUD/Strings/GameServices/OverlayService.fr.resx index a38a0de9f..1aa50b481 100644 --- a/Blish HUD/Strings/GameServices/OverlayService.fr.resx +++ b/Blish HUD/Strings/GameServices/OverlayService.fr.resx @@ -261,9 +261,9 @@ Guild Wars 2 et Blish HUD. Nouvelle version bêta disponible - + Lorsque cette option est activée, Blish HUD se met en sourdine lorsque le jeu n'émet aucun son. - + Mute lorsque le jeu est en sourdine. \ No newline at end of file