mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:43:21 +08:00
Fix beatmap details potentially using the incorrect metrics
This commit is contained in:
parent
dd7335079f
commit
f54f6e552b
@ -138,6 +138,25 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
});
|
||||
|
||||
AddStep("null beatmap", () => details.Beatmap = null);
|
||||
|
||||
AddStep("online ratings/retries/fails", () => details.Beatmap = new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = 162,
|
||||
Version = "online ratings/retries/fails",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Source = "osu!lazer",
|
||||
Tags = "this beatmap has online ratings/retries/fails",
|
||||
},
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 7,
|
||||
DrainRate = 1,
|
||||
OverallDifficulty = 5.7f,
|
||||
ApproachRate = 3.5f,
|
||||
},
|
||||
StarDifficulty = 5.3f
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,9 +185,9 @@ namespace osu.Game.Screens.Select
|
||||
tags.Text = Beatmap?.Metadata?.Tags;
|
||||
|
||||
// metrics may have been previously fetched
|
||||
if (Beatmap?.BeatmapSet?.Metrics != null)
|
||||
if (Beatmap?.BeatmapSet?.Metrics != null && Beatmap?.Metrics != null)
|
||||
{
|
||||
updateMetrics(Beatmap);
|
||||
updateMetrics(Beatmap.BeatmapSet.Metrics, Beatmap.Metrics);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -195,6 +195,7 @@ namespace osu.Game.Screens.Select
|
||||
if (Beatmap?.OnlineBeatmapID != null)
|
||||
{
|
||||
var requestedBeatmap = Beatmap;
|
||||
|
||||
var lookup = new GetBeatmapRequest(requestedBeatmap);
|
||||
lookup.Success += res =>
|
||||
{
|
||||
@ -204,28 +205,34 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
var b = res.ToBeatmap(rulesets);
|
||||
|
||||
requestedBeatmap.BeatmapSet.Metrics = b.BeatmapSet.Metrics;
|
||||
if (requestedBeatmap.BeatmapSet == null)
|
||||
requestedBeatmap.BeatmapSet = b.BeatmapSet;
|
||||
else
|
||||
requestedBeatmap.BeatmapSet.Metrics = b.BeatmapSet.Metrics;
|
||||
|
||||
requestedBeatmap.Metrics = b.Metrics;
|
||||
|
||||
Schedule(() => updateMetrics(requestedBeatmap));
|
||||
Schedule(() => updateMetrics(b.BeatmapSet.Metrics, b.Metrics));
|
||||
};
|
||||
lookup.Failure += e => Schedule(() => updateMetrics());
|
||||
|
||||
lookup.Failure += e => Schedule(() => updateMetrics(Beatmap?.BeatmapSet?.Metrics, Beatmap?.Metrics));
|
||||
|
||||
api.Queue(lookup);
|
||||
loading.Show();
|
||||
return;
|
||||
}
|
||||
|
||||
updateMetrics();
|
||||
updateMetrics(Beatmap?.BeatmapSet?.Metrics, Beatmap?.Metrics);
|
||||
}
|
||||
|
||||
private void updateMetrics(BeatmapInfo beatmap = null)
|
||||
private void updateMetrics(BeatmapSetMetrics setMetrics, BeatmapMetrics beatmapMetrics)
|
||||
{
|
||||
var hasRatings = beatmap?.BeatmapSet?.Metrics?.Ratings?.Any() ?? false;
|
||||
var hasRetriesFails = (beatmap?.Metrics?.Retries?.Any() ?? false) && (beatmap.Metrics.Fails?.Any() ?? false);
|
||||
var hasRatings = setMetrics?.Ratings?.Any() ?? false;
|
||||
var hasRetriesFails = (beatmapMetrics?.Retries?.Any() ?? false) && (beatmapMetrics.Fails?.Any() ?? false);
|
||||
|
||||
if (hasRatings)
|
||||
{
|
||||
ratings.Metrics = beatmap.BeatmapSet.Metrics;
|
||||
ratings.Metrics = setMetrics;
|
||||
ratingsContainer.FadeIn(transition_duration);
|
||||
}
|
||||
else
|
||||
@ -236,7 +243,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
if (hasRetriesFails)
|
||||
{
|
||||
failRetryGraph.Metrics = beatmap.Metrics;
|
||||
failRetryGraph.Metrics = beatmapMetrics;
|
||||
failRetryContainer.FadeIn(transition_duration);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user