1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-23 12:37:30 +08:00

Implement score fetch functionality

Copied logic from `BeatmapLeaderboard`.
This commit is contained in:
Salman Alshamrani
2025-04-18 05:43:47 -04:00
Unverified
parent 34e8943c74
commit 81d54a9f32
2 changed files with 23 additions and 7 deletions
@@ -182,8 +182,6 @@ namespace osu.Game.Tests.Visual.SongSelectV2
}
[Test]
[Ignore("Pending implementation")]
// todo: add score fetch functionality to BeatmapLeaderboardWedge
public void TestLocalScoresDisplay()
{
BeatmapInfo beatmapInfo = null!;
@@ -212,8 +210,6 @@ namespace osu.Game.Tests.Visual.SongSelectV2
}
[Test]
[Ignore("Pending implementation")]
// todo: add score fetch functionality to BeatmapLeaderboardWedge
public void TestLocalScoresDisplayOnBeatmapEdit()
{
BeatmapInfo beatmapInfo = null!;
@@ -7,7 +7,6 @@ using System.Linq;
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@@ -43,6 +42,9 @@ namespace osu.Game.Screens.SelectV2
private Container<Placeholder> placeholderContainer = null!;
private Placeholder? placeholder;
[Resolved]
private LeaderboardManager leaderboardManager { get; set; } = null!;
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
@@ -66,6 +68,8 @@ namespace osu.Game.Screens.SelectV2
private CancellationTokenSource? cancellationTokenSource;
private readonly Bindable<LeaderboardScores?> fetchedScores = new Bindable<LeaderboardScores?>();
[BackgroundDependencyLoader]
private void load()
{
@@ -142,6 +146,8 @@ namespace osu.Game.Screens.SelectV2
loading = new LoadingLayer(),
}
};
((IBindable<LeaderboardScores?>)fetchedScores).BindTo(leaderboardManager.Scores);
}
protected override void LoadComplete()
@@ -217,8 +223,22 @@ namespace osu.Game.Screens.SelectV2
return;
}
// todo: missing implementation
SetScores(Array.Empty<ScoreInfo>(), null);
leaderboardManager.FetchWithCriteriaAsync(new LeaderboardCriteria(fetchBeatmapInfo, fetchRuleset, Scope.Value, FilterBySelectedMods.Value ? mods.Value.ToArray() : null))
.ContinueWith(t =>
{
if (t.Exception != null && !t.IsCanceled)
{
Schedule(() => SetState(LeaderboardState.NetworkFailure));
return;
}
fetchedScores.UnbindEvents();
fetchedScores.BindValueChanged(scores =>
{
if (scores.NewValue != null)
Schedule(() => SetScores(scores.NewValue.TopScores, scores.NewValue.UserScore));
}, true);
});
}
protected void SetScores(IEnumerable<ScoreInfo> scores, ScoreInfo? userScore)