diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a10715..0ef6a12 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# CHANGELOG
+## v0.16.5
+
+- 修复对于无 size 行的旧 atlas 格式读取错误
+- 修复托盘化之后无法联动显示窗口的问题
+
## v0.16.4
- 增加 apng 导出格式
diff --git a/Spine/Implementations/TextureLoader.cs b/Spine/Implementations/TextureLoader.cs
index 4eb8da1..6c2036a 100644
--- a/Spine/Implementations/TextureLoader.cs
+++ b/Spine/Implementations/TextureLoader.cs
@@ -112,6 +112,14 @@ namespace Spine.Implementations
if (ForceMipmap) texture.GenerateMipmap();
page.rendererObject = texture;
+
+ // 有些旧的 atlas 会省略 size 行, 这时需要在读取纹理时赋值
+ if (page.width <= 0 || page.height <= 0)
+ {
+ var texSize = texture.Size;
+ page.width = (int)texSize.X;
+ page.height = (int)texSize.Y;
+ }
}
public virtual void Load(SpineRuntime34.AtlasPage page, string path)
@@ -147,6 +155,14 @@ namespace Spine.Implementations
if (ForceMipmap) texture.GenerateMipmap();
page.rendererObject = texture;
+
+ // 有些旧的 atlas 会省略 size 行, 这时需要在读取纹理时赋值
+ if (page.width <= 0 || page.height <= 0)
+ {
+ var texSize = texture.Size;
+ page.width = (int)texSize.X;
+ page.height = (int)texSize.Y;
+ }
}
public virtual void Load(SpineRuntime35.AtlasPage page, string path)
@@ -182,6 +198,14 @@ namespace Spine.Implementations
if (ForceMipmap) texture.GenerateMipmap();
page.rendererObject = texture;
+
+ // 有些旧的 atlas 会省略 size 行, 这时需要在读取纹理时赋值
+ if (page.width <= 0 || page.height <= 0)
+ {
+ var texSize = texture.Size;
+ page.width = (int)texSize.X;
+ page.height = (int)texSize.Y;
+ }
}
public virtual void Load(SpineRuntime36.AtlasPage page, string path)
@@ -217,6 +241,14 @@ namespace Spine.Implementations
if (ForceMipmap) texture.GenerateMipmap();
page.rendererObject = texture;
+
+ // 有些旧的 atlas 会省略 size 行, 这时需要在读取纹理时赋值
+ if (page.width <= 0 || page.height <= 0)
+ {
+ var texSize = texture.Size;
+ page.width = (int)texSize.X;
+ page.height = (int)texSize.Y;
+ }
}
public virtual void Load(SpineRuntime37.AtlasPage page, string path)
@@ -252,6 +284,14 @@ namespace Spine.Implementations
if (ForceMipmap) texture.GenerateMipmap();
page.rendererObject = texture;
+
+ // 有些旧的 atlas 会省略 size 行, 这时需要在读取纹理时赋值
+ if (page.width <= 0 || page.height <= 0)
+ {
+ var texSize = texture.Size;
+ page.width = (int)texSize.X;
+ page.height = (int)texSize.Y;
+ }
}
public virtual void Load(SpineRuntime38.AtlasPage page, string path)
@@ -288,9 +328,13 @@ namespace Spine.Implementations
page.rendererObject = texture;
- // 似乎是不需要设置的, 因为存在某些 png 和 atlas 大小不同的情况, 一般是有一些缩放, 如果设置了反而渲染异常
- // page.width = (int)texture.Size.X;
- // page.height = (int)texture.Size.Y;
+ // 有些旧的 atlas 会省略 size 行, 这时需要在读取纹理时赋值
+ if (page.width <= 0 || page.height <= 0)
+ {
+ var texSize = texture.Size;
+ page.width = (int)texSize.X;
+ page.height = (int)texSize.Y;
+ }
}
public virtual void Load(SpineRuntime40.AtlasPage page, string path)
@@ -326,6 +370,14 @@ namespace Spine.Implementations
if (ForceMipmap) texture.GenerateMipmap();
page.rendererObject = texture;
+
+ // 有些旧的 atlas 会省略 size 行, 这时需要在读取纹理时赋值
+ if (page.width <= 0 || page.height <= 0)
+ {
+ var texSize = texture.Size;
+ page.width = (int)texSize.X;
+ page.height = (int)texSize.Y;
+ }
}
public virtual void Load(SpineRuntime41.AtlasPage page, string path)
@@ -361,6 +413,14 @@ namespace Spine.Implementations
if (ForceMipmap) texture.GenerateMipmap();
page.rendererObject = texture;
+
+ // 有些旧的 atlas 会省略 size 行, 这时需要在读取纹理时赋值
+ if (page.width <= 0 || page.height <= 0)
+ {
+ var texSize = texture.Size;
+ page.width = (int)texSize.X;
+ page.height = (int)texSize.Y;
+ }
}
public virtual void Load(SpineRuntime42.AtlasPage page, string path)
@@ -396,6 +456,14 @@ namespace Spine.Implementations
if (ForceMipmap) texture.GenerateMipmap();
page.rendererObject = texture;
+
+ // 有些旧的 atlas 会省略 size 行, 这时需要在读取纹理时赋值
+ if (page.width <= 0 || page.height <= 0)
+ {
+ var texSize = texture.Size;
+ page.width = (int)texSize.X;
+ page.height = (int)texSize.Y;
+ }
}
public virtual void Unload(object texture)
diff --git a/Spine/Spine.csproj b/Spine/Spine.csproj
index 9fcfb96..7aee62a 100644
--- a/Spine/Spine.csproj
+++ b/Spine/Spine.csproj
@@ -7,7 +7,7 @@
net8.0-windows
$(SolutionDir)out
false
- 0.16.4
+ 0.16.5
diff --git a/SpineViewer/App.xaml.cs b/SpineViewer/App.xaml.cs
index e7812a2..f190950 100644
--- a/SpineViewer/App.xaml.cs
+++ b/SpineViewer/App.xaml.cs
@@ -69,7 +69,6 @@ namespace SpineViewer
_instanceMutex = new Mutex(true, MutexName, out var createdNew);
if (!createdNew)
{
- ShowExistedInstance();
SendCommandLineArgs();
Environment.Exit(0); // 不再启动新实例
return;
@@ -100,37 +99,6 @@ namespace SpineViewer
LogManager.Configuration = config;
}
- private static void ShowExistedInstance()
- {
- try
- {
- // 遍历同名进程
- var processes = Process.GetProcessesByName(ProcessName);
- foreach (var p in processes)
- {
- // 跳过当前进程
- if (p.Id == Process.GetCurrentProcess().Id)
- continue;
-
- IntPtr hWnd = p.MainWindowHandle;
- if (hWnd != IntPtr.Zero)
- {
- // 3. 显示并置顶窗口
- if (User32.IsIconic(hWnd))
- {
- User32.ShowWindow(hWnd, User32.SW_RESTORE);
- }
- User32.SetForegroundWindow(hWnd);
- break; // 找到一个就可以退出
- }
- }
- }
- catch
- {
- // 忽略异常,不影响当前进程退出
- }
- }
-
private static void SendCommandLineArgs()
{
var args = Environment.GetCommandLineArgs().Skip(1).ToArray();
@@ -188,11 +156,29 @@ namespace SpineViewer
if (args.Count > 0)
{
- Current.Dispatcher.Invoke(() =>
+ try
{
- var vm = (MainWindowViewModel)((MainWindow)Current.MainWindow).DataContext;
- vm.SpineObjectListViewModel.AddSpineObjectFromFileList(args);
- });
+ Current.Dispatcher.Invoke(() =>
+ {
+ // 只要收到参数就可以显示窗口了
+ var window = (MainWindow)Current.MainWindow;
+ window.Show();
+ if (window.WindowState == WindowState.Minimized)
+ {
+ window.WindowState = WindowState.Normal;
+ }
+ window.Activate();
+
+ // 尝试加载参数内容
+ var vm = (MainWindowViewModel)window.DataContext;
+ vm.SpineObjectListViewModel.AddSpineObjectFromFileList(args);
+ });
+ }
+ catch (Exception ex)
+ {
+ _logger.Trace(ex.ToString());
+ _logger.Error("Failed to process arguments, {0}", ex.Message);
+ }
}
}
}
diff --git a/SpineViewer/SpineViewer.csproj b/SpineViewer/SpineViewer.csproj
index 4d5cb83..5c76285 100644
--- a/SpineViewer/SpineViewer.csproj
+++ b/SpineViewer/SpineViewer.csproj
@@ -7,7 +7,7 @@
net8.0-windows
$(SolutionDir)out
false
- 0.16.4
+ 0.16.5
WinExe
true