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