1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 22:22:54 +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>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -187,9 +188,7 @@ namespace osu.Game.Screens.Select
ratingsContainer.FadeIn(transition_duration); ratingsContainer.FadeIn(transition_duration);
advanced.Beatmap = Beatmap; advanced.Beatmap = Beatmap;
description.Text = Beatmap.Version; loadDetailsAsync(Beatmap);
source.Text = Beatmap.Metadata.Source;
tags.Text = Beatmap.Metadata.Tags;
var requestedBeatmap = Beatmap; var requestedBeatmap = Beatmap;
if (requestedBeatmap.Metrics == null) if (requestedBeatmap.Metrics == null)
@ -213,6 +212,19 @@ namespace osu.Game.Screens.Select
displayMetrics(requestedBeatmap.Metrics, false); 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) private void displayMetrics(BeatmapMetrics metrics, bool failOnMissing = true)
{ {
var hasRatings = metrics?.Ratings?.Any() ?? false; var hasRatings = metrics?.Ratings?.Any() ?? false;
@ -258,9 +270,7 @@ namespace osu.Game.Screens.Select
private void clearStats() private void clearStats()
{ {
description.Text = null; loadDetailsAsync(null);
source.Text = null;
tags.Text = null;
advanced.Beatmap = new BeatmapInfo advanced.Beatmap = new BeatmapInfo
{ {
StarDifficulty = 0, StarDifficulty = 0,