Store y positions inside items rather than in a separate array

This commit is contained in:
Dean Herbert
2020-10-13 13:21:21 +09:00
parent b92c22ad42
commit f6aa448523
2 changed files with 46 additions and 18 deletions

View File

@ -1,14 +1,20 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Bindables;
namespace osu.Game.Screens.Select.Carousel
{
public abstract class CarouselItem
public abstract class CarouselItem : IComparable<CarouselItem>
{
public virtual float TotalHeight => 0;
/// <summary>
/// An externally defined value used to determine this item's vertical display offset relative to the carousel.
/// </summary>
public float CarouselYPosition;
public readonly BindableBool Filtered = new BindableBool();
public readonly Bindable<CarouselItemState> State = new Bindable<CarouselItemState>(CarouselItemState.NotSelected);
@ -42,6 +48,8 @@ namespace osu.Game.Screens.Select.Carousel
}
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => ChildID.CompareTo(other.ChildID);
public int CompareTo(CarouselItem other) => CarouselYPosition.CompareTo(other.CarouselYPosition);
}
public enum CarouselItemState