Avoid using `.Children` for enumeration in other locations

pull/26674/head
Dean Herbert 2024-01-23 05:32:11 +09:00
parent 069af13aaf
commit 02bb506cce
No known key found for this signature in database
10 changed files with 18 additions and 19 deletions

View File

@ -16,15 +16,14 @@
"osu.Game.Tournament.Tests\\osu.Game.Tournament.Tests.csproj",
"osu.Game.Tournament\\osu.Game.Tournament.csproj",
"osu.Game\\osu.Game.csproj",
"Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform\\osu.Game.Rulesets.EmptyFreeform.csproj",
"Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform.Tests\\osu.Game.Rulesets.EmptyFreeform.Tests.csproj",
"Templates\\Rulesets\\ruleset-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj",
"Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform\\osu.Game.Rulesets.EmptyFreeform.csproj",
"Templates\\Rulesets\\ruleset-example\\osu.Game.Rulesets.Pippidon.Tests\\osu.Game.Rulesets.Pippidon.Tests.csproj",
"Templates\\Rulesets\\ruleset-scrolling-empty\\osu.Game.Rulesets.EmptyScrolling\\osu.Game.Rulesets.EmptyScrolling.csproj",
"Templates\\Rulesets\\ruleset-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj",
"Templates\\Rulesets\\ruleset-scrolling-empty\\osu.Game.Rulesets.EmptyScrolling.Tests\\osu.Game.Rulesets.EmptyScrolling.Tests.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon.Tests\\osu.Game.Rulesets.Pippidon.Tests.csproj"
"Templates\\Rulesets\\ruleset-scrolling-empty\\osu.Game.Rulesets.EmptyScrolling\\osu.Game.Rulesets.EmptyScrolling.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon.Tests\\osu.Game.Rulesets.Pippidon.Tests.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj"
]
}
}
}

View File

@ -122,7 +122,7 @@ namespace osu.Game.Graphics.Containers
protected override void PopIn()
{
foreach (var w in wavesContainer.Children)
foreach (var w in wavesContainer)
w.Show();
contentContainer.MoveToY(0, APPEAR_DURATION, Easing.OutQuint);
@ -132,7 +132,7 @@ namespace osu.Game.Graphics.Containers
protected override void PopOut()
{
foreach (var w in wavesContainer.Children)
foreach (var w in wavesContainer)
w.Hide();
contentContainer.MoveToY(2, DISAPPEAR_DURATION, Easing.In);

View File

@ -33,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface
Current.ValueChanged += index =>
{
foreach (var t in TabContainer.Children.OfType<BreadcrumbTabItem>())
foreach (var t in TabContainer.OfType<BreadcrumbTabItem>())
{
int tIndex = TabContainer.IndexOf(t);
int tabIndex = TabContainer.IndexOf(TabMap[index.NewValue]);

View File

@ -37,7 +37,7 @@ namespace osu.Game.Graphics.UserInterface
if (Dropdown is IHasAccentColour dropdown)
dropdown.AccentColour = value;
foreach (var i in TabContainer.Children.OfType<IHasAccentColour>())
foreach (var i in TabContainer.OfType<IHasAccentColour>())
i.AccentColour = value;
}
}
@ -48,7 +48,7 @@ namespace osu.Game.Graphics.UserInterface
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
protected virtual float StripWidth => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
protected virtual float StripWidth => TabContainer.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
/// <summary>
/// Whether entries should be automatically populated if <typeparamref name="T"/> is an <see cref="Enum"/> type.

View File

@ -101,7 +101,7 @@ namespace osu.Game.Graphics.UserInterface
public void StopAnimation()
{
animate(current);
foreach (var star in stars.Children)
foreach (var star in stars)
star.FinishTransforms(true);
}

View File

@ -63,7 +63,7 @@ namespace osu.Game.Overlays.Chat.Listing
flow.ChildrenEnumerable = newChannels.Where(c => c.Type == ChannelType.Public)
.Select(c => new ChannelListingItem(c));
foreach (var item in flow.Children)
foreach (var item in flow)
{
item.OnRequestJoin += channel => OnRequestJoin?.Invoke(channel);
item.OnRequestLeave += channel => OnRequestLeave?.Invoke(channel);

View File

@ -41,7 +41,7 @@ namespace osu.Game.Overlays
protected override bool OnHover(HoverEvent e)
{
foreach (var streamBadge in TabContainer.Children.OfType<OverlayStreamItem<T>>())
foreach (var streamBadge in TabContainer.OfType<OverlayStreamItem<T>>())
streamBadge.UserHoveringArea = true;
return base.OnHover(e);
@ -49,7 +49,7 @@ namespace osu.Game.Overlays
protected override void OnHoverLost(HoverLostEvent e)
{
foreach (var streamBadge in TabContainer.Children.OfType<OverlayStreamItem<T>>())
foreach (var streamBadge in TabContainer.OfType<OverlayStreamItem<T>>())
streamBadge.UserHoveringArea = false;
base.OnHoverLost(e);

View File

@ -343,7 +343,7 @@ namespace osu.Game.Screens.Menu
{
buttonArea.ButtonSystemState = state;
foreach (var b in buttonArea.Children.OfType<MainMenuButton>())
foreach (var b in buttonArea.OfType<MainMenuButton>())
b.ButtonSystemState = state;
}

View File

@ -64,7 +64,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
CounterFlow.Direction = convertedDirection;
foreach (var counter in CounterFlow.Children)
foreach (var counter in CounterFlow)
counter.Direction.Value = convertedDirection;
}, true);

View File

@ -242,7 +242,7 @@ namespace osu.Game.Screens.Select.Carousel
bool isSelected = Item?.State.Value == CarouselItemState.Selected;
foreach (var panel in beatmapContainer.Children)
foreach (var panel in beatmapContainer)
{
Debug.Assert(panel.Item != null);