1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 20:47:22 +08:00

Fix backgrounds not correctly handling initial async load

This commit is contained in:
Dean Herbert 2019-03-12 00:05:05 +09:00
parent 81d9e391f4
commit e9ab329e93
2 changed files with 38 additions and 30 deletions

View File

@ -36,28 +36,34 @@ namespace osu.Game.Screens.Backgrounds
beatmap = value; beatmap = value;
Schedule(() => Schedule(() => { LoadComponentAsync(new BeatmapBackground(beatmap), b => Schedule(() => backgroundLoaded(b))); });
{
LoadComponentAsync(new BeatmapBackground(beatmap), b => Schedule(() =>
{
float newDepth = 0;
if (Background != null)
{
newDepth = Background.Depth + 1;
Background.FinishTransforms();
Background.FadeOut(250);
Background.Expire();
}
b.Depth = newDepth;
fadeContainer.Add(Background = b);
Background.BlurSigma = BlurTarget;
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
}));
});
} }
} }
private void backgroundLoaded(BeatmapBackground b)
{
float newDepth = 0;
if (Background != null)
{
newDepth = Background.Depth + 1;
Background.FinishTransforms();
Background.FadeOut(250);
Background.Expire();
}
b.Depth = newDepth;
fadeContainer.Add(Background = b);
Background.BlurSigma = BlurTarget;
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
}
[BackgroundDependencyLoader]
private void load()
{
if (beatmap != null)
backgroundLoaded(new BeatmapBackground(beatmap));
}
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null) public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
{ {
Beatmap = beatmap; Beatmap = beatmap;

View File

@ -34,7 +34,7 @@ namespace osu.Game.Screens.Backgrounds
currentDisplay = RNG.Next(0, background_count); currentDisplay = RNG.Next(0, background_count);
Next(); display(createBackground());
} }
private void display(Background newBackground) private void display(Background newBackground)
@ -51,19 +51,21 @@ namespace osu.Game.Screens.Backgrounds
public void Next() public void Next()
{ {
nextTask?.Cancel(); nextTask?.Cancel();
nextTask = Scheduler.AddDelayed(() => nextTask = Scheduler.AddDelayed(() => { LoadComponentAsync(createBackground(), display); }, 100);
{ }
Background background;
if (user.Value?.IsSupporter ?? false) private Background createBackground()
background = new SkinnedBackground(skin.Value, backgroundName); {
else Background background;
background = new Background(backgroundName);
background.Depth = currentDisplay; if (user.Value?.IsSupporter ?? false)
background = new SkinnedBackground(skin.Value, backgroundName);
else
background = new Background(backgroundName);
LoadComponentAsync(background, display); background.Depth = currentDisplay;
}, 100);
return background;
} }
private class SkinnedBackground : Background private class SkinnedBackground : Background