mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Centralise global rank display logic to new class
This commit is contained in:
parent
8d1d65a469
commit
ae89b89928
@ -0,0 +1,32 @@
|
||||
// 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.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 GlobalRankDisplay()
|
||||
: base(true)
|
||||
{
|
||||
Title = UsersStrings.ShowRankGlobalSimple;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
UserStatistics.BindValueChanged(s =>
|
||||
{
|
||||
Content = s.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
private readonly Dictionary<ScoreRank, ScoreRankInfo> scoreRankInfos = new Dictionary<ScoreRank, ScoreRankInfo>();
|
||||
private ProfileValueDisplay medalInfo = null!;
|
||||
private ProfileValueDisplay ppInfo = null!;
|
||||
private ProfileValueDisplay detailGlobalRank = null!;
|
||||
private GlobalRankDisplay detailGlobalRank = null!;
|
||||
private ProfileValueDisplay detailCountryRank = null!;
|
||||
private RankGraph rankGraph = null!;
|
||||
|
||||
@ -52,10 +52,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
Spacing = new Vector2(20),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
detailGlobalRank = new ProfileValueDisplay(true)
|
||||
{
|
||||
Title = UsersStrings.ShowRankGlobalSimple,
|
||||
},
|
||||
detailGlobalRank = new GlobalRankDisplay(),
|
||||
detailCountryRank = new ProfileValueDisplay(true)
|
||||
{
|
||||
Title = UsersStrings.ShowRankCountrySimple,
|
||||
@ -142,7 +139,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
foreach (var scoreRankInfo in scoreRankInfos)
|
||||
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
|
||||
|
||||
detailGlobalRank.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
||||
detailGlobalRank.UserStatistics.Value = user?.Statistics;
|
||||
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
||||
|
||||
rankGraph.Statistics.Value = user?.Statistics;
|
||||
|
@ -27,7 +27,6 @@ namespace osu.Game.Users
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
private ProfileValueDisplay globalRankDisplay = null!;
|
||||
private ProfileValueDisplay countryRankDisplay = null!;
|
||||
|
||||
private readonly IBindable<UserStatistics?> statistics = new Bindable<UserStatistics?>();
|
||||
@ -47,7 +46,6 @@ namespace osu.Game.Users
|
||||
statistics.BindTo(api.Statistics);
|
||||
statistics.BindValueChanged(stats =>
|
||||
{
|
||||
globalRankDisplay.Content = stats.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? "-";
|
||||
countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-";
|
||||
}, true);
|
||||
}
|
||||
@ -163,9 +161,9 @@ namespace osu.Game.Users
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
globalRankDisplay = new ProfileValueDisplay(true)
|
||||
new GlobalRankDisplay
|
||||
{
|
||||
Title = UsersStrings.ShowRankGlobalSimple,
|
||||
UserStatistics = { BindTarget = statistics },
|
||||
},
|
||||
countryRankDisplay = new ProfileValueDisplay(true)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user