mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Fix newly imported beatmaps not using correct comparer for sorting
This commit is contained in:
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Carousel
|
namespace osu.Game.Screens.Select.Carousel
|
||||||
{
|
{
|
||||||
@ -15,7 +14,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
public IReadOnlyList<CarouselItem> Items => items;
|
public IReadOnlyList<CarouselItem> Items => items;
|
||||||
|
|
||||||
private List<CarouselItem> items = new List<CarouselItem>();
|
private readonly List<CarouselItem> items = new List<CarouselItem>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to assign a monotonically increasing ID to items as they are added. This member is
|
/// Used to assign a monotonically increasing ID to items as they are added. This member is
|
||||||
@ -24,9 +23,6 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
private ulong currentItemID;
|
private ulong currentItemID;
|
||||||
|
|
||||||
private Comparer<CarouselItem>? criteriaComparer;
|
private Comparer<CarouselItem>? criteriaComparer;
|
||||||
|
|
||||||
private static readonly Comparer<CarouselItem> item_id_comparer = Comparer<CarouselItem>.Create((x, y) => x.ItemID.CompareTo(y.ItemID));
|
|
||||||
|
|
||||||
private FilterCriteria? lastCriteria;
|
private FilterCriteria? lastCriteria;
|
||||||
|
|
||||||
protected int GetIndexOfItem(CarouselItem lastSelected) => items.IndexOf(lastSelected);
|
protected int GetIndexOfItem(CarouselItem lastSelected) => items.IndexOf(lastSelected);
|
||||||
@ -90,9 +86,16 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
items.ForEach(c => c.Filter(criteria));
|
items.ForEach(c => c.Filter(criteria));
|
||||||
|
|
||||||
// IEnumerable<T>.OrderBy() is used instead of List<T>.Sort() to ensure sorting stability
|
criteriaComparer = Comparer<CarouselItem>.Create((x, y) =>
|
||||||
criteriaComparer = Comparer<CarouselItem>.Create((x, y) => x.CompareTo(criteria, y));
|
{
|
||||||
items = items.OrderBy(c => c, criteriaComparer).ThenBy(c => c, item_id_comparer).ToList();
|
int comparison = x.CompareTo(criteria, y);
|
||||||
|
if (comparison != 0)
|
||||||
|
return comparison;
|
||||||
|
|
||||||
|
return x.ItemID.CompareTo(y.ItemID);
|
||||||
|
});
|
||||||
|
|
||||||
|
items.Sort(criteriaComparer);
|
||||||
|
|
||||||
lastCriteria = criteria;
|
lastCriteria = criteria;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user