1
0
mirror of https://github.com/ppy/osu.git synced 2024-05-14 14:40:23 +08:00

Avoid using .Children for enumeration in other locations

This commit is contained in:
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.Tests\\osu.Game.Tournament.Tests.csproj",
"osu.Game.Tournament\\osu.Game.Tournament.csproj", "osu.Game.Tournament\\osu.Game.Tournament.csproj",
"osu.Game\\osu.Game.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-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-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-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-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.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() protected override void PopIn()
{ {
foreach (var w in wavesContainer.Children) foreach (var w in wavesContainer)
w.Show(); w.Show();
contentContainer.MoveToY(0, APPEAR_DURATION, Easing.OutQuint); contentContainer.MoveToY(0, APPEAR_DURATION, Easing.OutQuint);
@ -132,7 +132,7 @@ namespace osu.Game.Graphics.Containers
protected override void PopOut() protected override void PopOut()
{ {
foreach (var w in wavesContainer.Children) foreach (var w in wavesContainer)
w.Hide(); w.Hide();
contentContainer.MoveToY(2, DISAPPEAR_DURATION, Easing.In); contentContainer.MoveToY(2, DISAPPEAR_DURATION, Easing.In);

View File

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

View File

@ -37,7 +37,7 @@ namespace osu.Game.Graphics.UserInterface
if (Dropdown is IHasAccentColour dropdown) if (Dropdown is IHasAccentColour dropdown)
dropdown.AccentColour = value; dropdown.AccentColour = value;
foreach (var i in TabContainer.Children.OfType<IHasAccentColour>()) foreach (var i in TabContainer.OfType<IHasAccentColour>())
i.AccentColour = value; i.AccentColour = value;
} }
} }
@ -48,7 +48,7 @@ namespace osu.Game.Graphics.UserInterface
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value); 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> /// <summary>
/// Whether entries should be automatically populated if <typeparamref name="T"/> is an <see cref="Enum"/> type. /// 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() public void StopAnimation()
{ {
animate(current); animate(current);
foreach (var star in stars.Children) foreach (var star in stars)
star.FinishTransforms(true); star.FinishTransforms(true);
} }

View File

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

View File

@ -41,7 +41,7 @@ namespace osu.Game.Overlays
protected override bool OnHover(HoverEvent e) 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; streamBadge.UserHoveringArea = true;
return base.OnHover(e); return base.OnHover(e);
@ -49,7 +49,7 @@ namespace osu.Game.Overlays
protected override void OnHoverLost(HoverLostEvent e) 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; streamBadge.UserHoveringArea = false;
base.OnHoverLost(e); base.OnHoverLost(e);

View File

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

View File

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

View File

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