1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +08:00

Make prev and next work again.

This commit is contained in:
Huo Yaoyuan 2016-10-28 20:08:27 +08:00
parent b7ada4866e
commit 7d14e6e6cf
2 changed files with 24 additions and 7 deletions

View File

@ -34,7 +34,6 @@ namespace osu.Desktop.Tests
{
base.Reset();
ourClock.ProcessFrame();
mc?.CurrentTrack?.Stop();
mc = new MusicController
{
Origin = Anchor.Centre,

View File

@ -186,6 +186,10 @@ namespace osu.Game.Overlays
playButton.Icon = FontAwesome.pause;
updateCurrent(beatmapSource, null);
}
else if (playList.Count > 0)
{
play(playList[0].Beatmaps[0], null);
}
}
protected override void Update()
@ -196,22 +200,36 @@ namespace osu.Game.Overlays
if (CurrentTrack.HasCompleted) next();
}
private int findInPlaylist(Beatmap beatmap)
{
if (beatmap == null) return -1;
for (int i = 0; i < playList.Count; i++)
if (beatmap.BeatmapInfo.BeatmapSetID == playList[i].BeatmapSetID)
return i;
return -1;
}
private void prev()
{
int i = playList.IndexOf(currentPlay);
int i = findInPlaylist(beatmapSource.Value?.Beatmap);
if (i == -1) return;
i = (i - 1 + playList.Count) % playList.Count;
currentPlay = playList[i];
play(currentPlay, false);
play(playList[i].Beatmaps[0], false);
}
private void next()
{
int i = playList.IndexOf(currentPlay);
int i = findInPlaylist(beatmapSource.Value?.Beatmap);
if (i == -1) return;
i = (i + 1) % playList.Count;
currentPlay = playList[i];
play(currentPlay, true);
play(playList[i].Beatmaps[0], true);
}
private void play(BeatmapInfo info, bool? isNext)
{
WorkingBeatmap working = database.GetWorkingBeatmap(info, beatmapSource.Value);
beatmapSource.Value = working;
updateCurrent(working, isNext);
}
private void updateCurrent(WorkingBeatmap beatmap, bool? isNext)