mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 05:22:54 +08:00
Fade out volume on game exiting (#5242)
Fade out volume on game exiting Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
427d245de4
@ -33,13 +33,18 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack();
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack();
|
||||||
|
|
||||||
|
private readonly BindableDouble exitingVolumeFade = new BindableDouble(1);
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private AudioManager audio { get; set; }
|
||||||
|
|
||||||
private Bindable<bool> menuVoice;
|
private Bindable<bool> menuVoice;
|
||||||
private Bindable<bool> menuMusic;
|
private Bindable<bool> menuMusic;
|
||||||
private Track track;
|
private Track track;
|
||||||
private WorkingBeatmap introBeatmap;
|
private WorkingBeatmap introBeatmap;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game)
|
private void load(OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game)
|
||||||
{
|
{
|
||||||
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
|
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
|
||||||
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
|
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
|
||||||
@ -161,7 +166,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
else
|
else
|
||||||
fadeOutTime = 500;
|
fadeOutTime = 500;
|
||||||
|
|
||||||
Scheduler.AddDelayed(this.Exit, fadeOutTime);
|
audio.AddAdjustment(AdjustableProperty.Volume, exitingVolumeFade);
|
||||||
|
this.TransformBindableTo(exitingVolumeFade, 0, fadeOutTime).OnComplete(_ => this.Exit());
|
||||||
|
|
||||||
//don't want to fade out completely else we will stop running updates.
|
//don't want to fade out completely else we will stop running updates.
|
||||||
Game.FadeTo(0.01f, fadeOutTime);
|
Game.FadeTo(0.01f, fadeOutTime);
|
||||||
|
Loading…
Reference in New Issue
Block a user