mirror of
https://github.com/ppy/osu.git
synced 2026-06-07 06:23:39 +08:00
Merge pull request #34353 from EYHN/eyhn/fix/present-preview-point
Fix present beatmap audio start at the preview point
This commit is contained in:
@@ -697,44 +697,6 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddUntilStep("wait for score panel removal", () => scorePanel.Parent == null);
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestSongContinuesAfterExitPlayer(bool withUserPause)
|
||||
{
|
||||
Player player = null;
|
||||
|
||||
IWorkingBeatmap beatmap() => Game.Beatmap.Value;
|
||||
|
||||
Screens.SelectV2.SongSelect songSelect = null;
|
||||
PushAndConfirm(() => songSelect = new SoloSongSelect());
|
||||
AddUntilStep("wait for song select", () => songSelect.CarouselItemsPresented);
|
||||
|
||||
AddStep("import beatmap", () => BeatmapImportHelper.LoadOszIntoOsu(Game, virtualTrack: true).WaitSafely());
|
||||
|
||||
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
||||
|
||||
if (withUserPause)
|
||||
AddStep("pause", () => Game.Dependencies.Get<MusicController>().Stop(true));
|
||||
|
||||
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||
|
||||
AddUntilStep("wait for player", () =>
|
||||
{
|
||||
DismissAnyNotifications();
|
||||
return (player = Game.ScreenStack.CurrentScreen as Player) != null;
|
||||
});
|
||||
|
||||
AddUntilStep("wait for fail", () => player.GameplayState.HasFailed);
|
||||
|
||||
AddUntilStep("wait for track stop", () => !Game.MusicController.IsPlaying);
|
||||
AddAssert("Ensure time before preview point", () => Game.MusicController.CurrentTrack.CurrentTime < beatmap().BeatmapInfo.Metadata.PreviewTime);
|
||||
|
||||
pushEscape();
|
||||
|
||||
AddUntilStep("wait for track playing", () => Game.MusicController.IsPlaying);
|
||||
AddAssert("Ensure time wasn't reset to preview point", () => Game.MusicController.CurrentTrack.CurrentTime < beatmap().BeatmapInfo.Metadata.PreviewTime);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMenuMakesMusic()
|
||||
{
|
||||
|
||||
@@ -92,6 +92,30 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
waitForScreen<SoloSongSelect>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPresentBeatmapFromMainMenuUsesPreviewPoint()
|
||||
{
|
||||
BeatmapSetInfo beatmapInfo = null!;
|
||||
|
||||
AddStep("import beatmap", () =>
|
||||
{
|
||||
var task = BeatmapImportHelper.LoadOszIntoOsu(Game, virtualTrack: true);
|
||||
task.WaitSafely();
|
||||
beatmapInfo = task.GetResultSafely();
|
||||
});
|
||||
|
||||
AddStep("present beatmap", () => Game.PresentBeatmap(beatmapInfo));
|
||||
|
||||
AddUntilStep("wait for track playing", () => Game.MusicController.IsPlaying);
|
||||
|
||||
AddAssert("ensure time is reset to preview point",
|
||||
() =>
|
||||
{
|
||||
double timeFromPreviewPoint = Math.Abs(Game.MusicController.CurrentTrack.CurrentTime - beatmapInfo.Metadata.PreviewTime);
|
||||
return timeFromPreviewPoint < 5000;
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestSongContinuesAfterExitPlayer(bool withUserPause)
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
ensureGlobalBeatmapValid();
|
||||
|
||||
ensurePlayingSelected(true);
|
||||
ensurePlayingSelected();
|
||||
updateBackgroundDim();
|
||||
updateWedgeVisibility();
|
||||
});
|
||||
@@ -379,7 +379,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
/// Ensures some music is playing for the current track.
|
||||
/// Will resume playback from a manual user pause if the track has changed.
|
||||
/// </summary>
|
||||
private void ensurePlayingSelected(bool restart)
|
||||
private void ensurePlayingSelected()
|
||||
{
|
||||
if (!ControlGlobalMusic)
|
||||
return;
|
||||
@@ -391,7 +391,10 @@ namespace osu.Game.Screens.SelectV2
|
||||
if (!track.IsRunning && (music.UserPauseRequested != true || isNewTrack))
|
||||
{
|
||||
Logger.Log($"Song select decided to {nameof(ensurePlayingSelected)}");
|
||||
music.Play(restart);
|
||||
|
||||
// Only restart playback if a new track.
|
||||
// This is important so that when exiting gameplay, the track is not restarted back to the preview point.
|
||||
music.Play(isNewTrack);
|
||||
}
|
||||
|
||||
lastTrack.SetTarget(track);
|
||||
@@ -634,7 +637,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
ensureGlobalBeatmapValid();
|
||||
|
||||
ensurePlayingSelected(false);
|
||||
ensurePlayingSelected();
|
||||
updateBackgroundDim();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user