1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:52:56 +08:00

Remove remaining uses of "child" terminology in non-drawable components

This commit is contained in:
Salman Ahmed 2022-07-26 09:39:30 +03:00
parent d7ef4170be
commit 693ac8750c
3 changed files with 15 additions and 15 deletions

View File

@ -7,7 +7,7 @@ using System.Linq;
namespace osu.Game.Screens.Select.Carousel
{
/// <summary>
/// A group which ensures only one child is selected.
/// A group which ensures only one item is selected.
/// </summary>
public class CarouselGroup : CarouselItem
{
@ -18,10 +18,10 @@ namespace osu.Game.Screens.Select.Carousel
private List<CarouselItem> items = 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.
/// Used to assign a monotonically increasing ID to items as they are added. This member is
/// incremented whenever an item is added.
/// </summary>
private ulong currentChildID;
private ulong currentItemID;
private Comparer<CarouselItem>? criteriaComparer;
private Comparer<CarouselItem>? itemIDComparer;
@ -42,7 +42,7 @@ namespace osu.Game.Screens.Select.Carousel
public virtual void AddItem(CarouselItem i)
{
i.State.ValueChanged += state => ChildItemStateChanged(i, state.NewValue);
i.ChildID = ++currentChildID;
i.ItemID = ++currentItemID;
if (lastCriteria != null)
{
@ -91,7 +91,7 @@ namespace osu.Game.Screens.Select.Carousel
// IEnumerable<T>.OrderBy() is used instead of List<T>.Sort() to ensure sorting stability
criteriaComparer = Comparer<CarouselItem>.Create((x, y) => x.CompareTo(criteria, y));
itemIDComparer = Comparer<CarouselItem>.Create((x, y) => x.ChildID.CompareTo(y.ChildID));
itemIDComparer = Comparer<CarouselItem>.Create((x, y) => x.ItemID.CompareTo(y.ItemID));
items = items.OrderBy(c => c, criteriaComparer).ThenBy(c => c, itemIDComparer).ToList();
lastCriteria = criteria;

View File

@ -10,7 +10,7 @@ using System.Linq;
namespace osu.Game.Screens.Select.Carousel
{
/// <summary>
/// A group which ensures at least one child is selected (if the group itself is selected).
/// A group which ensures at least one item is selected (if the group itself is selected).
/// </summary>
public class CarouselGroupEagerSelect : CarouselGroup
{
@ -35,16 +35,16 @@ namespace osu.Game.Screens.Select.Carousel
/// <summary>
/// To avoid overhead during filter operations, we don't attempt any selections until after all
/// children have been filtered. This bool will be true during the base <see cref="Filter(FilterCriteria)"/>
/// items have been filtered. This bool will be true during the base <see cref="Filter(FilterCriteria)"/>
/// operation.
/// </summary>
private bool filteringChildren;
private bool filteringItems;
public override void Filter(FilterCriteria criteria)
{
filteringChildren = true;
filteringItems = true;
base.Filter(criteria);
filteringChildren = false;
filteringItems = false;
attemptSelection();
}
@ -97,12 +97,12 @@ namespace osu.Game.Screens.Select.Carousel
private void attemptSelection()
{
if (filteringChildren) return;
if (filteringItems) return;
// we only perform eager selection if we are a currently selected group.
if (State.Value != CarouselItemState.Selected) return;
// we only perform eager selection if none of our children are in a selected state already.
// we only perform eager selection if none of our items are in a selected state already.
if (Items.Any(i => i.State.Value == CarouselItemState.Selected)) return;
PerformSelection();

View File

@ -38,7 +38,7 @@ namespace osu.Game.Screens.Select.Carousel
/// <summary>
/// Used as a default sort method for <see cref="CarouselItem"/>s of differing types.
/// </summary>
internal ulong ChildID;
internal ulong ItemID;
/// <summary>
/// Create a fresh drawable version of this item.
@ -49,7 +49,7 @@ namespace osu.Game.Screens.Select.Carousel
{
}
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => ChildID.CompareTo(other.ChildID);
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => ItemID.CompareTo(other.ItemID);
public int CompareTo(CarouselItem other) => CarouselYPosition.CompareTo(other.CarouselYPosition);
}