Change carousel terminology to not use Children / InternalChildren

This commit is contained in:
Dean Herbert
2022-07-21 16:06:06 +09:00
parent 55bde4eeb0
commit a05d7f4d8c
6 changed files with 44 additions and 42 deletions

View File

@ -49,9 +49,9 @@ namespace osu.Game.Screens.Select.Carousel
attemptSelection();
}
public override void RemoveChild(CarouselItem i)
public override void RemoveItem(CarouselItem i)
{
base.RemoveChild(i);
base.RemoveItem(i);
if (i != LastSelected)
updateSelectedIndex();
@ -64,16 +64,16 @@ namespace osu.Game.Screens.Select.Carousel
addingChildren = true;
foreach (var i in items)
AddChild(i);
AddItem(i);
addingChildren = false;
attemptSelection();
}
public override void AddChild(CarouselItem i)
public override void AddItem(CarouselItem i)
{
base.AddChild(i);
base.AddItem(i);
if (!addingChildren)
attemptSelection();
}
@ -103,15 +103,15 @@ namespace osu.Game.Screens.Select.Carousel
if (State.Value != CarouselItemState.Selected) return;
// we only perform eager selection if none of our children are in a selected state already.
if (Children.Any(i => i.State.Value == CarouselItemState.Selected)) return;
if (Items.Any(i => i.State.Value == CarouselItemState.Selected)) return;
PerformSelection();
}
protected virtual CarouselItem GetNextToSelect()
{
return Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value) ??
Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value);
return Items.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value) ??
Items.Reverse().Skip(Items.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value);
}
protected virtual void PerformSelection()
@ -131,6 +131,6 @@ namespace osu.Game.Screens.Select.Carousel
updateSelectedIndex();
}
private void updateSelectedIndex() => lastSelectedIndex = LastSelected == null ? 0 : Math.Max(0, InternalChildren.IndexOf(LastSelected));
private void updateSelectedIndex() => lastSelectedIndex = LastSelected == null ? 0 : Math.Max(0, GetIndexOfItem(LastSelected));
}
}