1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Prevent not saving audio levels when user alt tabs before the window closes

This commit is contained in:
aQaTL 2018-01-16 21:30:48 +01:00
parent 0340e4f8dc
commit 538c20a947
No known key found for this signature in database
GPG Key ID: 181719411A8555F0

View File

@ -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<bool>(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();
}