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

Revert "Centralise global rank display logic to new class"

Also don't show on `LoginOverlay` usage for now.
This commit is contained in:
Joseph Madamba 2024-02-19 12:11:12 -08:00
parent a03835bf1c
commit 2ff8667dd2
3 changed files with 19 additions and 55 deletions

View File

@ -1,44 +0,0 @@
// 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.
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;
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)
{
Title = UsersStrings.ShowRankGlobalSimple;
}
protected override void LoadComplete()
{
base.LoadComplete();
UserStatistics.BindValueChanged(s =>
{
Content = s.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
}, true);
// needed as `UserStatistics` 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

@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
private readonly Dictionary<ScoreRank, ScoreRankInfo> scoreRankInfos = new Dictionary<ScoreRank, ScoreRankInfo>(); private readonly Dictionary<ScoreRank, ScoreRankInfo> scoreRankInfos = new Dictionary<ScoreRank, ScoreRankInfo>();
private ProfileValueDisplay medalInfo = null!; private ProfileValueDisplay medalInfo = null!;
private ProfileValueDisplay ppInfo = null!; private ProfileValueDisplay ppInfo = null!;
private GlobalRankDisplay detailGlobalRank = null!; private ProfileValueDisplay detailGlobalRank = null!;
private ProfileValueDisplay detailCountryRank = null!; private ProfileValueDisplay detailCountryRank = null!;
private RankGraph rankGraph = null!; private RankGraph rankGraph = null!;
@ -52,7 +52,10 @@ namespace osu.Game.Overlays.Profile.Header.Components
Spacing = new Vector2(20), Spacing = new Vector2(20),
Children = new Drawable[] Children = new Drawable[]
{ {
detailGlobalRank = new GlobalRankDisplay(), detailGlobalRank = new ProfileValueDisplay(true)
{
Title = UsersStrings.ShowRankGlobalSimple,
},
detailCountryRank = new ProfileValueDisplay(true) detailCountryRank = new ProfileValueDisplay(true)
{ {
Title = UsersStrings.ShowRankCountrySimple, Title = UsersStrings.ShowRankCountrySimple,
@ -139,8 +142,14 @@ namespace osu.Game.Overlays.Profile.Header.Components
foreach (var scoreRankInfo in scoreRankInfos) foreach (var scoreRankInfo in scoreRankInfos)
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0; scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
detailGlobalRank.UserStatistics.Value = user?.Statistics; detailGlobalRank.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
detailGlobalRank.User.Value = user;
var rankHighest = user?.RankHighest;
detailGlobalRank.ContentTooltipText = rankHighest != null
? UsersStrings.ShowRankHighest(rankHighest.Rank.ToLocalisableString("\\##,##0"), rankHighest.UpdatedAt.ToLocalisableString(@"d MMM yyyy"))
: string.Empty;
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;

View File

@ -27,10 +27,10 @@ namespace osu.Game.Users
[Resolved] [Resolved]
private IAPIProvider api { get; set; } = null!; private IAPIProvider api { get; set; } = null!;
private ProfileValueDisplay globalRankDisplay = null!;
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)
@ -47,10 +47,9 @@ namespace osu.Game.Users
statistics.BindTo(api.Statistics); statistics.BindTo(api.Statistics);
statistics.BindValueChanged(stats => statistics.BindValueChanged(stats =>
{ {
globalRankDisplay.Content = stats.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? "-";
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,12 +163,12 @@ namespace osu.Game.Users
{ {
new Drawable[] new Drawable[]
{ {
new GlobalRankDisplay globalRankDisplay = new ProfileValueDisplay(true)
{ {
UserStatistics = { BindTarget = statistics }, Title = UsersStrings.ShowRankGlobalSimple,
// TODO: make highest rank update, as `api.LocalUser` doesn't update // TODO: implement highest rank tooltip
// `RankHighest` resides in `APIUser`, but `api.LocalUser` doesn't update
// maybe move to `UserStatistics` in api, so `SoloStatisticsWatcher` can update the value // maybe move to `UserStatistics` in api, so `SoloStatisticsWatcher` can update the value
User = { BindTarget = user },
}, },
countryRankDisplay = new ProfileValueDisplay(true) countryRankDisplay = new ProfileValueDisplay(true)
{ {