mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 10:33:07 +08:00
Centralise and share logic for storyboard frame lookup method
This commit is contained in:
parent
e2552d4c36
commit
1b84402b96
@ -2,16 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osuTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Animations;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Storyboards.Drawables
|
||||
{
|
||||
@ -117,18 +113,13 @@ namespace osu.Game.Storyboards.Drawables
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore, Storyboard storyboard)
|
||||
private void load(TextureStore textureStore, Storyboard storyboard)
|
||||
{
|
||||
for (var frame = 0; frame < Animation.FrameCount; frame++)
|
||||
for (int frame = 0; frame < Animation.FrameCount; frame++)
|
||||
{
|
||||
var framePath = Animation.Path.Replace(".", frame + ".");
|
||||
string framePath = Animation.Path.Replace(".", frame + ".");
|
||||
|
||||
var storyboardPath = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.Equals(framePath, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
|
||||
var frameSprite = storyboard.UseSkinSprites && storyboardPath == null
|
||||
? (Drawable)new SkinnableSprite(framePath)
|
||||
: new Sprite { Texture = textureStore.Get(storyboardPath) };
|
||||
|
||||
AddFrame(frameSprite, Animation.FrameDelay);
|
||||
AddFrame(storyboard.CreateSpriteFromResourcePath(framePath, textureStore), Animation.FrameDelay);
|
||||
}
|
||||
|
||||
Animation.ApplyTransforms(this);
|
||||
|
@ -2,16 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osuTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Storyboards.Drawables
|
||||
{
|
||||
@ -116,14 +112,12 @@ namespace osu.Game.Storyboards.Drawables
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore, Storyboard storyboard)
|
||||
private void load(TextureStore textureStore, Storyboard storyboard)
|
||||
{
|
||||
var storyboardPath = beatmap.Value.BeatmapSetInfo?.Files?.Find(f => f.Filename.Equals(Sprite.Path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
|
||||
var sprite = storyboard.UseSkinSprites && storyboardPath == null
|
||||
? (Drawable)new SkinnableSprite(Sprite.Path)
|
||||
: new Sprite { Texture = textureStore.Get(storyboardPath) };
|
||||
var drawable = storyboard.CreateSpriteFromResourcePath(Sprite.Path, textureStore);
|
||||
|
||||
InternalChild = sprite.With(s => s.Anchor = s.Origin = Anchor.Centre);
|
||||
if (drawable != null)
|
||||
InternalChild = drawable.With(s => s.Anchor = s.Origin = Anchor.Centre);
|
||||
|
||||
Sprite.ApplyTransforms(this);
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
|
||||
namespace osu.Game.Storyboards
|
||||
@ -69,5 +74,19 @@ namespace osu.Game.Storyboards
|
||||
drawable.Width = drawable.Height * (BeatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
public Drawable CreateSpriteFromResourcePath(string path, TextureStore textureStore)
|
||||
{
|
||||
Drawable drawable = null;
|
||||
var storyboardPath = BeatmapInfo.BeatmapSet?.Files?.Find(f => f.Filename.Equals(path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
|
||||
|
||||
if (storyboardPath != null)
|
||||
drawable = new Sprite { Texture = textureStore.Get(storyboardPath) };
|
||||
// if the texture isn't available locally in the beatmap, some storyboards choose to source from the underlying skin lookup hierarchy.
|
||||
else if (UseSkinSprites)
|
||||
drawable = new SkinnableSprite(path);
|
||||
|
||||
return drawable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user