增加版本检测

This commit is contained in:
ww-rm
2025-03-16 16:12:36 +08:00
parent c228cf9072
commit c622b60215
4 changed files with 20 additions and 7 deletions

View File

@@ -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");

View File

@@ -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<string>().ToArray();
Version = (Spine.Version)comboBox_Version.SelectedValue;
Version = version;
DialogResult = DialogResult.OK;
}

View File

@@ -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;
}

View File

@@ -40,6 +40,7 @@ namespace SpineViewer.Spine
/// 实现类缓存
/// </summary>
private static readonly Dictionary<Version, Type> ImplementationTypes = [];
public static readonly Dictionary<Version, Type>.KeyCollection ImplementedVersions;
/// <summary>
/// 用于解决 PMA 和渐变动画问题的片段着色器
@@ -74,6 +75,7 @@ namespace SpineViewer.Spine
}
}
Program.Logger.Debug("Find Spine implementations: [{}]", string.Join(", ", ImplementationTypes.Keys));
ImplementedVersions = ImplementationTypes.Keys;
// 加载 FragmentShader
try