mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 08:12:56 +08: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() =>
|
protected override APIRequest<List<APIBeatmapSet>> CreateRequest() =>
|
||||||
new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
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))
|
protected override Drawable CreateDrawableItem(APIBeatmapSet item) => new DirectGridPanel(item.ToBeatmapSet(Rulesets))
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadComponentsAsync(items.Select(CreateDrawableItem), drawables =>
|
LoadComponentsAsync(items.Where(item => AllowCreate(item)).Select(CreateDrawableItem), drawables =>
|
||||||
{
|
{
|
||||||
missingText.Hide();
|
missingText.Hide();
|
||||||
moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0);
|
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 APIRequest<List<T>> CreateRequest();
|
||||||
|
|
||||||
protected abstract Drawable CreateDrawableItem(T item);
|
protected abstract Drawable CreateDrawableItem(T item);
|
||||||
|
Loading…
Reference in New Issue
Block a user