1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Use the playable beatmap provided in CreateStatisticsForScore

This commit is contained in:
Henry Lin 2022-02-05 21:36:34 +08:00
parent 440b674bb0
commit 0b1fef38af
5 changed files with 15 additions and 17 deletions

View File

@ -381,7 +381,7 @@ namespace osu.Game.Rulesets.Mania
{ {
Columns = new[] Columns = new[]
{ {
new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score) new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score, playableBeatmap)
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y AutoSizeAxes = Axes.Y

View File

@ -301,7 +301,7 @@ namespace osu.Game.Rulesets.Osu
{ {
Columns = new[] Columns = new[]
{ {
new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score) new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score, playableBeatmap)
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y AutoSizeAxes = Axes.Y

View File

@ -224,7 +224,7 @@ namespace osu.Game.Rulesets.Taiko
{ {
Columns = new[] Columns = new[]
{ {
new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score) new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score, playableBeatmap)
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y AutoSizeAxes = Axes.Y

View File

@ -16,13 +16,13 @@ namespace osu.Game.Rulesets.Difficulty
{ {
public class PerformanceBreakdownCalculator public class PerformanceBreakdownCalculator
{ {
private readonly BeatmapManager beatmapManager; private readonly IBeatmap playableBeatmap;
private readonly BeatmapDifficultyCache difficultyCache; private readonly BeatmapDifficultyCache difficultyCache;
private readonly ScorePerformanceCache performanceCache; private readonly ScorePerformanceCache performanceCache;
public PerformanceBreakdownCalculator(BeatmapManager beatmapManager, BeatmapDifficultyCache difficultyCache, ScorePerformanceCache performanceCache) public PerformanceBreakdownCalculator(IBeatmap playableBeatmap, BeatmapDifficultyCache difficultyCache, ScorePerformanceCache performanceCache)
{ {
this.beatmapManager = beatmapManager; this.playableBeatmap = playableBeatmap;
this.difficultyCache = difficultyCache; this.difficultyCache = difficultyCache;
this.performanceCache = performanceCache; this.performanceCache = performanceCache;
} }
@ -46,14 +46,13 @@ namespace osu.Game.Rulesets.Difficulty
return Task.Run(async () => return Task.Run(async () =>
{ {
Ruleset ruleset = score.Ruleset.CreateInstance(); Ruleset ruleset = score.Ruleset.CreateInstance();
IBeatmap beatmap = beatmapManager.GetWorkingBeatmap(score.BeatmapInfo).GetPlayableBeatmap(score.Ruleset, score.Mods);
ScoreInfo perfectPlay = score.DeepClone(); ScoreInfo perfectPlay = score.DeepClone();
perfectPlay.Accuracy = 1; perfectPlay.Accuracy = 1;
perfectPlay.Passed = true; perfectPlay.Passed = true;
// calculate max combo // calculate max combo
var difficulty = await difficultyCache.GetDifficultyAsync( var difficulty = await difficultyCache.GetDifficultyAsync(
beatmap.BeatmapInfo, playableBeatmap.BeatmapInfo,
score.Ruleset, score.Ruleset,
score.Mods, score.Mods,
cancellationToken cancellationToken
@ -65,10 +64,10 @@ namespace osu.Game.Rulesets.Difficulty
perfectPlay.MaxCombo = difficulty.Value.MaxCombo; perfectPlay.MaxCombo = difficulty.Value.MaxCombo;
// create statistics assuming all hit objects have perfect hit result // create statistics assuming all hit objects have perfect hit result
var statistics = beatmap.HitObjects var statistics = playableBeatmap.HitObjects
.SelectMany(getPerfectHitResults) .SelectMany(getPerfectHitResults)
.GroupBy(hr => hr, (hr, list) => (hitResult: hr, count: list.Count())) .GroupBy(hr => hr, (hr, list) => (hitResult: hr, count: list.Count()))
.ToDictionary(pair => pair.hitResult, pair => pair.count); .ToDictionary(pair => pair.hitResult, pair => pair.count);
perfectPlay.Statistics = statistics; perfectPlay.Statistics = statistics;
// calculate total score // calculate total score

View File

@ -26,6 +26,7 @@ namespace osu.Game.Screens.Ranking.Statistics
public class PerformanceBreakdownChart : Container public class PerformanceBreakdownChart : Container
{ {
private readonly ScoreInfo score; private readonly ScoreInfo score;
private readonly IBeatmap playableBeatmap;
private Drawable spinner; private Drawable spinner;
private Drawable content; private Drawable content;
@ -41,12 +42,10 @@ namespace osu.Game.Screens.Ranking.Statistics
[Resolved] [Resolved]
private BeatmapDifficultyCache difficultyCache { get; set; } private BeatmapDifficultyCache difficultyCache { get; set; }
[Resolved] public PerformanceBreakdownChart(ScoreInfo score, IBeatmap playableBeatmap)
private BeatmapManager beatmapManager { get; set; }
public PerformanceBreakdownChart(ScoreInfo score)
{ {
this.score = score; this.score = score;
this.playableBeatmap = playableBeatmap;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -146,7 +145,7 @@ namespace osu.Game.Screens.Ranking.Statistics
spinner.Show(); spinner.Show();
new PerformanceBreakdownCalculator(beatmapManager, difficultyCache, performanceCache) new PerformanceBreakdownCalculator(playableBeatmap, difficultyCache, performanceCache)
.CalculateAsync(score, cancellationTokenSource.Token) .CalculateAsync(score, cancellationTokenSource.Token)
.ContinueWith(t => Schedule(() => setPerformanceValue(t.GetResultSafely()))); .ContinueWith(t => Schedule(() => setPerformanceValue(t.GetResultSafely())));
} }