mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 17:13:20 +08:00
Prevent not saving audio levels when user alt tabs before the window closes
This commit is contained in:
parent
0340e4f8dc
commit
538c20a947
@ -79,6 +79,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
private SettingsOverlay settings;
|
private SettingsOverlay settings;
|
||||||
|
|
||||||
|
private bool exiting;
|
||||||
|
|
||||||
public OsuGame(string[] args = null)
|
public OsuGame(string[] args = null)
|
||||||
{
|
{
|
||||||
this.args = args;
|
this.args = args;
|
||||||
@ -117,6 +119,13 @@ namespace osu.Game
|
|||||||
Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0;
|
Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0;
|
||||||
|
|
||||||
muteWhenInactive = LocalConfig.GetBindable<bool>(OsuSetting.MuteWhenInactive);
|
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;
|
private ScheduledDelegate scoreLoad;
|
||||||
@ -394,7 +403,7 @@ namespace osu.Game
|
|||||||
protected override void OnDeactivated()
|
protected override void OnDeactivated()
|
||||||
{
|
{
|
||||||
base.OnDeactivated();
|
base.OnDeactivated();
|
||||||
if (muteWhenInactive)
|
if (muteWhenInactive && !exiting)
|
||||||
{
|
{
|
||||||
wasMuted = volume.IsMuted;
|
wasMuted = volume.IsMuted;
|
||||||
volume.Mute();
|
volume.Mute();
|
||||||
@ -404,7 +413,7 @@ namespace osu.Game
|
|||||||
protected override void OnActivated()
|
protected override void OnActivated()
|
||||||
{
|
{
|
||||||
base.OnActivated();
|
base.OnActivated();
|
||||||
if (IsLoaded && muteWhenInactive && !wasMuted)
|
if (IsLoaded && muteWhenInactive && !wasMuted && !exiting)
|
||||||
{
|
{
|
||||||
volume.Unmute();
|
volume.Unmute();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user