mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 17:17:24 +08:00
Add safeties to beatmap panel loading code
This commit is contained in:
parent
954d43ef56
commit
3cfc0dc82d
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -78,6 +79,9 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
base.UpdateItem();
|
base.UpdateItem();
|
||||||
|
|
||||||
|
beatmapContainer.Clear();
|
||||||
|
beatmapSetState?.UnbindAll();
|
||||||
|
|
||||||
Content.Children = new Drawable[]
|
Content.Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new DelayedLoadUnloadWrapper(() =>
|
new DelayedLoadUnloadWrapper(() =>
|
||||||
@ -145,8 +149,6 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
}, 100, 5000)
|
}, 100, 5000)
|
||||||
};
|
};
|
||||||
|
|
||||||
beatmapContainer.Clear();
|
|
||||||
|
|
||||||
beatmapSetState = Item.State.GetBoundCopy();
|
beatmapSetState = Item.State.GetBoundCopy();
|
||||||
beatmapSetState.BindValueChanged(setSelected, true);
|
beatmapSetState.BindValueChanged(setSelected, true);
|
||||||
}
|
}
|
||||||
@ -156,14 +158,16 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
switch (obj.NewValue)
|
switch (obj.NewValue)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
beatmapContainer.Clear();
|
foreach (var beatmap in beatmapContainer)
|
||||||
|
beatmap.FadeOut(50).Expire();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CarouselItemState.Selected:
|
case CarouselItemState.Selected:
|
||||||
|
|
||||||
var carouselBeatmapSet = (CarouselBeatmapSet)Item;
|
var carouselBeatmapSet = (CarouselBeatmapSet)Item;
|
||||||
|
|
||||||
LoadComponentsAsync(carouselBeatmapSet.Children.Select(c => c.CreateDrawableRepresentation()), loaded =>
|
// ToArray() in this line is required due to framework oversight: https://github.com/ppy/osu-framework/pull/3929
|
||||||
|
LoadComponentsAsync(carouselBeatmapSet.Children.Select(c => c.CreateDrawableRepresentation()).ToArray(), loaded =>
|
||||||
{
|
{
|
||||||
// make sure the pooled target hasn't changed.
|
// make sure the pooled target hasn't changed.
|
||||||
if (carouselBeatmapSet != Item)
|
if (carouselBeatmapSet != Item)
|
||||||
@ -175,9 +179,9 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
item.Y = yPos;
|
item.Y = yPos;
|
||||||
yPos += item.Item.TotalHeight;
|
yPos += item.Item.TotalHeight;
|
||||||
|
|
||||||
beatmapContainer.Add(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beatmapContainer.ChildrenEnumerable = loaded;
|
||||||
});
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user