重命名SpineVersion

This commit is contained in:
ww-rm
2025-03-29 16:59:28 +08:00
parent 9a97e84296
commit ad39a04fff
17 changed files with 70 additions and 70 deletions

View File

@@ -219,11 +219,11 @@ namespace SpineViewer.Controls
if (MessageBox.Quest($"共发现 {validPaths.Count} 个可加载骨骼,数量较多,是否一次性全部加载?") == DialogResult.Cancel) if (MessageBox.Quest($"共发现 {validPaths.Count} 个可加载骨骼,数量较多,是否一次性全部加载?") == DialogResult.Cancel)
return; return;
} }
BatchAdd(new Dialogs.BatchOpenSpineDialogResult(Spine.Version.Auto, validPaths.ToArray())); BatchAdd(new Dialogs.BatchOpenSpineDialogResult(SpineVersion.Auto, validPaths.ToArray()));
} }
else if (validPaths.Count > 0) else if (validPaths.Count > 0)
{ {
Insert(new Dialogs.OpenSpineDialogResult(Spine.Version.Auto, validPaths[0])); Insert(new Dialogs.OpenSpineDialogResult(SpineVersion.Auto, validPaths[0]));
} }
} }

View File

@@ -24,12 +24,12 @@ namespace SpineViewer.Dialogs
comboBox_Version.DataSource = SpineHelper.Names.ToList(); comboBox_Version.DataSource = SpineHelper.Names.ToList();
comboBox_Version.DisplayMember = "Value"; comboBox_Version.DisplayMember = "Value";
comboBox_Version.ValueMember = "Key"; comboBox_Version.ValueMember = "Key";
comboBox_Version.SelectedValue = Spine.Version.Auto; comboBox_Version.SelectedValue = SpineVersion.Auto;
} }
private void button_Ok_Click(object sender, EventArgs e) private void button_Ok_Click(object sender, EventArgs e)
{ {
var version = (Spine.Version)comboBox_Version.SelectedValue; var version = (SpineVersion)comboBox_Version.SelectedValue;
var items = skelFileListBox.Items; var items = skelFileListBox.Items;
@@ -48,7 +48,7 @@ namespace SpineViewer.Dialogs
} }
} }
if (version != Spine.Version.Auto && !Spine.Spine.HasImplementation(version)) if (version != SpineVersion.Auto && !Spine.Spine.HasImplementation(version))
{ {
MessageBox.Info($"{version.GetName()} 版本尚未实现(咕咕咕~"); MessageBox.Info($"{version.GetName()} 版本尚未实现(咕咕咕~");
return; return;
@@ -67,12 +67,12 @@ namespace SpineViewer.Dialogs
/// <summary> /// <summary>
/// 批量打开对话框结果 /// 批量打开对话框结果
/// </summary> /// </summary>
public class BatchOpenSpineDialogResult(Spine.Version version, string[] skelPaths) public class BatchOpenSpineDialogResult(SpineVersion version, string[] skelPaths)
{ {
/// <summary> /// <summary>
/// 版本 /// 版本
/// </summary> /// </summary>
public Spine.Version Version => version; public SpineVersion Version => version;
/// <summary> /// <summary>
/// 路径列表 /// 路径列表

View File

@@ -25,21 +25,21 @@ namespace SpineViewer.Dialogs
comboBox_SourceVersion.DataSource = SpineHelper.Names.ToList(); comboBox_SourceVersion.DataSource = SpineHelper.Names.ToList();
comboBox_SourceVersion.DisplayMember = "Value"; comboBox_SourceVersion.DisplayMember = "Value";
comboBox_SourceVersion.ValueMember = "Key"; comboBox_SourceVersion.ValueMember = "Key";
comboBox_SourceVersion.SelectedValue = Spine.Version.Auto; comboBox_SourceVersion.SelectedValue = SpineVersion.Auto;
// 目标版本不包含自动 // 目标版本不包含自动
var versionsWithoutAuto = SpineHelper.Names.ToDictionary(); var versionsWithoutAuto = SpineHelper.Names.ToDictionary();
versionsWithoutAuto.Remove(Spine.Version.Auto); versionsWithoutAuto.Remove(SpineVersion.Auto);
comboBox_TargetVersion.DataSource = versionsWithoutAuto.ToList(); comboBox_TargetVersion.DataSource = versionsWithoutAuto.ToList();
comboBox_TargetVersion.DisplayMember = "Value"; comboBox_TargetVersion.DisplayMember = "Value";
comboBox_TargetVersion.ValueMember = "Key"; comboBox_TargetVersion.ValueMember = "Key";
comboBox_TargetVersion.SelectedValue = Spine.Version.V38; comboBox_TargetVersion.SelectedValue = SpineVersion.V38;
} }
private void button_Ok_Click(object sender, EventArgs e) private void button_Ok_Click(object sender, EventArgs e)
{ {
var sourceVersion = (Spine.Version)comboBox_SourceVersion.SelectedValue; var sourceVersion = (SpineVersion)comboBox_SourceVersion.SelectedValue;
var targetVersion = (Spine.Version)comboBox_TargetVersion.SelectedValue; var targetVersion = (SpineVersion)comboBox_TargetVersion.SelectedValue;
var jsonTarget = radioButton_JsonTarget.Checked; var jsonTarget = radioButton_JsonTarget.Checked;
var items = skelFileListBox.Items; var items = skelFileListBox.Items;
@@ -59,7 +59,7 @@ namespace SpineViewer.Dialogs
} }
} }
if (sourceVersion != Spine.Version.Auto && !SkeletonConverter.HasImplementation(sourceVersion)) if (sourceVersion != SpineVersion.Auto && !SkeletonConverter.HasImplementation(sourceVersion))
{ {
MessageBox.Info($"{sourceVersion.GetName()} 版本尚未实现(咕咕咕~"); MessageBox.Info($"{sourceVersion.GetName()} 版本尚未实现(咕咕咕~");
return; return;
@@ -84,7 +84,7 @@ namespace SpineViewer.Dialogs
/// <summary> /// <summary>
/// 文件格式转换对话框结果包装类 /// 文件格式转换对话框结果包装类
/// </summary> /// </summary>
public class ConvertFileFormatDialogResult(string[] skelPaths, Spine.Version sourceVersion, Spine.Version targetVersion, bool jsonTarget) public class ConvertFileFormatDialogResult(string[] skelPaths, SpineVersion sourceVersion, SpineVersion targetVersion, bool jsonTarget)
{ {
/// <summary> /// <summary>
/// 骨骼文件路径列表 /// 骨骼文件路径列表
@@ -94,12 +94,12 @@ namespace SpineViewer.Dialogs
/// <summary> /// <summary>
/// 源版本 /// 源版本
/// </summary> /// </summary>
public Spine.Version SourceVersion => sourceVersion; public SpineVersion SourceVersion => sourceVersion;
/// <summary> /// <summary>
/// 目标版本 /// 目标版本
/// </summary> /// </summary>
public Spine.Version TargetVersion => targetVersion; public SpineVersion TargetVersion => targetVersion;
/// <summary> /// <summary>
/// 目标格式是否为 Json /// 目标格式是否为 Json

View File

@@ -23,7 +23,7 @@ namespace SpineViewer.Dialogs
comboBox_Version.DataSource = SpineHelper.Names.ToList(); comboBox_Version.DataSource = SpineHelper.Names.ToList();
comboBox_Version.DisplayMember = "Value"; comboBox_Version.DisplayMember = "Value";
comboBox_Version.ValueMember = "Key"; comboBox_Version.ValueMember = "Key";
comboBox_Version.SelectedValue = Spine.Version.Auto; comboBox_Version.SelectedValue = SpineVersion.Auto;
} }
private void OpenSpineDialog_Load(object sender, EventArgs e) private void OpenSpineDialog_Load(object sender, EventArgs e)
@@ -53,7 +53,7 @@ namespace SpineViewer.Dialogs
{ {
var skelPath = textBox_SkelPath.Text; var skelPath = textBox_SkelPath.Text;
var atlasPath = textBox_AtlasPath.Text; var atlasPath = textBox_AtlasPath.Text;
var version = (Spine.Version)comboBox_Version.SelectedValue; var version = (SpineVersion)comboBox_Version.SelectedValue;
if (!File.Exists(skelPath)) if (!File.Exists(skelPath))
{ {
@@ -79,7 +79,7 @@ namespace SpineViewer.Dialogs
atlasPath = Path.GetFullPath(atlasPath); atlasPath = Path.GetFullPath(atlasPath);
} }
if (version != Spine.Version.Auto && !Spine.Spine.HasImplementation(version)) if (version != SpineVersion.Auto && !Spine.Spine.HasImplementation(version))
{ {
MessageBox.Info($"{version.GetName()} 版本尚未实现(咕咕咕~"); MessageBox.Info($"{version.GetName()} 版本尚未实现(咕咕咕~");
return; return;
@@ -98,12 +98,12 @@ namespace SpineViewer.Dialogs
/// <summary> /// <summary>
/// 打开骨骼对话框结果 /// 打开骨骼对话框结果
/// </summary> /// </summary>
public class OpenSpineDialogResult(Spine.Version version, string skelPath, string? atlasPath = null) public class OpenSpineDialogResult(SpineVersion version, string skelPath, string? atlasPath = null)
{ {
/// <summary> /// <summary>
/// 版本 /// 版本
/// </summary> /// </summary>
public Spine.Version Version => version; public SpineVersion Version => version;
/// <summary> /// <summary>
/// skel 文件路径 /// skel 文件路径

View File

@@ -183,7 +183,7 @@ namespace SpineViewer
int success = 0; int success = 0;
int error = 0; int error = 0;
SkeletonConverter srcCvter = srcVersion != Spine.Version.Auto ? SkeletonConverter.New(srcVersion) : null; SkeletonConverter srcCvter = srcVersion != SpineVersion.Auto ? SkeletonConverter.New(srcVersion) : null;
SkeletonConverter tgtCvter = SkeletonConverter.New(tgtVersion); SkeletonConverter tgtCvter = SkeletonConverter.New(tgtVersion);
worker.ReportProgress(0, $"已处理 0/{totalCount}"); worker.ReportProgress(0, $"已处理 0/{totalCount}");
@@ -200,7 +200,7 @@ namespace SpineViewer
try try
{ {
if (srcVersion == Spine.Version.Auto) if (srcVersion == SpineVersion.Auto)
{ {
try try
{ {

View File

@@ -11,7 +11,7 @@ using System.Globalization;
namespace SpineViewer.Spine.Implementations.SkeletonConverter namespace SpineViewer.Spine.Implementations.SkeletonConverter
{ {
[SpineImplementation(Version.V38)] [SpineImplementation(SpineVersion.V38)]
class SkeletonConverter38 : SpineViewer.Spine.SkeletonConverter class SkeletonConverter38 : SpineViewer.Spine.SkeletonConverter
{ {
private BinaryReader reader = null; private BinaryReader reader = null;
@@ -1286,11 +1286,11 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
base.WriteJson(root, jsonPath); base.WriteJson(root, jsonPath);
} }
public override JsonObject ToVersion(JsonObject root, Version version) public override JsonObject ToVersion(JsonObject root, SpineVersion version)
{ {
root = version switch root = version switch
{ {
Version.V38 => root.DeepClone().AsObject(), SpineVersion.V38 => root.DeepClone().AsObject(),
_ => throw new NotImplementedException(), _ => throw new NotImplementedException(),
}; };
return root; return root;

View File

@@ -10,7 +10,7 @@ using SpineRuntime21;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(Version.V21)] [SpineImplementation(SpineVersion.V21)]
internal class Spine21 : SpineViewer.Spine.Spine internal class Spine21 : SpineViewer.Spine.Spine
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);

View File

@@ -10,7 +10,7 @@ using SpineRuntime36;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(Version.V36)] [SpineImplementation(SpineVersion.V36)]
internal class Spine36 : SpineViewer.Spine.Spine internal class Spine36 : SpineViewer.Spine.Spine
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);

View File

@@ -7,7 +7,7 @@ using SpineRuntime37;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(Version.V37)] [SpineImplementation(SpineVersion.V37)]
internal class Spine37 : SpineViewer.Spine.Spine internal class Spine37 : SpineViewer.Spine.Spine
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);

View File

@@ -10,7 +10,7 @@ using SpineRuntime38.Attachments;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(Version.V38)] [SpineImplementation(SpineVersion.V38)]
internal class Spine38 : SpineViewer.Spine.Spine internal class Spine38 : SpineViewer.Spine.Spine
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);

View File

@@ -9,7 +9,7 @@ using SpineRuntime40;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(Version.V40)] [SpineImplementation(SpineVersion.V40)]
internal class Spine40 : SpineViewer.Spine.Spine internal class Spine40 : SpineViewer.Spine.Spine
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);

View File

@@ -9,7 +9,7 @@ using SpineRuntime41;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(Version.V41)] [SpineImplementation(SpineVersion.V41)]
internal class Spine41 : SpineViewer.Spine.Spine internal class Spine41 : SpineViewer.Spine.Spine
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);

View File

@@ -9,7 +9,7 @@ using SpineRuntime42;
namespace SpineViewer.Spine.Implementations.Spine namespace SpineViewer.Spine.Implementations.Spine
{ {
[SpineImplementation(Version.V42)] [SpineImplementation(SpineVersion.V42)]
internal class Spine42 : SpineViewer.Spine.Spine internal class Spine42 : SpineViewer.Spine.Spine
{ {
private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0); private static readonly Animation EmptyAnimation = new(EMPTY_ANIMATION, [], 0);

View File

@@ -15,12 +15,12 @@ namespace SpineViewer.Spine
/// <summary> /// <summary>
/// SkeletonConverter 基类, 使用静态方法 New 来创建具体版本对象 /// SkeletonConverter 基类, 使用静态方法 New 来创建具体版本对象
/// </summary> /// </summary>
public abstract class SkeletonConverter : ImplementationResolver<SkeletonConverter, SpineImplementationAttribute, Version> public abstract class SkeletonConverter : ImplementationResolver<SkeletonConverter, SpineImplementationAttribute, SpineVersion>
{ {
/// <summary> /// <summary>
/// 创建特定版本的 SkeletonConverter /// 创建特定版本的 SkeletonConverter
/// </summary> /// </summary>
public static SkeletonConverter New(Version version) => New(version, []); public static SkeletonConverter New(SpineVersion version) => New(version, []);
/// <summary> /// <summary>
/// Json 格式控制 /// Json 格式控制
@@ -89,7 +89,7 @@ namespace SpineViewer.Spine
/// <summary> /// <summary>
/// 转换到目标版本 /// 转换到目标版本
/// </summary> /// </summary>
public abstract JsonObject ToVersion(JsonObject root, Version version); public abstract JsonObject ToVersion(JsonObject root, SpineVersion version);
/// <summary> /// <summary>
/// 二进制骨骼文件读 /// 二进制骨骼文件读

View File

@@ -21,7 +21,7 @@ namespace SpineViewer.Spine
/// <summary> /// <summary>
/// Spine 基类, 使用静态方法 New 来创建具体版本对象 /// Spine 基类, 使用静态方法 New 来创建具体版本对象
/// </summary> /// </summary>
public abstract class Spine : ImplementationResolver<Spine, SpineImplementationAttribute, Version>, SFML.Graphics.Drawable, IDisposable public abstract class Spine : ImplementationResolver<Spine, SpineImplementationAttribute, SpineVersion>, SFML.Graphics.Drawable, IDisposable
{ {
/// <summary> /// <summary>
/// 常规骨骼文件后缀集合 /// 常规骨骼文件后缀集合
@@ -54,7 +54,7 @@ namespace SpineViewer.Spine
/// <param name="skelPath"></param> /// <param name="skelPath"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="InvalidDataException"></exception> /// <exception cref="InvalidDataException"></exception>
public static Version GetVersion(string skelPath) public static SpineVersion GetVersion(string skelPath)
{ {
string versionString = null; string versionString = null;
using var input = File.OpenRead(skelPath); using var input = File.OpenRead(skelPath);
@@ -105,9 +105,9 @@ namespace SpineViewer.Spine
/// <summary> /// <summary>
/// 创建特定版本的 Spine /// 创建特定版本的 Spine
/// </summary> /// </summary>
public static Spine New(Version version, string skelPath, string? atlasPath = null) public static Spine New(SpineVersion version, string skelPath, string? atlasPath = null)
{ {
if (version == Version.Auto) version = GetVersion(skelPath); if (version == SpineVersion.Auto) version = GetVersion(skelPath);
var spine = New(version, [skelPath, atlasPath]); var spine = New(version, [skelPath, atlasPath]);
// 统一初始化 // 统一初始化
@@ -176,7 +176,7 @@ namespace SpineViewer.Spine
/// </summary> /// </summary>
[TypeConverter(typeof(VersionConverter))] [TypeConverter(typeof(VersionConverter))]
[Category("[0] "), DisplayName("")] [Category("[0] "), DisplayName("")]
public Version Version { get; } public SpineVersion Version { get; }
/// <summary> /// <summary>
/// 资源所在完整目录 /// 资源所在完整目录

View File

@@ -12,7 +12,7 @@ namespace SpineViewer.Spine
/// <summary> /// <summary>
/// 支持的 Spine 版本 /// 支持的 Spine 版本
/// </summary> /// </summary>
public enum Version public enum SpineVersion
{ {
[Description("<Auto>")] Auto = 0x0000, [Description("<Auto>")] Auto = 0x0000,
[Description("2.1.x")] V21 = 0x0201, [Description("2.1.x")] V21 = 0x0201,
@@ -29,9 +29,9 @@ namespace SpineViewer.Spine
/// Spine 实现类标记 /// Spine 实现类标记
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class SpineImplementationAttribute(Version version) : Attribute, IImplementationKey<Version> public class SpineImplementationAttribute(SpineVersion version) : Attribute, IImplementationKey<SpineVersion>
{ {
public Version ImplementationKey { get; private set; } = version; public SpineVersion ImplementationKey { get; private set; } = version;
} }
/// <summary> /// <summary>
@@ -42,38 +42,38 @@ namespace SpineViewer.Spine
/// <summary> /// <summary>
/// 版本名称 /// 版本名称
/// </summary> /// </summary>
public static readonly ReadOnlyDictionary<Version, string> Names; public static readonly ReadOnlyDictionary<SpineVersion, string> Names;
private static readonly Dictionary<Version, string> names = []; private static readonly Dictionary<SpineVersion, string> names = [];
/// <summary> /// <summary>
/// Runtime 版本字符串 /// Runtime 版本字符串
/// </summary> /// </summary>
private static readonly Dictionary<Version, string> runtimes = []; private static readonly Dictionary<SpineVersion, string> runtimes = [];
static SpineHelper() static SpineHelper()
{ {
// 初始化缓存 // 初始化缓存
foreach (var value in Enum.GetValues(typeof(Version))) foreach (var value in Enum.GetValues(typeof(SpineVersion)))
{ {
var field = typeof(Version).GetField(value.ToString()); var field = typeof(SpineVersion).GetField(value.ToString());
var attribute = field?.GetCustomAttribute<DescriptionAttribute>(); var attribute = field?.GetCustomAttribute<DescriptionAttribute>();
names[(Version)value] = attribute?.Description ?? value.ToString(); names[(SpineVersion)value] = attribute?.Description ?? value.ToString();
} }
Names = names.AsReadOnly(); Names = names.AsReadOnly();
runtimes[Version.V21] = Assembly.GetAssembly(typeof(SpineRuntime21.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion; runtimes[SpineVersion.V21] = Assembly.GetAssembly(typeof(SpineRuntime21.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
runtimes[Version.V36] = Assembly.GetAssembly(typeof(SpineRuntime36.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion; runtimes[SpineVersion.V36] = Assembly.GetAssembly(typeof(SpineRuntime36.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
runtimes[Version.V37] = Assembly.GetAssembly(typeof(SpineRuntime37.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion; runtimes[SpineVersion.V37] = Assembly.GetAssembly(typeof(SpineRuntime37.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
runtimes[Version.V38] = Assembly.GetAssembly(typeof(SpineRuntime38.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion; runtimes[SpineVersion.V38] = Assembly.GetAssembly(typeof(SpineRuntime38.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
runtimes[Version.V40] = Assembly.GetAssembly(typeof(SpineRuntime40.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion; runtimes[SpineVersion.V40] = Assembly.GetAssembly(typeof(SpineRuntime40.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
runtimes[Version.V41] = Assembly.GetAssembly(typeof(SpineRuntime41.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion; runtimes[SpineVersion.V41] = Assembly.GetAssembly(typeof(SpineRuntime41.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
runtimes[Version.V42] = Assembly.GetAssembly(typeof(SpineRuntime42.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion; runtimes[SpineVersion.V42] = Assembly.GetAssembly(typeof(SpineRuntime42.Skeleton)).GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
} }
/// <summary> /// <summary>
/// 版本字符串名称 /// 版本字符串名称
/// </summary> /// </summary>
public static string GetName(this Version version) public static string GetName(this SpineVersion version)
{ {
return Names.TryGetValue(version, out var val) ? val : version.ToString(); return Names.TryGetValue(version, out var val) ? val : version.ToString();
} }
@@ -81,7 +81,7 @@ namespace SpineViewer.Spine
/// <summary> /// <summary>
/// Runtime 版本字符串名称 /// Runtime 版本字符串名称
/// </summary> /// </summary>
public static string GetRuntime(this Version version) public static string GetRuntime(this SpineVersion version)
{ {
return runtimes.TryGetValue(version, out var val) ? val : GetName(version); return runtimes.TryGetValue(version, out var val) ? val : GetName(version);
} }
@@ -92,17 +92,17 @@ namespace SpineViewer.Spine
/// <param name="versionString"></param> /// <param name="versionString"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="InvalidDataException"></exception> /// <exception cref="InvalidDataException"></exception>
public static Version GetVersion(string versionString) public static SpineVersion GetVersion(string versionString)
{ {
ArgumentNullException.ThrowIfNullOrEmpty(versionString); ArgumentNullException.ThrowIfNullOrEmpty(versionString);
if (versionString.StartsWith("2.1.")) return Version.V21; if (versionString.StartsWith("2.1.")) return SpineVersion.V21;
else if (versionString.StartsWith("3.6.")) return Version.V36; else if (versionString.StartsWith("3.6.")) return SpineVersion.V36;
else if (versionString.StartsWith("3.7.")) return Version.V37; else if (versionString.StartsWith("3.7.")) return SpineVersion.V37;
else if (versionString.StartsWith("3.8.")) return Version.V38; else if (versionString.StartsWith("3.8.")) return SpineVersion.V38;
else if (versionString.StartsWith("4.0.")) return Version.V40; else if (versionString.StartsWith("4.0.")) return SpineVersion.V40;
else if (versionString.StartsWith("4.1.")) return Version.V41; else if (versionString.StartsWith("4.1.")) return SpineVersion.V41;
else if (versionString.StartsWith("4.2.")) return Version.V42; else if (versionString.StartsWith("4.2.")) return SpineVersion.V42;
else if (versionString.StartsWith("4.3.")) return Version.V43; else if (versionString.StartsWith("4.3.")) return SpineVersion.V43;
else throw new InvalidDataException($"Unknown verison: {versionString}"); else throw new InvalidDataException($"Unknown verison: {versionString}");
} }
} }

View File

@@ -11,11 +11,11 @@ namespace SpineViewer.Spine
{ {
public class VersionConverter : EnumConverter public class VersionConverter : EnumConverter
{ {
public VersionConverter() : base(typeof(Version)) { } public VersionConverter() : base(typeof(SpineVersion)) { }
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type? destinationType) public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type? destinationType)
{ {
if (destinationType == typeof(string) && value is Version version) if (destinationType == typeof(string) && value is SpineVersion version)
return version.GetName(); return version.GetName();
return base.ConvertTo(context, culture, value, destinationType); return base.ConvertTo(context, culture, value, destinationType);
} }