Skip to content

Commit

Permalink
Some Carousel classes can be abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Dec 11, 2024
1 parent 89e3c55 commit de31a48
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
48 changes: 24 additions & 24 deletions osu.Game/Screens/Select/Carousel/CarouselGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -67,29 +90,6 @@ public virtual void AddItem(CarouselItem i)
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);
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
{
Expand Down

0 comments on commit de31a48

Please sign in to comment.