From c622b602159253d4169fe2fd17d6d106f356adf8 Mon Sep 17 00:00:00 2001 From: ww-rm Date: Sun, 16 Mar 2025 16:12:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC=E6=A3=80?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpineViewer/Controls/SpineListView.cs | 5 +---- SpineViewer/Dialogs/BatchOpenSpineDialog.cs | 10 +++++++++- SpineViewer/Dialogs/OpenSpineDialog.cs | 10 ++++++++-- SpineViewer/Spine/Spine.cs | 2 ++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/SpineViewer/Controls/SpineListView.cs b/SpineViewer/Controls/SpineListView.cs index 0cbcb58..e252109 100644 --- a/SpineViewer/Controls/SpineListView.cs +++ b/SpineViewer/Controls/SpineListView.cs @@ -69,10 +69,7 @@ namespace SpineViewer.Controls { Program.Logger.Error(ex.ToString()); Program.Logger.Error("Failed to load {} {}", dialog.SkelPath, dialog.AtlasPath); - if (ex is NotImplementedException) - MessageBox.Show($"{dialog.Version.String()} 版本尚未实现(咕咕咕~)", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Information); - else - MessageBox.Show(ex.ToString(), "骨骼加载失败", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.ToString(), "骨骼加载失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } Program.Logger.Info($"Current memory usage: {Program.Process.WorkingSet64 / 1024.0 / 1024.0:F2} MB"); diff --git a/SpineViewer/Dialogs/BatchOpenSpineDialog.cs b/SpineViewer/Dialogs/BatchOpenSpineDialog.cs index 0ff6583..3709d97 100644 --- a/SpineViewer/Dialogs/BatchOpenSpineDialog.cs +++ b/SpineViewer/Dialogs/BatchOpenSpineDialog.cs @@ -43,6 +43,8 @@ namespace SpineViewer.Dialogs private void button_Ok_Click(object sender, EventArgs e) { + var version = (Spine.Version)comboBox_Version.SelectedValue; + if (listBox_FilePath.Items.Count <= 0) { MessageBox.Show("未选择任何文件", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Information); @@ -58,8 +60,14 @@ namespace SpineViewer.Dialogs } } + if (!Spine.Spine.ImplementedVersions.Contains(version)) + { + MessageBox.Show($"{version.String()} 版本尚未实现(咕咕咕~)", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + SkelPaths = listBox_FilePath.Items.Cast().ToArray(); - Version = (Spine.Version)comboBox_Version.SelectedValue; + Version = version; DialogResult = DialogResult.OK; } diff --git a/SpineViewer/Dialogs/OpenSpineDialog.cs b/SpineViewer/Dialogs/OpenSpineDialog.cs index c4ced8a..f73cfaa 100644 --- a/SpineViewer/Dialogs/OpenSpineDialog.cs +++ b/SpineViewer/Dialogs/OpenSpineDialog.cs @@ -8,7 +8,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; - namespace SpineViewer.Dialogs { public partial class OpenSpineDialog : Form @@ -53,6 +52,7 @@ namespace SpineViewer.Dialogs { var skelPath = textBox_SkelPath.Text; var atlasPath = textBox_AtlasPath.Text; + var version = (Spine.Version)comboBox_Version.SelectedValue; if (!File.Exists(skelPath)) { @@ -78,9 +78,15 @@ namespace SpineViewer.Dialogs atlasPath = Path.GetFullPath(atlasPath); } + if (!Spine.Spine.ImplementedVersions.Contains(version)) + { + MessageBox.Show($"{version.String()} 版本尚未实现(咕咕咕~)", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + SkelPath = skelPath; AtlasPath = atlasPath; - Version = (Spine.Version)comboBox_Version.SelectedValue; + Version = version; DialogResult = DialogResult.OK; } diff --git a/SpineViewer/Spine/Spine.cs b/SpineViewer/Spine/Spine.cs index 5a2c9ef..686dd7d 100644 --- a/SpineViewer/Spine/Spine.cs +++ b/SpineViewer/Spine/Spine.cs @@ -40,6 +40,7 @@ namespace SpineViewer.Spine /// 实现类缓存 /// private static readonly Dictionary ImplementationTypes = []; + public static readonly Dictionary.KeyCollection ImplementedVersions; /// /// 用于解决 PMA 和渐变动画问题的片段着色器 @@ -74,6 +75,7 @@ namespace SpineViewer.Spine } } Program.Logger.Debug("Find Spine implementations: [{}]", string.Join(", ", ImplementationTypes.Keys)); + ImplementedVersions = ImplementationTypes.Keys; // 加载 FragmentShader try