small change

This commit is contained in:
ww-rm
2025-04-11 00:07:09 +08:00
parent 61b7b90722
commit b6f9cd0c7c
39 changed files with 99 additions and 92 deletions

View File

@@ -15,7 +15,7 @@ using System.Collections.Specialized;
using NLog; using NLog;
using SpineViewer.Extensions; using SpineViewer.Extensions;
using SpineViewer.PropertyGridWrappers.Spine; using SpineViewer.PropertyGridWrappers.Spine;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Controls namespace SpineViewer.Controls
{ {
@@ -29,12 +29,12 @@ namespace SpineViewer.Controls
/// <summary> /// <summary>
/// Spine 列表只读视图, 访问时必须使用 lock 语句锁定视图本身 /// Spine 列表只读视图, 访问时必须使用 lock 语句锁定视图本身
/// </summary> /// </summary>
public readonly ReadOnlyCollection<Spine.Spine> Spines; public readonly ReadOnlyCollection<Spine.SpineObject> Spines;
/// <summary> /// <summary>
/// Spine 列表, 访问时必须使用 lock 语句锁定只读视图 Spines /// Spine 列表, 访问时必须使用 lock 语句锁定只读视图 Spines
/// </summary> /// </summary>
private readonly List<Spine.Spine> spines = []; private readonly List<Spine.SpineObject> spines = [];
/// <summary> /// <summary>
/// 用于属性页显示模型参数的包装类 /// 用于属性页显示模型参数的包装类
@@ -80,7 +80,7 @@ namespace SpineViewer.Controls
{ {
try try
{ {
var spine = Spine.Spine.New(result.Version, result.SkelPath, result.AtlasPath); var spine = Spine.SpineObject.New(result.Version, result.SkelPath, result.AtlasPath);
// 如果索引无效则在末尾添加 // 如果索引无效则在末尾添加
if (index < 0 || index > listView.Items.Count) if (index < 0 || index > listView.Items.Count)
@@ -155,7 +155,7 @@ namespace SpineViewer.Controls
try try
{ {
var spine = Spine.Spine.New(version, skelPath); var spine = Spine.SpineObject.New(version, skelPath);
var preview = spine.Preview; var preview = spine.Preview;
lock (Spines) { spines.Add(spine); } lock (Spines) { spines.Add(spine); }
spinePropertyWrappers[spine.ID] = new(spine); spinePropertyWrappers[spine.ID] = new(spine);

View File

@@ -10,7 +10,7 @@ using System.Windows.Forms;
using System.Security.Policy; using System.Security.Policy;
using System.Diagnostics; using System.Diagnostics;
using NLog; using NLog;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Controls namespace SpineViewer.Controls
{ {

View File

@@ -8,7 +8,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using SpineViewer.PropertyGridWrappers.Spine; using SpineViewer.PropertyGridWrappers.Spine;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Controls namespace SpineViewer.Controls
{ {

View File

@@ -1,4 +1,4 @@
using SpineViewer.Utilities; using SpineViewer.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@@ -1,5 +1,5 @@
using SpineViewer.Spine; using SpineViewer.Spine;
using SpineViewer.Utilities; using SpineViewer.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -49,7 +49,7 @@ namespace SpineViewer.Dialogs
} }
} }
if (version != SpineVersion.Auto && !Spine.Spine.HasImplementation(version)) if (version != SpineVersion.Auto && !Spine.SpineObject.HasImplementation(version))
{ {
MessagePopup.Info($"{version.GetName()} 版本尚未实现(咕咕咕~"); MessagePopup.Info($"{version.GetName()} 版本尚未实现(咕咕咕~");
return; return;

View File

@@ -1,5 +1,5 @@
using SpineViewer.Spine; using SpineViewer.Spine;
using SpineViewer.Utilities; using SpineViewer.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@@ -1,5 +1,5 @@
using Microsoft.Win32; using Microsoft.Win32;
using SpineViewer.Utilities; using SpineViewer.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@@ -1,5 +1,5 @@
using SpineViewer.PropertyGridWrappers.Exporter; using SpineViewer.PropertyGridWrappers.Exporter;
using SpineViewer.Utilities; using SpineViewer.Utils;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,5 +1,5 @@
using SpineViewer.Spine; using SpineViewer.Spine;
using SpineViewer.Utilities; using SpineViewer.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -80,7 +80,7 @@ namespace SpineViewer.Dialogs
atlasPath = Path.GetFullPath(atlasPath); atlasPath = Path.GetFullPath(atlasPath);
} }
if (version != SpineVersion.Auto && !Spine.Spine.HasImplementation(version)) if (version != SpineVersion.Auto && !Spine.SpineObject.HasImplementation(version))
{ {
MessagePopup.Info($"{version.GetName()} 版本尚未实现(咕咕咕~"); MessagePopup.Info($"{version.GetName()} 版本尚未实现(咕咕咕~");
return; return;

View File

@@ -1,5 +1,5 @@
using NLog; using NLog;
using SpineViewer.Utilities; using SpineViewer.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@@ -1,7 +1,7 @@
using NLog; using NLog;
using SpineViewer.Extensions; using SpineViewer.Extensions;
using SpineViewer.PropertyGridWrappers; using SpineViewer.PropertyGridWrappers;
using SpineViewer.Utilities; using SpineViewer.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -96,12 +96,12 @@ namespace SpineViewer.Exporter
/// <summary> /// <summary>
/// 获取单个模型的单帧画面 /// 获取单个模型的单帧画面
/// </summary> /// </summary>
protected SFMLImageVideoFrame GetFrame(Spine.Spine spine) => GetFrame([spine]); protected SFMLImageVideoFrame GetFrame(Spine.SpineObject spine) => GetFrame([spine]);
/// <summary> /// <summary>
/// 获取模型列表的单帧画面 /// 获取模型列表的单帧画面
/// </summary> /// </summary>
protected SFMLImageVideoFrame GetFrame(Spine.Spine[] spinesToRender) protected SFMLImageVideoFrame GetFrame(Spine.SpineObject[] spinesToRender)
{ {
// RenderTexture 必须临时创建, 随用随取, 防止出现跨线程的情况 // RenderTexture 必须临时创建, 随用随取, 防止出现跨线程的情况
using var texPma = GetRenderTexture(); using var texPma = GetRenderTexture();
@@ -149,12 +149,12 @@ namespace SpineViewer.Exporter
/// <summary> /// <summary>
/// 每个模型在同一个画面进行导出 /// 每个模型在同一个画面进行导出
/// </summary> /// </summary>
protected abstract void ExportSingle(Spine.Spine[] spinesToRender, BackgroundWorker? worker = null); protected abstract void ExportSingle(Spine.SpineObject[] spinesToRender, BackgroundWorker? worker = null);
/// <summary> /// <summary>
/// 每个模型独立导出 /// 每个模型独立导出
/// </summary> /// </summary>
protected abstract void ExportIndividual(Spine.Spine[] spinesToRender, BackgroundWorker? worker = null); protected abstract void ExportIndividual(Spine.SpineObject[] spinesToRender, BackgroundWorker? worker = null);
/// <summary> /// <summary>
/// 检查参数是否合法并规范化参数值, 否则返回用户错误原因 /// 检查参数是否合法并规范化参数值, 否则返回用户错误原因
@@ -178,7 +178,7 @@ namespace SpineViewer.Exporter
/// <param name="spines">要进行导出的 Spine 列表</param> /// <param name="spines">要进行导出的 Spine 列表</param>
/// <param name="worker">用来执行该函数的 worker</param> /// <param name="worker">用来执行该函数的 worker</param>
/// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentException"></exception>
public virtual void Export(Spine.Spine[] spines, BackgroundWorker? worker = null) public virtual void Export(Spine.SpineObject[] spines, BackgroundWorker? worker = null)
{ {
if (Validate() is string err) if (Validate() is string err)
throw new ArgumentException(err); throw new ArgumentException(err);

View File

@@ -51,7 +51,7 @@ namespace SpineViewer.Exporter
return null; return null;
} }
protected override void ExportSingle(Spine.Spine[] spinesToRender, BackgroundWorker? worker = null) protected override void ExportSingle(Spine.SpineObject[] spinesToRender, BackgroundWorker? worker = null)
{ {
var noteSuffix = FileNameNoteSuffix; var noteSuffix = FileNameNoteSuffix;
if (!string.IsNullOrWhiteSpace(noteSuffix)) noteSuffix = $"_{noteSuffix}"; if (!string.IsNullOrWhiteSpace(noteSuffix)) noteSuffix = $"_{noteSuffix}";
@@ -76,7 +76,7 @@ namespace SpineViewer.Exporter
} }
} }
protected override void ExportIndividual(Spine.Spine[] spinesToRender, BackgroundWorker? worker = null) protected override void ExportIndividual(Spine.SpineObject[] spinesToRender, BackgroundWorker? worker = null)
{ {
var noteSuffix = FileNameNoteSuffix; var noteSuffix = FileNameNoteSuffix;
if (!string.IsNullOrWhiteSpace(noteSuffix)) noteSuffix = $"_{noteSuffix}"; if (!string.IsNullOrWhiteSpace(noteSuffix)) noteSuffix = $"_{noteSuffix}";

View File

@@ -43,7 +43,7 @@ namespace SpineViewer.Exporter
} }
private SizeF dpi = new(144, 144); private SizeF dpi = new(144, 144);
protected override void ExportSingle(Spine.Spine[] spinesToRender, BackgroundWorker? worker = null) protected override void ExportSingle(Spine.SpineObject[] spinesToRender, BackgroundWorker? worker = null)
{ {
// 导出单个时必定提供输出文件夹 // 导出单个时必定提供输出文件夹
var filename = $"frame_{timestamp}{ImageFormat.GetSuffix()}"; var filename = $"frame_{timestamp}{ImageFormat.GetSuffix()}";
@@ -65,7 +65,7 @@ namespace SpineViewer.Exporter
worker?.ReportProgress(100, $"已处理 1/1"); worker?.ReportProgress(100, $"已处理 1/1");
} }
protected override void ExportIndividual(Spine.Spine[] spinesToRender, BackgroundWorker? worker = null) protected override void ExportIndividual(Spine.SpineObject[] spinesToRender, BackgroundWorker? worker = null)
{ {
int total = spinesToRender.Length; int total = spinesToRender.Length;
int success = 0; int success = 0;

View File

@@ -18,7 +18,7 @@ namespace SpineViewer.Exporter
/// </summary> /// </summary>
public string Suffix { get; set; } = ".png"; public string Suffix { get; set; } = ".png";
protected override void ExportSingle(Spine.Spine[] spinesToRender, BackgroundWorker? worker = null) protected override void ExportSingle(Spine.SpineObject[] spinesToRender, BackgroundWorker? worker = null)
{ {
// 导出单个时必定提供输出文件夹, // 导出单个时必定提供输出文件夹,
var saveDir = Path.Combine(OutputDir, $"frames_{timestamp}_{FPS:f0}"); var saveDir = Path.Combine(OutputDir, $"frames_{timestamp}_{FPS:f0}");
@@ -47,7 +47,7 @@ namespace SpineViewer.Exporter
} }
} }
protected override void ExportIndividual(Spine.Spine[] spinesToRender, BackgroundWorker? worker = null) protected override void ExportIndividual(Spine.SpineObject[] spinesToRender, BackgroundWorker? worker = null)
{ {
foreach (var spine in spinesToRender) foreach (var spine in spinesToRender)
{ {

View File

@@ -41,7 +41,7 @@ namespace SpineViewer.Exporter
/// <summary> /// <summary>
/// 生成单个模型的帧序列 /// 生成单个模型的帧序列
/// </summary> /// </summary>
protected IEnumerable<SFMLImageVideoFrame> GetFrames(Spine.Spine spine, BackgroundWorker? worker = null) protected IEnumerable<SFMLImageVideoFrame> GetFrames(Spine.SpineObject spine, BackgroundWorker? worker = null)
{ {
// 独立导出时如果 Duration 小于 0 则使用所有轨道上动画时长最大值 // 独立导出时如果 Duration 小于 0 则使用所有轨道上动画时长最大值
var duration = Duration; var duration = Duration;
@@ -90,7 +90,7 @@ namespace SpineViewer.Exporter
/// <summary> /// <summary>
/// 生成多个模型的帧序列 /// 生成多个模型的帧序列
/// </summary> /// </summary>
protected IEnumerable<SFMLImageVideoFrame> GetFrames(Spine.Spine[] spinesToRender, BackgroundWorker? worker = null) protected IEnumerable<SFMLImageVideoFrame> GetFrames(Spine.SpineObject[] spinesToRender, BackgroundWorker? worker = null)
{ {
// 导出单个时必须根据 Duration 决定导出时长 // 导出单个时必须根据 Duration 决定导出时长
var duration = Duration; var duration = Duration;
@@ -135,7 +135,7 @@ namespace SpineViewer.Exporter
} }
} }
public override void Export(Spine.Spine[] spines, BackgroundWorker? worker = null) public override void Export(Spine.SpineObject[] spines, BackgroundWorker? worker = null)
{ {
// 导出视频格式需要把模型时间都重置到 0 // 导出视频格式需要把模型时间都重置到 0
foreach (var spine in spines) spine.ResetAnimationsTime(); foreach (var spine in spines) spine.ResetAnimationsTime();

View File

@@ -5,8 +5,8 @@ using System.Diagnostics;
using SpineViewer.Exporter; using SpineViewer.Exporter;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using SpineViewer.PropertyGridWrappers.Exporter; using SpineViewer.PropertyGridWrappers.Exporter;
using SpineViewer.Utilities;
using SpineViewer.Natives; using SpineViewer.Natives;
using SpineViewer.Utils;
namespace SpineViewer namespace SpineViewer
{ {

View File

@@ -1,5 +1,5 @@
using NLog; using NLog;
using SpineViewer.Utilities; using SpineViewer.Utils;
using System.Diagnostics; using System.Diagnostics;
using System.Reflection; using System.Reflection;

View File

@@ -14,9 +14,9 @@ namespace SpineViewer.PropertyGridWrappers.Spine
/// <param name="spine"></param> /// <param name="spine"></param>
/// <param name="i"></param> /// <param name="i"></param>
[TypeConverter(typeof(TrackWrapperConverter))] [TypeConverter(typeof(TrackWrapperConverter))]
public class TrackWrapper(SpineViewer.Spine.Spine spine, int i) public class TrackWrapper(SpineObject spine, int i)
{ {
private readonly SpineViewer.Spine.Spine spine = spine; private readonly SpineObject spine = spine;
[Browsable(false)] [Browsable(false)]
public int Index { get; } = i; public int Index { get; } = i;
@@ -47,7 +47,7 @@ namespace SpineViewer.PropertyGridWrappers.Spine
/// <summary> /// <summary>
/// 用于在 PropertyGrid 上显示 Spine 动画列表的包装类 /// 用于在 PropertyGrid 上显示 Spine 动画列表的包装类
/// </summary> /// </summary>
public class SpineAnimationWrapper(SpineViewer.Spine.Spine spine) : ICustomTypeDescriptor public class SpineAnimationWrapper(SpineObject spine) : ICustomTypeDescriptor
{ {
/// <summary> /// <summary>
/// 轨道属性描述符, 实现对属性的读取和赋值 /// 轨道属性描述符, 实现对属性的读取和赋值
@@ -88,7 +88,7 @@ namespace SpineViewer.PropertyGridWrappers.Spine
} }
[Browsable(false)] [Browsable(false)]
public SpineViewer.Spine.Spine Spine { get; } = spine; public SpineObject Spine { get; } = spine;
/// <summary> /// <summary>
/// 全轨道动画最大时长 /// 全轨道动画最大时长

View File

@@ -11,10 +11,10 @@ namespace SpineViewer.PropertyGridWrappers.Spine
/// <summary> /// <summary>
/// 用于在 PropertyGrid 上显示 Spine 基本信息的包装类 /// 用于在 PropertyGrid 上显示 Spine 基本信息的包装类
/// </summary> /// </summary>
public class SpineBaseInfoWrapper(SpineViewer.Spine.Spine spine) public class SpineBaseInfoWrapper(SpineObject spine)
{ {
[Browsable(false)] [Browsable(false)]
public SpineViewer.Spine.Spine Spine { get; } = spine; public SpineObject Spine { get; } = spine;
/// <summary> /// <summary>
/// 获取所属版本 /// 获取所属版本

View File

@@ -4,16 +4,17 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineViewer.Spine;
namespace SpineViewer.PropertyGridWrappers.Spine namespace SpineViewer.PropertyGridWrappers.Spine
{ {
/// <summary> /// <summary>
/// 用于在 PropertyGrid 上显示 Spine 调试属性的包装类 /// 用于在 PropertyGrid 上显示 Spine 调试属性的包装类
/// </summary> /// </summary>
public class SpineDebugWrapper(SpineViewer.Spine.Spine spine) public class SpineDebugWrapper(SpineObject spine)
{ {
[Browsable(false)] [Browsable(false)]
public SpineViewer.Spine.Spine Spine { get; } = spine; public SpineObject Spine { get; } = spine;
/// <summary> /// <summary>
/// 显示纹理 /// 显示纹理

View File

@@ -4,16 +4,17 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineViewer.Spine;
namespace SpineViewer.PropertyGridWrappers.Spine namespace SpineViewer.PropertyGridWrappers.Spine
{ {
/// <summary> /// <summary>
/// 用于在 PropertyGrid 上显示 Spine 渲染设置的包装类 /// 用于在 PropertyGrid 上显示 Spine 渲染设置的包装类
/// </summary> /// </summary>
public class SpineRenderWrapper(SpineViewer.Spine.Spine spine) public class SpineRenderWrapper(SpineObject spine)
{ {
[Browsable(false)] [Browsable(false)]
public SpineViewer.Spine.Spine Spine { get; } = spine; public SpineObject Spine { get; } = spine;
/// <summary> /// <summary>
/// 是否被隐藏, 被隐藏的模型将仅仅在列表显示, 不参与其他行为 /// 是否被隐藏, 被隐藏的模型将仅仅在列表显示, 不参与其他行为

View File

@@ -12,9 +12,9 @@ namespace SpineViewer.PropertyGridWrappers.Spine
/// 对皮肤属性的包装类 /// 对皮肤属性的包装类
/// </summary> /// </summary>
[TypeConverter(typeof(SkinWrapperConverter))] [TypeConverter(typeof(SkinWrapperConverter))]
public class SkinWrapper(SpineViewer.Spine.Spine spine, int i) public class SkinWrapper(SpineObject spine, int i)
{ {
private readonly SpineViewer.Spine.Spine spine = spine; private readonly SpineObject spine = spine;
[Browsable(false)] [Browsable(false)]
public int Index { get; } = i; public int Index { get; } = i;
@@ -40,7 +40,7 @@ namespace SpineViewer.PropertyGridWrappers.Spine
/// 皮肤列表动态类型包装类, 用于提供对 Spine 皮肤列表的管理能力 /// 皮肤列表动态类型包装类, 用于提供对 Spine 皮肤列表的管理能力
/// </summary> /// </summary>
/// <param name="spine">关联的 Spine 对象</param> /// <param name="spine">关联的 Spine 对象</param>
public class SpineSkinWrapper(SpineViewer.Spine.Spine spine) : ICustomTypeDescriptor public class SpineSkinWrapper(SpineObject spine) : ICustomTypeDescriptor
{ {
/// <summary> /// <summary>
/// 皮肤属性描述符, 实现对属性的读取和赋值 /// 皮肤属性描述符, 实现对属性的读取和赋值
@@ -80,7 +80,7 @@ namespace SpineViewer.PropertyGridWrappers.Spine
} }
[Browsable(false)] [Browsable(false)]
public SpineViewer.Spine.Spine Spine { get; } = spine; public SpineObject Spine { get; } = spine;
/// <summary> /// <summary>
/// SkinWrapper 属性缓存 /// SkinWrapper 属性缓存

View File

@@ -4,16 +4,17 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineViewer.Spine;
namespace SpineViewer.PropertyGridWrappers.Spine namespace SpineViewer.PropertyGridWrappers.Spine
{ {
/// <summary> /// <summary>
/// 用于在 PropertyGrid 上显示 Spine 空间变换的包装类 /// 用于在 PropertyGrid 上显示 Spine 空间变换的包装类
/// </summary> /// </summary>
public class SpineTransformWrapper(SpineViewer.Spine.Spine spine) public class SpineTransformWrapper(SpineObject spine)
{ {
[Browsable(false)] [Browsable(false)]
public SpineViewer.Spine.Spine Spine { get; } = spine; public SpineObject Spine { get; } = spine;
/// <summary> /// <summary>
/// 缩放比例 /// 缩放比例

View File

@@ -5,13 +5,14 @@ using System.Drawing.Design;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineViewer.Spine;
namespace SpineViewer.PropertyGridWrappers.Spine namespace SpineViewer.PropertyGridWrappers.Spine
{ {
public class SpineWrapper(SpineViewer.Spine.Spine spine) public class SpineWrapper(SpineObject spine)
{ {
[Browsable(false)] [Browsable(false)]
public SpineViewer.Spine.Spine Spine { get; } = spine; public SpineObject Spine { get; } = spine;
[DisplayName("基本信息")] [DisplayName("基本信息")]
public SpineBaseInfoWrapper BaseInfo { get; } = new(spine); public SpineBaseInfoWrapper BaseInfo { get; } = new(spine);

View File

@@ -120,11 +120,11 @@ namespace SpineViewer.PropertyGridWrappers
public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context) public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context)
{ {
if (context?.Instance is SpineViewer.Spine.Spine obj) if (context?.Instance is SpineObject obj)
{ {
return new StandardValuesCollection(obj.SkinNames); return new StandardValuesCollection(obj.SkinNames);
} }
else if (context?.Instance is SpineViewer.Spine.Spine[] spines) else if (context?.Instance is SpineObject[] spines)
{ {
if (spines.Length > 0) if (spines.Length > 0)
{ {
@@ -146,11 +146,11 @@ namespace SpineViewer.PropertyGridWrappers
public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context) public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context)
{ {
if (context?.Instance is SpineViewer.Spine.Spine obj) if (context?.Instance is SpineObject obj)
{ {
return new StandardValuesCollection(obj.AnimationNames); return new StandardValuesCollection(obj.AnimationNames);
} }
else if (context?.Instance is SpineViewer.Spine.Spine[] spines) else if (context?.Instance is SpineObject[] spines)
{ {
if (spines.Length > 0) if (spines.Length > 0)
{ {

View File

@@ -7,12 +7,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime21; using SpineRuntime21;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(SpineVersion.V21)] [SpineImplementation(SpineVersion.V21)]
internal class Spine21 : SpineViewer.Spine.Spine internal class SpineObject21 : SpineObject
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
@@ -48,7 +48,7 @@ namespace SpineViewer.Spine.Implementations.Spine
// 2.1.x 不支持剪裁 // 2.1.x 不支持剪裁
//private SkeletonClipping clipping = new(); //private SkeletonClipping clipping = new();
public Spine21(string skelPath, string atlasPath) : base(skelPath, atlasPath) public SpineObject21(string skelPath, string atlasPath) : base(skelPath, atlasPath)
{ {
atlas = new Atlas(AtlasPath, textureLoader); atlas = new Atlas(AtlasPath, textureLoader);
try try

View File

@@ -7,12 +7,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime36; using SpineRuntime36;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(SpineVersion.V36)] [SpineImplementation(SpineVersion.V36)]
internal class Spine36 : SpineViewer.Spine.Spine internal class SpineObject36 : SpineObject
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
@@ -47,7 +47,7 @@ namespace SpineViewer.Spine.Implementations.Spine
private SkeletonClipping clipping = new(); private SkeletonClipping clipping = new();
public Spine36(string skelPath, string atlasPath) : base(skelPath, atlasPath) public SpineObject36(string skelPath, string atlasPath) : base(skelPath, atlasPath)
{ {
atlas = new Atlas(AtlasPath, textureLoader); atlas = new Atlas(AtlasPath, textureLoader);
try try

View File

@@ -4,12 +4,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime37; using SpineRuntime37;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(SpineVersion.V37)] [SpineImplementation(SpineVersion.V37)]
internal class Spine37 : SpineViewer.Spine.Spine internal class SpineObject37 : SpineObject
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
@@ -45,7 +45,7 @@ namespace SpineViewer.Spine.Implementations.Spine
private SkeletonClipping clipping = new(); private SkeletonClipping clipping = new();
public Spine37(string skelPath, string atlasPath) : base(skelPath, atlasPath) public SpineObject37(string skelPath, string atlasPath) : base(skelPath, atlasPath)
{ {
atlas = new Atlas(AtlasPath, textureLoader); atlas = new Atlas(AtlasPath, textureLoader);
try try

View File

@@ -7,12 +7,12 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime38; using SpineRuntime38;
using SpineRuntime38.Attachments; using SpineRuntime38.Attachments;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(SpineVersion.V38)] [SpineImplementation(SpineVersion.V38)]
internal class Spine38 : SpineViewer.Spine.Spine internal class SpineObject38 : SpineObject
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
@@ -51,7 +51,7 @@ namespace SpineViewer.Spine.Implementations.Spine
private SkeletonClipping clipping = new(); private SkeletonClipping clipping = new();
public Spine38(string skelPath, string atlasPath) : base(skelPath, atlasPath) public SpineObject38(string skelPath, string atlasPath) : base(skelPath, atlasPath)
{ {
atlas = new Atlas(AtlasPath, textureLoader); atlas = new Atlas(AtlasPath, textureLoader);
try try

View File

@@ -6,12 +6,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime40; using SpineRuntime40;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(SpineVersion.V40)] [SpineImplementation(SpineVersion.V40)]
internal class Spine40 : SpineViewer.Spine.Spine internal class SpineObject40 : SpineObject
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
@@ -47,7 +47,7 @@ namespace SpineViewer.Spine.Implementations.Spine
private SkeletonClipping clipping = new(); private SkeletonClipping clipping = new();
public Spine40(string skelPath, string atlasPath) : base(skelPath, atlasPath) public SpineObject40(string skelPath, string atlasPath) : base(skelPath, atlasPath)
{ {
atlas = new Atlas(AtlasPath, textureLoader); atlas = new Atlas(AtlasPath, textureLoader);
try try

View File

@@ -6,12 +6,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime41; using SpineRuntime41;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(SpineVersion.V41)] [SpineImplementation(SpineVersion.V41)]
internal class Spine41 : SpineViewer.Spine.Spine internal class SpineObject41 : SpineObject
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
@@ -47,7 +47,7 @@ namespace SpineViewer.Spine.Implementations.Spine
private SkeletonClipping clipping = new(); private SkeletonClipping clipping = new();
public Spine41(string skelPath, string atlasPath) : base(skelPath, atlasPath) public SpineObject41(string skelPath, string atlasPath) : base(skelPath, atlasPath)
{ {
atlas = new Atlas(AtlasPath, textureLoader); atlas = new Atlas(AtlasPath, textureLoader);
try try

View File

@@ -6,12 +6,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime42; using SpineRuntime42;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(SpineVersion.V42)] [SpineImplementation(SpineVersion.V42)]
internal class Spine42 : SpineViewer.Spine.Spine internal class Spineobject42 : SpineObject
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);
@@ -47,7 +47,7 @@ namespace SpineViewer.Spine.Implementations.Spine
private SkeletonClipping clipping = new(); private SkeletonClipping clipping = new();
public Spine42(string skelPath, string atlasPath) : base(skelPath, atlasPath) public Spineobject42(string skelPath, string atlasPath) : base(skelPath, atlasPath)
{ {
atlas = new Atlas(AtlasPath, textureLoader); atlas = new Atlas(AtlasPath, textureLoader);
try try

View File

@@ -9,7 +9,7 @@ using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Spine namespace SpineViewer.Spine
{ {

View File

@@ -1,4 +1,4 @@
using SpineViewer.Utilities; using SpineViewer.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;

View File

@@ -5,14 +5,14 @@ using System.Drawing.Design;
using NLog; using NLog;
using System.Xml.Linq; using System.Xml.Linq;
using SpineViewer.Extensions; using SpineViewer.Extensions;
using SpineViewer.Utilities; using SpineViewer.Utils;
namespace SpineViewer.Spine namespace SpineViewer.Spine
{ {
/// <summary> /// <summary>
/// Spine 基类, 使用静态方法 New 来创建具体版本对象, 该类是线程安全的 /// Spine 基类, 使用静态方法 New 来创建具体版本对象, 该类是线程安全的
/// </summary> /// </summary>
public abstract class Spine : ImplementationResolver<Spine, SpineImplementationAttribute, SpineVersion>, SFML.Graphics.Drawable, IDisposable public abstract class SpineObject : ImplementationResolver<SpineObject, SpineImplementationAttribute, SpineVersion>, SFML.Graphics.Drawable, IDisposable
{ {
/// <summary> /// <summary>
/// 空动画标记 /// 空动画标记
@@ -32,7 +32,7 @@ namespace SpineViewer.Spine
/// <summary> /// <summary>
/// 创建特定版本的 Spine /// 创建特定版本的 Spine
/// </summary> /// </summary>
public static Spine New(SpineVersion version, string skelPath, string? atlasPath = null) public static SpineObject New(SpineVersion version, string skelPath, string? atlasPath = null)
{ {
atlasPath ??= Path.ChangeExtension(skelPath, ".atlas"); atlasPath ??= Path.ChangeExtension(skelPath, ".atlas");
skelPath = Path.GetFullPath(skelPath); skelPath = Path.GetFullPath(skelPath);
@@ -48,13 +48,16 @@ namespace SpineViewer.Spine
/// </summary> /// </summary>
private readonly object _lock = new(); private readonly object _lock = new();
private readonly Logger logger = LogManager.GetCurrentClassLogger(); /// <summary>
/// 日志器
/// </summary>
protected readonly Logger logger = LogManager.GetCurrentClassLogger();
private bool skinLoggerWarned = false; private bool skinLoggerWarned = false;
/// <summary> /// <summary>
/// 构造函数 /// 构造函数
/// </summary> /// </summary>
public Spine(string skelPath, string atlasPath) public SpineObject(string skelPath, string atlasPath)
{ {
Version = GetType().GetCustomAttribute<SpineImplementationAttribute>().ImplementationKey; Version = GetType().GetCustomAttribute<SpineImplementationAttribute>().ImplementationKey;
AssetsDir = Directory.GetParent(skelPath).FullName; AssetsDir = Directory.GetParent(skelPath).FullName;
@@ -66,7 +69,7 @@ namespace SpineViewer.Spine
/// <summary> /// <summary>
/// 构造函数之后的初始化工作 /// 构造函数之后的初始化工作
/// </summary> /// </summary>
private Spine PostInit() private SpineObject PostInit()
{ {
SkinNames = skinNames.AsReadOnly(); SkinNames = skinNames.AsReadOnly();
AnimationNames = animationNames.AsReadOnly(); AnimationNames = animationNames.AsReadOnly();
@@ -98,7 +101,7 @@ namespace SpineViewer.Spine
return this; return this;
} }
~Spine() { Dispose(false); } ~SpineObject() { Dispose(false); }
public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); }
protected virtual void Dispose(bool disposing) { Preview?.Dispose(); } protected virtual void Dispose(bool disposing) { Preview?.Dispose(); }
@@ -279,7 +282,7 @@ namespace SpineViewer.Spine
loadedSkins.Add(name); loadedSkins.Add(name);
reloadSkins(); reloadSkins();
if (!skinLoggerWarned && Version <= SpineVersion.V37 && loadedSkins.Count > 1) if (!skinLoggerWarned && Version < SpineVersion.V38 && loadedSkins.Count > 1)
{ {
logger.Warn($"Multiplt skins not supported in SpineVersion {Version.GetName()}"); logger.Warn($"Multiplt skins not supported in SpineVersion {Version.GetName()}");
skinLoggerWarned = true; skinLoggerWarned = true;
@@ -292,9 +295,9 @@ namespace SpineViewer.Spine
/// </summary> /// </summary>
public void UnloadSkin(int idx) public void UnloadSkin(int idx)
{ {
if (idx < 0 || idx >= loadedSkins.Count) return;
lock (_lock) lock (_lock)
{ {
if (idx < 0 || idx >= loadedSkins.Count) return;
loadedSkins.RemoveAt(idx); loadedSkins.RemoveAt(idx);
reloadSkins(); reloadSkins();
} }
@@ -305,9 +308,9 @@ namespace SpineViewer.Spine
/// </summary> /// </summary>
public void ReplaceSkin(int idx, string name) public void ReplaceSkin(int idx, string name)
{ {
if (idx < 0 || idx >= loadedSkins.Count || !skinNames.Contains(name)) return;
lock (_lock) lock (_lock)
{ {
if (idx < 0 || idx >= loadedSkins.Count || !skinNames.Contains(name)) return;
loadedSkins[idx] = name; loadedSkins[idx] = name;
reloadSkins(); reloadSkins();
} }

View File

@@ -6,7 +6,7 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SpineViewer.Utilities namespace SpineViewer.Utils
{ {
public interface IImplementationKey<TKey> public interface IImplementationKey<TKey>
{ {

View File

@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
namespace SpineViewer.Utilities namespace SpineViewer.Utils
{ {
/// <summary> /// <summary>
/// 弹窗消息静态类 /// 弹窗消息静态类

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SpineViewer.Utilities namespace SpineViewer.Utils
{ {
/// <summary> /// <summary>
/// SFML 混合模式, 预乘模式下输入和输出的像素值都是预乘的 /// SFML 混合模式, 预乘模式下输入和输出的像素值都是预乘的

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SpineViewer.Utilities namespace SpineViewer.Utils
{ {
public static class SFMLShader public static class SFMLShader
{ {