1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 01:02:56 +08:00

Integration into overlay

This commit is contained in:
Andrei Zavatski 2019-12-17 12:36:44 +03:00
parent 8cd96acffc
commit 023892738a
4 changed files with 77 additions and 3 deletions

View File

@ -38,5 +38,27 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
};
protected override int GetCount(User user)
{
switch (type)
{
default:
case BeatmapSetType.Favourite:
return user.FavouriteBeatmapsetCount;
case BeatmapSetType.Graveyard:
return user.GraveyardBeatmapsetCount;
case BeatmapSetType.Loved:
return user.LovedBeatmapsetCount;
case BeatmapSetType.RankedAndApproved:
return user.RankedAndApprovedBeatmapsetCount;
case BeatmapSetType.Unranked:
return user.UnrankedBeatmapsetCount;
}
}
}
}

View File

@ -23,6 +23,7 @@ namespace osu.Game.Overlays.Profile.Sections
private readonly OsuSpriteText missingText;
private APIRequest<List<TModel>> retrievalRequest;
private CancellationTokenSource loadCancellation;
private readonly BindableInt count = new BindableInt();
[Resolved]
private IAPIProvider api { get; set; }
@ -44,11 +45,28 @@ namespace osu.Game.Overlays.Profile.Sections
Children = new Drawable[]
{
new OsuSpriteText
new FillFlowContainer
{
Text = header,
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Margin = new MarginPadding { Top = 10, Bottom = 10 },
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = header,
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
},
new CounterPill
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Current = { BindTarget = count }
}
}
},
ItemsContainer = new FillFlowContainer
{
@ -90,6 +108,8 @@ namespace osu.Game.Overlays.Profile.Sections
VisiblePages = 0;
ItemsContainer.Clear();
count.Value = GetCount(e.NewValue);
if (e.NewValue != null)
showMore();
}
@ -124,6 +144,8 @@ namespace osu.Game.Overlays.Profile.Sections
}, loadCancellation.Token);
});
protected virtual int GetCount(User user) => 0;
protected abstract APIRequest<List<TModel>> CreateRequest();
protected abstract Drawable CreateDrawableItem(TModel model);

View File

@ -32,6 +32,18 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
protected override APIRequest<List<APILegacyScoreInfo>> CreateRequest() =>
new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
protected override int GetCount(User user)
{
switch (type)
{
default:
return 0;
case ScoreType.Firsts:
return user.ScoresFirstCount;
}
}
protected override Drawable CreateDrawableItem(APILegacyScoreInfo model)
{
switch (type)

View File

@ -126,6 +126,24 @@ namespace osu.Game.Users
[JsonProperty(@"follower_count")]
public int FollowerCount;
[JsonProperty(@"favourite_beatmapset_count")]
public int FavouriteBeatmapsetCount;
[JsonProperty(@"graveyard_beatmapset_count")]
public int GraveyardBeatmapsetCount;
[JsonProperty(@"loved_beatmapset_count")]
public int LovedBeatmapsetCount;
[JsonProperty(@"ranked_and_approved_beatmapset_count")]
public int RankedAndApprovedBeatmapsetCount;
[JsonProperty(@"unranked_beatmapset_count")]
public int UnrankedBeatmapsetCount;
[JsonProperty(@"scores_first_count")]
public int ScoresFirstCount;
[JsonProperty]
private string[] playstyle
{