mirror of
https://github.com/ppy/osu
synced 2024-12-23 23:33:36 +00:00
Simplify logic and add test coverage for remaining case
This commit is contained in:
parent
a819a64036
commit
5eba33e876
@ -92,8 +92,9 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
exitViaEscapeAndConfirm();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSongContinuesAfterExitPlayer()
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestSongContinuesAfterExitPlayer(bool withUserPause)
|
||||
{
|
||||
Player player = null;
|
||||
|
||||
@ -106,6 +107,9 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
|
||||
AddUntilStep("wait for selected", () => !game.Beatmap.IsDefault);
|
||||
|
||||
if (withUserPause)
|
||||
AddStep("pause", () => game.Dependencies.Get<MusicController>().Stop());
|
||||
|
||||
AddStep("press enter", () => pressAndRelease(Key.Enter));
|
||||
|
||||
AddUntilStep("wait for player", () => (player = game.ScreenStack.CurrentScreen as Player) != null);
|
||||
|
@ -129,11 +129,9 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
var track = current?.Track;
|
||||
|
||||
if (track.IsRunning)
|
||||
{
|
||||
IsUserPaused = true;
|
||||
IsUserPaused = true;
|
||||
if (track?.IsRunning == true)
|
||||
track.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -490,7 +490,9 @@ namespace osu.Game.Screens.Select
|
||||
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
|
||||
{
|
||||
UpdateBeatmap(Beatmap.Value);
|
||||
ensurePlayingSelected(false);
|
||||
|
||||
// restart playback on returning to song select, regardless.
|
||||
music?.Play();
|
||||
}
|
||||
|
||||
base.OnResuming(last);
|
||||
@ -587,8 +589,7 @@ namespace osu.Game.Screens.Select
|
||||
/// Ensures some music is playing for the current track.
|
||||
/// Will resume playback from a manual user pause if the track has changed.
|
||||
/// </summary>
|
||||
/// <param name="fromPreviewPoint">Whether to restart from the preview point, rather than resuming from previous location.</param>
|
||||
private void ensurePlayingSelected(bool fromPreviewPoint = true)
|
||||
private void ensurePlayingSelected()
|
||||
{
|
||||
Track track = Beatmap.Value.Track;
|
||||
|
||||
@ -597,7 +598,7 @@ namespace osu.Game.Screens.Select
|
||||
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||
|
||||
if (!track.IsRunning && (music?.IsUserPaused != true || isNewTrack))
|
||||
music?.Play(fromPreviewPoint);
|
||||
music?.Play(true);
|
||||
|
||||
lastTrack.SetTarget(track);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user