diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index e37040b3de..40c3ae0fdc 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -67,7 +67,7 @@ namespace osu.Game.Screens.Select Task.Run(() => { value.Select(createCarouselSet).Where(g => g != null).ForEach(newRoot.AddChild); - newRoot.Filter(criteria); + newRoot.Filter(activeCriteria); }).ContinueWith(t => { Schedule(() => @@ -149,7 +149,7 @@ namespace osu.Game.Screens.Select root.AddChild(newSet); - Filter(debounce: false); + applyActiveCriteria(false); //check if we can/need to maintain our current selection. if (hadSelection) @@ -158,7 +158,7 @@ namespace osu.Game.Screens.Select updateItems(); } - public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true) + public void SelectBeatmap(BeatmapInfo beatmap) { if (beatmap == null || beatmap.Hidden) { @@ -212,14 +212,12 @@ namespace osu.Game.Screens.Select } } - private IEnumerable getVisibleSets() => beatmapSets.Where(select => !select.Filtered); - public void SelectNextRandom() { if (!beatmapSets.Any()) return; - var visible = getVisibleSets().ToList(); + var visible = beatmapSets.Where(select => !select.Filtered).ToList(); if (!visible.Any()) return; @@ -269,28 +267,33 @@ namespace osu.Game.Screens.Select } } - private FilterCriteria criteria = new FilterCriteria(); + private FilterCriteria activeCriteria = new FilterCriteria(); protected ScheduledDelegate FilterTask; public bool AllowSelection = true; - public void FlushPendingFilters() + public void FlushPendingFilterOperations() { if (FilterTask?.Completed == false) - Filter(debounce: false); + applyActiveCriteria(false); } - public void Filter(FilterCriteria newCriteria = null, bool debounce = true) + public void Filter(FilterCriteria newCriteria, bool debounce = true) { if (newCriteria != null) - criteria = newCriteria; + activeCriteria = newCriteria; + applyActiveCriteria(debounce); + } + + private void applyActiveCriteria(bool debounce) + { Action perform = delegate { FilterTask = null; - root.Filter(criteria); + root.Filter(activeCriteria); updateItems(); ScrollToSelected(false); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index d71108a686..d9a3f2faea 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -212,7 +212,7 @@ namespace osu.Game.Screens.Select { // if we have a pending filter operation, we want to run it now. // it could change selection (ie. if the ruleset has been changed). - carousel.FlushPendingFilters(); + carousel.FlushPendingFilterOperations(); if (selectionChangedDebounce?.Completed == false) { @@ -447,7 +447,7 @@ namespace osu.Game.Screens.Select private void carouselBeatmapsLoaded() { if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false) - carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false); + carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo); else carousel.SelectNextRandom(); }