Merge pull request #120 from ww-rm/dev/wpf

v0.16.5
This commit is contained in:
ww-rm
2025-10-04 16:59:08 +08:00
committed by GitHub
5 changed files with 100 additions and 41 deletions

View File

@@ -1,5 +1,10 @@
# CHANGELOG
## v0.16.5
- 修复对于无 size 行的旧 atlas 格式读取错误
- 修复托盘化之后无法联动显示窗口的问题
## v0.16.4
- 增加 apng 导出格式

View File

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

View File

@@ -7,7 +7,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.16.4</Version>
<Version>0.16.5</Version>
</PropertyGroup>
<PropertyGroup>

View File

@@ -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();
@@ -187,13 +155,31 @@ namespace SpineViewer
args.Add(line);
if (args.Count > 0)
{
try
{
Current.Dispatcher.Invoke(() =>
{
var vm = (MainWindowViewModel)((MainWindow)Current.MainWindow).DataContext;
// 只要收到参数就可以显示窗口了
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);
}
}
}
}
}

View File

@@ -7,7 +7,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.16.4</Version>
<Version>0.16.5</Version>
<OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF>
</PropertyGroup>