2019-01-24 17:43:03 +09:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-08-27 15:47:37 +03:00
|
|
|
|
using System.Collections.Generic;
|
2020-09-07 23:08:50 +03:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 19:04:31 +09:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-07-17 15:45:17 +02:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-10-24 19:20:57 +02:00
|
|
|
|
using osu.Game.Beatmaps.Drawables.Cards;
|
2019-08-27 15:47:37 +03:00
|
|
|
|
using osu.Game.Online.API;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Game.Online.API.Requests;
|
2019-08-27 15:47:37 +03:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2018-11-20 16:51:59 +09:00
|
|
|
|
using osuTK;
|
2021-11-04 18:02:44 +09:00
|
|
|
|
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
|
|
|
|
{
|
2022-11-24 14:32:20 +09:00
|
|
|
|
public partial class PaginatedBeatmapContainer : PaginatedProfileSubsection<APIBeatmapSet>
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
|
|
|
|
private const float panel_padding = 10f;
|
|
|
|
|
private readonly BeatmapSetType type;
|
|
|
|
|
|
2022-04-18 23:04:21 +03:00
|
|
|
|
protected override int InitialItemsCount => type == BeatmapSetType.Graveyard ? 2 : 6;
|
|
|
|
|
|
2023-01-10 19:24:54 +01:00
|
|
|
|
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<UserProfileData?> user, LocalisableString headerText)
|
2021-07-17 15:53:24 +02:00
|
|
|
|
: base(user, headerText)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
|
|
|
|
this.type = type;
|
2020-09-07 23:08:50 +03:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2020-09-07 23:08:50 +03:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2018-04-13 18:19:50 +09:00
|
|
|
|
ItemsContainer.Spacing = new Vector2(panel_padding);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-04 18:02:44 +09:00
|
|
|
|
protected override int GetCount(APIUser user)
|
2020-09-07 23:08:50 +03:00
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case BeatmapSetType.Favourite:
|
|
|
|
|
return user.FavouriteBeatmapsetCount;
|
|
|
|
|
|
|
|
|
|
case BeatmapSetType.Graveyard:
|
|
|
|
|
return user.GraveyardBeatmapsetCount;
|
|
|
|
|
|
|
|
|
|
case BeatmapSetType.Loved:
|
|
|
|
|
return user.LovedBeatmapsetCount;
|
|
|
|
|
|
2021-07-20 21:48:38 +02:00
|
|
|
|
case BeatmapSetType.Ranked:
|
|
|
|
|
return user.RankedBeatmapsetCount;
|
2020-09-07 23:08:50 +03:00
|
|
|
|
|
2021-07-20 21:48:38 +02:00
|
|
|
|
case BeatmapSetType.Pending:
|
|
|
|
|
return user.PendingBeatmapsetCount;
|
2020-09-07 23:08:50 +03:00
|
|
|
|
|
2022-04-22 07:55:39 +03:00
|
|
|
|
case BeatmapSetType.Guest:
|
|
|
|
|
return user.GuestBeatmapsetCount;
|
|
|
|
|
|
2022-12-06 23:36:11 -08:00
|
|
|
|
case BeatmapSetType.Nominated:
|
|
|
|
|
return user.NominatedBeatmapsetCount;
|
|
|
|
|
|
2020-09-07 23:08:50 +03:00
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-11 19:11:40 +01:00
|
|
|
|
protected override APIRequest<List<APIBeatmapSet>> CreateRequest(UserProfileData user, PaginationParameters pagination) =>
|
|
|
|
|
new GetUserBeatmapsRequest(user.User.Id, type, pagination);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2022-12-30 13:17:59 +01:00
|
|
|
|
protected override Drawable? CreateDrawableItem(APIBeatmapSet model) => model.OnlineID > 0
|
2021-12-21 08:25:52 +01:00
|
|
|
|
? new BeatmapCardNormal(model)
|
2019-08-28 13:27:44 +09:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-10-21 18:53:49 +09:00
|
|
|
|
}
|
|
|
|
|
: null;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
}
|