From 538c20a947d0e231ff9b84ba9ce36bac78c52c70 Mon Sep 17 00:00:00 2001 From: aQaTL Date: Tue, 16 Jan 2018 21:30:48 +0100 Subject: [PATCH] Prevent not saving audio levels when user alt tabs before the window closes --- osu.Game/OsuGame.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 56cfffdeae..de923b3451 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -79,6 +79,8 @@ namespace osu.Game private SettingsOverlay settings; + private bool exiting; + public OsuGame(string[] args = null) { this.args = args; @@ -117,6 +119,13 @@ namespace osu.Game Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0; muteWhenInactive = LocalConfig.GetBindable(OsuSetting.MuteWhenInactive); + Host.Window.Exited += () => + { + //Prevent not saving audio levels when user alt tabs before the window closes + if (volume.IsMuted) + volume.Unmute(); + exiting = true; + }; } private ScheduledDelegate scoreLoad; @@ -394,7 +403,7 @@ namespace osu.Game protected override void OnDeactivated() { base.OnDeactivated(); - if (muteWhenInactive) + if (muteWhenInactive && !exiting) { wasMuted = volume.IsMuted; volume.Mute(); @@ -404,7 +413,7 @@ namespace osu.Game protected override void OnActivated() { base.OnActivated(); - if (IsLoaded && muteWhenInactive && !wasMuted) + if (IsLoaded && muteWhenInactive && !wasMuted && !exiting) { volume.Unmute(); }