1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:07:25 +08:00

Add AllowCreate function

This commit is contained in:
Andrei Zavatski 2019-08-27 15:58:57 +03:00
parent 22ee7db805
commit 9a383eee1a
2 changed files with 10 additions and 1 deletions

View File

@ -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,

View File

@ -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);