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

Changed the text updates into a scheduled (async) operation, and implemented this in the updateStatistics and clearStats methods

This commit is contained in:
FreezyLemon 2017-11-23 12:31:18 +01:00
parent 103bf1ddc9
commit a60e53c382

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
@ -187,9 +188,7 @@ namespace osu.Game.Screens.Select
ratingsContainer.FadeIn(transition_duration);
advanced.Beatmap = Beatmap;
description.Text = Beatmap.Version;
source.Text = Beatmap.Metadata.Source;
tags.Text = Beatmap.Metadata.Tags;
loadDetailsAsync(Beatmap);
var requestedBeatmap = Beatmap;
if (requestedBeatmap.Metrics == null)
@ -213,6 +212,19 @@ namespace osu.Game.Screens.Select
displayMetrics(requestedBeatmap.Metrics, false);
}
private void loadDetailsAsync(BeatmapInfo beatmap)
{
if (description == null || source == null || tags == null)
throw new InvalidOperationException($@"Requires all {nameof(MetadataSection)} elements to be non-null.");
Schedule(() =>
{
description.Text = Beatmap?.Version;
source.Text = Beatmap?.Metadata?.Source;
tags.Text = Beatmap?.Metadata?.Tags;
});
}
private void displayMetrics(BeatmapMetrics metrics, bool failOnMissing = true)
{
var hasRatings = metrics?.Ratings?.Any() ?? false;
@ -258,9 +270,7 @@ namespace osu.Game.Screens.Select
private void clearStats()
{
description.Text = null;
source.Text = null;
tags.Text = null;
loadDetailsAsync(null);
advanced.Beatmap = new BeatmapInfo
{
StarDifficulty = 0,