mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 09:03:01 +08:00
Add highest rank tooltip to global rank display
This commit is contained in:
parent
ae89b89928
commit
ffd0d9bb39
@ -4,6 +4,7 @@
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
public partial class GlobalRankDisplay : ProfileValueDisplay
|
public partial class GlobalRankDisplay : ProfileValueDisplay
|
||||||
{
|
{
|
||||||
public readonly Bindable<UserStatistics?> UserStatistics = new Bindable<UserStatistics?>();
|
public readonly Bindable<UserStatistics?> UserStatistics = new Bindable<UserStatistics?>();
|
||||||
|
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
|
||||||
|
|
||||||
public GlobalRankDisplay()
|
public GlobalRankDisplay()
|
||||||
: base(true)
|
: base(true)
|
||||||
@ -27,6 +29,16 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
{
|
{
|
||||||
Content = s.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
Content = s.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
||||||
}, true);
|
}, 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
|
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
|
||||||
|
|
||||||
detailGlobalRank.UserStatistics.Value = user?.Statistics;
|
detailGlobalRank.UserStatistics.Value = user?.Statistics;
|
||||||
|
detailGlobalRank.User.Value = user;
|
||||||
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
||||||
|
|
||||||
rankGraph.Statistics.Value = user?.Statistics;
|
rankGraph.Statistics.Value = user?.Statistics;
|
||||||
|
@ -30,6 +30,7 @@ namespace osu.Game.Users
|
|||||||
private ProfileValueDisplay countryRankDisplay = null!;
|
private ProfileValueDisplay countryRankDisplay = null!;
|
||||||
|
|
||||||
private readonly IBindable<UserStatistics?> statistics = new Bindable<UserStatistics?>();
|
private readonly IBindable<UserStatistics?> statistics = new Bindable<UserStatistics?>();
|
||||||
|
private readonly IBindable<APIUser?> user = new Bindable<APIUser?>();
|
||||||
|
|
||||||
public UserRankPanel(APIUser user)
|
public UserRankPanel(APIUser user)
|
||||||
: base(user)
|
: base(user)
|
||||||
@ -48,6 +49,8 @@ namespace osu.Game.Users
|
|||||||
{
|
{
|
||||||
countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-";
|
countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-";
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
user.BindTo(api.LocalUser!);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable CreateLayout()
|
protected override Drawable CreateLayout()
|
||||||
@ -164,6 +167,9 @@ namespace osu.Game.Users
|
|||||||
new GlobalRankDisplay
|
new GlobalRankDisplay
|
||||||
{
|
{
|
||||||
UserStatistics = { BindTarget = statistics },
|
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)
|
countryRankDisplay = new ProfileValueDisplay(true)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user