1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:18:22 +08:00

Apply same fix to DrawableStoryboardAnimation

This commit is contained in:
Dean Herbert 2023-09-20 12:54:36 +09:00
parent 50adb5f7a7
commit b5e64d933c
2 changed files with 28 additions and 21 deletions

View File

@ -94,25 +94,19 @@ namespace osu.Game.Storyboards.Drawables
[Resolved]
private IBeatSyncProvider beatSyncProvider { get; set; }
[Resolved]
private TextureStore textureStore { get; set; }
[BackgroundDependencyLoader]
private void load(TextureStore textureStore, Storyboard storyboard)
private void load(Storyboard storyboard)
{
int frameIndex = 0;
Texture frameTexture = textureStore.Get(getFramePath(frameIndex));
if (frameTexture != null)
if (storyboard.UseSkinSprites)
{
// sourcing from storyboard.
for (frameIndex = 0; frameIndex < Animation.FrameCount; frameIndex++)
AddFrame(textureStore.Get(getFramePath(frameIndex)), Animation.FrameDelay);
}
else if (storyboard.UseSkinSprites)
{
// fallback to skin if required.
skin.SourceChanged += skinSourceChanged;
skinSourceChanged();
}
else
addFramesFromStoryboardSource();
Animation.ApplyTransforms(this);
}
@ -135,11 +129,28 @@ namespace osu.Game.Storyboards.Drawables
// When reading from a skin, we match stables weird behaviour where `FrameCount` is ignored
// 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 _))
AddFrame(texture, Animation.FrameDelay);
var skinTextures = skin.GetTextures(Path.GetFileNameWithoutExtension(Animation.Path)!, default, default, true, string.Empty, out _);
if (skinTextures.Length > 0)
{
foreach (var texture in skinTextures)
AddFrame(texture, Animation.FrameDelay);
}
else
{
addFramesFromStoryboardSource();
}
}
private string getFramePath(int i) => Animation.Path.Replace(".", $"{i}.");
private void addFramesFromStoryboardSource()
{
int frameIndex;
// sourcing from storyboard.
for (frameIndex = 0; frameIndex < Animation.FrameCount; frameIndex++)
AddFrame(textureStore.Get(getFramePath(frameIndex)), Animation.FrameDelay);
string getFramePath(int i) => Animation.Path.Replace(".", $"{i}.");
}
protected override void Dispose(bool isDisposing)
{

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
@ -78,9 +77,6 @@ namespace osu.Game.Storyboards.Drawables
[Resolved]
private ISkinSource skin { get; set; } = null!;
[Resolved]
private Storyboard storyboard { get; set; } = null!;
[Resolved]
private TextureStore textureStore { get; set; } = null!;
@ -95,7 +91,7 @@ namespace osu.Game.Storyboards.Drawables
}
[BackgroundDependencyLoader]
private void load()
private void load(Storyboard storyboard)
{
if (storyboard.UseSkinSprites)
{