1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Fix showing outdated data for non-online beatmaps

This commit is contained in:
Jamie Taylor 2019-03-08 18:44:35 +09:00
parent 192c257aac
commit 8e5816805c
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C

View File

@ -175,21 +175,21 @@ namespace osu.Game.Screens.Select
private void updateStatistics()
{
advanced.Beatmap = Beatmap;
description.Text = Beatmap?.Version;
source.Text = Beatmap?.Metadata?.Source;
tags.Text = Beatmap?.Metadata?.Tags;
if (Beatmap == null)
{
clearStats();
ratingsContainer.FadeOut(transition_duration);
failRetryContainer.FadeOut(transition_duration);
return;
}
ratingsContainer.FadeIn(transition_duration);
advanced.Beatmap = Beatmap;
description.Text = Beatmap.Version;
source.Text = Beatmap.Metadata.Source;
tags.Text = Beatmap.Metadata.Tags;
var requestedBeatmap = Beatmap;
if (requestedBeatmap.Metrics == null && requestedBeatmap.OnlineBeatmapID != null)
if (Beatmap.Metrics == null && Beatmap.OnlineBeatmapID != null)
{
var requestedBeatmap = Beatmap;
var lookup = new GetBeatmapDetailsRequest(requestedBeatmap);
lookup.Success += res =>
{
@ -198,39 +198,35 @@ namespace osu.Game.Screens.Select
return;
requestedBeatmap.Metrics = res;
Schedule(() => displayMetrics(res));
Schedule(() => updateMetrics(res));
};
lookup.Failure += e => Schedule(() => displayMetrics(null));
lookup.Failure += e => Schedule(() => updateMetrics(null));
api.Queue(lookup);
loading.Show();
}
displayMetrics(requestedBeatmap.Metrics, false);
else
{
updateMetrics(Beatmap.Metrics);
}
}
private void displayMetrics(BeatmapMetrics metrics, bool failOnMissing = true)
private void updateMetrics(BeatmapMetrics metrics)
{
var hasRatings = metrics?.Ratings?.Any() ?? false;
var hasRetriesFails = (metrics?.Retries?.Any() ?? false) && (metrics.Fails?.Any() ?? false);
if (failOnMissing) loading.Hide();
if (hasRatings)
{
ratings.Metrics = metrics;
ratings.FadeIn(transition_duration);
ratingsContainer.FadeIn(transition_duration);
}
else if (failOnMissing)
else
{
ratings.Metrics = new BeatmapMetrics
{
Ratings = new int[10],
};
}
else
{
ratings.FadeTo(0.25f, transition_duration);
ratingsContainer.FadeTo(0.25f, transition_duration);
}
if (hasRetriesFails)
@ -238,41 +234,17 @@ namespace osu.Game.Screens.Select
failRetryGraph.Metrics = metrics;
failRetryContainer.FadeIn(transition_duration);
}
else if (failOnMissing)
else
{
failRetryGraph.Metrics = new BeatmapMetrics
{
Fails = new int[100],
Retries = new int[100],
};
failRetryContainer.FadeOut(transition_duration);
}
else
{
failRetryContainer.FadeTo(0.25f, transition_duration);
}
}
private void clearStats()
{
description.Text = null;
source.Text = null;
tags.Text = null;
advanced.Beatmap = new BeatmapInfo
{
StarDifficulty = 0,
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 0,
DrainRate = 0,
OverallDifficulty = 0,
ApproachRate = 0,
},
};
loading.Hide();
ratingsContainer.FadeOut(transition_duration);
failRetryContainer.FadeOut(transition_duration);
}
private class DetailBox : Container