mirror of
https://github.com/ppy/osu.git
synced 2025-02-07 22:53:09 +08:00
Use for
with exposed IReadOnlyList
rather than making internal container public
This commit is contained in:
parent
97a51af5a0
commit
dfe11dc68a
@ -1405,9 +1405,9 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
yield return item;
|
yield return item;
|
||||||
|
|
||||||
if (item is DrawableCarouselBeatmapSet set && set.Beatmaps?.IsLoaded == true)
|
if (item is DrawableCarouselBeatmapSet set)
|
||||||
{
|
{
|
||||||
foreach (var difficulty in set.Beatmaps)
|
foreach (var difficulty in set.DrawableBeatmaps)
|
||||||
yield return difficulty;
|
yield return difficulty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -899,12 +899,10 @@ namespace osu.Game.Screens.Select
|
|||||||
Scroll.ChangeChildDepth(item, hasPassedSelection ? -item.Item.CarouselYPosition : item.Item.CarouselYPosition);
|
Scroll.ChangeChildDepth(item, hasPassedSelection ? -item.Item.CarouselYPosition : item.Item.CarouselYPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is DrawableCarouselBeatmapSet set && set.Beatmaps?.IsLoaded == true)
|
if (item is DrawableCarouselBeatmapSet set)
|
||||||
{
|
{
|
||||||
foreach (var diff in set.Beatmaps)
|
for (int i = 0; i < set.DrawableBeatmaps.Count; i++)
|
||||||
{
|
updateItem(set.DrawableBeatmaps[i], item);
|
||||||
updateItem(diff, item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,9 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
|
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
|
||||||
|
|
||||||
public Container<DrawableCarouselItem>? Beatmaps;
|
public IReadOnlyList<DrawableCarouselItem> DrawableBeatmaps => beatmapContainer?.IsLoaded != true ? Array.Empty<DrawableCarouselItem>() : beatmapContainer;
|
||||||
|
|
||||||
|
private Container<DrawableCarouselItem>? beatmapContainer;
|
||||||
|
|
||||||
private BeatmapSetInfo beatmapSet = null!;
|
private BeatmapSetInfo beatmapSet = null!;
|
||||||
|
|
||||||
@ -124,7 +126,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
Content.Clear();
|
Content.Clear();
|
||||||
Header.Clear();
|
Header.Clear();
|
||||||
|
|
||||||
Beatmaps = null;
|
beatmapContainer = null;
|
||||||
beatmapsLoadTask = null;
|
beatmapsLoadTask = null;
|
||||||
|
|
||||||
if (Item == null)
|
if (Item == null)
|
||||||
@ -162,7 +164,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
// if we are already displaying all the correct beatmaps, only run animation updates.
|
// if we are already displaying all the correct beatmaps, only run animation updates.
|
||||||
// note that the displayed beatmaps may change due to the applied filter.
|
// note that the displayed beatmaps may change due to the applied filter.
|
||||||
// a future optimisation could add/remove only changed difficulties rather than reinitialise.
|
// a future optimisation could add/remove only changed difficulties rather than reinitialise.
|
||||||
if (Beatmaps != null && visibleBeatmaps.Length == Beatmaps.Count && visibleBeatmaps.All(b => Beatmaps.Any(c => c.Item == b)))
|
if (beatmapContainer != null && visibleBeatmaps.Length == beatmapContainer.Count && visibleBeatmaps.All(b => beatmapContainer.Any(c => c.Item == b)))
|
||||||
{
|
{
|
||||||
updateBeatmapYPositions();
|
updateBeatmapYPositions();
|
||||||
}
|
}
|
||||||
@ -171,17 +173,17 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
// on selection we show our child beatmaps.
|
// on selection we show our child beatmaps.
|
||||||
// for now this is a simple drawable construction each selection.
|
// for now this is a simple drawable construction each selection.
|
||||||
// can be improved in the future.
|
// can be improved in the future.
|
||||||
Beatmaps = new Container<DrawableCarouselItem>
|
beatmapContainer = new Container<DrawableCarouselItem>
|
||||||
{
|
{
|
||||||
X = 100,
|
X = 100,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ChildrenEnumerable = visibleBeatmaps.Select(c => c.CreateDrawableRepresentation()!)
|
ChildrenEnumerable = visibleBeatmaps.Select(c => c.CreateDrawableRepresentation()!)
|
||||||
};
|
};
|
||||||
|
|
||||||
beatmapsLoadTask = LoadComponentAsync(Beatmaps, loaded =>
|
beatmapsLoadTask = LoadComponentAsync(beatmapContainer, loaded =>
|
||||||
{
|
{
|
||||||
// make sure the pooled target hasn't changed.
|
// make sure the pooled target hasn't changed.
|
||||||
if (Beatmaps != loaded)
|
if (beatmapContainer != loaded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Content.Child = loaded;
|
Content.Child = loaded;
|
||||||
@ -242,7 +244,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
private void updateBeatmapYPositions()
|
private void updateBeatmapYPositions()
|
||||||
{
|
{
|
||||||
if (Beatmaps == null)
|
if (beatmapContainer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (beatmapsLoadTask == null || !beatmapsLoadTask.IsCompleted)
|
if (beatmapsLoadTask == null || !beatmapsLoadTask.IsCompleted)
|
||||||
@ -252,7 +254,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 Beatmaps)
|
foreach (var panel in beatmapContainer)
|
||||||
{
|
{
|
||||||
Debug.Assert(panel.Item != null);
|
Debug.Assert(panel.Item != null);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user