mirror of
https://github.com/ppy/osu.git
synced 2026-06-03 04:52:59 +08:00
Fix count statistics causing direct beatmap load
This commit is contained in:
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
@@ -241,8 +242,6 @@ namespace osu.Game.Screens.SelectV2
|
||||
cancellationSource?.Cancel();
|
||||
cancellationSource = new CancellationTokenSource();
|
||||
|
||||
computeStarDifficulty(cancellationSource.Token);
|
||||
|
||||
if (beatmap.IsDefault)
|
||||
{
|
||||
ratingAndNameContainer.FadeOut(300, Easing.OutQuint);
|
||||
@@ -254,17 +253,53 @@ namespace osu.Game.Screens.SelectV2
|
||||
difficultyText.Text = beatmap.Value.BeatmapInfo.DifficultyName;
|
||||
mapperLink.Action = () => linkHandler?.HandleLink(new LinkDetails(LinkAction.OpenUserProfile, beatmap.Value.Metadata.Author));
|
||||
mapperText.Text = beatmap.Value.Metadata.Author.Username;
|
||||
|
||||
var playableBeatmap = beatmap.Value.GetPlayableBeatmap(ruleset.Value);
|
||||
|
||||
countStatisticsDisplay.Statistics = playableBeatmap.GetStatistics()
|
||||
.Select(s => new StatisticDifficulty.Data(s.Name, s.BarDisplayLength ?? 0, s.BarDisplayLength ?? 0, 1, s.Content))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
updateStarDifficulty(cancellationSource.Token);
|
||||
updateCountStatistics(cancellationSource.Token);
|
||||
updateDifficultyStatistics();
|
||||
}
|
||||
|
||||
private void updateStarDifficulty(CancellationToken cancellationToken)
|
||||
{
|
||||
difficultyCache.GetDifficultyAsync(beatmap.Value.BeatmapInfo, ruleset.Value, mods.Value, cancellationToken)
|
||||
.ContinueWith(task =>
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
starRatingDisplay.Current.Value = task.GetResultSafely() ?? default;
|
||||
});
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
private void updateCountStatistics(CancellationToken cancellationToken)
|
||||
{
|
||||
if (beatmap.IsDefault)
|
||||
{
|
||||
countStatisticsDisplay.Statistics = Array.Empty<StatisticDifficulty.Data>();
|
||||
return;
|
||||
}
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var playableBeatmap = beatmap.Value.GetPlayableBeatmap(ruleset.Value);
|
||||
var statistics = playableBeatmap.GetStatistics()
|
||||
.Select(s => new StatisticDifficulty.Data(s.Name, s.BarDisplayLength ?? 0, s.BarDisplayLength ?? 0, 1, s.Content))
|
||||
.ToList();
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
countStatisticsDisplay.Statistics = statistics;
|
||||
});
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
private void updateDifficultyStatistics() => Scheduler.AddOnce(() =>
|
||||
{
|
||||
if (beatmap.IsDefault)
|
||||
@@ -321,21 +356,6 @@ namespace osu.Game.Screens.SelectV2
|
||||
};
|
||||
});
|
||||
|
||||
private void computeStarDifficulty(CancellationToken cancellationToken)
|
||||
{
|
||||
difficultyCache.GetDifficultyAsync(beatmap.Value.BeatmapInfo, ruleset.Value, mods.Value, cancellationToken)
|
||||
.ContinueWith(task =>
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
starRatingDisplay.Current.Value = task.GetResultSafely() ?? default;
|
||||
});
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Reference in New Issue
Block a user