From ad8d5b9b5622f331db0e0e2a7f5ba715b2aa8302 Mon Sep 17 00:00:00 2001 From: rmg-x Date: Mon, 11 Dec 2023 20:26:11 +0000 Subject: [PATCH] Ava UI: Fix temporary volume not being set after unmute (#5833) --- src/Ryujinx.Ava/AppHost.cs | 3 ++- src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs | 12 ++++++++++++ src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Ava/AppHost.cs b/src/Ryujinx.Ava/AppHost.cs index dac4a3c5..2fd9ce00 100644 --- a/src/Ryujinx.Ava/AppHost.cs +++ b/src/Ryujinx.Ava/AppHost.cs @@ -1088,10 +1088,11 @@ namespace Ryujinx.Ava case KeyboardHotkeyState.ToggleMute: if (Device.IsAudioMuted()) { - Device.SetVolume(ConfigurationState.Instance.System.AudioVolume); + Device.SetVolume(_viewModel.VolumeBeforeMute); } else { + _viewModel.VolumeBeforeMute = Device.GetVolume(); Device.SetVolume(0); } diff --git a/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs index 80df5d39..7146dfd7 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs @@ -90,6 +90,7 @@ namespace Ryujinx.Ava.UI.ViewModels private string _pauseKey = "F5"; private string _screenshotKey = "F8"; private float _volume; + private float _volumeBeforeMute; private string _backendText; private bool _canUpdate = true; @@ -554,6 +555,17 @@ namespace Ryujinx.Ava.UI.ViewModels } } + public float VolumeBeforeMute + { + get => _volumeBeforeMute; + set + { + _volumeBeforeMute = value; + + OnPropertyChanged(); + } + } + public bool ShowStatusSeparator { get => _showStatusSeparator; diff --git a/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs b/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs index c78f4160..1aecbd04 100644 --- a/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs +++ b/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs @@ -436,10 +436,11 @@ namespace Ryujinx.Ava.UI.Windows { if (!volumeSplitButton.IsChecked) { - ViewModel.AppHost.Device.SetVolume(ConfigurationState.Instance.System.AudioVolume); + ViewModel.AppHost.Device.SetVolume(ViewModel.VolumeBeforeMute); } else { + ViewModel.VolumeBeforeMute = ViewModel.AppHost.Device.GetVolume(); ViewModel.AppHost.Device.SetVolume(0); }