diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index f86ee480fd..e0f2ed89e3 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -137,14 +137,16 @@ namespace osu.Game.Screens.Select var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap)); if (panel != null) { - SelectGroup(group, panel, animated); + selectGroup(group, panel, animated); return; } } } - public void SelectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = true) + private void selectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = true) { + Trace.Assert(group.BeatmapPanels.Contains(panel), @"Selected panel must be in provided group"); + if (SelectedGroup != null && SelectedGroup != group && SelectedGroup.State != BeatmapGroupState.Hidden) SelectedGroup.State = BeatmapGroupState.Collapsed; @@ -334,7 +336,7 @@ namespace osu.Game.Screens.Select if (i >= 0 && i < SelectedGroup.BeatmapPanels.Count) { //changing difficulty panel, not set. - SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[i]); + selectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[i]); return; } } @@ -357,11 +359,14 @@ namespace osu.Game.Screens.Select { if (groups.Count < 1) return; + BeatmapGroup group = groups[RNG.Next(groups.Count)]; BeatmapPanel panel = group?.BeatmapPanels.First(); + if (panel == null) return; - SelectGroup(group, panel); + + selectGroup(group, panel); } public IEnumerator GetEnumerator() => groups.GetEnumerator(); diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 68783f33db..49c80552bd 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -403,11 +403,7 @@ namespace osu.Game.Screens.Select if (Beatmap == null || select) carousel.SelectBeatmap(beatmapSet.Beatmaps.First()); else - { - var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(Beatmap.BeatmapInfo)); - if (panel != null) - carousel.SelectGroup(group, panel); - } + carousel.SelectBeatmap(Beatmap.BeatmapInfo); })); }