mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 13:07:18 +08:00
Fix instability in carousel item sorting
This commit is contained in:
parent
8b1b605c09
commit
2d1cef79d6
@ -16,6 +16,12 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
protected List<CarouselItem> InternalChildren = new List<CarouselItem>();
|
protected List<CarouselItem> InternalChildren = new List<CarouselItem>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to assign a monotonically increasing ID to children as they are added. This member is
|
||||||
|
/// incremented whenever a child is added.
|
||||||
|
/// </summary>
|
||||||
|
private ulong currentChildID;
|
||||||
|
|
||||||
public override List<DrawableCarouselItem> Drawables
|
public override List<DrawableCarouselItem> Drawables
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -39,6 +45,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
public virtual void AddChild(CarouselItem i)
|
public virtual void AddChild(CarouselItem i)
|
||||||
{
|
{
|
||||||
i.State.ValueChanged += v => ChildItemStateChanged(i, v);
|
i.State.ValueChanged += v => ChildItemStateChanged(i, v);
|
||||||
|
i.ChildID = ++currentChildID;
|
||||||
InternalChildren.Add(i);
|
InternalChildren.Add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int creationOrder;
|
||||||
|
|
||||||
protected CarouselItem()
|
protected CarouselItem()
|
||||||
{
|
{
|
||||||
drawableRepresentation = new Lazy<DrawableCarouselItem>(CreateDrawableRepresentation);
|
drawableRepresentation = new Lazy<DrawableCarouselItem>(CreateDrawableRepresentation);
|
||||||
@ -44,13 +46,18 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
private readonly Lazy<DrawableCarouselItem> drawableRepresentation;
|
private readonly Lazy<DrawableCarouselItem> drawableRepresentation;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used as a default sort method for <see cref="CarouselItem"/>s of differing types.
|
||||||
|
/// </summary>
|
||||||
|
internal ulong ChildID;
|
||||||
|
|
||||||
protected abstract DrawableCarouselItem CreateDrawableRepresentation();
|
protected abstract DrawableCarouselItem CreateDrawableRepresentation();
|
||||||
|
|
||||||
public virtual void Filter(FilterCriteria criteria)
|
public virtual void Filter(FilterCriteria criteria)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => GetHashCode().CompareTo(other.GetHashCode());
|
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => ChildID.CompareTo(other.ChildID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CarouselItemState
|
public enum CarouselItemState
|
||||||
|
Loading…
x
Reference in New Issue
Block a user