Fix displayed scores in gameplay leaderboard not tracking display mode changes

This commit is contained in:
Dean Herbert 2022-09-14 14:02:35 +09:00
parent 81b5e4a865
commit 8a6977213a
1 changed files with 15 additions and 3 deletions

View File

@ -18,9 +18,15 @@ public class SoloGameplayLeaderboard : GameplayLeaderboard
private readonly IBindableList<ScoreInfo> scores = new BindableList<ScoreInfo>();
// hold references to ensure bindables are updated.
private readonly List<Bindable<long>> scoreBindables = new List<Bindable<long>>();
[Resolved]
private ScoreProcessor scoreProcessor { get; set; } = null!;
[Resolved]
private ScoreManager scoreManager { get; set; } = null!;
public SoloGameplayLeaderboard(IUser trackingUser)
{
this.trackingUser = trackingUser;
@ -32,12 +38,13 @@ private void load(ILeaderboardScoreSource? scoreSource)
if (scoreSource != null)
scores.BindTo(scoreSource.Scores);
scores.BindCollectionChanged((_, __) => Scheduler.AddOnce(showScores, scores), true);
scores.BindCollectionChanged((_, _) => Scheduler.AddOnce(showScores), true);
}
private void showScores(IEnumerable<IScoreInfo> scores)
private void showScores()
{
Clear();
scoreBindables.Clear();
if (!scores.Any())
return;
@ -52,7 +59,12 @@ private void showScores(IEnumerable<IScoreInfo> scores)
{
var score = Add(s.User, false);
score.TotalScore.Value = s.TotalScore;
var bindableTotal = scoreManager.GetBindableTotalScore(s);
// Direct binding not possible due to differing types (see https://github.com/ppy/osu/issues/20298).
bindableTotal.BindValueChanged(total => score.TotalScore.Value = total.NewValue, true);
scoreBindables.Add(bindableTotal);
score.Accuracy.Value = s.Accuracy;
score.Combo.Value = s.MaxCombo;
}