1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 01:23:44 +08:00

Fix one more incorrect bindable flow and simplify string setters

This commit is contained in:
Dean Herbert 2024-01-17 17:00:30 +09:00
parent 66c7a29e79
commit 353df2f312
No known key found for this signature in database

View File

@ -2,11 +2,11 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Overlays.Profile.Header.Components;
@ -30,6 +30,8 @@ namespace osu.Game.Users
private ProfileValueDisplay globalRankDisplay = null!; private ProfileValueDisplay globalRankDisplay = null!;
private ProfileValueDisplay countryRankDisplay = null!; private ProfileValueDisplay countryRankDisplay = null!;
private readonly IBindable<UserStatistics?> statistics = new Bindable<UserStatistics?>();
public UserRankPanel(APIUser user) public UserRankPanel(APIUser user)
: base(user) : base(user)
{ {
@ -42,11 +44,12 @@ namespace osu.Game.Users
{ {
BorderColour = ColourProvider?.Light1 ?? Colours.GreyVioletLighter; BorderColour = ColourProvider?.Light1 ?? Colours.GreyVioletLighter;
api.Statistics.ValueChanged += e => statistics.BindTo(api.Statistics);
statistics.BindValueChanged(stats =>
{ {
globalRankDisplay.Content = e.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; globalRankDisplay.Content = stats.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? "-";
countryRankDisplay.Content = e.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-";
}; }, true);
} }
protected override Drawable CreateLayout() protected override Drawable CreateLayout()
@ -184,12 +187,10 @@ namespace osu.Game.Users
globalRankDisplay = new ProfileValueDisplay(true) globalRankDisplay = new ProfileValueDisplay(true)
{ {
Title = UsersStrings.ShowRankGlobalSimple, Title = UsersStrings.ShowRankGlobalSimple,
Content = User.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"
}, },
countryRankDisplay = new ProfileValueDisplay(true) countryRankDisplay = new ProfileValueDisplay(true)
{ {
Title = UsersStrings.ShowRankCountrySimple, Title = UsersStrings.ShowRankCountrySimple,
Content = User.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"
} }
} }
} }