Utilise UseSkinSprites value in storyboard sprite logic

This commit is contained in:
Bartłomiej Dach 2020-10-19 23:40:20 +02:00
parent cdd56ece87
commit 58a54c5b6c
3 changed files with 9 additions and 14 deletions

View File

@ -15,6 +15,7 @@ namespace osu.Game.Storyboards.Drawables
{ {
public class DrawableStoryboard : Container<DrawableStoryboardLayer> public class DrawableStoryboard : Container<DrawableStoryboardLayer>
{ {
[Cached]
public Storyboard Storyboard { get; } public Storyboard Storyboard { get; }
protected override Container<DrawableStoryboardLayer> Content { get; } protected override Container<DrawableStoryboardLayer> Content { get; }

View File

@ -117,19 +117,16 @@ namespace osu.Game.Storyboards.Drawables
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore) private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore, Storyboard storyboard)
{ {
for (var frame = 0; frame < Animation.FrameCount; frame++) for (var frame = 0; frame < Animation.FrameCount; frame++)
{ {
var framePath = Animation.Path.Replace(".", frame + "."); var framePath = Animation.Path.Replace(".", frame + ".");
var storyboardPath = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.Equals(framePath, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath; var storyboardPath = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.Equals(framePath, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
var frameSprite = storyboardPath != null var frameSprite = storyboard.UseSkinSprites && storyboardPath == null
? (Drawable)new Sprite ? (Drawable)new SkinnableSprite(framePath)
{ : new Sprite { Texture = textureStore.Get(storyboardPath) };
Texture = textureStore.Get(storyboardPath)
}
: new SkinnableSprite(framePath); // fall back to skin textures if not found in storyboard files.
AddFrame(frameSprite, Animation.FrameDelay); AddFrame(frameSprite, Animation.FrameDelay);
} }

View File

@ -116,15 +116,12 @@ namespace osu.Game.Storyboards.Drawables
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore) private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore, Storyboard storyboard)
{ {
var storyboardPath = beatmap.Value.BeatmapSetInfo?.Files?.Find(f => f.Filename.Equals(Sprite.Path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath; var storyboardPath = beatmap.Value.BeatmapSetInfo?.Files?.Find(f => f.Filename.Equals(Sprite.Path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
var sprite = storyboardPath != null var sprite = storyboard.UseSkinSprites && storyboardPath == null
? (Drawable)new Sprite ? (Drawable)new SkinnableSprite(Sprite.Path)
{ : new Sprite { Texture = textureStore.Get(storyboardPath) };
Texture = textureStore.Get(storyboardPath)
}
: new SkinnableSprite(Sprite.Path); // fall back to skin textures if not found in storyboard files.
InternalChild = sprite.With(s => s.Anchor = s.Origin = Anchor.Centre); InternalChild = sprite.With(s => s.Anchor = s.Origin = Anchor.Centre);