mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Optimise carousel memory usage by unloading off-screen panels
This commit is contained in:
@ -30,6 +30,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
private DialogOverlay dialogOverlay;
|
||||
private readonly BeatmapSetInfo beatmapSet;
|
||||
private DelayedLoadUnloadWrapper delayed;
|
||||
|
||||
public DrawableCarouselBeatmapSet(CarouselBeatmapSet set)
|
||||
: base(set)
|
||||
@ -37,6 +38,10 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
beatmapSet = set.BeatmapSet;
|
||||
}
|
||||
|
||||
public override bool CanBeRemoved => delayed?.DelayedLoadCompleted != true;
|
||||
|
||||
protected override bool RequiresChildrenUpdate => true;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(LocalisationEngine localisation, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay, DialogOverlay overlay)
|
||||
{
|
||||
@ -50,12 +55,12 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DelayedLoadWrapper(
|
||||
delayed = new DelayedLoadUnloadWrapper(() =>
|
||||
new PanelBackground(manager.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault()))
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
OnLoadComplete = d => d.FadeInFromZero(1000, Easing.OutQuint),
|
||||
}, 300
|
||||
}, 300, 5000
|
||||
),
|
||||
new FillFlowContainer
|
||||
{
|
||||
|
@ -24,6 +24,11 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
public override bool IsPresent => base.IsPresent || Item.Visible;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this item can be removed from the scroll container (usually due to being off-screen).
|
||||
/// </summary>
|
||||
public virtual bool CanBeRemoved => true;
|
||||
|
||||
public readonly CarouselItem Item;
|
||||
|
||||
private Container nestedContainer;
|
||||
@ -86,7 +91,13 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
public void SetMultiplicativeAlpha(float alpha) => borderContainer.Alpha = alpha;
|
||||
protected bool VisibleInCarousel;
|
||||
|
||||
public void SetMultiplicativeAlpha(float alpha)
|
||||
{
|
||||
borderContainer.Alpha = alpha;
|
||||
VisibleInCarousel = alpha > 0;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
|
Reference in New Issue
Block a user