mirror of
https://github.com/ppy/osu
synced 2025-01-31 10:22:02 +00:00
Load beatmap carousel panels asynchronously
This commit is contained in:
parent
a0488b8219
commit
2603219350
@ -11,7 +11,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -28,10 +27,8 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
public Action<BeatmapSetInfo> RestoreHiddenRequested;
|
public Action<BeatmapSetInfo> RestoreHiddenRequested;
|
||||||
|
|
||||||
private readonly SpriteText title;
|
|
||||||
private readonly SpriteText artist;
|
|
||||||
|
|
||||||
private readonly WorkingBeatmap beatmap;
|
private readonly WorkingBeatmap beatmap;
|
||||||
|
|
||||||
private readonly FillFlowContainer difficultyIcons;
|
private readonly FillFlowContainer difficultyIcons;
|
||||||
|
|
||||||
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
||||||
@ -41,6 +38,25 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
|
||||||
|
difficultyIcons = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding { Top = 5 },
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Selected()
|
||||||
|
{
|
||||||
|
base.Selected();
|
||||||
|
GainedSelection?.Invoke(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(LocalisationEngine localisation)
|
||||||
|
{
|
||||||
|
if (localisation == null)
|
||||||
|
throw new ArgumentNullException(nameof(localisation));
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new DelayedLoadWrapper(
|
new DelayedLoadWrapper(
|
||||||
@ -60,44 +76,26 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
title = new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Font = @"Exo2.0-BoldItalic",
|
Font = @"Exo2.0-BoldItalic",
|
||||||
|
Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title),
|
||||||
TextSize = 22,
|
TextSize = 22,
|
||||||
Shadow = true,
|
Shadow = true,
|
||||||
},
|
},
|
||||||
artist = new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Font = @"Exo2.0-SemiBoldItalic",
|
Font = @"Exo2.0-SemiBoldItalic",
|
||||||
|
Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist),
|
||||||
TextSize = 17,
|
TextSize = 17,
|
||||||
Shadow = true,
|
Shadow = true,
|
||||||
},
|
},
|
||||||
difficultyIcons = new FillFlowContainer
|
difficultyIcons
|
||||||
{
|
|
||||||
Margin = new MarginPadding { Top = 5 },
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Selected()
|
|
||||||
{
|
|
||||||
base.Selected();
|
|
||||||
GainedSelection?.Invoke(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(LocalisationEngine localisation)
|
|
||||||
{
|
|
||||||
if (localisation == null)
|
|
||||||
throw new ArgumentNullException(nameof(localisation));
|
|
||||||
|
|
||||||
title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title);
|
|
||||||
artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PanelBackground : BufferedContainer
|
private class PanelBackground : BufferedContainer
|
||||||
{
|
{
|
||||||
public PanelBackground(WorkingBeatmap working)
|
public PanelBackground(WorkingBeatmap working)
|
||||||
@ -185,4 +183,4 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,7 +572,18 @@ namespace osu.Game.Screens.Select
|
|||||||
// Makes sure headers are always _below_ panels,
|
// Makes sure headers are always _below_ panels,
|
||||||
// and depth flows downward.
|
// and depth flows downward.
|
||||||
panel.Depth = i + (panel is BeatmapSetHeader ? panels.Count : 0);
|
panel.Depth = i + (panel is BeatmapSetHeader ? panels.Count : 0);
|
||||||
scrollableContent.Add(panel);
|
|
||||||
|
switch (panel.LoadState)
|
||||||
|
{
|
||||||
|
case LoadState.NotLoaded:
|
||||||
|
LoadComponentAsync(panel);
|
||||||
|
break;
|
||||||
|
case LoadState.Loading:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
scrollableContent.Add(panel);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user