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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-05-26 16:00:41 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
2022-12-24 17:58:38 +08:00
|
|
|
using osu.Framework.Bindables;
|
2020-06-03 10:06:47 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2020-05-26 16:00:41 +08:00
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.API.Requests;
|
2022-12-24 17:58:38 +08:00
|
|
|
using osu.Game.Online.Solo;
|
2020-05-26 16:00:41 +08:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Scoring;
|
2022-12-24 17:58:38 +08:00
|
|
|
using osu.Game.Screens.Ranking.Statistics;
|
2020-05-26 16:00:41 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Ranking
|
|
|
|
{
|
|
|
|
public partial class SoloResultsScreen : ResultsScreen
|
|
|
|
{
|
2022-12-27 06:25:54 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether the user's personal statistics should be shown on the extended statistics panel
|
|
|
|
/// after clicking the score panel associated with the <see cref="ResultsScreen.Score"/> being presented.
|
|
|
|
/// </summary>
|
|
|
|
public bool ShowUserStatistics { get; init; }
|
|
|
|
|
2021-02-24 18:54:52 +08:00
|
|
|
private GetScoresRequest getScoreRequest;
|
|
|
|
|
2020-05-26 16:00:41 +08:00
|
|
|
[Resolved]
|
|
|
|
private RulesetStore rulesets { get; set; }
|
|
|
|
|
2022-12-24 17:58:38 +08:00
|
|
|
[Resolved]
|
|
|
|
private SoloStatisticsWatcher soloStatisticsWatcher { get; set; }
|
|
|
|
|
|
|
|
private readonly Bindable<SoloStatisticsUpdate> statisticsUpdate = new Bindable<SoloStatisticsUpdate>();
|
|
|
|
|
2020-11-20 13:35:44 +08:00
|
|
|
public SoloResultsScreen(ScoreInfo score, bool allowRetry)
|
2020-05-26 16:00:41 +08:00
|
|
|
: base(score, allowRetry)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-24 17:58:38 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-12-27 06:25:54 +08:00
|
|
|
if (ShowUserStatistics)
|
|
|
|
soloStatisticsWatcher.RegisterForStatisticsUpdateAfter(Score, update => statisticsUpdate.Value = update);
|
2022-12-24 17:58:38 +08:00
|
|
|
}
|
|
|
|
|
2022-12-27 06:25:54 +08:00
|
|
|
protected override StatisticsPanel CreateStatisticsPanel()
|
2022-12-24 17:58:38 +08:00
|
|
|
{
|
2022-12-27 06:25:54 +08:00
|
|
|
if (ShowUserStatistics)
|
|
|
|
{
|
|
|
|
return new SoloStatisticsPanel(Score)
|
|
|
|
{
|
|
|
|
StatisticsUpdate = { BindTarget = statisticsUpdate }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.CreateStatisticsPanel();
|
|
|
|
}
|
2022-12-24 17:58:38 +08:00
|
|
|
|
2020-05-26 16:00:41 +08:00
|
|
|
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
|
|
|
|
{
|
2021-12-14 18:47:11 +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);
|
2022-07-12 16:14:31 +08:00
|
|
|
getScoreRequest.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => s.OnlineID != Score.OnlineID).Select(s => s.ToScoreInfo(rulesets, Beatmap.Value.BeatmapInfo)));
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|