1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 15:42:55 +08:00

Revert "refactor BeatmapBackgroundWithStoryboard to reduce overhead"

This reverts commit 277545bb06.
This commit is contained in:
Dean Herbert 2021-06-03 12:33:16 +09:00
parent 277545bb06
commit a62dd7cca0
2 changed files with 17 additions and 23 deletions

View File

@ -13,21 +13,16 @@ namespace osu.Game.Graphics.Backgrounds
private readonly string fallbackTextureName; private readonly string fallbackTextureName;
[Resolved]
private LargeTextureStore textures { get; set; }
public BeatmapBackground(WorkingBeatmap beatmap, string fallbackTextureName = @"Backgrounds/bg1") public BeatmapBackground(WorkingBeatmap beatmap, string fallbackTextureName = @"Backgrounds/bg1")
{ {
Beatmap = beatmap; Beatmap = beatmap;
this.fallbackTextureName = fallbackTextureName; this.fallbackTextureName = fallbackTextureName;
} }
protected override void LoadComplete() [BackgroundDependencyLoader]
private void load(LargeTextureStore textures)
{ {
base.LoadComplete(); Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName);
Initialize();
} }
protected virtual void Initialize() => Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName);
} }
} }

View File

@ -1,7 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // 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.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Storyboards.Drawables; 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)
{ {
LoadComponentAsync(new DrawableStoryboard(Beatmap.Storyboard) { Clock = new InterpolatingFramedClock(Beatmap.Track) }, AddInternal); Clock = new InterpolatingFramedClock(Beatmap.Track),
} },
loaded =>
if (Beatmap.Storyboard.ReplacesBackground || Beatmap.Storyboard.Layers.First(l => l.Name == "Video").Elements.Any())
{ {
Sprite.Expire(); AddInternal(loaded);
} if (Beatmap.Storyboard.ReplacesBackground)
else Sprite.FadeOut(300, Easing.OutQuint);
{ });
base.Initialize();
}
} }
} }
} }