mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:43:00 +08:00
Change DrawableStoryboardAnimation
to derive from TextureAnimation
This commit is contained in:
parent
cbc4e5319d
commit
040afff670
@ -6,7 +6,6 @@ using System.IO;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Animations;
|
using osu.Framework.Graphics.Animations;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -14,7 +13,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Storyboards.Drawables
|
namespace osu.Game.Storyboards.Drawables
|
||||||
{
|
{
|
||||||
public class DrawableStoryboardAnimation : DrawableAnimation, IFlippable, IVectorScalable
|
public class DrawableStoryboardAnimation : TextureAnimation, IFlippable, IVectorScalable
|
||||||
{
|
{
|
||||||
public StoryboardAnimation Animation { get; }
|
public StoryboardAnimation Animation { get; }
|
||||||
|
|
||||||
@ -91,14 +90,6 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
LifetimeEnd = animation.EndTime;
|
LifetimeEnd = animation.EndTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Vector2 GetCurrentDisplaySize()
|
|
||||||
{
|
|
||||||
Texture texture = (CurrentFrame as Sprite)?.Texture
|
|
||||||
?? ((CurrentFrame as SkinnableSprite)?.Drawable as Sprite)?.Texture;
|
|
||||||
|
|
||||||
return new Vector2(texture?.DisplayWidth ?? 0, texture?.DisplayHeight ?? 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private ISkinSource skin { get; set; }
|
private ISkinSource skin { get; set; }
|
||||||
|
|
||||||
@ -114,8 +105,7 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
// sourcing from storyboard.
|
// sourcing from storyboard.
|
||||||
for (frameIndex = 0; frameIndex < Animation.FrameCount; frameIndex++)
|
for (frameIndex = 0; frameIndex < Animation.FrameCount; frameIndex++)
|
||||||
{
|
{
|
||||||
frameTexture = storyboard.GetTextureFromPath(getFramePath(frameIndex), textureStore);
|
AddFrame(storyboard.GetTextureFromPath(getFramePath(frameIndex), textureStore), Animation.FrameDelay);
|
||||||
AddFrame(new Sprite { Texture = frameTexture }, Animation.FrameDelay);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (storyboard.UseSkinSprites)
|
else if (storyboard.UseSkinSprites)
|
||||||
@ -132,14 +122,10 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
{
|
{
|
||||||
ClearFrames();
|
ClearFrames();
|
||||||
|
|
||||||
// ClearFrames doesn't clear the last displayed frame.
|
|
||||||
// Clear manually for now, in case the skin doesn't provide any frames.
|
|
||||||
DisplayFrame(Empty());
|
|
||||||
|
|
||||||
// When reading from a skin, we match stables weird behaviour where `FrameCount` is ignored
|
// When reading from a skin, we match stables weird behaviour where `FrameCount` is ignored
|
||||||
// and resources are retrieved until the end of the animation.
|
// and resources are retrieved until the end of the animation.
|
||||||
foreach (var texture in skin.GetTextures(Path.GetFileNameWithoutExtension(Animation.Path), default, default, true, string.Empty, out _))
|
foreach (var texture in skin.GetTextures(Path.GetFileNameWithoutExtension(Animation.Path), default, default, true, string.Empty, out _))
|
||||||
AddFrame(new Sprite { Texture = texture }, Animation.FrameDelay);
|
AddFrame(texture, Animation.FrameDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string getFramePath(int i) => Animation.Path.Replace(".", $"{i}.");
|
private string getFramePath(int i) => Animation.Path.Replace(".", $"{i}.");
|
||||||
|
Loading…
Reference in New Issue
Block a user