diff --git a/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs b/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs index 2a4c5e194b..058d2ed0f9 100644 --- a/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs +++ b/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs @@ -13,21 +13,16 @@ namespace osu.Game.Graphics.Backgrounds private readonly string fallbackTextureName; - [Resolved] - private LargeTextureStore textures { get; set; } - public BeatmapBackground(WorkingBeatmap beatmap, string fallbackTextureName = @"Backgrounds/bg1") { Beatmap = beatmap; this.fallbackTextureName = fallbackTextureName; } - protected override void LoadComplete() + [BackgroundDependencyLoader] + private void load(LargeTextureStore textures) { - base.LoadComplete(); - Initialize(); + Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName); } - - protected virtual void Initialize() => Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName); } } diff --git a/osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs b/osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs index 1925cb927e..21c536ee30 100644 --- a/osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs +++ b/osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs @@ -1,7 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Graphics; using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Storyboards.Drawables; @@ -15,21 +16,19 @@ namespace osu.Game.Graphics.Backgrounds { } - protected override void Initialize() + [BackgroundDependencyLoader] + private void load() { - if (Beatmap.Storyboard.HasDrawable) - { - LoadComponentAsync(new DrawableStoryboard(Beatmap.Storyboard) { Clock = new InterpolatingFramedClock(Beatmap.Track) }, AddInternal); - } - - if (Beatmap.Storyboard.ReplacesBackground || Beatmap.Storyboard.Layers.First(l => l.Name == "Video").Elements.Any()) - { - Sprite.Expire(); - } - else - { - base.Initialize(); - } + LoadComponentAsync(new DrawableStoryboard(Beatmap.Storyboard) + { + Clock = new InterpolatingFramedClock(Beatmap.Track), + }, + loaded => + { + AddInternal(loaded); + if (Beatmap.Storyboard.ReplacesBackground) + Sprite.FadeOut(300, Easing.OutQuint); + }); } } }