2020-05-26 16:00:41 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2024-01-29 15:13:30 +08:00
|
|
|
using System.Diagnostics;
|
2020-05-26 16:00:41 +08:00
|
|
|
using osu.Framework.Allocation;
|
2020-06-03 10:06:47 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2023-10-26 21:09:59 +08:00
|
|
|
using osu.Game.Extensions;
|
2020-05-26 16:00:41 +08:00
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.API.Requests;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Ranking
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class SoloResultsScreen : ResultsScreen
|
2020-05-26 16:00:41 +08:00
|
|
|
{
|
2022-12-28 14:49:09 +08:00
|
|
|
private GetScoresRequest? getScoreRequest;
|
2021-02-24 18:54:52 +08:00
|
|
|
|
2020-05-26 16:00:41 +08:00
|
|
|
[Resolved]
|
2022-12-28 14:49:09 +08:00
|
|
|
private RulesetStore rulesets { get; set; } = null!;
|
2020-05-26 16:00:41 +08:00
|
|
|
|
2024-02-23 02:15:02 +08:00
|
|
|
public SoloResultsScreen(ScoreInfo score)
|
|
|
|
: base(score)
|
2020-05-26 16:00:41 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-04-25 15:52:26 +08:00
|
|
|
protected override APIRequest? FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
|
2020-05-26 16:00:41 +08:00
|
|
|
{
|
2024-01-29 15:13:30 +08:00
|
|
|
Debug.Assert(Score != null);
|
|
|
|
|
2023-07-04 13:50:34 +08:00
|
|
|
if (Score.BeatmapInfo!.OnlineID <= 0 || Score.BeatmapInfo.Status <= BeatmapOnlineStatus.Pending)
|
2020-06-03 10:06:47 +08:00
|
|
|
return null;
|
|
|
|
|
2021-10-04 16:35:53 +08:00
|
|
|
getScoreRequest = new GetScoresRequest(Score.BeatmapInfo, Score.Ruleset);
|
2025-02-10 19:13:46 +08:00
|
|
|
getScoreRequest.Success += r =>
|
|
|
|
{
|
|
|
|
var toDisplay = new List<ScoreInfo>();
|
|
|
|
|
|
|
|
for (int i = 0; i < r.Scores.Count; ++i)
|
|
|
|
{
|
|
|
|
var score = r.Scores[i];
|
|
|
|
int position = i + 1;
|
|
|
|
|
|
|
|
if (score.MatchesOnlineID(Score))
|
|
|
|
{
|
|
|
|
// we don't want to add the same score twice, but also setting any properties of `Score` this late will have no visible effect,
|
|
|
|
// so we have to fish out the actual drawable panel and set the position to it directly.
|
|
|
|
var panel = ScorePanelList.GetPanelForScore(Score);
|
|
|
|
Score.Position = panel.ScorePosition.Value = position;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var converted = score.ToScoreInfo(rulesets, Beatmap.Value.BeatmapInfo);
|
|
|
|
converted.Position = position;
|
|
|
|
toDisplay.Add(converted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scoresCallback.Invoke(toDisplay);
|
|
|
|
};
|
2021-02-24 18:54:52 +08:00
|
|
|
return getScoreRequest;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
getScoreRequest?.Cancel();
|
2020-05-26 16:00:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|