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
1 changed files with 8 additions and 7 deletions

View File

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