diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 29ae5983be..abbcec5094 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -55,6 +55,8 @@ namespace osu.Game.Overlays private Container dragContainer; private Container playerContainer; + public bool IsUserPaused { get; private set; } + [Resolved] private Bindable beatmap { get; set; } @@ -157,7 +159,7 @@ namespace osu.Game.Overlays Origin = Anchor.Centre, Scale = new Vector2(1.4f), IconScale = new Vector2(1.4f), - Action = play, + Action = togglePause, Icon = FontAwesome.Regular.PlayCircle, }, nextButton = new MusicIconButton @@ -276,7 +278,7 @@ namespace osu.Game.Overlays } } - private void play() + private void togglePause() { var track = current?.Track; @@ -288,9 +290,15 @@ namespace osu.Game.Overlays } if (track.IsRunning) + { + IsUserPaused = true; track.Stop(); + } else + { track.Start(); + IsUserPaused = false; + } } private void prev() diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 89da9ae063..8cc227d9be 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -224,30 +224,32 @@ namespace osu.Game.Screens.Edit public override void OnResuming(IScreen last) { - Beatmap.Value.Track?.Stop(); base.OnResuming(last); + Beatmap.Value.Track?.Stop(); } public override void OnEntering(IScreen last) { base.OnEntering(last); + Background.FadeColour(Color4.DarkGray, 500); - Beatmap.Value.Track?.Stop(); + resetTrack(); } public override bool OnExiting(IScreen next) { Background.FadeColour(Color4.White, 500); - - if (Beatmap.Value.Track != null) - { - Beatmap.Value.Track.Tempo.Value = 1; - Beatmap.Value.Track.Start(); - } + resetTrack(); return base.OnExiting(next); } + private void resetTrack() + { + Beatmap.Value.Track?.ResetSpeedAdjustments(); + Beatmap.Value.Track?.Stop(); + } + private void exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save()); private void onModeChanged(ValueChangedEvent e) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index c64bea840f..5999cbdfb5 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -42,6 +42,9 @@ namespace osu.Game.Screens.Menu [Resolved] private GameHost host { get; set; } + [Resolved(canBeNull: true)] + private MusicController music { get; set; } + private BackgroundScreenDefault background; protected override BackgroundScreen CreateBackground() => background; @@ -189,6 +192,9 @@ namespace osu.Game.Screens.Menu //we may have consumed our preloaded instance, so let's make another. preloadSongSelect(); + + if (Beatmap.Value.Track != null && music?.IsUserPaused != true) + Beatmap.Value.Track.Start(); } public override bool OnExiting(IScreen next) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index bf5857f725..0eeffda5eb 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -87,6 +87,9 @@ namespace osu.Game.Screens.Select private readonly Bindable decoupledRuleset = new Bindable(); + [Resolved(canBeNull: true)] + private MusicController music { get; set; } + [Cached] [Cached(Type = typeof(IBindable>))] private readonly Bindable> mods = new Bindable>(Array.Empty()); // Bound to the game's mods, but is not reset on exiting @@ -570,7 +573,7 @@ namespace osu.Game.Screens.Select { Track track = Beatmap.Value.Track; - if (!track.IsRunning || restart) + if ((!track.IsRunning || restart) && music?.IsUserPaused != true) { track.RestartPoint = Beatmap.Value.Metadata.PreviewTime; track.Restart();