1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Add highest rank tooltip to global rank display

This commit is contained in:
Joseph Madamba 2024-02-09 15:36:15 -08:00
parent ae89b89928
commit ffd0d9bb39
3 changed files with 19 additions and 0 deletions

View File

@ -4,6 +4,7 @@
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users;
@ -12,6 +13,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
public partial class GlobalRankDisplay : ProfileValueDisplay
{
public readonly Bindable<UserStatistics?> UserStatistics = new Bindable<UserStatistics?>();
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public GlobalRankDisplay()
: base(true)
@ -27,6 +29,16 @@ namespace osu.Game.Overlays.Profile.Header.Components
{
Content = s.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
}, true);
// needed as statistics doesn't populate User
User.BindValueChanged(u =>
{
var rankHighest = u.NewValue?.RankHighest;
ContentTooltipText = rankHighest != null
? UsersStrings.ShowRankHighest(rankHighest.Rank.ToLocalisableString("\\##,##0"), rankHighest.UpdatedAt.ToLocalisableString(@"d MMM yyyy"))
: string.Empty;
}, true);
}
}
}

View File

@ -140,6 +140,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
detailGlobalRank.UserStatistics.Value = user?.Statistics;
detailGlobalRank.User.Value = user;
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
rankGraph.Statistics.Value = user?.Statistics;

View File

@ -30,6 +30,7 @@ namespace osu.Game.Users
private ProfileValueDisplay countryRankDisplay = null!;
private readonly IBindable<UserStatistics?> statistics = new Bindable<UserStatistics?>();
private readonly IBindable<APIUser?> user = new Bindable<APIUser?>();
public UserRankPanel(APIUser user)
: base(user)
@ -48,6 +49,8 @@ namespace osu.Game.Users
{
countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-";
}, true);
user.BindTo(api.LocalUser!);
}
protected override Drawable CreateLayout()
@ -164,6 +167,9 @@ namespace osu.Game.Users
new GlobalRankDisplay
{
UserStatistics = { BindTarget = statistics },
// TODO: make highest rank update, as api.LocalUser doesn't update
// maybe move to statistics in api, so `SoloStatisticsWatcher` can update the value
User = { BindTarget = user },
},
countryRankDisplay = new ProfileValueDisplay(true)
{