1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-18 11:02:57 +08:00

Some Carousel classes can be abstract

This commit is contained in:
Dean Herbert 2024-12-09 23:29:50 +09:00
parent 89e3c551ff
commit de31a48beb
No known key found for this signature in database
2 changed files with 26 additions and 26 deletions

View File

@ -10,8 +10,31 @@ namespace osu.Game.Screens.Select.Carousel
/// <summary>
/// A group which ensures only one item is selected.
/// </summary>
public class CarouselGroup : CarouselItem
public abstract class CarouselGroup : CarouselItem
{
protected CarouselGroup(List<CarouselItem>? items = null)
{
if (items != null) this.items = items;
State.ValueChanged += state =>
{
switch (state.NewValue)
{
case CarouselItemState.Collapsed:
case CarouselItemState.NotSelected:
this.items.ForEach(c => c.State.Value = CarouselItemState.Collapsed);
break;
case CarouselItemState.Selected:
this.items.ForEach(c =>
{
if (c.State.Value == CarouselItemState.Collapsed) c.State.Value = CarouselItemState.NotSelected;
});
break;
}
};
}
public override DrawableCarouselItem? CreateDrawableRepresentation() => null;
public SlimReadOnlyListWrapper<CarouselItem> Items => items.AsSlimReadOnly();
@ -67,29 +90,6 @@ namespace osu.Game.Screens.Select.Carousel
TotalItemsNotFiltered++;
}
public CarouselGroup(List<CarouselItem>? items = null)
{
if (items != null) this.items = items;
State.ValueChanged += state =>
{
switch (state.NewValue)
{
case CarouselItemState.Collapsed:
case CarouselItemState.NotSelected:
this.items.ForEach(c => c.State.Value = CarouselItemState.Collapsed);
break;
case CarouselItemState.Selected:
this.items.ForEach(c =>
{
if (c.State.Value == CarouselItemState.Collapsed) c.State.Value = CarouselItemState.NotSelected;
});
break;
}
};
}
public override void Filter(FilterCriteria criteria)
{
base.Filter(criteria);

View File

@ -10,9 +10,9 @@ namespace osu.Game.Screens.Select.Carousel
/// <summary>
/// A group which ensures at least one item is selected (if the group itself is selected).
/// </summary>
public class CarouselGroupEagerSelect : CarouselGroup
public abstract class CarouselGroupEagerSelect : CarouselGroup
{
public CarouselGroupEagerSelect()
protected CarouselGroupEagerSelect()
{
State.ValueChanged += state =>
{