diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 9793440348..02bad82ca9 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -169,20 +169,29 @@ namespace osu.Game.Screens.Select }); } - public void SelectBeatmap(BeatmapInfo beatmap) + /// + /// Selects a given beatmap on the carousel. + /// + /// The beatmap to select. + /// Whether to skip selecting filtered beatmaps. + /// True if a selection was made, false if it was skipped. + public bool SelectBeatmap(BeatmapInfo beatmap, bool skipFiltered = false) { if (beatmap?.Hidden != false) - return; + return false; - foreach (CarouselBeatmapSet group in beatmapSets) - { - var item = group.Beatmaps.FirstOrDefault(p => p.Beatmap.Equals(beatmap)); - if (item != null) - { - select(item); - return; - } - } + var group = beatmapSets.FirstOrDefault(s => s.BeatmapSet.OnlineBeatmapSetID == beatmap.BeatmapSet.OnlineBeatmapSetID); + + if (group == null || !skipFiltered && group.Filtered) + return false; + + var item = group.Beatmaps.FirstOrDefault(p => p.Beatmap.Equals(beatmap)); + + if (item == null || !skipFiltered && item.Filtered) + return false; + + select(item); + return true; } /// diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index d4fd64dcd9..2c8dcae3cf 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -267,10 +267,7 @@ namespace osu.Game.Screens.Select protected void WorkingBeatmapChanged(WorkingBeatmap beatmap) { if (IsCurrentScreen) - { Carousel.SelectBeatmap(beatmap?.BeatmapInfo); - ensurePlayableRuleset(); - } } /// @@ -328,7 +325,6 @@ namespace osu.Game.Screens.Select { base.OnEntering(last); - ensurePlayableRuleset(); Content.FadeInFromZero(250); FilterControl.Activate(); } @@ -456,34 +452,6 @@ namespace osu.Game.Screens.Select } } - private void ensurePlayableRuleset() - { - if (Beatmap.IsDefault) - // DummyBeatmap won't be playable anyway - return; - - bool conversionAllowed = rulesetConversionAllowed.Value; - int? currentRuleset = Ruleset.Value.ID; - int beatmapRuleset = Beatmap.Value.BeatmapInfo.RulesetID; - - if (currentRuleset == beatmapRuleset || conversionAllowed && beatmapRuleset == 0) - // Current beatmap is playable, nothing more to do - return; - - // Otherwise, first check if the current beatmapset has any playable beatmaps - BeatmapInfo beatmap = Beatmap.Value.BeatmapSetInfo.Beatmaps?.FirstOrDefault(b => b.RulesetID == currentRuleset || conversionAllowed && b.RulesetID == 0); - - // If it does then update the WorkingBeatmap - if (beatmap != null) - { - Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap); - return; - } - - // If it doesn't, then update the current ruleset so that the current beatmap is playable - Ruleset.Value = Beatmap.Value.BeatmapInfo.Ruleset; - } - private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s); private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s); private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));