From 02b903f1ea31ac84053a9b57db6370f5b1c4ff48 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 7 Nov 2016 22:12:58 +0800 Subject: [PATCH] Shuffle playlist. --- osu.Game/Overlays/MusicController.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 77e0a2e667..a1928caf0b 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -15,6 +15,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; +using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Graphics; @@ -242,6 +243,15 @@ namespace osu.Game.Overlays play(playHistory[++playHistoryIndex], true); else { + //shuffle + int j = RNG.Next(playListIndex, playList.Count); + if (j != playListIndex) + { + BeatmapSetInfo temp = playList[playListIndex]; + playList[playListIndex] = playList[j]; + playList[j] = temp; + } + BeatmapInfo nextToPlay = playList[playListIndex++].Beatmaps[0]; if (playListIndex == playList.Count) playListIndex = 0; play(nextToPlay, true);