From 092fa76124dc90956baefd3e7161351ba3147a1d Mon Sep 17 00:00:00 2001 From: ww-rm Date: Sat, 4 Oct 2025 16:38:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=B9=E4=BA=8E?= =?UTF-8?q?=E6=9F=90=E4=BA=9B=E6=97=A7atlas=E6=B2=A1=E6=9C=89size=E8=A1=8C?= =?UTF-8?q?=E7=9A=84=E8=AF=BB=E5=8F=96=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Spine/Implementations/TextureLoader.cs | 74 ++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) 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) From f19f172e7c84f02ebe73724d9453c55635356e82 Mon Sep 17 00:00:00 2001 From: ww-rm Date: Sat, 4 Oct 2025 16:56:32 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E8=81=94=E5=8A=A8=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpineViewer/App.xaml.cs | 58 ++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 36 deletions(-) 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); + } } } } From 1931c4713a7e5c6b61dc7e118bf6364f69636da9 Mon Sep 17 00:00:00 2001 From: ww-rm Date: Sat, 4 Oct 2025 16:58:09 +0800 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) 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 导出格式 From 66d8c489b539a3d2400ba3e7a9215d0c354a9457 Mon Sep 17 00:00:00 2001 From: ww-rm Date: Sat, 4 Oct 2025 16:58:32 +0800 Subject: [PATCH 4/4] update to v0.16.5 --- Spine/Spine.csproj | 2 +- SpineViewer/SpineViewer.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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