1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 03:02:54 +08:00

Stop exposing CarouselItem externally

This commit is contained in:
Dean Herbert 2025-01-10 20:30:41 +09:00
parent ad04681b28
commit 6fbab1bbce
No known key found for this signature in database
2 changed files with 13 additions and 4 deletions

View File

@ -60,6 +60,8 @@ namespace osu.Game.Screens.SelectV2
return drawable;
}
protected override CarouselItem CreateCarouselItemForModel(object model) => new BeatmapCarouselItem(model);
private void beatmapSetsChanged(object? beatmaps, NotifyCollectionChangedEventArgs changed)
{
// TODO: moving management of BeatmapInfo tracking to BeatmapStore might be something we want to consider.
@ -70,7 +72,7 @@ namespace osu.Game.Screens.SelectV2
switch (changed.Action)
{
case NotifyCollectionChangedAction.Add:
Items.AddRange(newBeatmapSets!.SelectMany(s => s.Beatmaps).Select(b => new BeatmapCarouselItem(b)));
Items.AddRange(newBeatmapSets!.SelectMany(s => s.Beatmaps));
break;
case NotifyCollectionChangedAction.Remove:
@ -78,7 +80,7 @@ namespace osu.Game.Screens.SelectV2
foreach (var set in beatmapSetInfos!)
{
foreach (var beatmap in set.Beatmaps)
Items.RemoveAll(i => i.Model is BeatmapInfo bi && beatmap.Equals(bi));
Items.RemoveAll(i => i is BeatmapInfo bi && beatmap.Equals(bi));
}
break;

View File

@ -80,7 +80,7 @@ namespace osu.Game.Screens.SelectV2
/// <remarks>
/// Note that an <see cref="ICarouselFilter"/> may add new items which are displayed but not tracked in this list.
/// </remarks>
protected readonly BindableList<CarouselItem> Items = new BindableList<CarouselItem>();
protected readonly BindableList<object> Items = new BindableList<object>();
/// <summary>
/// The currently selected model.
@ -143,6 +143,13 @@ namespace osu.Game.Screens.SelectV2
/// <returns>The manifested drawable.</returns>
protected abstract Drawable GetDrawableForDisplay(CarouselItem item);
/// <summary>
/// Create an internal carousel representation for the provided model object.
/// </summary>
/// <param name="model">The model.</param>
/// <returns>A <see cref="CarouselItem"/> representing the model.</returns>
protected abstract CarouselItem CreateCarouselItemForModel(object model);
#region Filtering and display preparation
private Task filterTask = Task.CompletedTask;
@ -161,7 +168,7 @@ namespace osu.Game.Screens.SelectV2
}
Stopwatch stopwatch = Stopwatch.StartNew();
IEnumerable<CarouselItem> items = new List<CarouselItem>(Items);
IEnumerable<CarouselItem> items = new List<CarouselItem>(Items.Select(CreateCarouselItemForModel));
await Task.Run(async () =>
{