mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 09:42:54 +08:00
Update paginated profile subsections to display items inline with web
This commit is contained in:
parent
9d59cd408f
commit
f08449e432
@ -20,11 +20,12 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
||||
private const float panel_padding = 10f;
|
||||
private readonly BeatmapSetType type;
|
||||
|
||||
protected override int InitialItemsCount => type == BeatmapSetType.Graveyard ? 2 : 6;
|
||||
|
||||
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<APIUser> user, LocalisableString headerText)
|
||||
: base(user, headerText)
|
||||
{
|
||||
this.type = type;
|
||||
ItemsPerPage = 6;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -57,8 +58,8 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
||||
}
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIBeatmapSet>> CreateRequest() =>
|
||||
new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
||||
protected override APIRequest<List<APIBeatmapSet>> CreateRequest(int itemsPerPage, int initialItems) =>
|
||||
new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, itemsPerPage, initialItems);
|
||||
|
||||
protected override Drawable CreateDrawableItem(APIBeatmapSet model) => model.OnlineID > 0
|
||||
? new BeatmapCardNormal(model)
|
||||
|
@ -19,7 +19,6 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
public PaginatedMostPlayedBeatmapContainer(Bindable<APIUser> user)
|
||||
: base(user, UsersStrings.ShowExtraHistoricalMostPlayedTitle)
|
||||
{
|
||||
ItemsPerPage = 5;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -30,8 +29,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
|
||||
protected override int GetCount(APIUser user) => user.BeatmapPlayCountsCount;
|
||||
|
||||
protected override APIRequest<List<APIUserMostPlayedBeatmap>> CreateRequest() =>
|
||||
new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
|
||||
protected override APIRequest<List<APIUserMostPlayedBeatmap>> CreateRequest(int itemsPerPage, int initialItems) =>
|
||||
new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++, itemsPerPage, initialItems);
|
||||
|
||||
protected override Drawable CreateDrawableItem(APIUserMostPlayedBeatmap mostPlayed) =>
|
||||
new DrawableMostPlayedBeatmap(mostPlayed);
|
||||
|
@ -17,11 +17,10 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
|
||||
public PaginatedKudosuHistoryContainer(Bindable<APIUser> user)
|
||||
: base(user, missingText: UsersStrings.ShowExtraKudosuEntryEmpty)
|
||||
{
|
||||
ItemsPerPage = 5;
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIKudosuHistory>> CreateRequest()
|
||||
=> new GetUserKudosuHistoryRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
|
||||
protected override APIRequest<List<APIKudosuHistory>> CreateRequest(int itemsPerPage, int initialItems)
|
||||
=> new GetUserKudosuHistoryRequest(User.Value.Id, VisiblePages++, itemsPerPage, initialItems);
|
||||
|
||||
protected override Drawable CreateDrawableItem(APIKudosuHistory item) => new DrawableKudosuHistoryItem(item);
|
||||
}
|
||||
|
@ -21,11 +21,20 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public abstract class PaginatedProfileSubsection<TModel> : ProfileSubsection
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of items displayed per page.
|
||||
/// </summary>
|
||||
protected virtual int ItemsPerPage => 50;
|
||||
|
||||
/// <summary>
|
||||
/// The number of items displayed initially.
|
||||
/// </summary>
|
||||
protected virtual int InitialItemsCount => 5;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
protected int VisiblePages;
|
||||
protected int ItemsPerPage;
|
||||
|
||||
protected ReverseChildIDFillFlowContainer<Drawable> ItemsContainer { get; private set; }
|
||||
|
||||
@ -101,7 +110,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
loadCancellation = new CancellationTokenSource();
|
||||
|
||||
retrievalRequest = CreateRequest();
|
||||
retrievalRequest = CreateRequest(ItemsPerPage, InitialItemsCount);
|
||||
retrievalRequest.Success += UpdateItems;
|
||||
|
||||
api.Queue(retrievalRequest);
|
||||
@ -125,7 +134,9 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
LoadComponentsAsync(items.Select(CreateDrawableItem).Where(d => d != null), drawables =>
|
||||
{
|
||||
missing.Hide();
|
||||
moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0);
|
||||
|
||||
int maxCount = VisiblePages == 1 ? InitialItemsCount : ItemsPerPage;
|
||||
moreButton.FadeTo(items.Count == maxCount ? 1 : 0);
|
||||
moreButton.IsLoading = false;
|
||||
|
||||
ItemsContainer.AddRange(drawables);
|
||||
@ -138,7 +149,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract APIRequest<List<TModel>> CreateRequest();
|
||||
protected abstract APIRequest<List<TModel>> CreateRequest(int itemsPerPage, int initialItems);
|
||||
|
||||
protected abstract Drawable CreateDrawableItem(TModel model);
|
||||
|
||||
|
@ -23,8 +23,6 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
: base(user, headerText)
|
||||
{
|
||||
this.type = type;
|
||||
|
||||
ItemsPerPage = 5;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -62,8 +60,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
base.OnItemsReceived(items);
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIScore>> CreateRequest() =>
|
||||
new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
||||
protected override APIRequest<List<APIScore>> CreateRequest(int itemsPerPage, int initialItems) =>
|
||||
new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, itemsPerPage, initialItems);
|
||||
|
||||
private int drawableItemIndex;
|
||||
|
||||
|
@ -19,7 +19,6 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
public PaginatedRecentActivityContainer(Bindable<APIUser> user)
|
||||
: base(user, missingText: EventsStrings.Empty)
|
||||
{
|
||||
ItemsPerPage = 10;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -28,8 +27,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
ItemsContainer.Spacing = new Vector2(0, 8);
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIRecentActivity>> CreateRequest() =>
|
||||
new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
|
||||
protected override APIRequest<List<APIRecentActivity>> CreateRequest(int itemsPerPage, int initialItems) =>
|
||||
new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++, itemsPerPage, initialItems);
|
||||
|
||||
protected override Drawable CreateDrawableItem(APIRecentActivity model) => new DrawableRecentActivity(model);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user