mirror of
https://github.com/ppy/osu
synced 2024-12-15 11:25:29 +00:00
Add AllowCreate function
This commit is contained in:
parent
22ee7db805
commit
9a383eee1a
@ -31,6 +31,8 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
||||
protected override APIRequest<List<APIBeatmapSet>> CreateRequest() =>
|
||||
new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
||||
|
||||
protected override bool AllowCreate(APIBeatmapSet item) => item.OnlineBeatmapSetID.HasValue;
|
||||
|
||||
protected override Drawable CreateDrawableItem(APIBeatmapSet item) => new DirectGridPanel(item.ToBeatmapSet(Rulesets))
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
return;
|
||||
}
|
||||
|
||||
LoadComponentsAsync(items.Select(CreateDrawableItem), drawables =>
|
||||
LoadComponentsAsync(items.Where(item => AllowCreate(item)).Select(CreateDrawableItem), drawables =>
|
||||
{
|
||||
missingText.Hide();
|
||||
moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0);
|
||||
@ -127,6 +127,13 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to check whether the item is suitable for drawable creation.
|
||||
/// </summary>
|
||||
/// <param name="item">An item to check</param>
|
||||
/// <returns></returns>
|
||||
protected virtual bool AllowCreate(T item) => true;
|
||||
|
||||
protected abstract APIRequest<List<T>> CreateRequest();
|
||||
|
||||
protected abstract Drawable CreateDrawableItem(T item);
|
||||
|
Loading…
Reference in New Issue
Block a user