1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 15:33:05 +08:00

Fix incorrect ordering of items at song select when certain sort modes are used

This commit is contained in:
Dean Herbert 2023-12-19 15:09:03 +09:00
parent 469a659938
commit 44efa2c540
No known key found for this signature in database
2 changed files with 39 additions and 1 deletions

View File

@ -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) =>
{

View File

@ -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();
}
}
public enum MatchMode
{
/// <summary>