增加空动画
This commit is contained in:
@@ -13,6 +13,8 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
[SpineImplementation(Version.V21)]
|
[SpineImplementation(Version.V21)]
|
||||||
internal class Spine21 : SpineViewer.Spine.Spine
|
internal class Spine21 : SpineViewer.Spine.Spine
|
||||||
{
|
{
|
||||||
|
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
|
||||||
|
|
||||||
private class TextureLoader : SpineRuntime21.TextureLoader
|
private class TextureLoader : SpineRuntime21.TextureLoader
|
||||||
{
|
{
|
||||||
public void Load(AtlasPage page, string path)
|
public void Load(AtlasPage page, string path)
|
||||||
@@ -172,8 +174,15 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
|
|
||||||
public override string CurrentAnimation
|
public override string CurrentAnimation
|
||||||
{
|
{
|
||||||
get => animationState.GetCurrent(0)?.Animation.Name ?? DefaultAnimationName;
|
get => animationState.GetCurrent(0)?.Animation.Name ?? EMPTY_ANIMATION;
|
||||||
set { if (animationNames.Contains(value)) { animationState.SetAnimation(0, value, true); Update(0); } }
|
set
|
||||||
|
{
|
||||||
|
if (value == EMPTY_ANIMATION)
|
||||||
|
animationState.SetAnimation(0, EmptyAnimation, false);
|
||||||
|
else if (animationNames.Contains(value))
|
||||||
|
animationState.SetAnimation(0, value, true);
|
||||||
|
Update(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RectangleF Bounds
|
public override RectangleF Bounds
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
[SpineImplementation(Version.V36)]
|
[SpineImplementation(Version.V36)]
|
||||||
internal class Spine36 : SpineViewer.Spine.Spine
|
internal class Spine36 : SpineViewer.Spine.Spine
|
||||||
{
|
{
|
||||||
|
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
|
||||||
|
|
||||||
private class TextureLoader : SpineRuntime36.TextureLoader
|
private class TextureLoader : SpineRuntime36.TextureLoader
|
||||||
{
|
{
|
||||||
public void Load(AtlasPage page, string path)
|
public void Load(AtlasPage page, string path)
|
||||||
@@ -170,8 +172,15 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
|
|
||||||
public override string CurrentAnimation
|
public override string CurrentAnimation
|
||||||
{
|
{
|
||||||
get => animationState.GetCurrent(0)?.Animation.Name ?? DefaultAnimationName;
|
get => animationState.GetCurrent(0)?.Animation.Name ?? EMPTY_ANIMATION;
|
||||||
set { if (animationNames.Contains(value)) { animationState.SetAnimation(0, value, true); Update(0); } }
|
set
|
||||||
|
{
|
||||||
|
if (value == EMPTY_ANIMATION)
|
||||||
|
animationState.SetAnimation(0, EmptyAnimation, false);
|
||||||
|
else if (animationNames.Contains(value))
|
||||||
|
animationState.SetAnimation(0, value, true);
|
||||||
|
Update(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RectangleF Bounds
|
public override RectangleF Bounds
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
[SpineImplementation(Version.V37)]
|
[SpineImplementation(Version.V37)]
|
||||||
internal class Spine37 : SpineViewer.Spine.Spine
|
internal class Spine37 : SpineViewer.Spine.Spine
|
||||||
{
|
{
|
||||||
|
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
|
||||||
|
|
||||||
private class TextureLoader : SpineRuntime37.TextureLoader
|
private class TextureLoader : SpineRuntime37.TextureLoader
|
||||||
{
|
{
|
||||||
public void Load(AtlasPage page, string path)
|
public void Load(AtlasPage page, string path)
|
||||||
@@ -177,8 +179,15 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
|
|
||||||
public override string CurrentAnimation
|
public override string CurrentAnimation
|
||||||
{
|
{
|
||||||
get => animationState.GetCurrent(0)?.Animation.Name ?? DefaultAnimationName;
|
get => animationState.GetCurrent(0)?.Animation.Name ?? EMPTY_ANIMATION;
|
||||||
set { if (animationNames.Contains(value)) { animationState.SetAnimation(0, value, true); Update(0); } }
|
set
|
||||||
|
{
|
||||||
|
if (value == EMPTY_ANIMATION)
|
||||||
|
animationState.SetAnimation(0, EmptyAnimation, false);
|
||||||
|
else if (animationNames.Contains(value))
|
||||||
|
animationState.SetAnimation(0, value, true);
|
||||||
|
Update(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RectangleF Bounds
|
public override RectangleF Bounds
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
[SpineImplementation(Version.V38)]
|
[SpineImplementation(Version.V38)]
|
||||||
internal class Spine38 : SpineViewer.Spine.Spine
|
internal class Spine38 : SpineViewer.Spine.Spine
|
||||||
{
|
{
|
||||||
|
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
|
||||||
|
|
||||||
private class TextureLoader : SpineRuntime38.TextureLoader
|
private class TextureLoader : SpineRuntime38.TextureLoader
|
||||||
{
|
{
|
||||||
public void Load(AtlasPage page, string path)
|
public void Load(AtlasPage page, string path)
|
||||||
@@ -180,8 +182,15 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
|
|
||||||
public override string CurrentAnimation
|
public override string CurrentAnimation
|
||||||
{
|
{
|
||||||
get => animationState.GetCurrent(0)?.Animation.Name ?? DefaultAnimationName;
|
get => animationState.GetCurrent(0)?.Animation.Name ?? EMPTY_ANIMATION;
|
||||||
set { if (animationNames.Contains(value)) { animationState.SetAnimation(0, value, true); Update(0); } }
|
set
|
||||||
|
{
|
||||||
|
if (value == EMPTY_ANIMATION)
|
||||||
|
animationState.SetAnimation(0, EmptyAnimation, false);
|
||||||
|
else if (animationNames.Contains(value))
|
||||||
|
animationState.SetAnimation(0, value, true);
|
||||||
|
Update(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RectangleF Bounds
|
public override RectangleF Bounds
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
[SpineImplementation(Version.V40)]
|
[SpineImplementation(Version.V40)]
|
||||||
internal class Spine40 : SpineViewer.Spine.Spine
|
internal class Spine40 : SpineViewer.Spine.Spine
|
||||||
{
|
{
|
||||||
|
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
|
||||||
|
|
||||||
private class TextureLoader : SpineRuntime40.TextureLoader
|
private class TextureLoader : SpineRuntime40.TextureLoader
|
||||||
{
|
{
|
||||||
public void Load(AtlasPage page, string path)
|
public void Load(AtlasPage page, string path)
|
||||||
@@ -179,8 +181,15 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
|
|
||||||
public override string CurrentAnimation
|
public override string CurrentAnimation
|
||||||
{
|
{
|
||||||
get => animationState.GetCurrent(0)?.Animation.Name ?? DefaultAnimationName;
|
get => animationState.GetCurrent(0)?.Animation.Name ?? EMPTY_ANIMATION;
|
||||||
set { if (animationNames.Contains(value)) { animationState.SetAnimation(0, value, true); Update(0); } }
|
set
|
||||||
|
{
|
||||||
|
if (value == EMPTY_ANIMATION)
|
||||||
|
animationState.SetAnimation(0, EmptyAnimation, false);
|
||||||
|
else if (animationNames.Contains(value))
|
||||||
|
animationState.SetAnimation(0, value, true);
|
||||||
|
Update(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RectangleF Bounds
|
public override RectangleF Bounds
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
[SpineImplementation(Version.V41)]
|
[SpineImplementation(Version.V41)]
|
||||||
internal class Spine41 : SpineViewer.Spine.Spine
|
internal class Spine41 : SpineViewer.Spine.Spine
|
||||||
{
|
{
|
||||||
|
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
|
||||||
|
|
||||||
private class TextureLoader : SpineRuntime41.TextureLoader
|
private class TextureLoader : SpineRuntime41.TextureLoader
|
||||||
{
|
{
|
||||||
public void Load(AtlasPage page, string path)
|
public void Load(AtlasPage page, string path)
|
||||||
@@ -179,8 +181,15 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
|
|
||||||
public override string CurrentAnimation
|
public override string CurrentAnimation
|
||||||
{
|
{
|
||||||
get => animationState.GetCurrent(0)?.Animation.Name ?? DefaultAnimationName;
|
get => animationState.GetCurrent(0)?.Animation.Name ?? EMPTY_ANIMATION;
|
||||||
set { if (animationNames.Contains(value)) { animationState.SetAnimation(0, value, true); Update(0); } }
|
set
|
||||||
|
{
|
||||||
|
if (value == EMPTY_ANIMATION)
|
||||||
|
animationState.SetAnimation(0, EmptyAnimation, false);
|
||||||
|
else if (animationNames.Contains(value))
|
||||||
|
animationState.SetAnimation(0, value, true);
|
||||||
|
Update(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RectangleF Bounds
|
public override RectangleF Bounds
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
[SpineImplementation(Version.V42)]
|
[SpineImplementation(Version.V42)]
|
||||||
internal class Spine42 : SpineViewer.Spine.Spine
|
internal class Spine42 : SpineViewer.Spine.Spine
|
||||||
{
|
{
|
||||||
|
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
|
||||||
|
|
||||||
private class TextureLoader : SpineRuntime42.TextureLoader
|
private class TextureLoader : SpineRuntime42.TextureLoader
|
||||||
{
|
{
|
||||||
public void Load(AtlasPage page, string path)
|
public void Load(AtlasPage page, string path)
|
||||||
@@ -179,8 +181,15 @@ namespace SpineViewer.Spine.Implementations.Spine
|
|||||||
|
|
||||||
public override string CurrentAnimation
|
public override string CurrentAnimation
|
||||||
{
|
{
|
||||||
get => animationState.GetCurrent(0)?.Animation.Name ?? DefaultAnimationName;
|
get => animationState.GetCurrent(0)?.Animation.Name ?? EMPTY_ANIMATION;
|
||||||
set { if (animationNames.Contains(value)) { animationState.SetAnimation(0, value, true); Update(0); } }
|
set
|
||||||
|
{
|
||||||
|
if (value == EMPTY_ANIMATION)
|
||||||
|
animationState.SetAnimation(0, EmptyAnimation, false);
|
||||||
|
else if (animationNames.Contains(value))
|
||||||
|
animationState.SetAnimation(0, value, true);
|
||||||
|
Update(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RectangleF Bounds
|
public override RectangleF Bounds
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ namespace SpineViewer.Spine
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class Spine : SFML.Graphics.Drawable, IDisposable
|
public abstract class Spine : SFML.Graphics.Drawable, IDisposable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 空动画标记
|
||||||
|
/// </summary>
|
||||||
|
public const string EMPTY_ANIMATION = "<Empty>";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 实现类缓存
|
/// 实现类缓存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -199,7 +204,7 @@ namespace SpineViewer.Spine
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public ReadOnlyCollection<string> AnimationNames { get => animationNames.AsReadOnly(); }
|
public ReadOnlyCollection<string> AnimationNames { get => animationNames.AsReadOnly(); }
|
||||||
protected List<string> animationNames = [];
|
protected List<string> animationNames = [EMPTY_ANIMATION];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认动画名称
|
/// 默认动画名称
|
||||||
|
|||||||
@@ -42,11 +42,7 @@ namespace SpineViewer.Spine
|
|||||||
public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context)
|
public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context)
|
||||||
{
|
{
|
||||||
if (context?.Instance is Spine obj)
|
if (context?.Instance is Spine obj)
|
||||||
{
|
|
||||||
// 返回 AnimationNames 作为下拉选项
|
|
||||||
return new StandardValuesCollection(obj.AnimationNames);
|
return new StandardValuesCollection(obj.AnimationNames);
|
||||||
}
|
|
||||||
|
|
||||||
return base.GetStandardValues(context);
|
return base.GetStandardValues(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user