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

Add support for song select leaderboard to handle newly imported scores

This commit is contained in:
Dean Herbert 2021-06-14 14:20:23 +09:00
parent ebe850fe9f
commit 8dd48d48f6
2 changed files with 23 additions and 4 deletions

View File

@ -44,9 +44,9 @@ namespace osu.Game.Online.Leaderboards
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
private IEnumerable<TScoreInfo> scores; private ICollection<TScoreInfo> scores;
public IEnumerable<TScoreInfo> Scores public ICollection<TScoreInfo> Scores
{ {
get => scores; get => scores;
set set
@ -290,7 +290,7 @@ namespace osu.Game.Online.Leaderboards
getScoresRequest = FetchScores(scores => Schedule(() => getScoresRequest = FetchScores(scores => Schedule(() =>
{ {
Scores = scores; Scores = scores.ToArray();
PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
})); }));

View File

@ -44,6 +44,8 @@ namespace osu.Game.Screens.Select.Leaderboards
private IBindable<WeakReference<ScoreInfo>> itemRemoved; private IBindable<WeakReference<ScoreInfo>> itemRemoved;
private IBindable<WeakReference<ScoreInfo>> itemAdded;
/// <summary> /// <summary>
/// Whether to apply the game's currently selected mods as a filter when retrieving scores. /// Whether to apply the game's currently selected mods as a filter when retrieving scores.
/// </summary> /// </summary>
@ -85,6 +87,9 @@ namespace osu.Game.Screens.Select.Leaderboards
itemRemoved = scoreManager.ItemRemoved.GetBoundCopy(); itemRemoved = scoreManager.ItemRemoved.GetBoundCopy();
itemRemoved.BindValueChanged(onScoreRemoved); itemRemoved.BindValueChanged(onScoreRemoved);
itemAdded = scoreManager.ItemUpdated.GetBoundCopy();
itemAdded.BindValueChanged(onScoreAdded);
} }
protected override void Reset() protected override void Reset()
@ -93,7 +98,21 @@ namespace osu.Game.Screens.Select.Leaderboards
TopScore = null; TopScore = null;
} }
private void onScoreRemoved(ValueChangedEvent<WeakReference<ScoreInfo>> score) => Schedule(RefreshScores); private void onScoreRemoved(ValueChangedEvent<WeakReference<ScoreInfo>> score)
{
if (Scope != BeatmapLeaderboardScope.Local)
return;
Scheduler.AddOnce(RefreshScores);
}
private void onScoreAdded(ValueChangedEvent<WeakReference<ScoreInfo>> score)
{
if (Scope != BeatmapLeaderboardScope.Local)
return;
Scheduler.AddOnce(RefreshScores);
}
protected override bool IsOnlineScope => Scope != BeatmapLeaderboardScope.Local; protected override bool IsOnlineScope => Scope != BeatmapLeaderboardScope.Local;