mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:17:26 +08:00
Merge pull request #25888 from peppy/fix-sort-failures
Fix incorrect ordering of items at song select when certain sort modes are used
This commit is contained in:
commit
c078d63e90
@ -87,7 +87,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
items.ForEach(c => c.Filter(criteria));
|
||||
|
||||
// Sorting is expensive, so only perform if it's actually changed.
|
||||
if (lastCriteria?.Sort != criteria.Sort)
|
||||
if (lastCriteria?.RequiresSorting(criteria) != false)
|
||||
{
|
||||
criteriaComparer = Comparer<CarouselItem>.Create((x, y) =>
|
||||
{
|
||||
|
@ -219,6 +219,44 @@ namespace osu.Game.Screens.Select
|
||||
public bool Equals(OptionalTextFilter other) => SearchTerm == other.SearchTerm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given a new filter criteria, decide whether a full sort needs to be performed.
|
||||
/// </summary>
|
||||
/// <param name="newCriteria"></param>
|
||||
/// <returns></returns>
|
||||
public bool RequiresSorting(FilterCriteria newCriteria)
|
||||
{
|
||||
if (Sort != newCriteria.Sort)
|
||||
return true;
|
||||
|
||||
switch (Sort)
|
||||
{
|
||||
// Some sorts are stable across all other changes.
|
||||
// Running these sorts will sort all items, including currently hidden items.
|
||||
case SortMode.Artist:
|
||||
case SortMode.Author:
|
||||
case SortMode.DateSubmitted:
|
||||
case SortMode.DateAdded:
|
||||
case SortMode.DateRanked:
|
||||
case SortMode.Source:
|
||||
case SortMode.Title:
|
||||
return false;
|
||||
|
||||
// Some sorts use aggregate max comparisons, which will change based on filtered items.
|
||||
// These sorts generally ignore items hidden by filtered state, so we must force a sort under all circumstances here.
|
||||
//
|
||||
// This makes things very slow when typing a text search, and we probably want to consider a way to optimise things going forward.
|
||||
case SortMode.LastPlayed:
|
||||
case SortMode.BPM:
|
||||
case SortMode.Length:
|
||||
case SortMode.Difficulty:
|
||||
return true;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(Sort), Sort, "Unknown sort mode");
|
||||
}
|
||||
}
|
||||
|
||||
public enum MatchMode
|
||||
{
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user