diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index e611c0dfd0..60242393ab 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -85,12 +85,8 @@ namespace osu.Game.Graphics.UserInterface.Volume volumeMeterMaster.Increase(); return true; case GlobalAction.ToggleMute: - if (State == Visibility.Hidden) - Show(); - if (IsMuted) - Unmute(); - else - Mute(); + Show(); + Muted = !Muted; return true; } @@ -107,16 +103,10 @@ namespace osu.Game.Graphics.UserInterface.Volume private readonly BindableBool muted = new BindableBool(); - public bool IsMuted => muted.Value; - - public void Mute() + public bool Muted { - muted.Value = true; - } - - public void Unmute() - { - muted.Value = false; + get => muted.Value; + set => muted.Value = value; } [BackgroundDependencyLoader] @@ -129,11 +119,15 @@ namespace osu.Game.Graphics.UserInterface.Volume muted.ValueChanged += mute => { if (mute) + { audio.AddAdjustment(AdjustableProperty.Volume, muteBindable); + muteIcon.Icon = FontAwesome.fa_volume_off; + } else + { audio.RemoveAdjustment(AdjustableProperty.Volume, muteBindable); - - muteIcon.Icon = mute ? FontAwesome.fa_volume_off : FontAwesome.fa_volume_up; + muteIcon.Icon = FontAwesome.fa_volume_up; + } }; } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f1fb2a4f0a..b938595d57 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -396,8 +396,8 @@ namespace osu.Game base.OnDeactivated(); if (muteWhenInactive) { - wasMuted = volume.IsMuted; - volume.Mute(); + wasMuted = volume.Muted; + volume.Muted = true; } } @@ -405,7 +405,7 @@ namespace osu.Game { base.OnActivated(); if (IsLoaded && muteWhenInactive && !wasMuted) - volume.Unmute(); + volume.Muted = false; } public bool OnReleased(GlobalAction action) => false;