mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 14:53:01 +08:00
Tidy up updateMetrics flow
This commit is contained in:
parent
587edcb716
commit
2b48f5d3e0
@ -187,17 +187,24 @@ namespace osu.Game.Screens.Select
|
|||||||
// metrics may have been previously fetched
|
// metrics may have been previously fetched
|
||||||
if (Beatmap?.BeatmapSet?.Metrics != null && Beatmap?.Metrics != null)
|
if (Beatmap?.BeatmapSet?.Metrics != null && Beatmap?.Metrics != null)
|
||||||
{
|
{
|
||||||
updateMetrics(Beatmap.BeatmapSet.Metrics, Beatmap.Metrics);
|
updateMetrics();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// metrics may not be fetched but can be
|
// for now, let's early abort if an OnlineBeatmapID is not present (should have been populated at import time).
|
||||||
if (Beatmap?.OnlineBeatmapID != null)
|
if (Beatmap?.OnlineBeatmapID == null)
|
||||||
{
|
{
|
||||||
|
updateMetrics();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var requestedBeatmap = Beatmap;
|
var requestedBeatmap = Beatmap;
|
||||||
|
|
||||||
var lookup = new GetBeatmapRequest(requestedBeatmap);
|
var lookup = new GetBeatmapRequest(requestedBeatmap);
|
||||||
|
|
||||||
lookup.Success += res =>
|
lookup.Success += res =>
|
||||||
|
{
|
||||||
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (beatmap != requestedBeatmap)
|
if (beatmap != requestedBeatmap)
|
||||||
//the beatmap has been changed since we started the lookup.
|
//the beatmap has been changed since we started the lookup.
|
||||||
@ -212,27 +219,34 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
requestedBeatmap.Metrics = b.Metrics;
|
requestedBeatmap.Metrics = b.Metrics;
|
||||||
|
|
||||||
Schedule(() => updateMetrics(b.BeatmapSet.Metrics, b.Metrics));
|
updateMetrics();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
lookup.Failure += e => Schedule(() => updateMetrics(Beatmap?.BeatmapSet?.Metrics, Beatmap?.Metrics));
|
lookup.Failure += e =>
|
||||||
|
{
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
if (beatmap != requestedBeatmap)
|
||||||
|
//the beatmap has been changed since we started the lookup.
|
||||||
|
return;
|
||||||
|
|
||||||
|
updateMetrics();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
api.Queue(lookup);
|
api.Queue(lookup);
|
||||||
loading.Show();
|
loading.Show();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMetrics(Beatmap?.BeatmapSet?.Metrics, Beatmap?.Metrics);
|
private void updateMetrics()
|
||||||
}
|
|
||||||
|
|
||||||
private void updateMetrics(BeatmapSetMetrics setMetrics, BeatmapMetrics beatmapMetrics)
|
|
||||||
{
|
{
|
||||||
var hasRatings = setMetrics?.Ratings?.Any() ?? false;
|
var hasRatings = beatmap?.BeatmapSet?.Metrics?.Ratings?.Any() ?? false;
|
||||||
var hasRetriesFails = (beatmapMetrics?.Retries?.Any() ?? false) && (beatmapMetrics.Fails?.Any() ?? false);
|
var hasRetriesFails = (beatmap?.Metrics?.Retries?.Any() ?? false) && (beatmap?.Metrics.Fails?.Any() ?? false);
|
||||||
|
|
||||||
if (hasRatings)
|
if (hasRatings)
|
||||||
{
|
{
|
||||||
ratings.Metrics = setMetrics;
|
ratings.Metrics = beatmap.BeatmapSet.Metrics;
|
||||||
ratingsContainer.FadeIn(transition_duration);
|
ratingsContainer.FadeIn(transition_duration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -243,7 +257,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
if (hasRetriesFails)
|
if (hasRetriesFails)
|
||||||
{
|
{
|
||||||
failRetryGraph.Metrics = beatmapMetrics;
|
failRetryGraph.Metrics = beatmap.Metrics;
|
||||||
failRetryContainer.FadeIn(transition_duration);
|
failRetryContainer.FadeIn(transition_duration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user