1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 17:13:06 +08:00

Use for loop and SetLayoutPosition

This commit is contained in:
Dean Herbert 2018-06-08 21:20:15 +09:00
parent 1e7bffe5e3
commit a880e626d8

View File

@ -107,16 +107,19 @@ namespace osu.Game.Overlays.Profile.Header
visibleBadge = 0; visibleBadge = 0;
badgeFlowContainer.Clear(); badgeFlowContainer.Clear();
foreach (var badge in badges) for (var index = 0; index < badges.Length; index++)
{ {
LoadComponentAsync(new DrawableBadge(badge) int displayIndex = index;
LoadComponentAsync(new DrawableBadge(badges[index])
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
}, asyncBadge => }, asyncBadge =>
{ {
badgeFlowContainer.Add(asyncBadge); badgeFlowContainer.Add(asyncBadge);
badgeFlowContainer.ChangeChildDepth(asyncBadge, Array.IndexOf(badges, asyncBadge)); //Ensure the badges are ordered correctly
// load in stable order regardless of async load order.
badgeFlowContainer.SetLayoutPosition(asyncBadge, displayIndex);
}); });
} }
} }