Changed to LoadComponentAsync call instead of adding an AsyncLoadWrapper instance.

This commit is contained in:
FreezyLemon 2017-11-21 16:12:23 +01:00
parent 7c65048ae5
commit a033eb46d3
5 changed files with 37 additions and 31 deletions

View File

@ -146,18 +146,17 @@ private void beginAudioLoad()
loading = true;
Add(new AsyncLoadWrapper(trackLoader = new TrackLoader($"https://b.ppy.sh/preview/{BeatmapSet.OnlineBeatmapSetID}.mp3")
{
OnLoadComplete = d =>
LoadComponentAsync(trackLoader = new TrackLoader($"https://b.ppy.sh/preview/{BeatmapSet.OnlineBeatmapSetID}.mp3"),
d =>
{
// we may have been replaced by another loader
// We may have been replaced by another loader
if (trackLoader != d) return;
Preview = (d as TrackLoader)?.Preview;
Playing.TriggerChange();
loading = false;
},
}));
Add(trackLoader);
});
}
private class TrackLoader : Drawable

View File

@ -316,18 +316,18 @@ public User User
private void loadUser()
{
coverContainer.Add(new AsyncLoadWrapper(new UserCoverBackground(user)
LoadComponentAsync(new UserCoverBackground(user)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(200)
})
},
ucb =>
{
Masking = true,
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue
ucb.Depth = float.MaxValue;
coverContainer.Add(ucb);
});
if (user.IsSupporter) supporterTag.Show();

View File

@ -228,16 +228,19 @@ private void displayBeatmap(BeatmapInfo value)
if (value != null)
{
coverContainer.FadeIn(transition_duration);
coverContainer.Children = new[]
LoadComponentAsync(new BeatmapSetCover(value.BeatmapSet)
{
new AsyncLoadWrapper(new BeatmapSetCover(value.BeatmapSet)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
}) { RelativeSizeAxes = Axes.Both },
};
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
},
bsc =>
{
bsc.RelativeSizeAxes = Axes.Both;
coverContainer.Add(bsc);
});
beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title);
beatmapDash.Text = @" - ";

View File

@ -329,17 +329,20 @@ private void displayBeatmap(BeatmapInfo value)
if (value != null)
{
coverContainer.FadeIn(transition_duration);
coverContainer.Children = new[]
LoadComponentAsync(new BeatmapSetCover(value.BeatmapSet)
{
new AsyncLoadWrapper(new BeatmapSetCover(value.BeatmapSet)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
}) { RelativeSizeAxes = Axes.Both },
};
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
},
bsc =>
{
bsc.RelativeSizeAxes = Axes.Both;
coverContainer.Add(bsc);
});
beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title);
beatmapDash.Text = @" - ";

View File

@ -248,7 +248,8 @@ private void initializeStoryboard(bool asyncLoad)
storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value);
storyboard.Masking = true;
storyboardContainer.Add(asyncLoad ? new AsyncLoadWrapper(storyboard) { RelativeSizeAxes = Axes.Both } : (Drawable)storyboard);
if (asyncLoad) LoadComponentAsync(storyboard, s => storyboardContainer.Add(s));
else storyboardContainer.Add((Drawable)storyboard);
}
public void Restart()