Compare commits

..

787 Commits

Author SHA1 Message Date
ww-rm
c1677bda48 Merge pull request #148 from ww-rm/dev/wpf
v0.16.12
2025-11-09 23:23:22 +08:00
ww-rm
83d054382c update changelog 2025-11-09 23:22:11 +08:00
ww-rm
608de7f2e8 update to v0.16.12 2025-11-09 23:18:26 +08:00
ww-rm
6f2eb504ab 完善嵌入逻辑 2025-11-09 12:29:41 +08:00
ww-rm
2b53e0b60b 重构 2025-11-09 00:27:01 +08:00
ww-rm
e96db328fa 增加桌面投影帧率显示 2025-11-08 23:05:08 +08:00
ww-rm
874404e3d3 增加最大帧率的首选项,移除用户状态中最大帧率的记忆 2025-11-08 19:44:15 +08:00
ww-rm
8e771fbaa4 重构Win32Natives 2025-11-08 19:17:09 +08:00
ww-rm
fb319e09d8 完善逻辑 2025-11-08 17:42:11 +08:00
ww-rm
849f1813be 拆分双渲染线程 2025-11-08 17:34:20 +08:00
ww-rm
763d2e295e 拆分逻辑帧和渲染帧 2025-11-08 17:17:25 +08:00
ww-rm
d6ca3cca92 增加实时帧率显示 2025-11-08 00:09:55 +08:00
ww-rm
32c826a3db 修复label不显示下划线的问题 2025-11-07 23:20:05 +08:00
ww-rm
b17f3bec79 add comment 2025-11-07 18:40:30 +08:00
ww-rm
246f70fd4d 修改延迟保存时间为1s 2025-11-04 18:29:27 +08:00
ww-rm
7eb140a030 增强报错日志输出 2025-11-03 18:13:01 +08:00
ww-rm
c68a91fe3f 修改日志输出等级 2025-11-03 18:09:05 +08:00
ww-rm
dc2cb61219 Merge pull request #144 from ww-rm/dev/wpf
v0.16.11
2025-11-02 22:09:34 +08:00
ww-rm
decbb10fcb 修复可能的null错误 2025-11-02 22:05:58 +08:00
ww-rm
c538fd8960 Merge pull request #143 from ww-rm/dev/wpf
v0.16.11
2025-11-02 21:38:33 +08:00
ww-rm
cc884f7f5b update to v0.16.11 2025-11-02 21:36:29 +08:00
ww-rm
dcfe48912b 修改缩放倍数 2025-11-02 21:36:00 +08:00
ww-rm
3c77365f60 update readme 2025-11-02 21:34:22 +08:00
ww-rm
baff9579e5 update changelog 2025-11-02 21:33:10 +08:00
ww-rm
44f4367f3e 增加shift切换缩放倍速 2025-11-02 21:30:08 +08:00
ww-rm
5823d58dca 调整面板顺序 2025-11-02 15:26:20 +08:00
ww-rm
7bb76d508e 移动浏览目录至用户状态 2025-11-02 15:25:43 +08:00
ww-rm
b4c7579d24 修复字体颜色错误 2025-11-02 15:07:08 +08:00
ww-rm
aafe487d96 调试标题 2025-11-02 14:28:54 +08:00
ww-rm
dc2f6a2dad 改善性能 2025-11-02 14:22:00 +08:00
ww-rm
10b691d897 增加调试标志位 2025-11-02 12:24:17 +08:00
ww-rm
50219946ec 修改缩放变化量 2025-11-02 11:20:24 +08:00
ww-rm
659f6fb690 Merge pull request #142 from ww-rm/dev/wpf
update readme
2025-10-29 23:22:06 +08:00
ww-rm
af5cb97f1a update readme 2025-10-29 23:21:10 +08:00
ww-rm
1be9e9e75f Merge pull request #141 from ww-rm/dev/wpf
update readme
2025-10-29 23:19:26 +08:00
ww-rm
b0308db977 update readme 2025-10-29 23:18:40 +08:00
ww-rm
2dbcfe4ea7 update readme 2025-10-29 23:17:51 +08:00
ww-rm
9040e02025 Merge pull request #140 from ww-rm/dev/wpf
v0.16.10
2025-10-29 21:35:34 +08:00
ww-rm
b3ba073368 完善日志 2025-10-29 21:34:30 +08:00
ww-rm
332019a667 修复文件夹无法自动创建的bug 2025-10-29 21:00:38 +08:00
ww-rm
add9cf157d 修改压缩路径 2025-10-29 20:54:35 +08:00
ww-rm
8b0ea750d8 Merge pull request #139 from ww-rm/dev/wpf
v0.16.10
2025-10-29 20:45:24 +08:00
ww-rm
733739921d update changelog 2025-10-29 20:44:20 +08:00
ww-rm
e0f46f521a update to v0.16.10 2025-10-29 20:43:43 +08:00
ww-rm
aa4245ef2a add linux release 2025-10-29 20:42:31 +08:00
ww-rm
a262538eba 增加linux条件依赖 2025-10-29 19:48:23 +08:00
ww-rm
2e4a5a75c0 修复着色器语法兼容性错误 2025-10-29 19:33:45 +08:00
ww-rm
9331656431 修改项目配置 2025-10-28 22:03:39 +08:00
ww-rm
64bc12db06 Merge pull request #136 from ww-rm/dev/wpf
v0.16.9
2025-10-27 23:51:47 +08:00
ww-rm
7a29fee641 update readme 2025-10-27 23:50:39 +08:00
ww-rm
49f95ddbb7 add readme 2025-10-27 23:48:21 +08:00
ww-rm
317ee71882 update changelog 2025-10-27 23:45:16 +08:00
ww-rm
7780fbda28 update ignore 2025-10-27 23:43:57 +08:00
ww-rm
b54c6a1777 update to v0.16.9 2025-10-27 23:43:52 +08:00
ww-rm
617157044c 增加透明度参数 2025-10-27 23:33:25 +08:00
ww-rm
29d7e8d9d8 移除依赖库 2025-10-27 22:26:33 +08:00
ww-rm
701d1fcf90 增加日志 2025-10-27 07:35:05 +08:00
ww-rm
df36d46528 增加动态进度条 2025-10-27 00:00:44 +08:00
ww-rm
3459f3af03 修复进度回调done值错误 2025-10-26 23:59:57 +08:00
ww-rm
5498508700 移除不受支持的格式 2025-10-26 23:16:40 +08:00
ww-rm
a61bb43250 增加preview命令 2025-10-26 22:14:34 +08:00
ww-rm
aace461ae0 修改方法名 2025-10-26 22:05:48 +08:00
ww-rm
c02cec9a18 修改图像质量默认值为100 2025-10-26 22:01:40 +08:00
ww-rm
31daed9e81 移除不受支持的图像格式 2025-10-26 21:49:58 +08:00
ww-rm
997d55350d 修复可能的资源泄露 2025-10-26 21:28:11 +08:00
ww-rm
cc6d1b6c00 更新注释 2025-10-26 19:35:43 +08:00
ww-rm
e14c54c3a4 调整时间轴处理顺序 2025-10-26 17:35:51 +08:00
ww-rm
5eba515eac 增加 query 命令 2025-10-26 17:31:20 +08:00
ww-rm
f878530184 重构 2025-10-26 16:30:13 +08:00
ww-rm
81d9224658 增加参数验证 2025-10-26 16:22:49 +08:00
ww-rm
9d9edb8bc4 增加 export 命令 2025-10-26 16:16:43 +08:00
ww-rm
d3b5814c6f small change 2025-10-26 15:52:47 +08:00
ww-rm
aade44cffb 增加注释 2025-10-26 15:19:09 +08:00
ww-rm
c4956b9c16 重构 2025-10-26 13:26:47 +08:00
ww-rm
7ca431b214 增加System.CommandLine库 2025-10-25 17:19:27 +08:00
ww-rm
74538ddf74 apng和mov格式参数改为枚举量类型 2025-10-25 17:04:39 +08:00
ww-rm
779500ee8e 修改ApngPred属性名为PredMethod 2025-10-25 16:47:00 +08:00
ww-rm
ee7c9e9e54 Merge pull request #132 from jayng9663/dev/wpf
Add --warmup option to control physics warmup loops
2025-10-24 23:07:13 +08:00
ww-rm
d335645dc1 remove unnecessary frame loops 2025-10-19 20:46:42 +08:00
ww-rm
0893bd4b54 Merge pull request #133 from ww-rm/dev/wpf
v0.16.8
2025-10-19 20:19:48 +08:00
ww-rm
862926b43e update to v0.16.8 2025-10-19 20:18:11 +08:00
ww-rm
0324ba7971 update changelog 2025-10-19 20:18:02 +08:00
Jay
6a17ec0397 Add --warmup option to control physics warmup loops
Create a new --warmup argument to specify the number of warmup loops for physics before export. This allows users to control how many times the animation is pre-processed to stabilize physics.
2025-10-19 04:59:34 -07:00
ww-rm
53a7700798 增加单独的参数拷贝方式 2025-10-19 17:59:33 +08:00
ww-rm
30608e05bc 修改窗口默认大小 2025-10-19 15:16:05 +08:00
ww-rm
3dcd7b22ca 增加皮肤和插槽的全部启用禁用菜单项 2025-10-19 15:10:45 +08:00
ww-rm
dae5d0b7c7 增加侧边栏折叠功能 2025-10-19 01:01:34 +08:00
ww-rm
f5d3f93cde 增加侧边栏图标样式 2025-10-19 00:05:46 +08:00
ww-rm
dbd7c13c32 Merge branch 'dev/wpf' of github.com:ww-rm/SpineViewer into dev/wpf 2025-10-17 22:44:50 +08:00
ww-rm
b662d8f68a Merge pull request #131 from jhq223/feature/cli-enhancements
Feat(CLI): Add Single-Frame Export and Fix Related Bugs
2025-10-17 22:44:33 +08:00
ww-rm
02445d36e5 增加实时状态保存 2025-10-17 22:41:49 +08:00
ww-rm
b178e48e84 去除默认的最小化提示弹框 2025-10-16 23:54:07 +08:00
ww-rm
c90713ffe7 change tolower to tolowerinvariant 2025-10-16 22:33:36 +08:00
jhq223
dc472cf2a8 Fix: Resolve frame export logic and slot visibility issues
This commit addresses two critical bugs in the single-frame export functionality of the CLI tool.

1.  **Corrects Export Mode Detection for Ambiguous Formats (.webp):**
    - Previously, any output format also supported by the video exporter (like `.webp`) would incorrectly trigger video export mode, ignoring the `--time` argument intended for single-frame captures.
    - The logic is now updated to prioritize the presence of the `--time` argument. If this argument is provided, the tool is forced into single-frame export mode, correctly handling formats like static `.webp`.
    - This was implemented by changing the `time` variable to a nullable float (`float?`) to reliably detect if the argument was passed.

2.  **Fixes "Slot Not Found" Error for `--hide-slot`:**
    - The operation to hide slots was being performed *before* the animation was applied to the skeleton. This caused failures when trying to hide slots that are only activated or have attachments during a specific animation.
    - The slot visibility logic has been moved to execute *after* the animation state is set and the skeleton is updated to the target frame. This ensures that the skeleton is in its final pose, making all relevant slots available for modification.
2025-10-16 20:57:50 +08:00
jhq223
03c599264e feat(cli): Add single-frame image export
Extends the CLI to support exporting single frames as images (.png, .jpg, etc.) in addition to video.

The export logic now determines the output type based on the file extension of the `--output` path.

- Adds new arguments: `--time` to specify the frame and `--quality` for image compression.
- Uses `FrameExporter` for recognized image formats.
- Updates the help message with the new options.
2025-10-16 19:56:13 +08:00
ww-rm
8f7297bea5 Merge pull request #129 from jhq223/feature/cli-enhancements
feat: Add --skin and --hide-slot CLI arguments
2025-10-15 20:59:40 +08:00
jhq223
e4d655012b feat: Add --skin and --hide-slot CLI arguments 2025-10-15 16:01:18 +08:00
ww-rm
4b23c779d3 Merge pull request #124 from ww-rm/dev/wpf
v0.16.7
2025-10-06 14:04:13 +08:00
ww-rm
f5684a50dc update to v0.16.7 2025-10-06 14:03:19 +08:00
ww-rm
579ce9f944 update changelog 2025-10-06 14:03:03 +08:00
ww-rm
7aa88089b8 修复空帧导致的包围盒计算错误 2025-10-06 14:02:21 +08:00
ww-rm
be983f8407 修复窗口二次显示错误 2025-10-06 13:32:03 +08:00
ww-rm
249b930602 Merge pull request #122 from ww-rm/dev/wpf
v0.16.6
2025-10-04 20:55:59 +08:00
ww-rm
6472f378b7 update to v0.16.6 2025-10-04 20:53:29 +08:00
ww-rm
8672f0571c udpate changelog 2025-10-04 20:53:06 +08:00
ww-rm
e7a990c1bd 修复可能出现的0缩放错误 2025-10-04 20:50:08 +08:00
ww-rm
6727fa8e8f Merge pull request #120 from ww-rm/dev/wpf
v0.16.5
2025-10-04 16:59:08 +08:00
ww-rm
66d8c489b5 update to v0.16.5 2025-10-04 16:58:32 +08:00
ww-rm
1931c4713a update changelog 2025-10-04 16:58:09 +08:00
ww-rm
f19f172e7c 修复窗口联动显示问题 2025-10-04 16:56:32 +08:00
ww-rm
092fa76124 修复对于某些旧atlas没有size行的读取异常 2025-10-04 16:38:14 +08:00
ww-rm
a0b7db0a70 Merge pull request #119 from ww-rm/dev/wpf
v0.16.4
2025-10-04 00:11:15 +08:00
ww-rm
6438b46ea0 修复样式错误 2025-10-04 00:09:38 +08:00
ww-rm
2bf73db9d3 补充前景色绑定 2025-10-03 23:54:54 +08:00
ww-rm
03c4974c9f Merge pull request #118 from ww-rm/dev/wpf
v0.16.4
2025-10-03 23:50:05 +08:00
ww-rm
760fa3a451 update to v0.16.4 2025-10-03 23:49:12 +08:00
ww-rm
018d8f5330 update changelog 2025-10-03 23:48:25 +08:00
ww-rm
c9730e1a11 完善标题栏皮肤颜色切换 2025-10-03 23:45:35 +08:00
ww-rm
1f6e19e544 修改日志着色 2025-10-03 22:29:43 +08:00
ww-rm
a1a0777791 重构样式 2025-10-03 22:22:21 +08:00
ww-rm
887e3f76d2 增加程序皮肤首选项 2025-10-03 19:38:48 +08:00
ww-rm
8b622050fa 重构 2025-10-03 19:11:59 +08:00
ww-rm
20369aaf43 调整颜色按钮背景色固定白色 2025-10-03 16:17:26 +08:00
ww-rm
07c0e84b7d 修复颜色错误 2025-10-03 16:11:04 +08:00
ww-rm
6770acaffd small change 2025-10-03 13:34:45 +08:00
ww-rm
6201ccc7d1 去除独立颜色使用 2025-10-03 09:46:14 +08:00
ww-rm
965d1c469e 增加ColorPicker使用 2025-10-03 09:19:02 +08:00
ww-rm
b448ca8cb0 重构 2025-10-02 22:42:21 +08:00
ww-rm
2204eb6c75 增加apng格式并且调整部分布局结构 2025-10-02 22:18:05 +08:00
ww-rm
0abe063899 调整文件结构 2025-10-02 15:18:40 +08:00
ww-rm
6f9b357473 Merge pull request #116 from ww-rm/dev/wpf
v0.16.3
2025-10-02 14:22:11 +08:00
ww-rm
152d842043 update to v0.16.3 2025-10-02 14:21:35 +08:00
ww-rm
d16f97d574 update changelog 2025-10-02 14:21:18 +08:00
ww-rm
d28eabaca5 解决可能卡死问题 2025-10-02 14:19:53 +08:00
ww-rm
b730f677be 完善像素检测 2025-10-02 14:04:42 +08:00
ww-rm
8f8806417a 完善工作区加载模型逻辑 2025-10-02 11:44:51 +08:00
ww-rm
06694c9e89 补充注释 2025-10-02 11:29:13 +08:00
ww-rm
e9b0ce3db2 增加None命中测试等级 2025-10-02 11:19:22 +08:00
ww-rm
4c72608398 修改部分布局 2025-10-02 11:01:38 +08:00
ww-rm
7e99882fbf 增加命中测试等级选项 2025-10-02 10:32:24 +08:00
ww-rm
0d72d8749a 调整调试输出逻辑 2025-10-02 10:23:51 +08:00
ww-rm
d5b7a74520 增加Name属性 2025-10-02 10:17:12 +08:00
ww-rm
0202027edb 修复模型添加顺序错误 2025-10-02 09:32:17 +08:00
ww-rm
d1d32b6292 Merge pull request #115 from ww-rm/dev/wpf
v0.16.2
2025-10-01 23:48:03 +08:00
ww-rm
b32485e122 update to v0.16.2 2025-10-01 23:45:01 +08:00
ww-rm
36d578f4d4 update changelog 2025-10-01 23:44:42 +08:00
ww-rm
42bd5c2830 增加精确命中检测和插槽输出 2025-10-01 23:43:03 +08:00
ww-rm
44548618e8 精简代码 2025-10-01 19:58:39 +08:00
ww-rm
681b1be360 修复添加顺序错误 2025-10-01 18:45:03 +08:00
ww-rm
30dee9978c 重构并增加HitTest 2025-10-01 16:35:51 +08:00
ww-rm
47aafc7948 Merge pull request #113 from ww-rm/dev/wpf
v0.16.1
2025-09-30 22:19:01 +08:00
ww-rm
1d8e2efdff update to v0.16.1 2025-09-30 22:14:07 +08:00
ww-rm
dd504d32ca 修复3.4的附件残留问题 2025-09-30 14:47:00 +08:00
ww-rm
267c7b81c3 Merge pull request #111 from ww-rm/dev/wpf
update readme
2025-09-30 12:19:17 +08:00
ww-rm
c4a6fd9d86 update readme 2025-09-30 12:18:45 +08:00
ww-rm
6e46152e4c Merge pull request #110 from ww-rm/dev/wpf
update readme
2025-09-30 12:00:41 +08:00
ww-rm
f2f296e494 update readme 2025-09-30 11:59:51 +08:00
ww-rm
34f9eeff2c Merge pull request #109 from ww-rm/dev/wpf
v0.16.0
2025-09-30 11:49:45 +08:00
ww-rm
1278fefea2 update readme 2025-09-30 11:47:55 +08:00
ww-rm
48d46afcff update readme 2025-09-30 11:12:06 +08:00
ww-rm
6742dacaf2 update to v0.16.0 2025-09-30 10:53:06 +08:00
ww-rm
3337ecc03a update changelog 2025-09-30 10:52:10 +08:00
ww-rm
b9eaacd1f7 修复可能的3.4版本附件残留问题 2025-09-30 10:30:25 +08:00
ww-rm
a0ada51325 修复跨线程错误 2025-09-30 09:21:54 +08:00
ww-rm
8e03911957 修复可能的窗口大小不正确问题 2025-09-30 08:55:00 +08:00
ww-rm
0b3db0fd0d 增加IsShuttingDownFromTray标志位 2025-09-30 08:45:28 +08:00
ww-rm
bb2862ed4f 增加最小化至托盘图标功能 2025-09-30 01:53:14 +08:00
ww-rm
8c3be98b54 修复记忆状态中的长度单位错误 2025-09-30 00:28:05 +08:00
ww-rm
b76224c010 调整顺序 2025-09-30 00:00:32 +08:00
ww-rm
bd9f8d714a 增加开机自启功能和自启设置 2025-09-29 23:26:06 +08:00
ww-rm
6900968555 调整布局 2025-09-29 00:05:41 +08:00
ww-rm
741d334a92 切换桌面投影时自动设置预览分辨率为主屏幕分辨率 2025-09-28 22:20:48 +08:00
ww-rm
b583108afa 更新模板 2025-09-28 20:44:12 +08:00
ww-rm
f7ace4dfe9 Merge pull request #106 from ww-rm/dev/wpf
v0.15.19
2025-09-27 23:48:05 +08:00
ww-rm
7ce2bd5629 update to v0.15.19 2025-09-27 23:46:25 +08:00
ww-rm
41716df7b2 update changelog 2025-09-27 23:45:49 +08:00
ww-rm
fe9b9829e2 增加 wallpaper view 2025-09-27 23:43:54 +08:00
ww-rm
4365c2a008 small change 2025-09-27 23:41:31 +08:00
ww-rm
7896e072e7 移除LastState中背景图片的记忆 2025-09-27 21:24:15 +08:00
ww-rm
940397c673 增加Texture加载失败时的日志信息 2025-09-27 18:49:29 +08:00
ww-rm
d57ea781f0 修复由于可能存在问题的奇数长度顶点数组导致的数组越界问题 2025-09-27 18:48:54 +08:00
ww-rm
b74f2811a7 add SFMLRenderWindow 2025-09-27 18:20:06 +08:00
ww-rm
66223f952b 重载后自动选中列表模型 2025-09-24 23:54:05 +08:00
ww-rm
0443d5e3d5 Merge pull request #104 from ww-rm/dev/wpf
v0.15.18
2025-09-24 23:45:55 +08:00
ww-rm
0a0b6a08e9 update to v0.15.18 2025-09-24 23:44:52 +08:00
ww-rm
63af4a19e6 update readme 2025-09-24 23:44:43 +08:00
ww-rm
51f0446c18 update changelog 2025-09-24 23:43:16 +08:00
ww-rm
e965223284 增强支持的纹理图像格式 2025-09-24 23:00:21 +08:00
ww-rm
dbc15952cc 增加工作区背景图片参数 2025-09-22 23:30:02 +08:00
ww-rm
93b70509ec 增加日志输出 2025-09-22 23:27:23 +08:00
ww-rm
798883d4e0 增加背景图案选项 2025-09-22 23:23:01 +08:00
ww-rm
3e88e65bbd 增加托盘图标 2025-09-22 20:09:46 +08:00
ww-rm
0906817cd3 修复面板高度首次还原错误 2025-09-22 14:38:04 +08:00
ww-rm
37235fa7d0 修改预览图背景颜色为透明 2025-09-22 08:35:27 +08:00
ww-rm
72935d8f2b utf8 2025-09-21 22:08:16 +08:00
ww-rm
8a4095dae1 完善窗口日志显示 2025-09-21 22:06:00 +08:00
ww-rm
b59f228f2e refactor 2025-09-21 11:01:58 +08:00
ww-rm
a28cb3f424 Merge pull request #102 from ww-rm/dev/wpf
v0.15.17
2025-09-21 10:09:56 +08:00
ww-rm
05bb797a91 update to v0.15.17 2025-09-21 10:09:10 +08:00
ww-rm
eb0029a877 update changelog 2025-09-21 10:08:38 +08:00
ww-rm
ef0bfa85aa 修改图标配色 2025-09-21 10:07:27 +08:00
ww-rm
b5721e30a0 update readme 2025-09-21 01:21:38 +08:00
ww-rm
2c3b076b58 Merge pull request #101 from ww-rm/dev/wpf
v0.15.16
2025-09-21 01:14:57 +08:00
ww-rm
01e12f4524 增加打开单模型功能 2025-09-21 01:13:15 +08:00
ww-rm
a814d3d99a update to v0.15.16 2025-09-21 00:55:36 +08:00
ww-rm
6a4508dceb update changelog 2025-09-21 00:55:12 +08:00
ww-rm
b7d7274a5a 增加文件关联首选项 2025-09-21 00:55:01 +08:00
ww-rm
71359a4328 完善多选打开逻辑 2025-09-21 00:01:35 +08:00
ww-rm
3a3691bcca 增加单实例模式和命令行参数 2025-09-20 23:11:47 +08:00
ww-rm
3d649e36cc 完善画布焦点转移逻辑 2025-09-19 00:56:25 +08:00
ww-rm
a24db3c447 增加右键菜单移除全部模型 2025-09-17 23:51:05 +08:00
ww-rm
699a055707 选中项发生变化时转移焦点至模型列表 2025-09-17 23:34:28 +08:00
ww-rm
1f8ed1c31c 增加自动选中最后导入项 2025-09-17 23:28:48 +08:00
ww-rm
e2fc27663c 修改列表每次添加模型在开头 2025-09-17 20:13:03 +08:00
ww-rm
b3cd0b9349 Merge pull request #99 from ww-rm/dev/wpf
v0.15.15
2025-09-11 23:20:45 +08:00
ww-rm
1c545b8c37 update to v0.15.15 2025-09-11 23:19:24 +08:00
ww-rm
d660dd1c4a update changelog 2025-09-11 23:19:18 +08:00
ww-rm
9c0acf7302 增加报错信息 2025-09-11 23:17:13 +08:00
ww-rm
415df555c7 增加导入后自动选中最后一项 2025-09-08 21:50:11 +08:00
ww-rm
5ef13239da Merge pull request #97 from ww-rm/dev/wpf
v0.15.14
2025-09-08 00:07:36 +08:00
ww-rm
13ef873650 update to v0.15.14 2025-09-08 00:05:58 +08:00
ww-rm
78b9834f6c update changelog 2025-09-08 00:05:34 +08:00
ww-rm
672a695b20 增加上一次状态的保存和恢复 2025-09-08 00:00:49 +08:00
ww-rm
e9951ed79a 增加日志版本号输出 2025-09-05 11:36:52 +08:00
ww-rm
0c16b2f104 Merge pull request #93 from ww-rm/dev/wpf
v0.15.13
2025-09-04 20:09:18 +08:00
ww-rm
7628075420 update to v0.15.13 2025-09-04 20:08:08 +08:00
ww-rm
6f896bdaad update changelog 2025-09-04 20:07:54 +08:00
ww-rm
98930db4b6 增加预览画面首选项 2025-09-04 20:07:35 +08:00
ww-rm
c7493372e9 增加布局存储和还原 2025-09-04 19:27:10 +08:00
ww-rm
707aa7f570 Merge pull request #91 from ww-rm/dev/wpf
v0.15.12
2025-09-03 21:58:18 +08:00
ww-rm
99ff6f9f0a 增加轨道参数保存 2025-09-03 21:57:28 +08:00
ww-rm
be8193e235 Merge pull request #90 from ww-rm/dev/wpf
v0.15.12
2025-09-03 21:43:07 +08:00
ww-rm
21b6dbee4c 增加bug issue模板 2025-09-03 21:41:43 +08:00
ww-rm
f60418fecb update readme 2025-09-03 21:34:51 +08:00
ww-rm
1180c735c8 update to v0.15.12 2025-09-03 21:33:18 +08:00
ww-rm
3d8f6547e0 update changelog 2025-09-03 21:32:42 +08:00
ww-rm
99ec2704fe 增加单个轨道的时间因子和alpha混合 2025-09-03 21:30:31 +08:00
ww-rm
dbd2cef766 完善报错信息 2025-09-02 20:46:48 +08:00
ww-rm
212ecc2ff3 增加单个模型的时间因子参数 2025-09-02 00:32:02 +08:00
ww-rm
7806f9298d 增加半透明选中背景 2025-09-01 23:47:08 +08:00
ww-rm
3bc57a8990 增加最大帧率提示文本 2025-08-30 16:31:43 +08:00
ww-rm
67c9ea9291 移动轨道清除功能至右键菜单 2025-08-30 01:38:22 +08:00
ww-rm
f404acc834 修改默认标签页为模型列表 2025-08-21 23:00:40 +08:00
ww-rm
8e1f586d4f Merge pull request #86 from ww-rm/dev/wpf
fix bug
2025-08-20 22:44:47 +08:00
ww-rm
5dd1b84943 fix bug 2025-08-20 22:42:38 +08:00
ww-rm
ad190d8952 Merge pull request #85 from ww-rm/dev/wpf
v0.15.11
2025-08-20 22:36:14 +08:00
ww-rm
ddb11808a7 update to v0.15.11 2025-08-20 22:33:25 +08:00
ww-rm
9b1e26b2ac udpate changelog 2025-08-20 22:33:02 +08:00
ww-rm
c8e35a9aed 增加mov格式 2025-08-20 22:31:49 +08:00
ww-rm
4786b0434c 修复自定义导出参数构造错误 2025-08-19 18:02:21 +08:00
ww-rm
40bde84648 Merge pull request #81 from ww-rm/dev/wpf
v0.15.10
2025-08-18 18:54:13 +08:00
ww-rm
ebb2593526 update to v0.15.10 2025-08-18 18:52:16 +08:00
ww-rm
6a74204ba1 update readme 2025-08-18 18:51:33 +08:00
ww-rm
78c6c47300 update changelog 2025-08-18 18:48:55 +08:00
ww-rm
746a3decc8 补充插槽可见性属性值拷贝 2025-08-18 18:47:39 +08:00
ww-rm
6dfd25b760 修复插槽禁用功能 2025-08-18 18:39:27 +08:00
ww-rm
a697ccc923 Merge pull request #80 from ww-rm/dev/wpf 2025-08-18 01:26:40 +08:00
ww-rm
5bfa625868 更新至v0.15.9 2025-08-18 01:25:22 +08:00
ww-rm
0762a90fa9 update readme 2025-08-18 01:24:54 +08:00
ww-rm
a4926d905b update changelog 2025-08-18 01:24:47 +08:00
ww-rm
b08b6752cd imp v34 & v35 2025-08-18 01:23:31 +08:00
ww-rm
50b1c66e27 add spine34 & spine35 2025-08-17 16:16:59 +08:00
ww-rm
65508782c6 Merge pull request #77 from ww-rm/dev/wpf
v0.15.8
2025-08-01 00:03:42 +08:00
ww-rm
d02ab536b6 更新至v0.15.8 2025-08-01 00:02:26 +08:00
ww-rm
db3700bda3 update readme 2025-08-01 00:02:21 +08:00
ww-rm
6dea656e5e 修复可能的null引用报错 2025-08-01 00:00:54 +08:00
ww-rm
7bc82ab318 Merge pull request #75 from ww-rm/dev/wpf
fix bug
2025-07-26 23:06:01 +08:00
ww-rm
3eb9b1d008 fix bug 2025-07-26 23:05:23 +08:00
ww-rm
eca59dc67b Merge pull request #74 from ww-rm/dev/wpf
v0.15.7
2025-07-26 23:01:21 +08:00
ww-rm
93b806dccd 更新至v0.15.7 2025-07-26 22:59:32 +08:00
ww-rm
89c31d7c77 add contributing 2025-07-26 22:58:27 +08:00
ww-rm
0a5432bb30 增加cli项目的生成 2025-07-26 22:32:15 +08:00
ww-rm
2eded25c03 add cli project 2025-07-26 22:28:37 +08:00
ww-rm
fa00f0064e remove warning 2025-07-26 22:28:25 +08:00
ww-rm
ddd3e94698 fix wrong text 2025-07-26 22:28:15 +08:00
ww-rm
d7ee88f7f6 Merge pull request #72 from ashleney/dev/wpf
Add CLI
2025-07-26 08:51:02 +08:00
ww-rm
1d7a402749 Update SpineViewerCLI.csproj 2025-07-26 08:49:34 +08:00
ashlen
86bcb079b0 Move to its own project 2025-07-25 19:01:23 +02:00
ashlen
390416df06 Add CLI 2025-07-25 17:19:16 +02:00
ww-rm
1344b34d08 修复时长参数0值判断问题 2025-07-25 22:09:24 +08:00
ww-rm
497103bdb6 Merge pull request #69 from ww-rm/dev/wpf 2025-07-25 14:00:15 +08:00
ww-rm
04953d13b6 update readme 2025-07-25 13:59:37 +08:00
ww-rm
b272d9802e 更新至v0.15.6 2025-07-25 13:55:31 +08:00
ww-rm
bd5a537058 update changelog 2025-07-25 13:55:24 +08:00
ww-rm
64a3caf938 修改默认导出背景颜色为不透明黑色 2025-07-25 13:53:55 +08:00
ww-rm
ca34494483 修复导出单个模式的时长错误 2025-07-25 13:50:36 +08:00
ww-rm
e717eab6df Merge pull request #68 from ww-rm/dev/wpf 2025-07-24 21:36:56 +08:00
ww-rm
068734549c 更新至v0.15.5 2025-07-24 21:35:02 +08:00
ww-rm
3d1fa38eb3 update changelog 2025-07-24 21:34:54 +08:00
ww-rm
bff3b39371 增加导出速度设置 2025-07-24 21:31:05 +08:00
ww-rm
a44161053b 修复yuv420p像素格式分辨率必须被2整除的问题 2025-07-24 21:27:41 +08:00
ww-rm
4b64ec74c2 增加预览画面播放速度参数 2025-07-24 20:38:55 +08:00
ww-rm
1f56e2f03c 修改mp4导出像素格式避免兼容性问题 2025-07-24 18:18:11 +08:00
ww-rm
311b09cc63 修复自定义导出问题 2025-07-24 17:58:55 +08:00
ww-rm
cd7f841e38 修复提示文本错误 2025-07-24 17:55:10 +08:00
ww-rm
df798b481d Merge pull request #65 from ww-rm/dev/wpf
Dev/wpf
2025-07-11 23:32:05 +08:00
ww-rm
578a9ad3f3 更新至v0.15.4 2025-07-11 23:31:10 +08:00
ww-rm
b765b5f7ea update changelog 2025-07-11 23:31:05 +08:00
ww-rm
f1c013bd82 增加webp格式无损参数 2025-07-11 23:28:36 +08:00
ww-rm
65c1012205 更改提示文本 2025-07-11 16:56:01 +08:00
ww-rm
f1cd9e25e5 修复使用FFmpeg导出时的卡死问题 2025-07-11 16:52:50 +08:00
ww-rm
b2861ffb93 Merge pull request #62 from ww-rm/dev/wpf
Dev/wpf
2025-06-29 19:51:55 +09:00
ww-rm
b01d112d63 Update CHANGELOG.md 2025-06-29 19:51:20 +09:00
ww-rm
58b13d00c1 Update Spine.csproj 2025-06-29 19:49:58 +09:00
ww-rm
0f5539ad41 Update SpineViewer.csproj 2025-06-29 19:49:29 +09:00
ww-rm
6d18ce882c Update SpineViewer.csproj 2025-06-29 19:46:04 +09:00
ww-rm
e1ea95c195 Merge pull request #61 from xiantuan/dev/wpf
Update SpineObject.cs add .skel.bytes Support
2025-06-29 11:47:51 +09:00
饭团
48ee61d1c6 Update SpineObject.cs add .skel.bytes Support
add .skel.bytes Support #58
2025-06-28 20:40:56 +08:00
ww-rm
3ca22c3f00 Merge pull request #55 from ww-rm/dev/wpf
Dev/wpf
2025-06-19 23:22:35 +08:00
ww-rm
593d9b771c 更新至v0.15.2 2025-06-19 23:21:43 +08:00
ww-rm
35f9357355 update changelog 2025-06-19 23:20:20 +08:00
ww-rm
427d18df4c 工作区保存参数增加浏览路径 2025-06-19 23:19:04 +08:00
ww-rm
7d1a1f1aeb 修复首选项文件不存在时的提示信息 2025-06-19 22:54:12 +08:00
ww-rm
d7017f8984 Merge pull request #54 from ww-rm/dev/wpf
修复工作流版本号提取错误
2025-06-18 01:52:58 +08:00
ww-rm
7b58eeafe3 修复工作流版本号提取错误 2025-06-18 01:52:08 +08:00
ww-rm
0e2eb3fbb1 Merge pull request #53 from ww-rm/dev/wpf
Dev/wpf
2025-06-18 01:39:18 +08:00
ww-rm
1f65dfb854 更新至v0.15.1 2025-06-18 01:38:16 +08:00
ww-rm
522bd26581 update readme 2025-06-18 01:37:58 +08:00
ww-rm
8849ddec54 增加对Color的定制序列化逻辑 2025-06-18 01:14:53 +08:00
ww-rm
5039bc666f 增加工作区功能 2025-06-18 00:53:02 +08:00
ww-rm
7bd3e3669b 增加参数保存功能 2025-06-15 14:38:37 +08:00
ww-rm
0dcf8c5577 增加显示和渲染选中首选项 2025-06-15 11:08:43 +08:00
ww-rm
9a62d7eb53 增加骨骼文件重载功能 2025-06-15 01:12:16 +08:00
ww-rm
5f189a066d 修复静态画面的边界检测错误 2025-06-14 20:00:25 +08:00
ww-rm
2287542522 small change 2025-06-14 11:33:00 +08:00
ww-rm
333c5e9981 模型属性面板项进行排序 2025-06-14 11:26:09 +08:00
ww-rm
0e7e7dd5d9 修改LoadOptions的归属 2025-06-14 11:14:27 +08:00
ww-rm
6fe639d6dd 允许导出单个时自动使用所有模型的所有动画最大时长 2025-06-14 10:48:38 +08:00
ww-rm
6114d4c954 修改布局 2025-06-14 02:01:00 +08:00
ww-rm
7ec938b415 增加语言设置 2025-06-14 01:57:39 +08:00
ww-rm
b3010360b4 增加首选项对话框 2025-06-13 23:12:15 +08:00
ww-rm
125ce6fa86 去除构造函数里的版本参数 2025-06-13 23:09:53 +08:00
ww-rm
7f61ebda78 修改setproperty调用方式 2025-06-13 00:35:59 +08:00
ww-rm
1092f37a02 移除一些非必要默认值 2025-06-13 00:11:03 +08:00
ww-rm
9be77ba8bd 增加纹理加载选项 2025-06-12 23:47:46 +08:00
ww-rm
28fd11cf3e 修复骨骼文件尝试性读取错误 2025-06-06 22:02:22 +08:00
ww-rm
16d4388f3e 修一下缺省值 2025-05-29 21:55:47 +08:00
ww-rm
42cb782a96 移除winforms引用 2025-05-29 20:10:15 +08:00
ww-rm
fffe69c49f 修改结构 2025-05-29 19:49:06 +08:00
ww-rm
707bdf7d33 增加弹框样式 2025-05-29 19:36:15 +08:00
ww-rm
54f9a054cf 标题增加v 2025-05-28 19:47:43 +08:00
ww-rm
550dafb2c2 修改调试渲染逻辑和选中时效果 2025-05-28 19:37:22 +08:00
ww-rm
5aaca437af 更新构建发布工作流自动检测版本号 2025-05-28 18:43:42 +08:00
ww-rm
668b264836 修改生成规则为非单文件 2025-05-27 19:37:18 +08:00
ww-rm
6fbf902756 增加ja语言 2025-05-27 19:21:14 +08:00
ww-rm
f7940d1223 完善文档 2025-05-27 19:10:40 +08:00
ww-rm
10008166ac 补充文档 2025-05-27 17:23:32 +08:00
ww-rm
44b5bf8613 update changelog 2025-05-27 16:47:33 +08:00
ww-rm
39dae5cdb6 增加颜色提示文本 2025-05-27 16:40:09 +08:00
ww-rm
d7f7c7116c 增加按钮提示文本 2025-05-27 16:00:08 +08:00
ww-rm
17257a0ffe 更换为wpf 2025-05-27 15:55:10 +08:00
ww-rm
d0f629d9ba 补充v2.1的一些实现,与v3.x版本一致 2025-05-27 15:54:57 +08:00
ww-rm
cd652a72a1 更新至v0.12.13 2025-05-19 10:31:34 +08:00
ww-rm
828ff30dbf update changelog 2025-05-19 10:31:15 +08:00
ww-rm
f452fe8a71 生成文件增加额外的随机后缀 2025-05-19 10:30:29 +08:00
ww-rm
15e29a3b8a 修复readattachmentline里的顺序错误 2025-05-17 10:47:49 +08:00
ww-rm
5c6e98f5e1 更新至v0.12.12 2025-05-13 14:21:13 +08:00
ww-rm
ef06073119 update changelog 2025-05-13 14:19:52 +08:00
ww-rm
bca8b0ad85 补充SkinnedMeshAttachment附件的渲染 2025-05-13 14:19:15 +08:00
ww-rm
4983b1fa88 更新至v0.12.11 2025-05-08 18:35:23 +08:00
ww-rm
f6b6d9f0e7 update changelog 2025-05-08 18:35:12 +08:00
ww-rm
12a168df92 修复atlas null 引用导致的闪退 2025-05-08 18:34:43 +08:00
ww-rm
e06d2012d6 更新至v0.12.10 2025-05-07 17:45:07 +08:00
ww-rm
faed2448eb update changelog 2025-05-07 17:44:52 +08:00
ww-rm
a80aed54a0 增加纹理加载菜单选项 2025-05-07 17:43:55 +08:00
ww-rm
3f9c4dfe99 抽出TextureLoader,增加部分可调参数 2025-05-07 17:43:42 +08:00
ww-rm
3c91f335fc 修复skin索引顺序问题 2025-05-06 19:11:46 +08:00
ww-rm
1ea4586360 Merge pull request #21 from steve14608/main
4.1版本格式转换,以及4.2版本发现的一些小bug
2025-05-02 16:29:23 +08:00
YongQi Li
45e08b5b60 Merge branch 'main' of https://github.com/steve14608/SpineViewer 2025-05-02 16:25:53 +08:00
YongQi Li
43ce5a5288 修改了skin2idx的读取逻辑 2025-05-02 16:25:39 +08:00
YongQi Li
887315ceda Merge branch 'main' of https://github.com/steve14608/SpineViewer 2025-05-02 14:52:01 +08:00
ww-rm
30b5c8dd74 4.1的格式转换 2025-05-02 14:51:40 +08:00
ww-rm
ef7ef76a59 更新至v0.12.9 2025-05-01 22:40:59 +08:00
ww-rm
a9834bcc13 update changelog 2025-05-01 22:40:38 +08:00
ww-rm
ec2752464d 修复部分情况下为调用UpdateCache导致皮肤设置失败 2025-05-01 22:38:55 +08:00
ww-rm
7b6a9b2a0f 更新至v0.12.8 2025-05-01 20:56:02 +08:00
ww-rm
8eda4f0849 update readme 2025-05-01 20:55:43 +08:00
ww-rm
cde25214ae update changelog 2025-05-01 20:55:10 +08:00
ww-rm
9f1f66776c 修复浮点数转换问题 2025-05-01 20:52:55 +08:00
ww-rm
c93b78528d 修复浮点数转换问题 2025-05-01 20:49:29 +08:00
ww-rm
e567e61383 修复写入问题 2025-05-01 20:17:17 +08:00
ww-rm
7c3184d88a 修改 Write 输入类型 2025-05-01 17:07:04 +08:00
ww-rm
e6f38657a3 修复path constraints target错误 2025-05-01 00:28:10 +08:00
ww-rm
ebcd61a9a2 fix ConvertFileFormatDialog localization 2025-04-30 11:08:05 +08:00
ww-rm
179fbfe84f 修改默认值写入范式 2025-04-30 02:19:43 +08:00
ww-rm
79441abff3 fix some text and shortcut keys 2025-04-29 16:23:59 +08:00
ww-rm
c3db8cd4ea Merge pull request #17 from myssal/main
feat: english localization
2025-04-29 16:08:56 +08:00
Myssal
27c58ffd87 fix: remove duplicate elements 2025-04-29 01:57:29 +07:00
Myssal
244249db2b fix: displayResolution typo 2025-04-29 01:10:53 +07:00
Myssal
33b937da87 fix: use check and ignore action instead of disable item 2025-04-29 01:04:06 +07:00
ww-rm
058834e8a6 修复读取部分问题 2025-04-28 23:45:01 +08:00
ww-rm
b134af3727 small change 2025-04-28 23:44:50 +08:00
ww-rm
6d2eafb4f1 add SkeletonConverter42 2025-04-28 20:30:01 +08:00
ww-rm
9f618804df 明确null类型 2025-04-28 20:21:31 +08:00
Myssal
61a3a62b65 Merge pull request #1 from myssal/feat/en_localization
Feat: English localization
2025-04-28 01:26:57 +07:00
Myssal
ced25dec87 feat: tooltip button in previewpanel localize 2025-04-28 01:23:22 +07:00
Myssal
60d5f3361a feat: main form localize 2025-04-28 01:15:10 +07:00
Myssal
c8ee4cf0c9 feat: spine exporter localize 2025-04-28 01:03:18 +07:00
Myssal
177434e503 feat: spineview localize 2025-04-28 00:08:25 +07:00
Myssal
58b45cde31 feat: spineview localize 2025-04-27 23:48:36 +07:00
Myssal
ff87030894 fix: parse constructor parameter to field 2025-04-27 23:18:49 +07:00
Myssal
7635adf637 feat: messagebox title localize 2025-04-27 22:06:45 +07:00
Myssal
ca7a40044c feat: more controls localize 2025-04-27 21:57:53 +07:00
Myssal
ce5be30f1d feat: localize model parameters 2025-04-27 21:01:54 +07:00
Myssal
1cb8f077f5 feat: localize propertygrid class 2025-04-27 21:01:31 +07:00
Myssal
61794cf784 feat: localize forms, controls, dialogs. 2025-04-27 19:52:56 +07:00
Myssal
045b191e4d feat: correct culture and set message box based on localize 2025-04-27 18:42:57 +07:00
Myssal
6116f6a4be feat: base function to switch language 2025-04-26 23:16:11 +07:00
ww-rm
ca7e94a306 update win32 2025-04-26 15:23:50 +08:00
ww-rm
165be38cfe update changelog 2025-04-26 15:14:19 +08:00
ww-rm
f1fb5fe5e1 更新至v0.12.7 2025-04-26 15:13:32 +08:00
ww-rm
17554d3a8e 补充遗漏的方法 2025-04-26 15:13:17 +08:00
ww-rm
054ac3939b 修改函数调用 2025-04-26 15:04:09 +08:00
ww-rm
9566c0a6f5 修复跨线程调用问题 2025-04-26 13:27:08 +08:00
ww-rm
b8509ccb69 修正事件处理 2025-04-25 22:08:11 +08:00
ww-rm
1e043e4faa update readme 2025-04-23 15:19:09 +08:00
ww-rm
5b1c177f58 增加ScaleX和ScaleY 2025-04-22 23:54:20 +08:00
ww-rm
794de783db 设置空动画为循环避免空引用 2025-04-21 21:29:24 +08:00
ww-rm
7f6aa26986 补充注释 2025-04-21 00:54:04 +08:00
ww-rm
fcd809fda5 使用PerMonitorV2 2025-04-20 23:13:37 +08:00
ww-rm
71ff8007fb update preview 2025-04-20 21:04:42 +08:00
ww-rm
a8261f4f58 update readme 2025-04-20 21:01:24 +08:00
ww-rm
bb6a6f3664 small change 2025-04-20 17:26:26 +08:00
ww-rm
9c6af07d32 去除切换里的窗口显示 2025-04-20 17:24:38 +08:00
ww-rm
afc011adbb update readme 2025-04-20 17:10:06 +08:00
ww-rm
da42c14d35 更新至0.12.6 2025-04-20 17:09:46 +08:00
ww-rm
a7438e2026 update changelog 2025-04-20 17:09:25 +08:00
ww-rm
47e5314bb3 禁用用户关闭事件 2025-04-20 17:09:13 +08:00
ww-rm
1978c1da11 update changelog 2025-04-20 16:57:09 +08:00
ww-rm
914c9d0ea3 增加颜色预设 2025-04-20 16:55:14 +08:00
ww-rm
7134aebb7f 增加桌面投影 2025-04-20 16:14:40 +08:00
ww-rm
abb32e9ed2 修复一些奇怪的bug 2025-04-20 16:13:50 +08:00
ww-rm
2c77e385c5 small change 2025-04-20 16:13:02 +08:00
ww-rm
ba0f5ac124 修正窗口第一次会显示的问题 2025-04-20 14:23:02 +08:00
ww-rm
c4f17e3f06 延迟运行时属性在第一次调用时初始化 2025-04-20 14:05:04 +08:00
ww-rm
b802ec252a 改成属性暴露接口 2025-04-20 13:20:22 +08:00
ww-rm
68779caab0 缩短类限定名 2025-04-20 13:19:46 +08:00
ww-rm
5d819114d0 一个没问题的版本 2025-04-20 12:49:29 +08:00
ww-rm
46b3937236 增加背景颜色设置 2025-04-20 12:43:23 +08:00
ww-rm
6803b8cf4a 修改调试输出 2025-04-20 12:42:02 +08:00
ww-rm
bd9c5a176b 增加ResolutionConverter 2025-04-20 12:41:33 +08:00
ww-rm
76c1d96c87 增加实验性功能桌面投影 2025-04-19 18:58:17 +08:00
ww-rm
304af805cb 增加scaleX和scaleY 2025-04-19 14:32:56 +08:00
ww-rm
027d3af619 增加default皮肤显示 2025-04-19 12:05:04 +08:00
ww-rm
c612c01ac7 update changelog 2025-04-19 01:48:36 +08:00
ww-rm
cd7855a877 update readme 2025-04-19 01:39:34 +08:00
ww-rm
cdd81e0bfb 修改文本描述 2025-04-19 01:35:10 +08:00
ww-rm
750a8b8aff 更新至v0.12.5 2025-04-19 01:32:29 +08:00
ww-rm
cd86155878 修复问题 2025-04-19 01:32:19 +08:00
ww-rm
16739c39d6 修复小bug 2025-04-19 00:41:40 +08:00
ww-rm
c7971a9829 update readme 2025-04-19 00:19:56 +08:00
ww-rm
44c4fc4b21 update preview 2025-04-19 00:19:47 +08:00
ww-rm
6f1c8e3320 增加槽位属性面板 2025-04-19 00:12:27 +08:00
ww-rm
8f818416ba 优化缓存字典读取 2025-04-18 23:55:08 +08:00
ww-rm
de6858ca48 增加GetSlotAttachment/SetSlotAttachment 2025-04-18 23:15:46 +08:00
ww-rm
3fd3d2a378 增加SFMLColorConverter属性描述符缓存 2025-04-18 22:37:46 +08:00
ww-rm
706c9125e6 修改皮肤设置方式为GetSkinStatus/SetSkinStatus 2025-04-18 21:56:50 +08:00
ww-rm
5f026b000c 修改皮肤设置操作为布尔型 2025-04-18 21:23:26 +08:00
ww-rm
0b0d036f08 增加SlotAttachmentNames 2025-04-18 19:31:33 +08:00
ww-rm
6b9017d535 修改名字 2025-04-18 14:50:27 +08:00
ww-rm
5eb47e33ac 修正名字 2025-04-18 14:48:08 +08:00
ww-rm
4d31335da0 修复缩放之后皮肤null引用错误 2025-04-18 11:14:32 +08:00
ww-rm
0b5e76a448 增强分辨率缓存 2025-04-18 00:09:17 +08:00
ww-rm
775268c01a 修复包围盒并集错误 2025-04-17 20:29:20 +08:00
ww-rm
b0b1c85047 更新注释和文本描述 2025-04-17 20:10:59 +08:00
ww-rm
5f08fc6695 更新至v0.12.4 2025-04-17 20:06:52 +08:00
ww-rm
2de3bdf12b 同步重命名 2025-04-17 20:06:38 +08:00
ww-rm
3a424c7dc1 update readme 2025-04-17 20:04:06 +08:00
ww-rm
c3e2b37072 update changelog 2025-04-17 20:03:46 +08:00
ww-rm
65bd11a346 增加自动分辨率 2025-04-17 20:00:15 +08:00
ww-rm
e6e7fc539f 修复Union错误 2025-04-17 19:58:14 +08:00
ww-rm
6522d415b7 增加AllowContentOverflow参数 2025-04-17 16:31:29 +08:00
ww-rm
378c66a333 small change 2025-04-17 16:30:45 +08:00
ww-rm
07204417a5 增加SetViewport 2025-04-17 16:30:27 +08:00
ww-rm
c9c909cdf9 增加padding和margin参数 2025-04-17 00:09:04 +08:00
ww-rm
a9f59a4d2f 增加对话框高度 2025-04-16 22:35:35 +08:00
ww-rm
1d2513cef5 增加padding和margin参数 2025-04-16 22:28:35 +08:00
ww-rm
febb797ae2 增加GetResolutionBounds方法 2025-04-16 21:37:09 +08:00
ww-rm
68d279a7c3 修改缩放公式 2025-04-16 21:25:26 +08:00
ww-rm
d2d8b7955c 增加GetBounds获取最大包围盒方法 2025-04-15 20:20:18 +08:00
ww-rm
2a55fd9c36 补充3.7及以下版本的多皮肤功能 2025-04-15 20:19:32 +08:00
ww-rm
695d3c0735 增加Attachments公开属性 2025-04-15 20:16:10 +08:00
ww-rm
ce95db469b 增加GetBounds 2025-04-15 20:15:50 +08:00
ww-rm
5d187cf80f 修复Path读取错误 2025-04-15 17:47:37 +08:00
ww-rm
e704ebc224 修正eventTimelines和原逻辑不一致的地方 2025-04-15 15:49:38 +08:00
ww-rm
ee36f8981c 修改GetBounds为GetCurrentBounds 2025-04-15 14:58:25 +08:00
ww-rm
09dd220abf 更改Bounds属性为GetBounds方法 2025-04-15 11:23:11 +08:00
ww-rm
15bc2dc3b8 完善文件转换功能 2025-04-14 23:52:39 +08:00
ww-rm
1deb74eca9 修正某些可能的字符大小写问题 2025-04-14 23:52:05 +08:00
ww-rm
de76ce64ab 增加输出文件夹选项 2025-04-14 23:50:46 +08:00
ww-rm
94b4ba33e6 修正curve读写 2025-04-14 21:48:23 +08:00
ww-rm
7ce8a115f4 修复流写入错误 2025-04-14 20:19:06 +08:00
ww-rm
c036a4bb45 增加v38二进制文件输出 2025-04-14 17:51:16 +08:00
ww-rm
aa62f30b05 增加报错输出 2025-04-14 17:11:56 +08:00
ww-rm
3d967c9812 修改默认打开骨骼文件后缀筛选器 2025-04-13 13:50:31 +08:00
ww-rm
e87e9efb99 补充点附件TODO 2025-04-13 00:37:29 +08:00
ww-rm
8c1f6fb4a6 update preview 2025-04-13 00:25:16 +08:00
ww-rm
df82ed8a00 更新至v0.12.3 2025-04-13 00:22:36 +08:00
ww-rm
d01e3920ba update changelog 2025-04-13 00:22:02 +08:00
ww-rm
777cd5ea3f 增加部分调试渲染功能 2025-04-13 00:19:02 +08:00
ww-rm
3b73aea5c0 增加调试骨骼 2025-04-12 20:58:56 +08:00
ww-rm
168f7a8173 修复maxFps时快进帧除0错误 2025-04-12 20:57:11 +08:00
ww-rm
04437e2de2 修改文本描述 2025-04-12 13:28:12 +08:00
ww-rm
2ec83b2e87 增加ctrl滚轮对模型缩放 2025-04-12 12:58:21 +08:00
ww-rm
90bfaa7b56 整理结构 2025-04-12 11:35:36 +08:00
ww-rm
2ae175abd0 small change 2025-04-11 13:55:19 +08:00
ww-rm
e2a84d8f88 small change 2025-04-11 00:58:25 +08:00
ww-rm
b6f9cd0c7c small change 2025-04-11 00:07:09 +08:00
ww-rm
61b7b90722 修改缩放模式 2025-04-10 10:27:09 +08:00
ww-rm
093c159753 修改布局 2025-04-10 10:21:31 +08:00
ww-rm
32d36c0757 补充遗漏参数项 2025-04-09 15:56:51 +08:00
ww-rm
94dabebf2b 修正文字说明 2025-04-09 15:34:03 +08:00
ww-rm
8e875d4f7e update changelog 2025-04-09 15:25:15 +08:00
ww-rm
86c383f2cf 默认使用libwebp_anim编码器 2025-04-09 15:24:48 +08:00
ww-rm
b404d8e79a 增加最后一帧参数 2025-04-09 15:24:31 +08:00
ww-rm
d32b480ef2 更新readme 2025-04-09 14:00:26 +08:00
ww-rm
3654825f27 补充文字说明 2025-04-09 13:52:59 +08:00
ww-rm
d7231e8a09 更新至版本v0.12.2 2025-04-09 13:43:21 +08:00
ww-rm
98161aaf2e update changelog 2025-04-09 13:40:34 +08:00
ww-rm
7a942b16bc 调整动图默认帧率 2025-04-09 13:40:11 +08:00
ww-rm
067719c69b 补充面板属性刷新 2025-04-09 13:36:34 +08:00
ww-rm
f3fce53b91 增加导出参数缓存 2025-04-09 13:19:25 +08:00
ww-rm
e35903f436 增加webp和avif动图格式 2025-04-09 13:19:17 +08:00
ww-rm
64cfe5fdd7 限定readonly 2025-04-09 01:09:57 +08:00
ww-rm
dbe586cff8 调整结构 2025-04-09 01:07:17 +08:00
ww-rm
3104733db0 补充调试参数 2025-04-08 15:00:42 +08:00
ww-rm
9d4bdd1028 标题栏增加版本号 2025-04-08 13:51:10 +08:00
ww-rm
f8030b1645 整合参数标签页 2025-04-08 13:44:30 +08:00
ww-rm
0a999ceb41 增加 SpinePropertyGrid 2025-04-08 13:21:29 +08:00
ww-rm
64bd9907cb 重构 2025-04-07 15:06:23 +08:00
ww-rm
580eaf990d 测试代码 2025-04-05 11:57:44 +08:00
ww-rm
5ab232a961 更新至v0.12.1 2025-04-05 11:56:53 +08:00
ww-rm
e596cd7ea4 update changelog 2025-04-05 11:56:13 +08:00
ww-rm
05c47a4daa 增加初始动画皮肤空位 2025-04-05 11:52:34 +08:00
ww-rm
5a8783b5f4 增加确定按钮 2025-04-05 11:18:54 +08:00
ww-rm
08bc171a72 修复分辨率调整时父容器尺寸获取错误bug 2025-04-05 10:38:17 +08:00
ww-rm
7372f5fe08 optimize 2025-04-05 10:31:30 +08:00
ww-rm
6f032bdd05 optimize 2025-04-05 10:10:04 +08:00
ww-rm
153d3603d2 optimize 2025-04-05 09:40:02 +08:00
ww-rm
95261e6907 optimize 2025-04-05 01:53:39 +08:00
ww-rm
17b344376d update readme 2025-04-05 01:39:59 +08:00
ww-rm
0ed4e44878 更新至v0.12.0 2025-04-05 01:22:14 +08:00
ww-rm
b42c1832f0 update changelog 2025-04-05 01:16:00 +08:00
ww-rm
058534ba67 修复部分资源泄漏 2025-04-05 01:14:59 +08:00
ww-rm
204dcd6498 增加3.8及以上版本多皮肤支持 2025-04-05 00:57:04 +08:00
ww-rm
2c846c0db9 补充update0 2025-04-04 20:10:29 +08:00
ww-rm
2faeb044e0 增加 readonly 限定 2025-04-04 17:36:52 +08:00
ww-rm
09c8e4f779 修复导出过程中的PMA问题 2025-04-04 17:21:30 +08:00
ww-rm
6994fa6be8 修复shader问题 2025-04-04 11:26:23 +08:00
ww-rm
cc7beb7670 增加SFMLExtension 2025-04-03 20:14:13 +08:00
ww-rm
510653732d 移除冗余引用 2025-04-03 19:46:01 +08:00
ww-rm
93e8178d67 增加部分实验性样例代码 2025-04-03 19:39:13 +08:00
ww-rm
cebc4864cc 封装原生操作 2025-04-03 18:22:55 +08:00
ww-rm
6ad0449376 修复内存泄漏 2025-04-03 18:19:12 +08:00
ww-rm
c33c977326 update changelog 2025-04-03 15:02:18 +08:00
ww-rm
f0299d365a 补充update0 2025-04-03 09:55:51 +08:00
ww-rm
6ecdca73f5 不提供时长时按所有轨道动画时长最大值导出 2025-04-03 00:30:55 +08:00
ww-rm
af6a709b2c 完善动画时间重置功能 2025-04-03 00:30:33 +08:00
ww-rm
d5c27450ef 修改pma默认值为false 2025-04-03 00:15:44 +08:00
ww-rm
d10269fb07 small change 2025-04-03 00:13:36 +08:00
ww-rm
53d987476e 增加多轨道动画编辑 2025-04-02 23:59:18 +08:00
ww-rm
8b7866d37f 增加多轨方法 2025-04-02 11:43:25 +08:00
ww-rm
bb529729b6 增加Tracks公开属性 2025-04-02 11:41:23 +08:00
ww-rm
b7735d9ba8 改成并集动画皮肤列表 2025-04-01 21:07:52 +08:00
ww-rm
ce744e2b84 update badges 2025-03-31 22:56:50 +08:00
ww-rm
631c92da3f update readme 2025-03-31 22:18:06 +08:00
ww-rm
b7063804e9 add badges 2025-03-31 22:04:31 +08:00
ww-rm
75d47c8419 修改提示文本 2025-03-31 20:55:37 +08:00
ww-rm
114fb05e80 调整布局 2025-03-31 19:28:32 +08:00
ww-rm
1fec65b37d 更新至v0.11.5 2025-03-31 17:42:54 +08:00
ww-rm
9498e8f334 update readme 2025-03-31 17:42:44 +08:00
ww-rm
83b8411929 update changelog 2025-03-31 17:34:48 +08:00
ww-rm
e9accd13b3 增加所有导出格式 2025-03-31 17:30:20 +08:00
ww-rm
9e27a19258 允许多标记 2025-03-31 14:37:47 +08:00
ww-rm
252f3a5bea 优化显示 2025-03-31 02:07:02 +08:00
ww-rm
e0626bb126 增加项数显示 2025-03-31 01:58:30 +08:00
ww-rm
7ff62c7f40 增加错误日志 2025-03-31 01:45:16 +08:00
ww-rm
4b07e02acb 增加线程安全 2025-03-31 01:44:41 +08:00
ww-rm
4654d1d9c2 优化多项操作卡顿问题 2025-03-30 20:52:22 +08:00
ww-rm
ce1f75e8a5 增加报错调试 2025-03-30 20:07:29 +08:00
ww-rm
4d9aebc758 修复预览图不显示问题 2025-03-30 20:06:13 +08:00
ww-rm
e814368ef3 移除rid 2025-03-30 19:30:58 +08:00
ww-rm
bbbb02500f 增加StringEnumConverter 2025-03-30 17:26:17 +08:00
ww-rm
404f255f14 update readme 2025-03-30 15:22:48 +08:00
ww-rm
7a15e0d38a 隐藏不可见成员 2025-03-30 13:54:17 +08:00
ww-rm
bfe669bdd9 增加FFMpegCore版本信息 2025-03-30 12:07:28 +08:00
ww-rm
c0553042fd 更新至v0.11.4 2025-03-30 11:59:52 +08:00
ww-rm
af8b02654b update readme 2025-03-30 11:59:37 +08:00
ww-rm
4779ec91d0 update changelog 2025-03-30 11:59:13 +08:00
ww-rm
14d7f4af0e 增加MP4导出格式 2025-03-30 11:56:20 +08:00
ww-rm
f9888b23dd 设置GIF默认背景颜色为纯白透明背景 2025-03-30 11:56:06 +08:00
ww-rm
411cdbb00f 设置默认颜色为纯黑透明背景 2025-03-30 11:55:52 +08:00
ww-rm
d859f07469 增加导出时输出ffmpeg参数 2025-03-29 23:48:56 +08:00
ww-rm
c111819093 增加背景颜色参数 2025-03-29 22:17:08 +08:00
ww-rm
aa8321d13c 整理代码结构 2025-03-29 21:15:34 +08:00
ww-rm
5e3bd972e5 移动GetVersion至SpineHelper 2025-03-29 17:04:26 +08:00
ww-rm
ad39a04fff 重命名SpineVersion 2025-03-29 16:59:28 +08:00
ww-rm
9a97e84296 解耦对MessageBox的依赖,提供单独的Shader初始化函数 2025-03-29 16:51:05 +08:00
ww-rm
1b7b0dcb13 解耦日志器 2025-03-29 16:30:32 +08:00
ww-rm
d365a5060b small change 2025-03-29 15:34:56 +08:00
ww-rm
b69589394a 提取ImplementationResolver实现 2025-03-29 15:12:50 +08:00
ww-rm
00f5791766 增加导出时任务栏图标显示 2025-03-28 20:53:48 +08:00
ww-rm
38cab2eda7 修复可能的预览图资源泄漏 2025-03-27 23:31:03 +08:00
ww-rm
0db4d6e4e0 small change 2025-03-27 19:45:56 +08:00
ww-rm
549712962f 去除多余组件 2025-03-27 10:11:44 +08:00
ww-rm
34b7002faf 增加背景颜色选项 2025-03-27 10:08:16 +08:00
ww-rm
0e6f47b23c 预修改适配对多轨道动画 2025-03-27 09:56:21 +08:00
ww-rm
a372a89b5e 增加update0 2025-03-27 09:09:22 +08:00
ww-rm
239847aee7 皮肤更换后使用SetSlotsToSetupPose而不是SetToSetupPose 2025-03-27 09:03:09 +08:00
ww-rm
813249c6a7 调整布局 2025-03-26 21:09:52 +08:00
ww-rm
293ab28bce 更新预览图 2025-03-26 20:49:22 +08:00
ww-rm
98e73cdec5 调整面板比例 2025-03-26 20:48:23 +08:00
ww-rm
6d34bb9d25 移除无用引用 2025-03-26 20:37:27 +08:00
ww-rm
479a5e4da9 更新至v0.11.3 2025-03-26 20:33:48 +08:00
ww-rm
4829454877 update changelog 2025-03-26 20:33:31 +08:00
ww-rm
28664f6387 增加隐藏控制 2025-03-26 20:30:55 +08:00
ww-rm
1a08a23a9c 批量添加完成自动选中最后一项 2025-03-26 20:24:27 +08:00
ww-rm
16f344ff1b 增加纹理调试 2025-03-26 19:55:43 +08:00
ww-rm
693ce0e2e8 调整属性分组和注释 2025-03-26 19:52:29 +08:00
ww-rm
e6f533ea65 优化属性分组显示顺序 2025-03-26 18:54:35 +08:00
ww-rm
fcc21d63b0 优化排列顺序 2025-03-26 18:39:30 +08:00
ww-rm
afc0ffcb67 Merge branch 'main' of github.com:ww-rm/SpineViewer 2025-03-26 18:25:56 +08:00
ww-rm
9ffb9840e1 去除限制 2025-03-26 18:25:48 +08:00
ww-rm
4766ccf1b6 互换模型和画面参数面板位置 2025-03-26 18:23:59 +08:00
ww-rm
16b75c80a3 Update README.en.md 2025-03-26 17:00:08 +08:00
ww-rm
880f063046 优化分割条可感知宽度 2025-03-26 16:20:12 +08:00
ww-rm
723c11b886 更新至v0.11.2 2025-03-26 15:54:19 +08:00
ww-rm
5e074b1cf7 update changelog 2025-03-26 15:54:06 +08:00
ww-rm
71d2fee36e 修复纹理加载异常 2025-03-26 15:53:27 +08:00
ww-rm
7dc701464f 优化缩放实现 2025-03-26 15:43:54 +08:00
ww-rm
fd876ef90f 补充皮肤切换后的刷新 2025-03-26 15:25:55 +08:00
ww-rm
0597852178 增加皮肤属性 2025-03-26 15:20:59 +08:00
ww-rm
81b1333091 small change 2025-03-26 15:20:49 +08:00
ww-rm
7baebd79a6 update changelog 2025-03-26 14:32:07 +08:00
ww-rm
951d0e30ae 更新至v0.11.1 2025-03-26 14:28:57 +08:00
ww-rm
711e172769 优化显示 2025-03-26 13:57:08 +08:00
ww-rm
faa60f0ea1 update readme 2025-03-26 13:37:12 +08:00
ww-rm
99d81c4329 增加GIF导出格式 2025-03-26 13:10:51 +08:00
ww-rm
17904326f3 修复tex跨线程问题 2025-03-26 13:10:45 +08:00
ww-rm
5ee74f39d8 增加逐个导出时使用自动时长 2025-03-26 13:07:23 +08:00
ww-rm
72f898ed60 增加导出事件绑定 2025-03-26 10:30:57 +08:00
ww-rm
157eab5bac 修复Update顺序错误 2025-03-26 10:08:56 +08:00
ww-rm
e1b0d0a2ad small change 2025-03-26 02:53:09 +08:00
ww-rm
2c050ba031 update readme 2025-03-26 02:51:02 +08:00
ww-rm
41518b16b4 更新至v0.11.0 2025-03-26 02:45:01 +08:00
ww-rm
72a16dc95f 导出单个时也在子目录输出 2025-03-26 02:44:30 +08:00
ww-rm
3404c64f55 update changelog 2025-03-26 02:40:21 +08:00
ww-rm
b9015422f8 增加注释 2025-03-26 02:37:37 +08:00
ww-rm
a7441b968d 增加快进功能 2025-03-26 02:31:07 +08:00
ww-rm
2d44be31f7 优化Bitmap获取过程 2025-03-25 23:34:35 +08:00
ww-rm
c2cf25bb2b 统一导出类结构 2025-03-25 23:25:04 +08:00
ww-rm
7c4c53dcb0 简化时间标记 2025-03-25 18:46:17 +08:00
ww-rm
aceb3b17c8 统一调用 2025-03-25 18:42:24 +08:00
ww-rm
adfcfdb1de 优化显示 2025-03-25 11:24:37 +08:00
ww-rm
da329723bc 修改提示弹窗 2025-03-25 10:49:36 +08:00
ww-rm
63eb53fa06 调整命名空间 2025-03-25 00:53:32 +08:00
ww-rm
d32c824515 设置只读参数 2025-03-25 00:31:30 +08:00
ww-rm
e9ee8c481c 去除多余注释 2025-03-25 00:21:07 +08:00
ww-rm
6d78e52605 增加开始暂停图标按钮 2025-03-25 00:08:50 +08:00
ww-rm
90136a5562 重构导出 2025-03-24 23:05:01 +08:00
ww-rm
1592767c8c 增加注释 2025-03-24 21:14:10 +08:00
ww-rm
afa6ce2113 增加画面开始暂停 2025-03-24 21:01:07 +08:00
ww-rm
50e6e414ee 调整文件夹结构 2025-03-24 18:49:36 +08:00
ww-rm
ba9b8edcdc 增加文件夹路径编辑器 2025-03-24 18:49:01 +08:00
ww-rm
d7a927475c 修改父类 2025-03-24 18:48:16 +08:00
ww-rm
afe210343f 增加适合模型文件的UIEditor 2025-03-24 18:43:51 +08:00
ww-rm
4e293daf62 更新至v0.10.9 2025-03-24 15:18:09 +08:00
ww-rm
f9d7fdc516 update readme 2025-03-24 15:17:42 +08:00
ww-rm
6a04f3955c 完善预览图导出参数 2025-03-24 15:15:59 +08:00
ww-rm
dce3b1780c update readme 2025-03-24 14:44:44 +08:00
ww-rm
f47f3e9db6 更新至v0.10.8 2025-03-24 14:42:21 +08:00
ww-rm
4ac74acaf7 update changelog 2025-03-24 14:42:11 +08:00
ww-rm
cf7588c288 update readme 2025-03-24 14:41:25 +08:00
ww-rm
ec7bdf4000 预览图增加仅导出选中 2025-03-24 14:33:09 +08:00
ww-rm
51cd97f782 调整布局 2025-03-24 13:48:05 +08:00
ww-rm
a16f2f096d 完善预览图导出 2025-03-24 13:47:56 +08:00
ww-rm
4e92f14551 完善文件转换功能 2025-03-24 01:58:53 +08:00
ww-rm
8f6cc9ff44 增加任意格式读取 2025-03-24 01:57:49 +08:00
ww-rm
f885df5c67 增加文件选择控件 2025-03-24 01:57:13 +08:00
ww-rm
0ccb110e36 fix bug 2025-03-24 00:20:53 +08:00
ww-rm
2c238dca9b 更新至v0.10.7 2025-03-24 00:17:02 +08:00
ww-rm
3e0aa53fca update changelog 2025-03-24 00:16:33 +08:00
ww-rm
12b4e44296 增加仅导出选中 2025-03-24 00:14:43 +08:00
ww-rm
9a2cf4aefe 增加region注释 2025-03-24 00:10:32 +08:00
ww-rm
0e2a116e0a 增加显示包围盒调试 2025-03-24 00:05:11 +08:00
ww-rm
7bf30eb54a 增加仅渲染选中模式 2025-03-24 00:01:28 +08:00
ww-rm
8dda8c8ff3 增加动画交集选择 2025-03-23 10:58:57 +08:00
ww-rm
988fdb22be 增加重载 2025-03-23 10:55:28 +08:00
ww-rm
1dd2c8fb4d fix bug 2025-03-23 10:19:50 +08:00
ww-rm
2b39384b28 重构以及增加注释 2025-03-23 01:34:44 +08:00
ww-rm
28d1275023 增加公开属性 2025-03-22 23:11:13 +08:00
ww-rm
979181fc3b small change 2025-03-22 21:12:47 +08:00
ww-rm
b374b88ad5 add writeskins 2025-03-22 21:08:14 +08:00
ww-rm
6643c19a20 remove useless member 2025-03-22 16:07:04 +08:00
ww-rm
7460874c81 增加注释 2025-03-22 12:38:17 +08:00
ww-rm
13dd7511f6 优化预览图获取 2025-03-21 20:35:39 +08:00
ww-rm
f153d251c8 增加预览图留白 2025-03-21 20:09:08 +08:00
ww-rm
3442ace981 更新至v0.10.6 2025-03-21 14:57:50 +08:00
ww-rm
547cebf5a9 update readme 2025-03-21 14:57:30 +08:00
ww-rm
7a24d22bc6 update changelog 2025-03-21 14:57:25 +08:00
ww-rm
8f5728afe4 fix bug 2025-03-21 14:45:45 +08:00
ww-rm
41b5ac2c61 优化渲染 2025-03-21 14:31:20 +08:00
ww-rm
694ca3bf25 refactor 2025-03-21 13:32:03 +08:00
ww-rm
674d314b55 增加文件夹查找 2025-03-21 13:24:18 +08:00
ww-rm
08a35cc5d1 增加ctrlV导入 2025-03-21 11:14:31 +08:00
ww-rm
176e5db4d9 fix bug 2025-03-21 01:40:42 +08:00
ww-rm
2535a9ebf9 增加运行时标识 2025-03-21 01:05:08 +08:00
ww-rm
8ff99ee925 small optimize 2025-03-21 00:27:38 +08:00
ww-rm
abc8218487 add log 2025-03-21 00:23:31 +08:00
ww-rm
e4765750c3 更新至v0.10.5 2025-03-21 00:04:32 +08:00
ww-rm
02cddf556b update changelog 2025-03-21 00:04:07 +08:00
ww-rm
e1e6d3c72d fix bug 2025-03-21 00:03:31 +08:00
ww-rm
b401a16002 更新至v0.10.4 2025-03-20 23:50:04 +08:00
ww-rm
523b0ce295 update changelog 2025-03-20 23:49:54 +08:00
ww-rm
abb06726f0 fix bug 2025-03-20 23:49:45 +08:00
ww-rm
d9190e9418 修复图标显示问题 2025-03-20 20:30:04 +08:00
ww-rm
9fe3761eca 修改默认大小 2025-03-20 20:22:07 +08:00
ww-rm
51824afba6 优化列表使用 2025-03-20 20:02:25 +08:00
ww-rm
160a49ad5f 更新至v0.10.3 2025-03-20 15:38:04 +08:00
ww-rm
9d4907d77e update changelog and readme 2025-03-20 15:37:49 +08:00
ww-rm
53d30e0503 修改字母快捷键 2025-03-20 15:34:17 +08:00
ww-rm
9609a2fd5d 增加拖放文件打开 2025-03-20 15:32:31 +08:00
ww-rm
66cf0efcb9 增加单独的结果包装类 2025-03-20 15:31:35 +08:00
ww-rm
0129b9df31 small change 2025-03-20 14:20:45 +08:00
ww-rm
a7a5521be1 增加自动版本 2025-03-20 14:20:26 +08:00
ww-rm
f7f7211ca2 增加自动版本 2025-03-20 14:04:19 +08:00
ww-rm
8c921a6ed5 修改错误类型 2025-03-20 14:03:33 +08:00
ww-rm
f14ab870f7 update 2025-03-20 11:05:05 +08:00
ww-rm
26e81ffdb6 update readme preview 2025-03-20 10:14:59 +08:00
ww-rm
598a88203e 更新至v0.10.2 2025-03-20 00:12:41 +08:00
ww-rm
914d02e754 优化列表右键菜单功能 2025-03-20 00:10:09 +08:00
ww-rm
5cf30f391b 增加置顶 2025-03-19 17:07:47 +08:00
ww-rm
8de00cad76 更新至v0.10.1 2025-03-19 16:48:23 +08:00
ww-rm
e4c58f2f4e update changelog 2025-03-19 16:48:15 +08:00
ww-rm
063dba30b6 优化使用 2025-03-19 16:45:56 +08:00
ww-rm
01fa9287a1 修改默认列表宽度 2025-03-19 16:36:34 +08:00
ww-rm
008067fccb 增加预览图导出功能 2025-03-19 16:29:10 +08:00
ww-rm
091301e945 增加预览图 2025-03-19 15:12:05 +08:00
ww-rm
145f4f3265 增加空动画 2025-03-19 13:12:57 +08:00
ww-rm
36d4e8c948 增加管理资源按钮 2025-03-19 00:06:03 +08:00
ww-rm
63de847a57 add something 2025-03-18 15:16:12 +08:00
ww-rm
b3e1b7c902 修改类型转换 2025-03-18 13:52:58 +08:00
ww-rm
2dbc235631 Merge branch 'main' of github.com:ww-rm/SpineViewer 2025-03-18 12:15:14 +08:00
ww-rm
4d68b48367 增加版本转换接口 2025-03-18 12:15:07 +08:00
ww-rm
65e63e2b2d Update dotnet-desktop.yml 2025-03-18 09:55:09 +08:00
ww-rm
58071e1de1 add something 2025-03-17 21:14:47 +08:00
ww-rm
5009ef479f add something 2025-03-17 21:11:09 +08:00
ww-rm
e5e9357649 Merge branch 'main' of github.com:ww-rm/SpineViewer 2025-03-17 20:57:26 +08:00
ww-rm
a577474772 修改函数格式 2025-03-17 20:57:19 +08:00
ww-rm
e960a09153 Update README.en.md 2025-03-17 17:33:43 +08:00
ww-rm
13d50f59c3 Update README.md 2025-03-17 17:32:31 +08:00
ww-rm
ed4c8475e9 add post process 2025-03-16 19:49:34 +08:00
ww-rm
2338bf4e15 fix check bug 2025-03-16 17:21:41 +08:00
ww-rm
267aa7ee63 增加自动打开 2025-03-16 17:13:14 +08:00
ww-rm
3df7dbc769 remove debug 2025-03-16 17:09:59 +08:00
ww-rm
5f12ab7e85 update readme 2025-03-16 16:58:11 +08:00
ww-rm
ac0adc5f95 更新至v0.10.0 2025-03-16 16:47:34 +08:00
ww-rm
208b702065 update changelog 2025-03-16 16:46:58 +08:00
ww-rm
7e61fbfbac 增加后缀筛选选项 2025-03-16 16:46:49 +08:00
ww-rm
0591549727 fix bug 2025-03-16 16:38:51 +08:00
ww-rm
a0833580f8 增加格式转换 2025-03-16 16:22:19 +08:00
ww-rm
c622b60215 增加版本检测 2025-03-16 16:12:36 +08:00
ww-rm
c228cf9072 add readanimation 2025-03-16 14:22:00 +08:00
ww-rm
4c68dd4904 add something 2025-03-16 01:40:19 +08:00
ww-rm
32fde582fc refactor 2025-03-14 18:55:56 +08:00
ww-rm
2bf2509df7 add read attachments 2025-03-14 01:12:22 +08:00
ww-rm
07042189c8 增加注释 2025-03-13 17:31:04 +08:00
ww-rm
d251c94638 some change 2025-03-13 17:29:56 +08:00
ww-rm
b4119087fb update readme 2025-03-13 14:53:32 +08:00
ww-rm
e3959e80fb add something 2025-03-13 14:32:37 +08:00
ww-rm
0495a2344c add something 2025-03-13 14:32:11 +08:00
ww-rm
c781ec5a4f fix bug 2025-03-13 14:23:00 +08:00
ww-rm
a58566735f 增加提示信息 2025-03-13 14:22:46 +08:00
ww-rm
b37e5c25c3 rename 2025-03-13 13:30:35 +08:00
ww-rm
63a937a45b optimize 2025-03-13 10:32:18 +08:00
ww-rm
c920471c0c change name 2025-03-13 02:32:53 +08:00
ww-rm
c4863ee09b add binary writer/reader 2025-03-13 01:31:24 +08:00
ww-rm
c0b85c454e 调整结构 2025-03-12 19:14:22 +08:00
ww-rm
763a49a4d3 增加一些按钮 2025-03-12 18:33:52 +08:00
ww-rm
0e1540873c 增加自动弹出选择文件 2025-03-12 18:33:07 +08:00
ww-rm
39dcc636ca 增加文件版本显示 2025-03-12 15:23:15 +08:00
ww-rm
342778c56e 增加画面和列表联动 2025-03-11 00:01:54 +08:00
ww-rm
fd524891aa 增加属性IsSelected 2025-03-11 00:00:23 +08:00
ww-rm
48cb60020c 增加属性SelectedIndices 2025-03-11 00:00:09 +08:00
ww-rm
d502c592f7 update readme 2025-03-06 11:16:59 +08:00
ww-rm
e4377436a7 修改文件编码 2025-03-06 00:00:56 +08:00
ww-rm
eb44c1271e 修改命名 2025-03-05 16:24:19 +08:00
430 changed files with 48967 additions and 26840 deletions

18
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,18 @@
---
name: 问题报告/Bug report
about: 报告可能的程序错误/Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
## 问题描述/Describe the bug
清晰完整的描述问题是什么以及如何发生的。/A clear and concise description of what the bug is.
## 复现方式(可选)/To Reproduce (Optional)
## 截图(可选)/Screenshots (Optional)**
如果有必要,提供报错时的有关截图。/If applicable, add screenshots to help explain your problem.
## 附件(可选)/Attachments (Optional)
请将会**出现问题的文件**以及**日志文件**打包成一个 ZIP 后作为附件贴在 issue 内,日志文件位于程序目录下的 `logs` 文件夹内。/Please compress the problematic files and the log files into a single ZIP archive and attach it to this issue. The log files are located in the `logs` folder under the program directory.

View File

@@ -1,73 +0,0 @@
name: Build and Release
on:
push:
tags:
- 'v*.*.*'
jobs:
build-release:
runs-on: windows-latest
env:
PROJECT_NAME: SpineViewer
VERSION: ${{ github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Publish FrameworkDependent version
run: |
dotnet publish ${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj -c Release -r win-x64 --sc false -p:PublishSingleFile=true -o publish/${{ env.PROJECT_NAME }}-${{ env.VERSION }}
- name: Publish SelfContained version
run: |
dotnet publish ${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj -c Release -r win-x64 --sc true -p:PublishSingleFile=true -o publish/${{ env.PROJECT_NAME }}-${{ env.VERSION }}-SelfContained
- name: Create release directory
run: mkdir release
- name: Compress FrameworkDependent version
shell: pwsh
run: |
Compress-Archive -Path "publish/${env:PROJECT_NAME}-${env:VERSION}" -DestinationPath "release/${env:PROJECT_NAME}-${env:VERSION}.zip" -Force
- name: Compress SelfContained version
shell: pwsh
run: |
Compress-Archive -Path "publish/${env:PROJECT_NAME}-${env:VERSION}-SelfContained" -DestinationPath "release/${env:PROJECT_NAME}-${env:VERSION}-SelfContained.zip" -Force
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload FrameworkDependent zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/${{ env.PROJECT_NAME }}-${{ env.VERSION }}.zip
asset_name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}.zip
asset_content_type: application/zip
- name: Upload SelfContained zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/${{ env.PROJECT_NAME }}-${{ env.VERSION }}-SelfContained.zip
asset_name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-SelfContained.zip
asset_content_type: application/zip

140
.github/workflows/dotnet-release.yml vendored Normal file
View File

@@ -0,0 +1,140 @@
name: Build & Release
on:
pull_request:
branches:
- main
types:
- closed
jobs:
build-release:
if: ${{ github.event.pull_request.merged == true }}
runs-on: windows-latest
outputs:
version: ${{ steps.extract_version.outputs.version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
env:
PROJECT_NAME: SpineViewer
PROJ_CLI_NAME: SpineViewerCLI
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-tags: true
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
- name: Extract version from csproj
id: extract_version
shell: pwsh
run: |
[xml]$proj = Get-Content "$env:PROJECT_NAME\$env:PROJECT_NAME.csproj"
$VERSION_NUM = $proj.Project.PropertyGroup.Version
$VERSION_TAG = "v$VERSION_NUM".Trim()
echo "Version tag found: $VERSION_TAG"
echo "version=$VERSION_TAG" >> $env:GITHUB_OUTPUT
echo "VERSION=$VERSION_TAG" >> $env:GITHUB_ENV
- name: Tag merge commit
shell: pwsh
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag $env:VERSION
git push --tags
- name: Publish FrameworkDependent version
shell: pwsh
run: |
dotnet publish "$env:PROJECT_NAME\$env:PROJECT_NAME.csproj" -c Release -r win-x64 --sc false -o "publish\$env:PROJECT_NAME-$env:VERSION"
dotnet publish "$env:PROJ_CLI_NAME\$env:PROJ_CLI_NAME.csproj" -c Release -r win-x64 --sc false -o "publish\$env:PROJECT_NAME-$env:VERSION"
- name: Publish SelfContained version
shell: pwsh
run: |
dotnet publish "$env:PROJECT_NAME\$env:PROJECT_NAME.csproj" -c Release -r win-x64 --sc true -o "publish\$env:PROJECT_NAME-$env:VERSION-SelfContained"
dotnet publish "$env:PROJ_CLI_NAME\$env:PROJ_CLI_NAME.csproj" -c Release -r win-x64 --sc true -o "publish\$env:PROJECT_NAME-$env:VERSION-SelfContained"
- name: Compress Windows builds
shell: pwsh
run: |
New-Item -ItemType Directory -Path release -Force | Out-Null
Compress-Archive -Path "publish\$env:PROJECT_NAME-$env:VERSION\*" -DestinationPath "release\$env:PROJECT_NAME-$env:VERSION.zip" -Force
Compress-Archive -Path "publish\$env:PROJECT_NAME-$env:VERSION-SelfContained\*" -DestinationPath "release\$env:PROJECT_NAME-$env:VERSION-SelfContained.zip" -Force
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
draft: false
prerelease: false
- name: Upload Windows FrameworkDependent zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/${{ env.PROJECT_NAME }}-${{ env.VERSION }}.zip
asset_name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}.zip
asset_content_type: application/zip
- name: Upload Windows SelfContained zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/${{ env.PROJECT_NAME }}-${{ env.VERSION }}-SelfContained.zip
asset_name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-SelfContained.zip
asset_content_type: application/zip
build-release-linux:
needs: build-release
if: ${{ github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
env:
PROJ_CLI_NAME: SpineViewerCLI
VERSION: ${{ needs.build-release.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-tags: true
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
- name: Publish Linux SelfContained version
run: |
dotnet publish "$PROJ_CLI_NAME/$PROJ_CLI_NAME.csproj" -c Release -r linux-x64 --sc true -o "publish/${PROJ_CLI_NAME}-${VERSION}-Linux-SelfContained"
- name: Compress Linux build
run: |
mkdir -p release
cd publish
zip -r "../release/${PROJ_CLI_NAME}-${VERSION}-Linux-SelfContained.zip" "${PROJ_CLI_NAME}-${VERSION}-Linux-SelfContained"
- name: Upload Linux zip to GitHub Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build-release.outputs.upload_url }}
asset_path: release/${{ env.PROJ_CLI_NAME }}-${{ env.VERSION }}-Linux-SelfContained.zip
asset_name: ${{ env.PROJ_CLI_NAME }}-${{ env.VERSION }}-Linux-SelfContained.zip
asset_content_type: application/zip

2
.gitignore vendored
View File

@@ -396,3 +396,5 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
launchSettings.json

397
CHANGELOG.md Normal file
View File

@@ -0,0 +1,397 @@
# CHANGELOG
## v0.16.12
- 修复 label 控件文字显示问题
- 增强报错日志输出
- 增加实时帧率显示
- 首选项增加预览画面和投影最大帧率设置,移除用户状态和工作区帧率记忆
- 优化某些性能
## v0.16.11
- 增加 shift 切换缩放倍数
- 改善后台性能
- 修复字体显示颜色问题
- 调整浏览目录参数保存至用户状态
- 调整浏览面板至最后
## v0.16.10
- 增加 Linux 平台 CLI 工具构建
## v0.16.9
- 重构 CLI 工具
## v0.16.8
- 去除首次的最小化提示弹框
- 窗口布局改变后实时保存
- 增加侧边栏图标和折叠功能
- 增加皮肤和插槽参数面板的全部启用/禁用菜单项
- 修改窗口默认大小
- 支持复制并应用单独的模型皮肤或插槽参数
## v0.16.7
- 修复空帧导致的包围盒计算错误
- 修复重复启动程序无法唤出界面的问题
## v0.16.6
- 修复控件尺寸为0时导致的画面缩放错误
## v0.16.5
- 修复对于无 size 行的旧 atlas 格式读取错误
- 修复托盘化之后无法联动显示窗口的问题
## v0.16.4
- 增加 apng 导出格式
- 增加颜色拾取器面板
- 增加程序皮肤(主题颜色)首选项
- 优化部分使用体验
## v0.16.3
- 修复加载工作区时的顺序错误
- 调整部分调试渲染的逻辑
- 完善命中检测逻辑
## v0.16.2
- 修复批量添加时的添加顺序错误
- 增加精确命中检测和插槽输出功能
- 部分代码重构
## v0.16.1
- 修复 3.4 版本存在的附件残留问题
## v0.16.0
- 增加最小化至托盘图标功能
- 调整部分参数项的顺序
- 增加开机自启和自启文件设置
- 切换桌面投影时自动设置预览分辨率为主屏幕分辨率
- 修复 3.4 版本下可能存在的附件残留问题
## v0.15.19
- 模型重载后选中最后一个重载模型
- 修复 3.4 版本可能的奇数顶点数组导致的越界崩溃问题
- 移除参数自动记录中的背景图片路径
- 增加测试性桌面投影功能
## v0.15.18
- 完善窗口日志颜色标记
- 修复预览图背景颜色为透明
- 修复面板高度首次还原错误
- 增加托盘图标
- 增加可选预览背景画面和填充模式
- 增强支持的纹理格式(例如 webp
## v0.15.17
- 修改图标配色
## v0.15.16
- 修改模型添加顺序, 每次向顶层添加
- 添加模型后自动选中最近添加的模型S
- 点击预览画面或者选中项发生变化时转移焦点至列表
- 增加移除全部菜单项
- 增加单例模式和命令行文件参数
- 增加文件关联设置
## v0.15.15
- 增加报错信息
- 导入后自动选中最后一项
## v0.15.14
- 将预览画面的首选项移动至上一次状态参数中
- 增加预览画面像素的自动保存和恢复
- 增加日志启动时的版本号输出
## v0.15.13
- 增加程序布局自动存储和还原
- 增加部分预览画面首选项
## v0.15.12
- 增加单个模型和单个轨道的时间因子
- 增加单个轨道的 Alpha 混合参数
- 调整轨道清除命令至右键菜单
- 设置默认标签页为模型
- 完善导入时的报错信息
## v0.15.11
- 修复自定义导出中参数构造错误
- 增加 mov 格式及参数说明
## v0.15.10
- 增加插槽可见性参数, 允许任何情况下对插槽启用和禁用对插槽的渲染
## v0.15.9
- 添加 V34 和 V35 版本支持
## v0.15.8
- 修复渲染纹理过程中可能的 null 错误
## v0.15.7
- 合并社区 CLI 功能项目
## v0.15.6
- 修复导出单个的时长错误
- 修改默认导出背景色为不透明黑色
## v0.15.5
- 修复自定义导出时的画面错误
- 设置 mp4 像素格式为 yuv420p 避免 windows 默认播放器无法打开
- 增加预览画面和导出时的速度参数设置
- 修复一些提示文本错误
- 导出时自动将分辨率向下调整为 2 的倍数, 避免 yuv420p 格式出错
## v0.15.4
- 修复导出时可能的卡死问题
- 增加 webp 格式无损压缩参数
## v0.15.3
- 增加 skel.bytes 后缀识别
## v0.15.2
- 修复首选项文件读取为空时的提示信息
- 工作区参数增加浏览路径
## v0.15.1
- 新版本正式发布
## v0.15.0
### 项目分支变更
自 v0.15.0 开始, 该项目将全面更换至 WPF 框架, Winforms 版本将不再进行功能更新, 只进行 bug 修复.
整个项目将具有下列分支:
- `dev/wf`: Winforms 版本开发分支, 继承 v0.15.0 之前的内容.
- `dev/wpf`: WPF 版本开发分支, v0.15.0 之后的内容.
- `release/wf`: `dev/wf` 的发布分支, 用于保留旧版发布功能.
- `main`: 最新的稳定发布分支, 也就是现在的 WPF 版本发布分支.
所有的本地开发和 pr 操作均在 `dev` 子分支下进行, 确认无误后再合并到对应的发布分支进行发布.
### 项目结构变更
粗略的将一些功能模块划分为独立的库项目:
- `SpineViewer`: 项目主体, UI 和程序逻辑
- `Spine`: 对不同版本 Spine 运行时的封装库, 提供所有必需操作的统一接口
- `SFMLRenderer`: 一个 WPF 控件, 支持渲染 SFML 内容
- `SpineRuntimes/*`: 官方不同版本的运行时库, 部分版本在官方基础上有修改和扩展
- `NLog.Windows.Wpf`: NLog 在 WPF 上的扩展库 (尚未完工)
每个项目的具体内容见各自的 README 文档.
### 功能变更
目前 v0.15.0 仅为 pre-release, 功能尚未完全迁移, 有以下功能变化和预期计划:
- 完善了全屏查看功能. 快捷键 F11 可快速切换全屏/窗口模式, 并且支持全屏模式下, 鼠标移动至边缘唤出操作面板.
- 增加了浏览面板. 支持打开文件夹进行浏览, 可以对指定文件夹下所有模型生成预览图进行查看.
- 支持复制指定模型的参数, 并且可以一键应用到多个模型上, 无法应用的项会忽略.
- 导出功能进行了精简. 分为 4 种类型的导出, 且减少了参数项, 仅保留常用参数.
- 导出方式变化. 导出方式变为直接对选中项然后右键菜单进行导出, 不再受 "显示" 和 "仅渲染选中" 参数影响.
- 版本转换功能将暂时不在新版本中提供, 旧版本中已有的功能仍然可用.
- 未来将增加动态桌面功能.
## v0.12.13
- 导出文件名增加额外的随机字符串
## v0.12.12
- 修复 2.1 版本遗漏的 SkinnedMeshAttachment 附件渲染
## v0.12.11
- 修复可能的闪退错误
## v0.12.10
- 增加纹理全局加载选项
## v0.12.9
- 修复由于未调用 UpdateCache 导致的约束 bug
## v0.12.8
- 增加英语界面文本
- 增加 4.2 版本格式转换
- 修改格式转换中一些问题和编码范式
## v0.12.7
- 修复一些问题
## v0.12.6
- 增加全屏预览
- 增加桌面投影 (实验性功能)
- 增加预览画面背景色设置
- 增加分辨率和颜色预设列表
- 皮肤面板显示 default
## v0.12.5
- 增加插槽属性面板
- 修改皮肤属性面板设置方式为True/False
## v0.12.4
- 增加导出自动分辨率参数
- 增加导出边缘和填充参数
- 增加导出内容溢出参数
- 支持3.7及以下版本多皮肤功能
- 增加3.8版本的骨骼文件二进制和文本格式互转
- 增加格式转换输出文件夹参数
- 修改打开对话框的默认文件后缀筛选为所有类型
## v0.12.3
- 增加按住 ctrl 缩放选中模型
- 增加对骨骼/网格/剪裁的调试渲染
- 换回以前的上下参数面板布局
- 修改窗口缩放模式为 Font -> Dpi
- 修复部分问题
## v0.12.2
- 模型参数分标签显示
- 皮肤/动画列表使用右键菜单进行增删
- 标题栏显示版本号
- 增加 webp 和 avif 动图格式
- 增加导出参数缓存
- 动图默认帧率修改为 24 帧
- 增加保留最后一帧参数
## v0.12.1
- 优化使用体验, 提供初始皮肤/动画空位
- 修复预览画面分辨率调整时父容器尺寸获取错误
## v0.12.0
- 支持皮肤列表 (仅 3.8.x 及以上支持)
- 支持多轨道动画
- 动画和皮肤列表多选时改为取并集
- 修复导出时没有正确处理预乘像素的问题
## v0.11.5
- 导出格式全面支持
- 修复预览图不显示的问题
- 优化列表卡顿问题
- 模型列表增加数量显示
## v0.11.4
- 增加 MP4 导出格式
- 增加导出背景颜色参数
- 增加日志输出 FFMpeg 参数字符串
- 增加导出时任务栏图标执行动效
- 修复预览面板移动模型时物理效果不同步的问题
- 优化部分使用体验
## v0.11.3
- 增加模型隐藏设置属性
- 加宽面板分割条 (4 -> 8 像素)
- 优化属性面板分组显示
- 增加调试纹理
## v0.11.2
- 增加皮肤切换
- 优化模型缩放实现
- 修复部分情况纹理加载异常
## v0.11.1
- 增加 GIF 导出格式
- 增加逐个导出时可选自动时长
- 优化使用体验
## v0.11.0
- 完成导出系统, 支持完整的单帧和帧序列导出功能
- 预览画面增加快进功能
## v0.10.9
- 预览图导出增加名称后缀参数
## v0.10.8
- 完善预览图导出
- 优化骨骼文件选择
## v0.10.7
- 增加仅导出选中
- 增加模型调试属性
## v0.10.6
- 增加文件夹检测
- 增加从剪贴板添加(可复制本地文件/文件夹直接打开)
- 修复预览图导致的批量添加可能卡死
## v0.10.5
- 修复一些问题
## v0.10.4
- 修复一些问题
## v0.10.3
- 增加自动版本检测
- 增加文件拖放打开
## v0.10.2
- 增加列表右键菜单快捷键
- 增加预览缩略图复制
- 增加列表视图切换
## v0.10.1
- 增加列表预览图
- 增加列表预览图导出
## v0.10.0
- 增加了画面和列表的选择联动,并删除了预览画面显示包围盒选项
- 增加了骨骼文件格式转换功能,目前仅支持部分版本的不完整功能
- 优化了部分使用体验

41
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,41 @@
# CONTRIBUTING
## 仓库分支
仓库目前包含 4 个分支:
- `main`: 默认分支, 也是项目最新版的发布用分支
- `dev/wpf`: WPF 版本开发分支
- `release/wf`: Winforms 旧版本发布分支 (已弃用, 仅进行 bug 修复)
- `dev/wf`: Winforms 旧版本开发分支 (已弃用, 仅进行 bug 修复)
仓库的每个发布分支都有对应的开发分支 `dev/*`, **在进行贡献和推送时请在开发分支上进行**, 待开发分支上审核完毕进行必要的确认 (例如版本号的更新) 后, 再从开发分支向对应的发布分支发起 pr, 合并后将会通过 Actions 进行自动生成和发布.
## 仓库结构
仓库目前包含两个可执行文件项目, 分别是:
- `SpineViewer.csproj`
- `SpineViewerCLI.csproj`
前者为仓库主要项目, 提供一个预览操作 Spine 模型文件的 UI 界面, 后者基于社区贡献进行开发, 提供一些便捷的 CLI 功能, 从而可以对模型文件进行一些批量操作.
除此之外其余项目均为一些基础功能库, 为以上两个项目提供必要的功能支持. 原则上 UI 项目和 CLI 项目二者独立互不引用, 仅引用相同的基础功能库, 以保证整个仓库的层次结构清晰便于维护.
## 如何贡献
对于一些小改动, 例如:
- 某些文件内的 bug 修复 (例如一些逻辑上的错误)
- 已有功能的扩展性增强 (例如在已有代码逻辑结构上扩充某些功能字段)
- 其他可能的对**已有功能**的修复改进
可以直接 fork 修改后向开发分支发起 pr, 经 review 无问题后可直接合并.
对于较大的改动, 例如:
- 新增某些代码文件 (例如需要添加一些全新的类)
- 添加一些全新的逻辑或者功能代码 (例如在自行车上加装发动机)
- 其他可能影响项目代码逻辑结构的改动
这些改动请先提 Issue, 进行必要性讨论, 以及确认新功能的引入方式, 请不要直接将这些可能的破坏性改动发起 pr.

View File

@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>x64</Platforms>
<PlatformTarget>x64</PlatformTarget>
<TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.16.0</Version>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="5.4.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,53 @@
using NLog;
using NLog.Conditions;
using NLog.Config;
using NLog.Layouts;
using System.Windows;
namespace NLog.Windows.Wpf
{
[NLogConfigurationItem]
public class RichTextBoxRowColoringRule
{
public static RichTextBoxRowColoringRule Default { get; private set; }
[RequiredParameter]
public ConditionExpression Condition { get; set; }
public Layout FontColor { get; set; }
public Layout BackgroundColor { get; set; }
public FontStyle FontStyle { get; set; }
public FontWeight FontWeight { get; set; }
static RichTextBoxRowColoringRule()
{
RichTextBoxRowColoringRule.Default = new RichTextBoxRowColoringRule();
}
public RichTextBoxRowColoringRule() : this(null, "Empty", "Empty", FontStyles.Normal, FontWeights.Normal) { }
public RichTextBoxRowColoringRule(string condition, string fontColor, string backColor)
{
this.Condition = (ConditionExpression)condition;
this.FontColor = Layout.FromString(fontColor);
this.BackgroundColor = Layout.FromString(backColor);
this.FontStyle = FontStyles.Normal;
this.FontWeight = FontWeights.Normal;
}
public RichTextBoxRowColoringRule(string condition, string fontColor, string backColor, FontStyle fontStyle, FontWeight fontWeight)
{
this.Condition = (ConditionExpression)condition;
this.FontColor = Layout.FromString(fontColor);
this.BackgroundColor = Layout.FromString(backColor);
this.FontStyle = fontStyle;
this.FontWeight = fontWeight;
}
public bool CheckCondition(LogEventInfo logEvent)
{
return true.Equals(this.Condition.Evaluate(logEvent));
}
}
}

View File

@@ -0,0 +1,281 @@
using NLog;
using NLog.Common;
using NLog.Config;
using NLog.Targets;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace NLog.Windows.Wpf
{
[Target("RichTextBox")]
public sealed class RichTextBoxTarget : TargetWithLayout
{
public static ReadOnlyCollection<RichTextBoxRowColoringRule> DefaultRowColoringRules { get; } = CreateDefaultColoringRules();
private static ReadOnlyCollection<RichTextBoxRowColoringRule> CreateDefaultColoringRules()
{
return new List<RichTextBoxRowColoringRule>()
{
new RichTextBoxRowColoringRule("level == LogLevel.Fatal", "White", "Red", FontStyles.Normal, FontWeights.Bold),
new RichTextBoxRowColoringRule("level == LogLevel.Error", "Red", "Empty", FontStyles.Italic, FontWeights.Bold),
new RichTextBoxRowColoringRule("level == LogLevel.Warn", "Orange", "Empty"),
new RichTextBoxRowColoringRule("level == LogLevel.Info", "Black", "Empty"),
new RichTextBoxRowColoringRule("level == LogLevel.Debug", "Gray", "Empty"),
new RichTextBoxRowColoringRule("level == LogLevel.Trace", "DarkGray", "Empty", FontStyles.Italic, FontWeights.Normal),
}.AsReadOnly();
}
public RichTextBoxTarget() { }
public string ControlName { get; set; }
public string WindowName { get; set; }
public bool UseDefaultRowColoringRules { get; set; }
public bool AutoScroll { get; set; }
public int MaxLines { get; set; }
[ArrayParameter(typeof(RichTextBoxRowColoringRule), "row-coloring")]
public IList<RichTextBoxRowColoringRule> RowColoringRules { get; } = new List<RichTextBoxRowColoringRule>();
[ArrayParameter(typeof(RichTextBoxWordColoringRule), "word-coloring")]
public IList<RichTextBoxWordColoringRule> WordColoringRules { get; } = new List<RichTextBoxWordColoringRule>();
[NLogConfigurationIgnoreProperty]
public Window TargetWindow { get; set; }
[NLogConfigurationIgnoreProperty]
public RichTextBox TargetRichTextBox { get; set; }
protected override void InitializeTarget()
{
base.InitializeTarget();
if (TargetRichTextBox != null)
return;
if (WindowName == null)
{
HandleError("WindowName should be specified for {0}.{1}", GetType().Name, Name);
return;
}
if (string.IsNullOrEmpty(ControlName))
{
HandleError("Rich text box control name must be specified for {0}.{1}", GetType().Name, Name);
return;
}
var targetWindow = Application.Current.Windows.OfType<Window>().FirstOrDefault(w => w.Name == WindowName);
if (targetWindow == null)
{
InternalLogger.Info("{0}: WindowName '{1}' not found", this, WindowName);
return;
}
var targetControl = targetWindow.FindName(ControlName) as RichTextBox;
if (targetControl == null)
{
InternalLogger.Info("{0}: WIndowName '{1}' does not contain ControlName '{2}'", this, WindowName, ControlName);
return;
}
AttachToControl(targetWindow, targetControl);
}
private static void HandleError(string message, params object[] args)
{
if (LogManager.ThrowExceptions)
{
throw new NLogConfigurationException(string.Format(message, args));
}
InternalLogger.Error(message, args);
}
private void AttachToControl(Window window, RichTextBox textboxControl)
{
InternalLogger.Info("{0}: Attaching target to textbox {1}.{2}", this, window.Name, textboxControl.Name);
DetachFromControl();
TargetWindow = window;
TargetRichTextBox = textboxControl;
}
private void DetachFromControl()
{
TargetWindow = null;
TargetRichTextBox = null;
}
protected override void CloseTarget()
{
DetachFromControl();
}
protected override void Write(LogEventInfo logEvent)
{
RichTextBox textbox = TargetRichTextBox;
if (textbox == null || textbox.Dispatcher.HasShutdownStarted || textbox.Dispatcher.HasShutdownFinished)
{
//no last logged textbox
InternalLogger.Trace("{0}: Attached Textbox is {1}, skipping logging", this, textbox == null ? "null" : "disposed");
return;
}
string logMessage = RenderLogEvent(Layout, logEvent);
RichTextBoxRowColoringRule matchingRule = FindMatchingRule(logEvent);
_ = DoSendMessageToTextbox(logMessage, matchingRule, logEvent);
}
private bool DoSendMessageToTextbox(string logMessage, RichTextBoxRowColoringRule rule, LogEventInfo logEvent)
{
RichTextBox textbox = TargetRichTextBox;
try
{
if (textbox != null && !textbox.Dispatcher.HasShutdownStarted && !textbox.Dispatcher.HasShutdownFinished)
{
if (!textbox.Dispatcher.CheckAccess())
{
textbox.Dispatcher.BeginInvoke(() => SendTheMessageToRichTextBox(textbox, logMessage, rule, logEvent));
}
else
{
SendTheMessageToRichTextBox(textbox, logMessage, rule, logEvent);
}
return true;
}
}
catch (Exception ex)
{
InternalLogger.Warn(ex, "{0}: Failed to append RichTextBox", this);
if (LogManager.ThrowExceptions)
{
throw;
}
}
return false;
}
private RichTextBoxRowColoringRule FindMatchingRule(LogEventInfo logEvent)
{
//custom rules first
if (RowColoringRules.Count > 0)
{
foreach (RichTextBoxRowColoringRule coloringRule in RowColoringRules)
{
if (coloringRule.CheckCondition(logEvent))
{
return coloringRule;
}
}
}
if (UseDefaultRowColoringRules && DefaultRowColoringRules != null)
{
foreach (RichTextBoxRowColoringRule coloringRule in DefaultRowColoringRules)
{
if (coloringRule.CheckCondition(logEvent))
{
return coloringRule;
}
}
}
return RichTextBoxRowColoringRule.Default;
}
private void SendTheMessageToRichTextBox(RichTextBox textBox, string logMessage, RichTextBoxRowColoringRule rule, LogEventInfo logEvent)
{
if (textBox == null) return;
var document = textBox.Document;
// 插入文本(带换行)
var tr = new TextRange(document.ContentEnd, document.ContentEnd)
{
Text = logMessage + Environment.NewLine
};
// 设置行级样式
var fgColor = rule.FontColor?.Render(logEvent);
var bgColor = rule.BackgroundColor?.Render(logEvent);
tr.ApplyPropertyValue(TextElement.ForegroundProperty,
string.IsNullOrEmpty(fgColor) || fgColor == "Empty"
? textBox.Foreground
: new SolidColorBrush((Color)ColorConverter.ConvertFromString(fgColor)));
tr.ApplyPropertyValue(TextElement.BackgroundProperty,
string.IsNullOrEmpty(bgColor) || bgColor == "Empty"
? Brushes.Transparent
: new SolidColorBrush((Color)ColorConverter.ConvertFromString(bgColor)));
tr.ApplyPropertyValue(TextElement.FontStyleProperty, rule.FontStyle);
tr.ApplyPropertyValue(TextElement.FontWeightProperty, rule.FontWeight);
// Word coloring在刚插入的范围内做匹配
if (WordColoringRules.Count > 0)
{
foreach (var wordRule in WordColoringRules)
{
var pattern = wordRule.Regex?.Render(logEvent) ?? string.Empty;
var text = wordRule.Text?.Render(logEvent) ?? string.Empty;
var wholeWords = wordRule.WholeWords.RenderValue(logEvent);
var ignoreCase = wordRule.IgnoreCase.RenderValue(logEvent);
var regex = wordRule.ResolveRegEx(pattern, text, wholeWords, ignoreCase);
var matches = regex.Matches(tr.Text);
foreach (Match match in matches)
{
// 匹配到的部分范围
var start = tr.Start.GetPositionAtOffset(match.Index, LogicalDirection.Forward);
var endPos = tr.Start.GetPositionAtOffset(match.Index + match.Length, LogicalDirection.Backward);
if (start == null || endPos == null) continue;
var wordRange = new TextRange(start, endPos);
var wordFg = wordRule.FontColor?.Render(logEvent);
var wordBg = wordRule.BackgroundColor?.Render(logEvent);
wordRange.ApplyPropertyValue(TextElement.ForegroundProperty,
string.IsNullOrEmpty(wordFg) || wordFg == "Empty"
? tr.GetPropertyValue(TextElement.ForegroundProperty)
: new SolidColorBrush((Color)ColorConverter.ConvertFromString(wordFg)));
wordRange.ApplyPropertyValue(TextElement.BackgroundProperty,
string.IsNullOrEmpty(wordBg) || wordBg == "Empty"
? tr.GetPropertyValue(TextElement.BackgroundProperty)
: new SolidColorBrush((Color)ColorConverter.ConvertFromString(wordBg)));
wordRange.ApplyPropertyValue(TextElement.FontStyleProperty, wordRule.FontStyle);
wordRange.ApplyPropertyValue(TextElement.FontWeightProperty, wordRule.FontWeight);
}
}
}
// 限制最大行数
if (MaxLines > 0)
{
while (document.Blocks.Count > MaxLines)
{
document.Blocks.Remove(document.Blocks.FirstBlock);
}
}
// 自动滚动到最后
if (AutoScroll)
{
textBox.ScrollToEnd();
}
}
}
}

View File

@@ -0,0 +1,59 @@
using NLog.Config;
using NLog.Layouts;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Windows;
namespace NLog.Windows.Wpf
{
[NLogConfigurationItem]
public class RichTextBoxWordColoringRule
{
public Layout Regex { get; set; }
public Layout Text { get; set; }
public Layout<bool> WholeWords { get; set; }
public Layout<bool> IgnoreCase { get; set; }
public Layout FontColor { get; set; }
public Layout BackgroundColor { get; set; }
public FontStyle FontStyle { get; set; }
public FontWeight FontWeight { get; set; }
internal Regex ResolveRegEx(string pattern, string text, bool wholeWords, bool ignoreCase)
{
if (string.IsNullOrEmpty(pattern) && text != null)
{
pattern = System.Text.RegularExpressions.Regex.Escape(text);
if (wholeWords)
pattern = "\b" + pattern + "\b";
}
RegexOptions options = RegexOptions.None;
if (ignoreCase)
options |= RegexOptions.IgnoreCase;
return new Regex(pattern, options); // RegEx-Cache
}
public RichTextBoxWordColoringRule() : this(null, "Empty", "Empty", FontStyles.Normal, FontWeights.Normal) { }
public RichTextBoxWordColoringRule(string text, string fontColor, string backgroundColor)
{
this.Text = text;
this.FontColor = Layout.FromString(fontColor);
this.BackgroundColor = Layout.FromString(backgroundColor);
this.FontStyle = FontStyles.Normal;
this.FontWeight = FontWeights.Normal;
}
public RichTextBoxWordColoringRule(string text, string textColor, string backgroundColor, FontStyle fontStyle, FontWeight fontWeight)
{
this.Text = text;
this.FontColor = Layout.FromString(textColor);
this.BackgroundColor = Layout.FromString(backgroundColor);
this.FontStyle = fontStyle;
this.FontWeight = fontWeight;
}
}
}

View File

@@ -1,70 +1,167 @@
# SpineViewer
# [SpineViewer](https://github.com/ww-rm/SpineViewer)
[![Build and Release](https://github.com/ww-rm/SpineViewer/actions/workflows/dotnet-desktop.yml/badge.svg)](https://github.com/ww-rm/SpineViewer/actions/workflows/dotnet-desktop.yml)
[![Build and Release](https://github.com/ww-rm/SpineViewer/actions/workflows/dotnet-release.yml/badge.svg)](https://github.com/ww-rm/SpineViewer/actions/workflows/dotnet-release.yml)
[![GitHub Release](https://img.shields.io/github/v/release/ww-rm/SpineViewer?logo=github\&logoColor=959da5\&label=Release\&labelColor=3f4850)](https://github.com/ww-rm/SpineViewer/releases)
[![Downloads](https://img.shields.io/github/downloads/ww-rm/SpineViewer/total?logo=github\&logoColor=959da5\&label=Downloads\&labelColor=3f4850)](https://github.com/ww-rm/SpineViewer/releases)
![Languages](https://img.shields.io/badge/Languages-中文%20%7C%20English%20%7C%20日本語-blue)
[中文](README.md) | [English](README.en.md)
A simple and user-friendly Spine file viewer and exporter.
Spine file viewer & exporter, also a dynamic wallpaper program supporting Spine animations.
![previewer](img/previewer.jpg)
![previewer](https://github.com/user-attachments/assets/697ae86f-ddf0-445d-951c-cf04f5206e40)
[https://github.com/user-attachments/assets/37b6b730-088a-4352-827a-c338127a16f0](https://github.com/user-attachments/assets/37b6b730-088a-4352-827a-c338127a16f0)
---
## Features
- Supports multiple Spine file versions (`2.1.x; 3.4.x - 4.2.-`)
- List-based multi-skeleton view with rendering order management
- Supports multi-track animations
- Supports skin/slot/attachment settings
- Debug rendering support
- Frame rate / model / track time scale adjustment
- Track alpha blending control
- Export single frame / GIF / video
- Custom export via FFmpeg
- Supports non-PNG texture formats
- Desktop dynamic wallpaper with auto-start support
- ......
---
## Installation
Download the zip package from the [Releases](https://github.com/ww-rm/SpineViewer/releases) page.
Download the compressed package from the [Releases](https://github.com/ww-rm/SpineViewer/releases) page.
The application requires the [.NET Desktop Runtime 8.0.x](https://dotnet.microsoft.com/en-us/download/dotnet/8.0).
The program requires the [.NET Desktop Runtime 8.0.x](https://dotnet.microsoft.com/download/dotnet/8.0) to be installed.
Alternatively, you can download the zip package with the `SelfContained` suffix, which can run independently.
You can also download packages with the `SelfContained` suffix, which can run independently without additional installations.
## Features
- Supports viewing Spine files of different versions:
- [x] `v2.1.x`
- [x] `v3.6.x`
- [x] `v3.7.x`
- [x] `v3.8.x`
- [x] `v4.0.x`
- [x] `v4.1.x`
- [x] `v4.2.x`
- [ ] `v4.3.x`
- Supports animation preview for multi-skeleton files
- Allows independent parameter settings for each skeleton
- Supports exporting animation as PNG frame sequences
- Provides export settings such as zoom and rotation
- More features coming soon...
## Usage
### Importing Skeletons
Use the **File** menu to select **Open** or **Batch Open** to import skeleton files.
### Adjusting Skeletons
Select one or more items in the **Model List** to display adjustable parameters in the **Model Parameters** panel.
Right-clicking in the **Model List** allows you to add, delete, or adjust list items. You can also drag items with the left mouse button to rearrange them.
### Adjusting the View
Mouse operations supported in the **Preview** window:
- Left-click to drag the skeleton
- Right-click to drag the view
- Scroll wheel to zoom in/out
Additionally, you can adjust export and preview parameters through the **View Parameters** panel.
In the **Functions** menu, you can reset and synchronize the animation time for all skeletons.
### Exporting Animations
Select **Export** from the **File** menu to export all loaded skeleton animations as PNG frame sequences, based on the current preview settings.
You can view the full duration of each animation in the **Model Parameters** of each skeleton.
Exporting GIF/MP4 or other animated/video formats requires **ffmpeg** installed locally and added to the system PATH. Download [FFmpeg for Windows](https://ffmpeg.org/download.html#build-windows) or the latest full build [ffmpeg-release-full.7z](https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z).
---
*If you find this project helpful, please give it a :star: and share it with others! :)*
## Changing Display Language
Currently, the program supports the following interface languages:
- `ZH` (Chinese)
- `EN` (English)
- `JA` (Japanese)
Change the language via the menu: **File → Preferences… → Language**, then confirm.
---
## Usage
### Overview
The program uses a left-right layout: the left panel contains controls, the right panel displays the preview.
The left panel contains three sub-panels:
- **Models**: Lists imported and rendered models. Set model parameters, rendering order, and other model-related functions here.
- **Browser**: Preview files in a folder without actually importing them. Generate WebP previews or import selected models.
- **Canvas**: Set parameters for the right-side preview display.
Most buttons, labels, or input fields show help text on hover.
---
### Importing Skeletons
Drag-and-drop or paste skeleton files/folders directly into the **Models** panel.
Alternatively, use the right-click menu in the **Browser** panel to import selected items.
---
### Adjusting Content
The **Models** panel supports right-click menus, some hotkeys, and batch editing via multi-selection.
Mouse interactions in the preview panel:
- **Left click**: select and drag models. Hold `Ctrl` for multi-selection (synchronized with the model list).
- **Right click**: drag the entire canvas.
- **Mouse wheel**: zoom in/out. Hold `Ctrl` to scale selected models together, use `Shift` to switch zoom factor.
- **Render selected only**: preview only the selected models, selection can only be changed via the left panel.
Playback controls below the preview allow time adjustment, acting as a simple player.
---
### Exporting Content
Right-click on models in the list to access export options.
Key export parameters:
- **Output folder**: Optional. If not provided, outputs go to each models folder. Otherwise, all outputs go to the specified folder.
- **Single export**: Default exports each model separately. If enabled, all selected models are rendered together in one output.
- **Auto resolution**: Ignores preview canvas resolution; exported resolution matches the actual size of content. For animations or videos, ensures full display of the animation.
---
### Dynamic Wallpaper
The dynamic wallpaper projects the current preview content to the desktop in real time.
Enable or disable via program preferences or the tray icon menu. Save workspace files to preserve model and canvas settings.
Auto-start with Windows can also be enabled, along with loading a specific workspace on startup.
---
### Command-line Tool
The project includes a CLI tool `SpineViewerCLI` for simple operations on a single model (querying parameters, exporting, etc.). Windows and Linux binaries are provided in Releases.
```bash
$ SpineViewerCLI -h
Description:
Root Command
Usage:
SpineViewerCLI [command] [options]
Options:
-q, --quiet Suppress console logging (quiet mode).
-?, -h, --help Show help and usage information
--version Show version information
Commands:
query <skel> Query information of single model
preview <skel> Preview a model
export <skel> Export single model
```
---
### More
Detailed instructions and usage guides can be found in the [Wiki](https://github.com/ww-rm/SpineViewer/wiki).
Report issues or bugs via [GitHub Issues](https://github.com/ww-rm/SpineViewer/issues).
---
## Acknowledgements
- [spine-runtimes](https://github.com/EsotericSoftware/spine-runtimes)
- [SFML.Net](https://github.com/SFML/SFML.Net)
- [FFMpegCore](https://github.com/rosenbjerg/FFMpegCore)
- [HandyControl](https://github.com/HandyOrg/HandyControl)
- [NLog](https://github.com/NLog/NLog)
- [SkiaSharp](https://github.com/mono/SkiaSharp)
- [Spectre.Console](https://github.com/spectreconsole/spectre.console)
---
*If you like this project, please give it a :star: and share it with others! :\)*
[![Stargazers over time](https://starchart.cc/ww-rm/SpineViewer.svg?variant=adaptive)](https://starchart.cc/ww-rm/SpineViewer)

144
README.md
View File

@@ -1,14 +1,33 @@
# SpineViewer
# [SpineViewer](https://github.com/ww-rm/SpineViewer)
[![Build and Release](https://github.com/ww-rm/SpineViewer/actions/workflows/dotnet-desktop.yml/badge.svg)](https://github.com/ww-rm/SpineViewer/actions/workflows/dotnet-desktop.yml)
[![Build and Release](https://github.com/ww-rm/SpineViewer/actions/workflows/dotnet-release.yml/badge.svg)](https://github.com/ww-rm/SpineViewer/actions/workflows/dotnet-release.yml)
[![GitHub Release](https://img.shields.io/github/v/release/ww-rm/SpineViewer?logo=github&logoColor=959da5&label=Release&labelColor=3f4850)](https://github.com/ww-rm/SpineViewer/releases)
[![Downloads](https://img.shields.io/github/downloads/ww-rm/SpineViewer/total?logo=github&logoColor=959da5&label=Downloads&labelColor=3f4850)](https://github.com/ww-rm/SpineViewer/releases)
![Languages](https://img.shields.io/badge/Languages-中文%20%7C%20English%20%7C%20日本語-blue)
[中文](README.md) | [English](README.en.md)
一个简单好用的 Spine 文件查看&导出程序.
Spine 文件查看&导出程序, 同时也是支持 Spine 的动态壁纸程序.
![previewer](img/previewer.jpg)
![previewer](https://github.com/user-attachments/assets/697ae86f-ddf0-445d-951c-cf04f5206e40)
---
https://github.com/user-attachments/assets/37b6b730-088a-4352-827a-c338127a16f0
## 功能
- 支持多版本 spine 文件 (`2.1.x; 3.4.x - 4.2.x`)
- 支持列表式多骨骼查看和渲染层级管理
- 支持多轨道动画
- 支持皮肤/插槽/附件设置
- 支持调试渲染
- 支持画面/模型/轨道时间倍速设置
- 支持设置轨道 Alpha 混合参数
- 支持单帧/动图/视频文件导出
- 支持 FFmpeg 自定义导出
- 支持非 PNG 格式的纹理图片格式
- 支持开机自启常驻动态壁纸
- ......
## 安装
@@ -18,53 +37,108 @@
也可以下载带有 `SelfContained` 后缀的压缩包, 可以独立运行.
## 功能
导出 GIF/MP4 等动图/视频格式需要在本地安装 ffmpeg 命令行, 并且添加至环境变量, [点击前往 FFmpeg-Windows 下载页面](https://ffmpeg.org/download.html#build-windows), 也可以点这个下载最新版本 [ffmpeg-release-full.7z](https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z).
- 支持不同版本 Spine 查看
- [x] `v2.1.x`
- [x] `v3.6.x`
- [x] `v3.7.x`
- [x] `v3.8.x`
- [x] `v4.0.x`
- [x] `v4.1.x`
- [x] `v4.2.x`
- [ ] `v4.3.x`
- 支持多骨骼文件动画预览
- 支持每个骨骼独立参数设置
- 支持动画PNG帧序列导出
- 支持缩放旋转等导出画面设置
- Coming soon...
## 修改显示语言
本项目目前支持以下界面显示语言:
- `ZH` (中文)
- `EN` (English)
- `JA` (日本語)
可以通过窗口菜单的 "文件" -> "首选项..." -> "语言", 选择你需要的语言并确认修改.
## 使用方法
### 基本介绍
程序大致是左右布局, 左侧是功能面板, 右侧是画面.
左侧有三个子面板, 分别是:
- **模型**. 该面板记录导入并进行渲染的模型列表, 可以在这个面板设置与模型渲染相关的参数和渲染顺序, 以及一些与模型有关的功能.
- **浏览**. 该面板用于预览指定文件夹的内容, 并没有真正导入文件到程序. 在该面板可以为模型生成 webp 格式的预览图, 或者导入选中的模型.
- **画面**. 该面板用于设置右侧预览画面的参数.
绝大部分按钮或者标签或者输入框都可以通过鼠标指针悬停来获取帮助文本.
### 骨骼导入
**文件**菜单可以选择**打开**或者**批量打开**进行骨骼文件导入.
可以直接拖放/粘贴需要导入的骨骼文件/目录到模型面板.
### 骨骼调整
或者在浏览面板内右键菜单导入选中项.
在**模型列表**中选择一项或多项, 将会在**模型参数**面板显示可供调节的参数.
### 内容调整
**模型列表**右键菜单可以对列表项进行增删调整, 也可以使用鼠标左键拖动调整顺序.
模型面板支持右键菜单以及部分快捷键, 并且可以多选进行模型参数的批量调整.
### 画面调整
预览画面除了使用面板进行参数设置外, 支持部分鼠标动作:
**预览画面**支持的鼠标操作:
- 左键可以选择和拖拽模型, 按下 `Ctrl` 键可以实现多选, 与左侧列表选择是联动的.
- 右键对整体画面进行拖动.
- 滚轮进行画面缩放, 按住 `Ctrl` 可以对选中的模型进行批量缩放, `Shift` 可以切换缩放倍数.
- 仅渲染选中模式, 在该模式下, 预览画面仅包含被选中的模型, 并且只能通过左侧列表改变选中状态.
- 左键可以对骨骼进行拖动
- 右键对画面进行拖动
- 滚轮进行画面缩放
预览画面下方按钮支持对画面时间进行调整, 可以当作一个简易的播放器.
除此之外, 也可以通过**画面参数**面板调节导出和预览时的画面参数.
### 内容导出
**功能**菜单中, 可以重置同步所有骨骼动画时间.
模型列表里, 右键单击选中的模型, 弹出菜单里可以对选中项执行导出操作.
### 动画导出
导出有以下几个关键参数:
**文件**菜单中选择**导出**可以将目前加载的所有骨骼动画按照预览时的画面进行PNG帧序列导出.
- 输出文件夹. 这个参数某些时候可选, 当不提供时, 则将输出产物输出到每个模型各自的模型文件夹, 否则输出产物全部输出到提供的输出文件夹.
- 导出单个. 默认是每个模型独立导出, 即对模型列表进行批量操作, 如果选择仅导出单个, 那么被导出的所有模型将在同一个画面上被渲染, 输出产物只有一份.
- 自动分辨率. 该模式会忽略预览画面的分辨率和视区参数, 导出产物的分辨率与被导出内容的实际大小一致, 如果是动图或者视频则会与完整显示动画的必需大小一致.
可以在每个骨骼的**模型参数**中查看动画完整时长.
### 动态壁纸
动态壁纸通过桌面投影实现, 可以将当前预览画面上的内容实时投影至桌面.
在程序首选项或者托盘图标右键菜单中可以进行桌面投影的启用与否, 模型和画面参数调整完成后, 可以将当前参数保存为工作区文件, 方便之后恢复该配置.
如果希望开机自启常驻壁纸, 也可以在首选项中启用开机自启, 并且设置启动后需要加载的工作区文件.
### 命令行工具
项目附带一个纯命令行工具 `SpineViewerCLI`, 目前支持对单个模型执行一些简单操作, 例如参数值查询以及导出等, 并且 Release 界面提供 Windows 和 Linux 多平台二进制文件.
```bash
$ SpineViewerCLI -h
Description:
Root Command
Usage:
SpineViewerCLI [command] [options]
Options:
-q, --quiet Suppress console logging (quiet mode).
-?, -h, --help Show help and usage information
--version Show version information
Commands:
query <skel> Query information of single model
preview <skel> Preview a model
export <skel> Export single model
```
### 更多
更为详细的使用方法和说明见 [Wiki](https://github.com/ww-rm/SpineViewer/wiki), 有使用上的问题或者 BUG 可以提个 [Issue](https://github.com/ww-rm/SpineViewer/issues).
## Acknowledgements
- [spine-runtimes](https://github.com/EsotericSoftware/spine-runtimes)
- [SFML.Net](https://github.com/SFML/SFML.Net)
- [FFMpegCore](https://github.com/rosenbjerg/FFMpegCore)
- [HandyControl](https://github.com/HandyOrg/HandyControl)
- [NLog](https://github.com/NLog/NLog)
- [SkiaSharp](https://github.com/mono/SkiaSharp)
- [Spectre.Console](https://github.com/spectreconsole/spectre.console)
---
*如果你觉得这个项目不错请给个 :star:, 并分享给更多人知道! :)*
*如果你觉得这个项目不错请给个 :star:, 并分享给更多人知道! :\)*
[![Stargazers over time](https://starchart.cc/ww-rm/SpineViewer.svg?variant=adaptive)](https://starchart.cc/ww-rm/SpineViewer)

View File

@@ -0,0 +1,138 @@
using SFML.Graphics;
using SFML.System;
using SFML.Window;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SFMLRenderer
{
/// <summary>
/// 定义了 SFML 渲染器的基本功能和事件, 基本上是对 <see cref="RenderWindow"/> 的抽象
/// <para>实现示例可以见 <see cref="SFMLRenderPanel"/></para>
/// </summary>
public interface ISFMLRenderer
{
/// <summary>
/// 发生在资源首次创建完成后, 该事件发生之后渲染器才是可用的, 操作才会生效
/// </summary>
public event EventHandler? RendererCreated;
/// <summary>
/// 发生在资源即将不可用之前, 该事件发生之后对渲染器的操作将被忽略
/// </summary>
public event EventHandler? RendererDisposing;
public event EventHandler<MouseMoveEventArgs>? CanvasMouseMove;
public event EventHandler<MouseButtonEventArgs>? CanvasMouseButtonPressed;
public event EventHandler<MouseButtonEventArgs>? CanvasMouseButtonReleased;
public event EventHandler<MouseWheelScrollEventArgs>? CanvasMouseWheelScrolled;
/// <summary>
/// 分辨率, 影响画面的相对比例
/// </summary>
public Vector2u Resolution { get; set; }
/// <summary>
/// 快捷设置视区中心点
/// </summary>
public Vector2f Center { get; set; }
/// <summary>
/// 快捷设置视区缩放
/// </summary>
public float Zoom { get; set; }
/// <summary>
/// 快捷设置视区旋转
/// </summary>
public float Rotation { get; set; }
/// <summary>
/// 快捷设置视区水平翻转
/// </summary>
public bool FlipX { get; set; }
/// <summary>
/// 快捷设置视区垂直翻转
/// </summary>
public bool FlipY { get; set; }
/// <summary>
/// 最大帧率, 影响 Draw 的最大调用频率, <see cref="RenderWindow.SetFramerateLimit(uint)"/>
/// </summary>
public uint MaxFps { get; set; }
/// <summary>
/// 垂直同步, <see cref="RenderWindow.SetVerticalSyncEnabled(bool)"/>
/// </summary>
public bool VerticalSync { get; set; }
/// <summary>
/// <inheritdoc cref="RenderWindow.SetActive(bool)"/>
/// </summary>
public bool SetActive(bool active);
/// <summary>
/// <inheritdoc cref="RenderWindow.GetView"/>
/// </summary>
public View GetView();
/// <summary>
/// <inheritdoc cref="RenderWindow.SetView(View)"/>
/// </summary>
public void SetView(View view);
/// <summary>
/// <inheritdoc cref="RenderWindow.MapPixelToCoords(Vector2i)"/>
/// </summary>
public Vector2f MapPixelToCoords(Vector2i point);
/// <summary>
/// <inheritdoc cref="RenderWindow.MapCoordsToPixel(Vector2f)"/>
/// </summary>
public Vector2i MapCoordsToPixel(Vector2f point);
/// <summary>
/// <inheritdoc cref="RenderWindow.Clear()"/>
/// </summary>
public void Clear();
/// <summary>
/// <inheritdoc cref="RenderWindow.Clear(Color)"/>
/// </summary>
public void Clear(Color color);
/// <summary>
/// <inheritdoc cref="RenderWindow.Draw(Drawable)"/>
/// </summary>
public void Draw(Drawable drawable);
/// <summary>
/// <inheritdoc cref="RenderWindow.Draw(Drawable, RenderStates)"/>
/// </summary>
public void Draw(Drawable drawable, RenderStates states);
/// <summary>
/// <inheritdoc cref="RenderWindow.Draw(Vertex[], PrimitiveType)"/>
/// </summary>
public void Draw(Vertex[] vertices, PrimitiveType type);
/// <summary>
/// <inheritdoc cref="RenderWindow.Draw(Vertex[], PrimitiveType, RenderStates)"/>
/// </summary>
public void Draw(Vertex[] vertices, PrimitiveType type, RenderStates states);
/// <summary>
/// <inheritdoc cref="RenderWindow.Draw(Vertex[], uint, uint, PrimitiveType)"/>
/// </summary>
public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type);
/// <summary>
/// <inheritdoc cref="RenderWindow.Display"/>
/// </summary>
public void Display();
}
}

21
SFMLRenderer/README.md Normal file
View File

@@ -0,0 +1,21 @@
# SFMLRenderer
这个库封装了一个用于 WPF 的 SFML 渲染控件.
```mermaid
classDiagram
namespace SFMLRenderer {
class ISFMLRenderer {
<<Interface>>
}
class SFMLHwndHost
class SFMLRenderPanel
}
ISFMLRenderer <|.. SFMLRenderPanel
SFMLHwndHost <.. SFMLRenderPanel
```

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
namespace SFMLRenderer
{
/// <summary>
/// 原生窗口控件, 不应直接使用该类, 而是使用 <see cref="SFMLRenderPanel"/> 或者二次封装
/// </summary>
public class SFMLHwndHost : HwndHost
{
private HwndSource? _hwndSource;
private SFML.Graphics.RenderWindow? _renderWindow;
/// <summary>
/// 内部的 SFML 窗口对象
/// </summary>
public SFML.Graphics.RenderWindow? RenderWindow => _renderWindow;
/// <summary>
/// 窗口建立事件
/// </summary>
public event EventHandler? RenderWindowBuilded;
/// <summary>
/// 窗口销毁事件
/// </summary>
public event EventHandler? RenderWindowDestroying;
protected override HandleRef BuildWindowCore(HandleRef hwndParent)
{
var ps = new HwndSourceParameters(GetType().Name, (int)Width, (int)Height)
{
ParentWindow = hwndParent.Handle,
WindowStyle = 0x40000000 | 0x10000000, // WS_CHILD | WS_VISIBLE
HwndSourceHook = HwndMessageHook
};
_hwndSource = new HwndSource(ps);
_renderWindow = new(_hwndSource.Handle);
_renderWindow.SetActive(false);
RenderWindowBuilded?.Invoke(this, EventArgs.Empty);
return new HandleRef(this, _hwndSource.Handle);
}
protected override void DestroyWindowCore(HandleRef hwnd)
{
RenderWindowDestroying?.Invoke(this, EventArgs.Empty);
_renderWindow?.Close();
var rw = _renderWindow;
_renderWindow = null;
rw?.Dispose();
var hs = _hwndSource;
_hwndSource = null;
hs?.Dispose();
}
private IntPtr HwndMessageHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
_renderWindow?.DispatchEvents();
return IntPtr.Zero;
}
}
}

View File

@@ -0,0 +1,14 @@
<UserControl x:Class="SFMLRenderer.SFMLRenderPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SFMLRenderer"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<local:SFMLHwndHost x:Name="_hwndHost"
Width="100"
Height="100"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</UserControl>

View File

@@ -0,0 +1,253 @@
using SFML.Graphics;
using SFML.System;
using SFML.Window;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SFMLRenderer
{
/// <summary>
/// SFMLRenderPanel.xaml 的交互逻辑
/// </summary>
public partial class SFMLRenderPanel : System.Windows.Controls.UserControl, ISFMLRenderer
{
private RenderWindow? RenderWindow => _hwndHost.RenderWindow;
public SFMLRenderPanel()
{
InitializeComponent();
}
public event EventHandler? RendererCreated
{
add => _hwndHost.RenderWindowBuilded += value;
remove => _hwndHost.RenderWindowBuilded -= value;
}
public event EventHandler? RendererDisposing
{
add => _hwndHost.RenderWindowDestroying += value;
remove => _hwndHost.RenderWindowDestroying -= value;
}
public event EventHandler<MouseMoveEventArgs>? CanvasMouseMove
{
add { if (RenderWindow is RenderWindow w) w.MouseMoved += value; }
remove { if (RenderWindow is RenderWindow w) w.MouseMoved -= value; }
}
public event EventHandler<MouseButtonEventArgs>? CanvasMouseButtonPressed
{
add { if (RenderWindow is RenderWindow w) w.MouseButtonPressed += value; }
remove { if (RenderWindow is RenderWindow w) w.MouseButtonPressed -= value; }
}
public event EventHandler<MouseButtonEventArgs>? CanvasMouseButtonReleased
{
add { if (RenderWindow is RenderWindow w) w.MouseButtonReleased += value; }
remove { if (RenderWindow is RenderWindow w) w.MouseButtonReleased -= value; }
}
public event EventHandler<MouseWheelScrollEventArgs>? CanvasMouseWheelScrolled
{
add { if (RenderWindow is RenderWindow w) w.MouseWheelScrolled += value; }
remove { if (RenderWindow is RenderWindow w) w.MouseWheelScrolled -= value; }
}
public Vector2u Resolution
{
get => _resolution;
set
{
if (RenderWindow is null) return;
if (value == _resolution) return;
if (value.X <= 0 || value.Y <= 0) return;
var zoom = Zoom;
float parentW = (float)ActualWidth;
float parentH = (float)ActualHeight;
float renderW = value.X;
float renderH = value.Y;
float scale = Math.Min(parentW / renderW, parentH / renderH); // 两方向取较小值, 保证 parent 覆盖 render
renderW *= scale;
renderH *= scale;
_hwndHost.Width = renderW;
_hwndHost.Height = renderH;
_resolution = value;
// 设置完 resolution 后还原缩放比例
Zoom = zoom;
}
}
private Vector2u _resolution = new(100, 100);
public Vector2f Center
{
get
{
if (RenderWindow is null) return default;
using var view = RenderWindow.GetView();
return view.Center;
}
set
{
if (RenderWindow is null) return;
using var view = RenderWindow.GetView();
view.Center = value;
RenderWindow.SetView(view);
}
}
public float Zoom
{
get
{
if (RenderWindow is null) return 1;
using var view = RenderWindow.GetView();
return Math.Abs(_resolution.X / view.Size.X); // XXX: 仅使用宽度进行缩放计算
}
set
{
value = Math.Abs(value);
if (RenderWindow is null || value <= 0) return;
using var view = RenderWindow.GetView();
var signX = Math.Sign(view.Size.X);
var signY = Math.Sign(view.Size.Y);
view.Size = new(_resolution.X / value * signX, _resolution.Y / value * signY);
RenderWindow.SetView(view);
}
}
public float Rotation
{
get
{
if (RenderWindow is null) return default;
using var view = RenderWindow.GetView();
return view.Rotation;
}
set
{
if (RenderWindow is null) return;
using var view = RenderWindow.GetView();
view.Rotation = value;
RenderWindow.SetView(view);
}
}
public bool FlipX
{
get
{
if (RenderWindow is null) return false;
using var view = RenderWindow.GetView();
return view.Size.X < 0;
}
set
{
if (RenderWindow is null) return;
using var view = RenderWindow.GetView();
var size = view.Size;
if (size.X > 0 && value || size.X < 0 && !value)
size.X *= -1;
view.Size = size;
RenderWindow.SetView(view);
}
}
public bool FlipY
{
get
{
if (RenderWindow is null) return false;
using var view = RenderWindow.GetView();
return view.Size.Y < 0;
}
set
{
if (RenderWindow is null) return;
using var view = RenderWindow.GetView();
var size = view.Size;
if (size.Y > 0 && value || size.Y < 0 && !value)
size.Y *= -1;
view.Size = size;
RenderWindow.SetView(view);
}
}
public uint MaxFps
{
get => _maxFps;
set
{
if (RenderWindow is null) return;
RenderWindow.SetFramerateLimit(value);
_maxFps = value;
}
}
private uint _maxFps = 0;
public bool VerticalSync
{
get => _verticalSync;
set
{
if (RenderWindow is null) return;
RenderWindow.SetVerticalSyncEnabled(value);
_verticalSync = value;
}
}
private bool _verticalSync = false;
public void Clear() => RenderWindow?.Clear();
public void Clear(Color color) => RenderWindow?.Clear(color);
public void Display() => RenderWindow?.Display();
public void Draw(Drawable drawable) => RenderWindow?.Draw(drawable);
public void Draw(Drawable drawable, RenderStates states) => RenderWindow?.Draw(drawable, states);
public void Draw(Vertex[] vertices, PrimitiveType type) => RenderWindow?.Draw(vertices, type);
public void Draw(Vertex[] vertices, PrimitiveType type, RenderStates states) => RenderWindow?.Draw(vertices, type, states);
public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type) => RenderWindow?.Draw(vertices, start, count, type);
public View GetView() => RenderWindow?.GetView() ?? new();
public Vector2i MapCoordsToPixel(Vector2f point) => RenderWindow?.MapCoordsToPixel(point) ?? default;
public Vector2f MapPixelToCoords(Vector2i point) => RenderWindow?.MapPixelToCoords(point) ?? default;
public bool SetActive(bool active) => RenderWindow?.SetActive(active) ?? false;
public void SetView(View view) => RenderWindow?.SetView(view);
protected override void OnRenderSizeChanged(System.Windows.SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
if (RenderWindow is null) return;
float parentW = (float)sizeInfo.NewSize.Width;
float parentH = (float)sizeInfo.NewSize.Height;
float renderW = _resolution.X;
float renderH = _resolution.Y;
float scale = Math.Min(parentW / renderW, parentH / renderH); // 两方向取较小值, 保证 parent 覆盖 render
renderW *= scale;
renderH *= scale;
_hwndHost.Width = renderW;
_hwndHost.Height = renderH;
}
}
}

View File

@@ -0,0 +1,180 @@
using SFML.Graphics;
using SFML.System;
using SFML.Window;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
using Win32Natives;
namespace SFMLRenderer
{
public class SFMLRenderWindow : RenderWindow, ISFMLRenderer
{
private readonly DispatcherTimer _timer = new() { Interval = TimeSpan.FromMilliseconds(10) };
public SFMLRenderWindow(VideoMode mode, string title, Styles style) : base(mode, title, style)
{
SetActive(false);
_timer.Tick += (s, e) => DispatchEvents();
_timer.Start();
SetVisible(false);
var handle = SystemHandle;
var exStyle = User32.GetWindowLong(handle, User32.GWL_EXSTYLE) | User32.WS_EX_LAYERED;
User32.SetWindowLong(handle, User32.GWL_EXSTYLE, exStyle);
User32.SetLayeredWindowAttributes(handle, 0, byte.MaxValue, User32.LWA_ALPHA);
RendererCreated?.Invoke(this, EventArgs.Empty);
}
public event EventHandler? RendererCreated;
public event EventHandler? RendererDisposing
{
add => throw new NotImplementedException();
remove => throw new NotImplementedException();
}
public event EventHandler<MouseMoveEventArgs>? CanvasMouseMove
{
add { MouseMoved += value; }
remove { MouseMoved -= value; }
}
public event EventHandler<MouseButtonEventArgs>? CanvasMouseButtonPressed
{
add { MouseButtonPressed += value; }
remove { MouseButtonPressed -= value; }
}
public event EventHandler<MouseButtonEventArgs>? CanvasMouseButtonReleased
{
add { MouseButtonReleased += value; }
remove { MouseButtonReleased -= value; }
}
public event EventHandler<MouseWheelScrollEventArgs>? CanvasMouseWheelScrolled
{
add { MouseWheelScrolled += value; }
remove { MouseWheelScrolled -= value; }
}
public Vector2u Resolution
{
get => Size;
set => Size = value;
}
public Vector2f Center
{
get
{
using var view = GetView();
return view.Center;
}
set
{
using var view = GetView();
view.Center = value;
SetView(view);
}
}
public float Zoom
{
get
{
using var view = GetView();
return Math.Abs(Size.X / view.Size.X); // XXX: 仅使用宽度进行缩放计算
}
set
{
value = Math.Abs(value);
if (value <= 0) return;
using var view = GetView();
var signX = Math.Sign(view.Size.X);
var signY = Math.Sign(view.Size.Y);
var resolution = Size;
view.Size = new(resolution.X / value * signX, resolution.Y / value * signY);
SetView(view);
}
}
public float Rotation
{
get
{
using var view = GetView();
return view.Rotation;
}
set
{
using var view = GetView();
view.Rotation = value;
SetView(view);
}
}
public bool FlipX
{
get
{
using var view = GetView();
return view.Size.X < 0;
}
set
{
using var view = GetView();
var size = view.Size;
if (size.X > 0 && value || size.X < 0 && !value)
size.X *= -1;
view.Size = size;
SetView(view);
}
}
public bool FlipY
{
get
{
using var view = GetView();
return view.Size.Y < 0;
}
set
{
using var view = GetView();
var size = view.Size;
if (size.Y > 0 && value || size.Y < 0 && !value)
size.Y *= -1;
view.Size = size;
SetView(view);
}
}
public uint MaxFps
{
get => _maxFps;
set
{
SetFramerateLimit(value);
_maxFps = value;
}
}
private uint _maxFps = 0;
public bool VerticalSync
{
get => _verticalSync;
set
{
SetVerticalSyncEnabled(value);
_verticalSync = value;
}
}
private bool _verticalSync = false;
}
}

View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>x64</Platforms>
<PlatformTarget>x64</PlatformTarget>
<TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.16.6</Version>
<UseWPF>true</UseWPF>
</PropertyGroup>
<PropertyGroup>
<NoWarn>$(NoWarn);NETSDK1206</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SFML.Net" Version="2.6.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Win32Natives\Win32Natives.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,207 @@
using NLog;
using SFML.Graphics;
using SFML.System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Exporters
{
/// <summary>
/// 导出类基类, 提供基本的帧渲染功能
/// </summary>
public abstract class BaseExporter : IDisposable
{
/// <summary>
/// 日志器
/// </summary>
protected static readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary>
/// 用于渲染的画布
/// </summary>
protected RenderTexture _renderTexture;
/// <summary>
/// 初始化导出器
/// </summary>
/// <param name="width">画布宽像素值</param>
/// <param name="height">画布高像素值</param>
public BaseExporter(uint width , uint height)
{
// XXX: 强制变成 2 的倍数, 防止像是 yuv420p 这种像素格式报错
width = width >> 1 << 1;
height = height >> 1 << 1;
if (width <= 0 || height <= 0)
throw new ArgumentException($"Invalid resolution: {width}, {height}");
_renderTexture = new(width, height);
_renderTexture.SetActive(false);
}
/// <summary>
/// 初始化导出器
/// </summary>
public BaseExporter(Vector2u resolution)
{
// XXX: 强制变成 2 的倍数, 防止像是 yuv420p 这种像素格式报错
resolution.X = resolution.X >> 1 << 1;
resolution.Y = resolution.Y >> 1 << 1;
if (resolution.X <= 0 || resolution.Y <= 0)
throw new ArgumentException($"Invalid resolution: {resolution}");
_renderTexture = new(resolution.X, resolution.Y);
_renderTexture.SetActive(false);
}
/// <summary>
/// 可选的进度回调函数
/// <list type="number">
/// <item><c>total</c>: 任务总量</item>
/// <item><c>done</c>: 已完成量</item>
/// <item><c>progressText</c>: 需要设置的进度提示文本</item>
/// </list>
/// </summary>
public Action<float, float, string>? ProgressReporter { get => _progressReporter; set => _progressReporter = value; }
protected Action<float, float, string>? _progressReporter;
/// <summary>
/// 背景颜色
/// </summary>
public Color BackgroundColor
{
get => _backgroundColor;
set
{
_backgroundColor = value;
var bcPma = value;
var a = bcPma.A / 255f;
bcPma.R = (byte)(bcPma.R * a);
bcPma.G = (byte)(bcPma.G * a);
bcPma.B = (byte)(bcPma.B * a);
_backgroundColorPma = bcPma;
}
}
protected Color _backgroundColor = Color.Black;
/// <summary>
/// 预乘后的背景颜色
/// </summary>
protected Color _backgroundColorPma = Color.Black;
/// <summary>
/// 画面分辨率
/// <inheritdoc cref="RenderTexture.Size"/>
/// </summary>
public Vector2u Resolution
{
get => _renderTexture.Size;
set
{
// XXX: 强制变成 2 的倍数, 防止像是 yuv420p 这种像素格式报错
value.X = value.X >> 1 << 1;
value.Y = value.Y >> 1 << 1;
if (value.X <= 0 || value.Y <= 0)
{
_logger.Warn("Omit invalid exporter resolution: {0}", value);
return;
}
if (_renderTexture.Size != value)
{
using var old = _renderTexture;
using var view = old.GetView();
var renderTexture = new RenderTexture(value.X, value.Y);
renderTexture.SetActive(false);
renderTexture.SetView(view);
_renderTexture = renderTexture;
}
}
}
/// <summary>
/// <inheritdoc cref="View.Viewport"/>
/// </summary>
public FloatRect Viewport
{
get { using var view = _renderTexture.GetView(); return view.Viewport; }
set { using var view = _renderTexture.GetView(); view.Viewport = value; _renderTexture.SetView(view); }
}
/// <summary>
/// <inheritdoc cref="View.Center"/>
/// </summary>
public Vector2f Center
{
get { using var view = _renderTexture.GetView(); return view.Center; }
set { using var view = _renderTexture.GetView(); view.Center = value; _renderTexture.SetView(view); }
}
/// <summary>
/// <inheritdoc cref="View.Size"/>
/// </summary>
public Vector2f Size
{
get { using var view = _renderTexture.GetView(); return view.Size; }
set { using var view = _renderTexture.GetView(); view.Size = value; _renderTexture.SetView(view); }
}
/// <summary>
/// <inheritdoc cref="View.Rotation"/>
/// </summary>
public float Rotation
{
get { using var view = _renderTexture.GetView(); return view.Rotation; }
set { using var view = _renderTexture.GetView(); view.Rotation = value; _renderTexture.SetView(view); }
}
/// <summary>
/// 获取的一帧, 结果是预乘的
/// </summary>
protected virtual SFMLImageVideoFrame GetFrame(SpineObject[] spines)
{
_renderTexture.SetActive(true);
_renderTexture.Clear(_backgroundColorPma);
foreach (var sp in spines.Reverse()) _renderTexture.Draw(sp);
_renderTexture.Display();
_renderTexture.SetActive(false);
return new(_renderTexture.Texture.CopyToImage());
}
/// <summary>
/// 导出给定的模型, 从前往后对应从上往下的渲染顺序
/// </summary>
/// <param name="output">输出路径, 一般而言都是文件路径, 少数情况指定的是文件夹</param>
/// <param name="spines">要导出的模型, 从前往后对应从上往下的渲染顺序</param>
public abstract void Export(string output, params SpineObject[] spines);
#region IDisposable
private bool _disposed = false;
protected virtual void Dispose(bool disposing)
{
if (_disposed) return;
if (disposing)
{
_renderTexture.Dispose();
}
_disposed = true;
}
~BaseExporter()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
if (_disposed)
{
GC.SuppressFinalize(this);
}
}
#endregion
}
}

View File

@@ -0,0 +1,100 @@
using FFMpegCore;
using FFMpegCore.Pipes;
using SFML.Graphics;
using SFML.System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Exporters
{
/// <summary>
/// 自定义参数的 FFmpeg 导出类
/// </summary>
public class CustomFFmpegExporter : VideoExporter
{
public CustomFFmpegExporter(uint width = 100, uint height = 100) : base(width, height) { }
public CustomFFmpegExporter(Vector2u resolution) : base(resolution) { }
/// <summary>
/// <c>-f</c>
/// </summary>
public string? Format { get => _format; set => _format = value; }
private string? _format;
/// <summary>
/// <c>-c:v</c>
/// </summary>
public string? Codec { get => _codec; set => _codec = value; }
private string? _codec;
/// <summary>
/// <c>-pix_fmt</c>
/// </summary>
public string? PixelFormat { get => _pixelFormat; set => _pixelFormat = value; }
private string? _pixelFormat;
/// <summary>
/// <c>-b:v</c>
/// </summary>
public string? Bitrate { get => _bitrate; set => _bitrate = value; }
private string? _bitrate;
/// <summary>
/// <c>-vf</c>
/// </summary>
public string? Filter { get => _filter; set => _filter = value; }
private string? _filter;
/// <summary>
/// 其他自定义参数
/// </summary>
public string? CustomArgs { get => _customArgs; set => _customArgs = value; }
private string? _customArgs;
private void SetOutputOptions(FFMpegArgumentOptions options)
{
if (!string.IsNullOrEmpty(_format)) options.ForceFormat(_format);
if (!string.IsNullOrEmpty(_codec)) options.WithVideoCodec(_codec);
if (!string.IsNullOrEmpty(_pixelFormat)) options.ForcePixelFormat(_pixelFormat);
if (!string.IsNullOrEmpty(_bitrate)) options.WithCustomArgument($"-b:v {_bitrate}");
if (!string.IsNullOrEmpty(_filter)) options.WithCustomArgument($"-vf \"unpremultiply=inplace=1, {_filter}\"");
else options.WithCustomArgument("-vf unpremultiply=inplace=1");
if (!string.IsNullOrEmpty(_customArgs)) options.WithCustomArgument($"{_customArgs}");
}
/// <summary>
/// 获取的一帧, 结果是预乘的
/// </summary>
protected override SFMLImageVideoFrame GetFrame(SpineObject[] spines)
{
// BUG: 也许和 SFML 多线程或者 FFmpeg 调用有关, 当渲染线程也在运行的时候此处并行渲染会导致和 SFML 有关的内容都卡死
// 不知道为什么用 FFmpeg 必须临时创建 RenderTexture, 否则无法正常渲染, 会导致画面帧丢失
using var tex = new RenderTexture(_renderTexture.Size.X, _renderTexture.Size.Y);
using var view = _renderTexture.GetView();
tex.SetView(view);
tex.Clear(_backgroundColorPma);
foreach (var sp in spines.Reverse()) tex.Draw(sp);
tex.Display();
return new(tex.Texture.CopyToImage());
}
public override void Export(string output, CancellationToken ct, params SpineObject[] spines)
{
var videoFramesSource = new RawVideoPipeSource(GetFrames(spines, output, ct)) { FrameRate = _fps };
try
{
var ffmpegArgs = FFMpegArguments.FromPipeInput(videoFramesSource).OutputToFile(output, true, SetOutputOptions);
_logger.Info("FFmpeg arguments: {0}", ffmpegArgs.Arguments);
ffmpegArgs.ProcessSynchronously();
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_logger.Error("Failed to export {0} {1}, {2}", _format, output, ex.Message);
}
}
}
}

View File

@@ -0,0 +1,59 @@
using SFML.Graphics;
using SFML.System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Exporters
{
public static class Extension
{
/// <summary>
/// 获取适合指定画布参数下能够覆盖包围盒的画布视区包围盒
/// </summary>
public static FloatRect GetCanvasBounds(this FloatRect self, Vector2u resolution) => GetCanvasBounds(self, resolution, 0, 0);
/// <summary>
/// 获取适合指定画布参数下能够覆盖包围盒的画布视区包围盒
/// </summary>
public static FloatRect GetCanvasBounds(this FloatRect self, Vector2u resolution, uint margin) => GetCanvasBounds(self, resolution, margin, 0);
/// <summary>
/// 获取适合指定画布参数下能够覆盖包围盒的画布视区包围盒
/// </summary>
public static FloatRect GetCanvasBounds(this FloatRect self, Vector2u resolution, uint margin, uint padding)
{
float sizeW = self.Width;
float sizeH = self.Height;
float innerW = resolution.X - padding * 2;
float innerH = resolution.Y - padding * 2;
var scale = Math.Max(Math.Abs(sizeW / innerW), Math.Abs(sizeH / innerH)); // 取两方向上较大的缩放比, 以此让画布可以覆盖内容
var scaleW = scale * Math.Sign(sizeW);
var scaleH = scale * Math.Sign(sizeH);
innerW *= scaleW;
innerH *= scaleH;
var x = self.Left - (innerW - sizeW) / 2 - (margin + padding) * scaleW;
var y = self.Top - (innerH - sizeH) / 2 - (margin + padding) * scaleH;
var w = (resolution.X + margin * 2) * scaleW;
var h = (resolution.Y + margin * 2) * scaleH;
return new(x, y, w, h);
}
/// <summary>
/// 获取视区的包围盒
/// </summary>
public static FloatRect GetBounds(this View self)
{
return new(
self.Center.X - self.Size.X / 2,
self.Center.Y - self.Size.Y / 2,
self.Size.X,
self.Size.Y
);
}
}
}

View File

@@ -0,0 +1,213 @@
using FFMpegCore;
using FFMpegCore.Enums;
using FFMpegCore.Pipes;
using NLog;
using SFML.Graphics;
using SFML.System;
using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Exporters
{
/// <summary>
/// 基于 FFmpeg 命令行的导出类, 可以导出动图及视频格式
/// </summary>
public class FFmpegVideoExporter : VideoExporter
{
public FFmpegVideoExporter(uint width = 100, uint height = 100) : base(width, height) { }
public FFmpegVideoExporter(Vector2u resolution) : base(resolution) { }
/// <summary>
/// FFmpeg 导出格式
/// </summary>
public enum VideoFormat
{
Gif,
Webp,
Apng,
Mp4,
Webm,
Mkv,
Mov,
}
/// <summary>
/// Apng 格式预测器算法
/// </summary>
public enum ApngPredMethod
{
None = 0,
Sub = 1,
Up = 2,
Avg = 3,
Paeth = 4,
Mixed = 5,
}
/// <summary>
/// Mov prores_ks 编码器 profile 参数
/// </summary>
public enum MovProfile
{
Auto = -1,
Proxy = 0,
Light = 1,
Standard = 2,
High = 3,
Yuv4444 = 4,
Yuv4444Extreme = 5,
}
/// <summary>
/// 视频格式
/// </summary>
public VideoFormat Format { get => _format; set => _format = value; }
private VideoFormat _format = VideoFormat.Mp4;
/// <summary>
/// [Gif/Webp/Apng] 动图是否循环
/// </summary>
public bool Loop { get => _loop; set => _loop = value; }
private bool _loop = true;
/// <summary>
/// [Webp] 质量
/// </summary>
public int Quality { get => _quality; set => _quality = Math.Clamp(value, 0, 100); }
private int _quality = 75;
/// <summary>
/// [Webp] 无损压缩
/// </summary>
public bool Lossless { get => _lossless; set => _lossless = value; }
private bool _lossless = false;
/// <summary>
/// [Apng] 预测器算法
/// </summary>
public ApngPredMethod PredMethod { get => _predMethod; set => _predMethod = value; }
private ApngPredMethod _predMethod = ApngPredMethod.Mixed;
/// <summary>
/// [Mp4/Webm/Mkv] CRF
/// </summary>
public int Crf { get => _crf; set => _crf = Math.Clamp(value, 0, 63); }
private int _crf = 23;
/// <summary>
/// [Mov] prores_ks 编码器的配置等级, 越高质量越好, 只有 <see cref="MovProfile.Yuv4444"> 及以上才有透明通道
/// </summary>
public MovProfile Profile { get => _profile; set => _profile = value; }
private MovProfile _profile = MovProfile.Yuv4444Extreme;
/// <summary>
/// 获取的一帧, 结果是预乘的
/// </summary>
protected override SFMLImageVideoFrame GetFrame(SpineObject[] spines)
{
// BUG: 也许和 SFML 多线程或者 FFmpeg 调用有关, 当渲染线程也在运行的时候此处并行渲染会导致和 SFML 有关的内容都卡死
// 不知道为什么用 FFmpeg 必须临时创建 RenderTexture, 否则无法正常渲染, 会导致画面帧丢失
using var tex = new RenderTexture(_renderTexture.Size.X, _renderTexture.Size.Y);
using var view = _renderTexture.GetView();
tex.SetView(view);
tex.Clear(_backgroundColorPma);
foreach (var sp in spines.Reverse()) tex.Draw(sp);
tex.Display();
return new(tex.Texture.CopyToImage());
}
public override void Export(string output, CancellationToken ct, params SpineObject[] spines)
{
var videoFramesSource = new RawVideoPipeSource(GetFrames(spines, output, ct)) { FrameRate = _fps };
Action<FFMpegArgumentOptions> setOutputOptions = _format switch
{
VideoFormat.Gif => SetGifOptions,
VideoFormat.Webp => SetWebpOptions,
VideoFormat.Apng => SetApngOptions,
VideoFormat.Mp4 => SetMp4Options,
VideoFormat.Webm => SetWebmOptions,
VideoFormat.Mkv => SetMkvOptions,
VideoFormat.Mov => SetMovOptions,
_ => throw new NotImplementedException(),
};
try
{
var ffmpegArgs = FFMpegArguments.FromPipeInput(videoFramesSource).OutputToFile(output, true, setOutputOptions);
_logger.Info("FFmpeg arguments: {0}", ffmpegArgs.Arguments);
ffmpegArgs.ProcessSynchronously();
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_logger.Error("Failed to export {0} {1}, {2}", _format, output, ex.Message);
}
}
private void SetGifOptions(FFMpegArgumentOptions options)
{
// Gif 固定使用 256 调色板和 128 透明度阈值
var v = "split [s0][s1]";
var s0 = "[s0] palettegen=max_colors=256 [p]";
var s1 = "[s1][p] paletteuse=alpha_threshold=128";
var customArgs = $"-vf \"unpremultiply=inplace=1, {v};{s0};{s1}\" -loop {(_loop ? 0 : -1)}";
options.ForceFormat("gif")
.WithCustomArgument(customArgs);
}
private void SetWebpOptions(FFMpegArgumentOptions options)
{
var customArgs = $"-vf unpremultiply=inplace=1 -quality {_quality} -loop {(_loop ? 0 : 1)} -lossless {(_lossless ? 1 : 0)}";
options.ForceFormat("webp").WithVideoCodec("libwebp_anim").ForcePixelFormat("yuva420p")
.WithCustomArgument(customArgs);
}
private void SetApngOptions(FFMpegArgumentOptions options)
{
var customArgs = $"-vf unpremultiply=inplace=1 -plays {(_loop ? 0 : 1)} -pred {(int)_predMethod}";
options.ForceFormat("apng").WithVideoCodec("apng").ForcePixelFormat("rgba")
.WithCustomArgument(customArgs);
}
private void SetMp4Options(FFMpegArgumentOptions options)
{
// XXX: windows 默认播放器在播放 MP4 格式时对于 libx264 编码器只支持 yuv420p 的像素格式
// 但是如果是 libx265 则没有该限制
var customArgs = "-vf unpremultiply=inplace=1";
options.ForceFormat("mp4").WithVideoCodec("libx264").ForcePixelFormat("yuv420p")
.WithFastStart()
.WithConstantRateFactor(_crf)
.WithCustomArgument(customArgs);
}
private void SetWebmOptions(FFMpegArgumentOptions options)
{
var customArgs = "-vf unpremultiply=inplace=1";
options.ForceFormat("webm").WithVideoCodec("libvpx-vp9").ForcePixelFormat("yuva420p")
.WithConstantRateFactor(_crf)
.WithCustomArgument(customArgs);
}
private void SetMkvOptions(FFMpegArgumentOptions options)
{
var customArgs = "-vf unpremultiply=inplace=1";
options.ForceFormat("matroska").WithVideoCodec("libx265").ForcePixelFormat("yuv444p")
.WithConstantRateFactor(_crf)
.WithCustomArgument(customArgs);
}
private void SetMovOptions(FFMpegArgumentOptions options)
{
var customArgs = "-vf unpremultiply=inplace=1";
options.ForceFormat("mov").WithVideoCodec("prores_ks").ForcePixelFormat("yuva444p10le")
.WithFastStart()
.WithCustomArgument($"-profile {(int)_profile}")
.WithCustomArgument(customArgs);
}
}
}

View File

@@ -0,0 +1,63 @@
using SFML.System;
using SkiaSharp;
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Exporters
{
/// <summary>
/// 单帧画面导出类
/// </summary>
public class FrameExporter : BaseExporter
{
public FrameExporter(uint width = 100, uint height = 100) : base(width, height) { }
public FrameExporter(Vector2u resolution) : base(resolution) { }
public SKEncodedImageFormat Format
{
get => _format;
set {
switch (value)
{
case SKEncodedImageFormat.Jpeg:
case SKEncodedImageFormat.Png:
case SKEncodedImageFormat.Webp:
_format = value;
break;
default:
_logger.Warn("Omit unsupported exporter format: {0}", value);
break;
}
}
}
protected SKEncodedImageFormat _format = SKEncodedImageFormat.Png;
public int Quality { get => _quality; set => _quality = Math.Clamp(value, 0, 100); }
protected int _quality = 100;
public override void Export(string output, params SpineObject[] spines)
{
using var frame = GetFrame(spines);
var info = new SKImageInfo(frame.Width, frame.Height, SKColorType.Rgba8888, SKAlphaType.Premul);
using var skImage = SKImage.FromPixelCopy(info, frame.Image.Pixels);
using var data = skImage.Encode(_format, _quality);
using var stream = File.OpenWrite(output);
data.SaveTo(stream);
}
/// <summary>
/// 获取帧图像, 结果是预乘的
/// </summary>
public SKImage ExportMemoryImage(params SpineObject[] spines)
{
using var frame = GetFrame(spines);
var info = new SKImageInfo(frame.Width, frame.Height, SKColorType.Rgba8888, SKAlphaType.Premul);
return SKImage.FromPixelCopy(info, frame.Image.Pixels);
}
}
}

View File

@@ -0,0 +1,61 @@
using NLog;
using SFML.System;
using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Exporters
{
/// <summary>
/// 帧序列导出器, 导出 png 帧序列
/// </summary>
public class FrameSequenceExporter : VideoExporter
{
public FrameSequenceExporter(uint width = 100, uint height = 100) : base(width, height) { }
public FrameSequenceExporter(Vector2u resolution) : base(resolution) { }
public override void Export(string output, CancellationToken ct, params SpineObject[] spines)
{
Directory.CreateDirectory(output);
int frameCount = GetFrameCount();
int frameIdx = 0;
_progressReporter?.Invoke(frameCount, 0, $"[0/{frameCount}] {output}"); // 导出帧序列单独在此处调用进度报告
foreach (var frame in GetFrames(spines))
{
if (ct.IsCancellationRequested)
{
_logger.Info("Export cancelled");
frame.Dispose();
break;
}
var savePath = Path.Combine(output, $"frame_{_fps}_{frameIdx:d6}.png");
var info = new SKImageInfo(frame.Width, frame.Height, SKColorType.Rgba8888, SKAlphaType.Premul);
_progressReporter?.Invoke(frameCount, frameIdx + 1, $"[{frameIdx + 1}/{frameCount}] {savePath}");
try
{
using var skImage = SKImage.FromPixelCopy(info, frame.Image.Pixels);
using var data = skImage.Encode(SKEncodedImageFormat.Png, 100);
using var stream = File.OpenWrite(savePath);
data.SaveTo(stream);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_logger.Error("Failed to save frame {0}, {1}", savePath, ex.Message);
}
finally
{
frame.Dispose();
}
frameIdx++;
}
}
}
}

View File

@@ -0,0 +1,52 @@
using FFMpegCore.Pipes;
using SFML.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Spine.Exporters
{
/// <summary>
/// <see cref="SFML.Graphics.Image"/> 帧对象包装类, 将接管给定对象生命周期
/// </summary>
public class SFMLImageVideoFrame(Image image) : IVideoFrame, IDisposable
{
private readonly Image _image = image;
/// <summary>
/// 接管的 <see cref="SFML.Graphics.Image"/> 内部对象
/// </summary>
public Image Image => _image;
public int Width => (int)_image.Size.X;
public int Height => (int)_image.Size.Y;
public string Format => "rgba";
public void Serialize(Stream pipe) => pipe.Write(_image.Pixels);
public async Task SerializeAsync(Stream pipe, CancellationToken token) => await pipe.WriteAsync(_image.Pixels, token);
#region IDisposable
private bool _disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
_image.Dispose();
}
_disposed = true;
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}

View File

@@ -0,0 +1,157 @@
using NLog;
using SFML.System;
using SkiaSharp;
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Exporters
{
/// <summary>
/// 多帧画面导出基类, 可以获取连续的帧序列
/// </summary>
public abstract class VideoExporter : BaseExporter
{
public VideoExporter(uint width, uint height) : base(width, height) { }
public VideoExporter(Vector2u resolution) : base(resolution) { }
/// <summary>
/// 导出时长
/// </summary>
public float Duration
{
get => _duration;
set
{
if (value < 0)
{
_logger.Warn("Omit invalid duration: {0}", value);
return;
}
_duration = value;
}
}
protected float _duration = 0;
/// <summary>
/// 帧率
/// </summary>
public float Fps
{
get => _fps;
set
{
if (value <= 0)
{
_logger.Warn("Omit invalid fps: {0}", value);
return;
}
_fps = value;
}
}
protected float _fps = 24;
public float Speed
{
get => _speed;
set
{
if (_speed <= 0)
{
_logger.Warn("Omit invalid speed: {0}", value);
return;
}
_speed = value;
}
}
protected float _speed = 1f;
/// <summary>
/// 是否保留最后一帧
/// </summary>
public bool KeepLast { get => _keepLast; set => _keepLast = value; }
protected bool _keepLast = true;
/// <summary>
/// 获取总帧数
/// </summary>
public int GetFrameCount()
{
var delta = 1f / _fps;
var total = (int)(_duration * _fps); // 完整帧的数量
var deltaFinal = _duration - delta * total; // 最后一帧时长
var final = _keepLast && deltaFinal > 1e-3 ? 1 : 0;
var frameCount = 1 + total + final; // 所有帧的数量 = 起始帧 + 完整帧 + 最后一帧
return frameCount;
}
/// <summary>
/// 生成帧序列, 用于导出帧序列
/// </summary>
protected IEnumerable<SFMLImageVideoFrame> GetFrames(SpineObject[] spines)
{
float delta = 1f / _fps;
int total = (int)(_duration * _fps); // 完整帧的数量
bool hasFinal = _keepLast && (_duration - delta * total) > 1e-3;
// 导出首帧
var firstFrame = GetFrame(spines);
yield return firstFrame;
// 导出完整帧
for (int i = 0; i < total; i++)
{
foreach (var spine in spines) spine.Update(delta * _speed);
yield return GetFrame(spines);
}
// 导出最后一帧
if (hasFinal)
{
// XXX: 此处还是按照完整的一帧时长进行更新, 也许可以只更新准确的最后一帧时长
foreach (var spine in spines) spine.Update(delta * _speed);
yield return GetFrame(spines);
}
}
/// <summary>
/// 生成帧序列, 支持中途取消和进度输出, 用于动图视频等单个文件输出
/// </summary>
protected IEnumerable<SFMLImageVideoFrame> GetFrames(SpineObject[] spines, string output, CancellationToken ct)
{
int frameCount = GetFrameCount();
int frameIdx = 0;
_progressReporter?.Invoke(frameCount, 0, $"[0/{frameCount}] {output}");
foreach (var frame in GetFrames(spines))
{
if (ct.IsCancellationRequested)
{
_logger.Info("Export cancelled");
frame.Dispose();
break;
}
_progressReporter?.Invoke(frameCount, frameIdx + 1, $"[{frameIdx + 1}/{frameCount}] {output}");
yield return frame;
frameIdx++;
}
}
public sealed override void Export(string output, params SpineObject[] spines) => Export(output, default, spines);
/// <summary>
/// 导出给定的模型, 从前往后对应从上往下的渲染顺序
/// </summary>
/// <param name="output">输出路径, 一般而言都是文件路径, 少数情况指定的是文件夹</param>
/// <param name="ct">取消令牌</param>
/// <param name="spines">要导出的模型, 从前往后对应从上往下的渲染顺序</param>
public abstract void Export(string output, CancellationToken ct, params SpineObject[] spines);
}
}

View File

@@ -0,0 +1,474 @@
using NLog;
using SFML.Graphics;
using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations
{
/// <summary>
/// 实现不同版本的 TextureLoader
/// </summary>
public class TextureLoader :
SpineRuntime21.TextureLoader,
SpineRuntime34.TextureLoader,
SpineRuntime35.TextureLoader,
SpineRuntime36.TextureLoader,
SpineRuntime37.TextureLoader,
SpineRuntime38.TextureLoader,
SpineRuntime40.TextureLoader,
SpineRuntime41.TextureLoader,
SpineRuntime42.TextureLoader
{
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary>
/// 默认的全局纹理加载器
/// </summary>
public static TextureLoader DefaultLoader { get; } = new();
/// <summary>
/// 在读取纹理时强制进行通道预乘操作
/// </summary>
public bool ForcePremul { get; set; }
/// <summary>
/// 强制使用 Nearest
/// </summary>
public bool ForceNearest { get; set; }
/// <summary>
/// 强制启用 Mipmap
/// </summary>
public bool ForceMipmap { get; set; }
private Texture ReadTexture(string path)
{
if (!File.Exists(path))
{
_logger.Error($"Texture file not found, {path}");
throw new FileNotFoundException("Texture file not found", path);
}
using var codec = SKCodec.Create(path, out var result);
if (codec is null || result != SKCodecResult.Success)
{
_logger.Error($"Failed to create codec '{path}', {result}");
throw new InvalidOperationException($"Failed to create codec '{path}', {result}");
}
var width = codec.Info.Width;
var height = codec.Info.Height;
// 判断是否需要强制预乘
var alphaType = ForcePremul ? SKAlphaType.Premul : SKAlphaType.Unpremul;
var info = new SKImageInfo(width, height, SKColorType.Rgba8888, alphaType);
result = codec.GetPixels(info, out var pixels);
if (result != SKCodecResult.Success)
{
_logger.Error($"Failed to decode image '{path}', {result}");
throw new InvalidOperationException($"Failed to decode image '{path}', {result}");
}
Texture tex = new((uint)width, (uint)height);
tex.Update(pixels);
return tex;
}
public virtual void Load(SpineRuntime21.AtlasPage page, string path)
{
var texture = ReadTexture(path);
if (page.magFilter == SpineRuntime21.TextureFilter.Linear)
{
texture.Smooth = true;
}
if (page.uWrap == SpineRuntime21.TextureWrap.Repeat && page.vWrap == SpineRuntime21.TextureWrap.Repeat)
{
texture.Repeated = true;
}
switch (page.minFilter)
{
case SpineRuntime21.TextureFilter.Linear:
texture.Smooth = true;
break;
case SpineRuntime21.TextureFilter.MipMap:
case SpineRuntime21.TextureFilter.MipMapNearestNearest:
texture.GenerateMipmap();
break;
case SpineRuntime21.TextureFilter.MipMapLinearNearest:
case SpineRuntime21.TextureFilter.MipMapNearestLinear:
case SpineRuntime21.TextureFilter.MipMapLinearLinear:
texture.Smooth = true;
texture.GenerateMipmap();
break;
}
if (ForceNearest) texture.Smooth = false;
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)
{
var texture = ReadTexture(path);
if (page.magFilter == SpineRuntime34.TextureFilter.Linear)
{
texture.Smooth = true;
}
if (page.uWrap == SpineRuntime34.TextureWrap.Repeat && page.vWrap == SpineRuntime34.TextureWrap.Repeat)
{
texture.Repeated = true;
}
switch (page.minFilter)
{
case SpineRuntime34.TextureFilter.Linear:
texture.Smooth = true;
break;
case SpineRuntime34.TextureFilter.MipMap:
case SpineRuntime34.TextureFilter.MipMapNearestNearest:
texture.GenerateMipmap();
break;
case SpineRuntime34.TextureFilter.MipMapLinearNearest:
case SpineRuntime34.TextureFilter.MipMapNearestLinear:
case SpineRuntime34.TextureFilter.MipMapLinearLinear:
texture.Smooth = true;
texture.GenerateMipmap();
break;
}
if (ForceNearest) texture.Smooth = false;
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)
{
var texture = ReadTexture(path);
if (page.magFilter == SpineRuntime35.TextureFilter.Linear)
{
texture.Smooth = true;
}
if (page.uWrap == SpineRuntime35.TextureWrap.Repeat && page.vWrap == SpineRuntime35.TextureWrap.Repeat)
{
texture.Repeated = true;
}
switch (page.minFilter)
{
case SpineRuntime35.TextureFilter.Linear:
texture.Smooth = true;
break;
case SpineRuntime35.TextureFilter.MipMap:
case SpineRuntime35.TextureFilter.MipMapNearestNearest:
texture.GenerateMipmap();
break;
case SpineRuntime35.TextureFilter.MipMapLinearNearest:
case SpineRuntime35.TextureFilter.MipMapNearestLinear:
case SpineRuntime35.TextureFilter.MipMapLinearLinear:
texture.Smooth = true;
texture.GenerateMipmap();
break;
}
if (ForceNearest) texture.Smooth = false;
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)
{
var texture = ReadTexture(path);
if (page.magFilter == SpineRuntime36.TextureFilter.Linear)
{
texture.Smooth = true;
}
if (page.uWrap == SpineRuntime36.TextureWrap.Repeat && page.vWrap == SpineRuntime36.TextureWrap.Repeat)
{
texture.Repeated = true;
}
switch (page.minFilter)
{
case SpineRuntime36.TextureFilter.Linear:
texture.Smooth = true;
break;
case SpineRuntime36.TextureFilter.MipMap:
case SpineRuntime36.TextureFilter.MipMapNearestNearest:
texture.GenerateMipmap();
break;
case SpineRuntime36.TextureFilter.MipMapLinearNearest:
case SpineRuntime36.TextureFilter.MipMapNearestLinear:
case SpineRuntime36.TextureFilter.MipMapLinearLinear:
texture.Smooth = true;
texture.GenerateMipmap();
break;
}
if (ForceNearest) texture.Smooth = false;
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)
{
var texture = ReadTexture(path);
if (page.magFilter == SpineRuntime37.TextureFilter.Linear)
{
texture.Smooth = true;
}
if (page.uWrap == SpineRuntime37.TextureWrap.Repeat && page.vWrap == SpineRuntime37.TextureWrap.Repeat)
{
texture.Repeated = true;
}
switch (page.minFilter)
{
case SpineRuntime37.TextureFilter.Linear:
texture.Smooth = true;
break;
case SpineRuntime37.TextureFilter.MipMap:
case SpineRuntime37.TextureFilter.MipMapNearestNearest:
texture.GenerateMipmap();
break;
case SpineRuntime37.TextureFilter.MipMapLinearNearest:
case SpineRuntime37.TextureFilter.MipMapNearestLinear:
case SpineRuntime37.TextureFilter.MipMapLinearLinear:
texture.Smooth = true;
texture.GenerateMipmap();
break;
}
if (ForceNearest) texture.Smooth = false;
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)
{
var texture = ReadTexture(path);
if (page.magFilter == SpineRuntime38.TextureFilter.Linear)
{
texture.Smooth = true;
}
if (page.uWrap == SpineRuntime38.TextureWrap.Repeat && page.vWrap == SpineRuntime38.TextureWrap.Repeat)
{
texture.Repeated = true;
}
switch (page.minFilter)
{
case SpineRuntime38.TextureFilter.Linear:
texture.Smooth = true;
break;
case SpineRuntime38.TextureFilter.MipMap:
case SpineRuntime38.TextureFilter.MipMapNearestNearest:
texture.GenerateMipmap();
break;
case SpineRuntime38.TextureFilter.MipMapLinearNearest:
case SpineRuntime38.TextureFilter.MipMapNearestLinear:
case SpineRuntime38.TextureFilter.MipMapLinearLinear:
texture.Smooth = true;
texture.GenerateMipmap();
break;
}
if (ForceNearest) texture.Smooth = false;
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(SpineRuntime40.AtlasPage page, string path)
{
var texture = ReadTexture(path);
if (page.magFilter == SpineRuntime40.TextureFilter.Linear)
{
texture.Smooth = true;
}
if (page.uWrap == SpineRuntime40.TextureWrap.Repeat && page.vWrap == SpineRuntime40.TextureWrap.Repeat)
{
texture.Repeated = true;
}
switch (page.minFilter)
{
case SpineRuntime40.TextureFilter.Linear:
texture.Smooth = true;
break;
case SpineRuntime40.TextureFilter.MipMap:
case SpineRuntime40.TextureFilter.MipMapNearestNearest:
texture.GenerateMipmap();
break;
case SpineRuntime40.TextureFilter.MipMapLinearNearest:
case SpineRuntime40.TextureFilter.MipMapNearestLinear:
case SpineRuntime40.TextureFilter.MipMapLinearLinear:
texture.Smooth = true;
texture.GenerateMipmap();
break;
}
if (ForceNearest) texture.Smooth = false;
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)
{
var texture = ReadTexture(path);
if (page.magFilter == SpineRuntime41.TextureFilter.Linear)
{
texture.Smooth = true;
}
if (page.uWrap == SpineRuntime41.TextureWrap.Repeat && page.vWrap == SpineRuntime41.TextureWrap.Repeat)
{
texture.Repeated = true;
}
switch (page.minFilter)
{
case SpineRuntime41.TextureFilter.Linear:
texture.Smooth = true;
break;
case SpineRuntime41.TextureFilter.MipMap:
case SpineRuntime41.TextureFilter.MipMapNearestNearest:
texture.GenerateMipmap();
break;
case SpineRuntime41.TextureFilter.MipMapLinearNearest:
case SpineRuntime41.TextureFilter.MipMapNearestLinear:
case SpineRuntime41.TextureFilter.MipMapLinearLinear:
texture.Smooth = true;
texture.GenerateMipmap();
break;
}
if (ForceNearest) texture.Smooth = false;
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)
{
var texture = ReadTexture(path);
if (page.magFilter == SpineRuntime42.TextureFilter.Linear)
{
texture.Smooth = true;
}
if (page.uWrap == SpineRuntime42.TextureWrap.Repeat && page.vWrap == SpineRuntime42.TextureWrap.Repeat)
{
texture.Repeated = true;
}
switch (page.minFilter)
{
case SpineRuntime42.TextureFilter.Linear:
texture.Smooth = true;
break;
case SpineRuntime42.TextureFilter.MipMap:
case SpineRuntime42.TextureFilter.MipMapNearestNearest:
texture.GenerateMipmap();
break;
case SpineRuntime42.TextureFilter.MipMapLinearNearest:
case SpineRuntime42.TextureFilter.MipMapNearestLinear:
case SpineRuntime42.TextureFilter.MipMapLinearLinear:
texture.Smooth = true;
texture.GenerateMipmap();
break;
}
if (ForceNearest) texture.Smooth = false;
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)
{
((Texture)texture).Dispose();
}
}
}

View File

@@ -0,0 +1,23 @@
using Spine.Interfaces;
using SpineRuntime21;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V21
{
internal sealed class Animation21(Animation innerObject) : IAnimation
{
private readonly Animation _o = innerObject;
public Animation InnerObject => _o;
public string Name => _o.Name;
public float Duration => _o.Duration;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,179 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime21;
namespace Spine.Implementations.V21
{
internal sealed class AnimationState21(AnimationState innerObject, SpineObjectData21 data) : IAnimationState
{
private readonly AnimationState _o = innerObject;
private readonly SpineObjectData21 _data = data;
private readonly Dictionary<TrackEntry, TrackEntry21> _trackEntryPool = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, AnimationState.TrackEntryDelegate> _eventMapping = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, int> _eventCount = [];
public AnimationState InnerObject => _o;
#pragma warning disable CS0067
// NOTE: 2.1 没有这两个事件
public event IAnimationState.TrackEntryDelegate? Interrupt;
public event IAnimationState.TrackEntryDelegate? Dispose;
#pragma warning restore CS0067
public event IAnimationState.TrackEntryDelegate? Start
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Start += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Start -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? End
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.End += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.End -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Complete
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Complete += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Complete -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public float TimeScale { get => _o.TimeScale; set => _o.TimeScale = value; }
public void Update(float delta) => _o.Update(delta);
public void Apply(ISkeleton skeleton)
{
if (skeleton is Skeleton21 skel)
{
_o.Apply(skel.InnerObject);
return;
}
throw new ArgumentException($"Received {skeleton.GetType().Name}", nameof(skeleton));
}
/// <summary>
/// 获取 <see cref="ITrackEntry"/> 对象, 不存在则创建
/// </summary>
public ITrackEntry GetTrackEntry(TrackEntry trackEntry)
{
if (!_trackEntryPool.TryGetValue(trackEntry, out var tr))
_trackEntryPool[trackEntry] = tr = new(trackEntry, this, _data);
return tr;
}
public IEnumerable<ITrackEntry?> IterTracks() => _o.Tracks.Select(t => t is null ? null : GetTrackEntry(t));
public ITrackEntry? GetCurrent(int index) { var t = _o.GetCurrent(index); return t is null ? null : GetTrackEntry(t); }
public void ClearTrack(int index) => _o.ClearTrack(index);
public void ClearTracks() => _o.ClearTracks();
public ITrackEntry SetAnimation(int trackIndex, string animationName, bool loop)
=> GetTrackEntry(_o.SetAnimation(trackIndex, animationName, loop));
public ITrackEntry SetAnimation(int trackIndex, IAnimation animation, bool loop)
{
if (animation is Animation21 anime)
return GetTrackEntry(_o.SetAnimation(trackIndex, anime.InnerObject, loop));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry SetEmptyAnimation(int trackIndex, float mixDuration) => GetTrackEntry(_o.SetEmptyAnimation(trackIndex, mixDuration));
public void SetEmptyAnimations(float mixDuration) => _o.SetEmptyAnimations(mixDuration);
public ITrackEntry AddAnimation(int trackIndex, string animationName, bool loop, float delay)
=> GetTrackEntry(_o.AddAnimation(trackIndex, animationName, loop, delay));
public ITrackEntry AddAnimation(int trackIndex, IAnimation animation, bool loop, float delay)
{
if (animation is Animation21 anime)
return GetTrackEntry(_o.AddAnimation(trackIndex, anime.InnerObject, loop, delay));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry AddEmptyAnimation(int trackIndex, float mixDuration, float delay)
=> GetTrackEntry(_o.AddEmptyAnimation(trackIndex, mixDuration, delay));
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime21;
namespace Spine.Implementations.V21.Attachments
{
internal abstract class Attachment21(Attachment innerObject) : IAttachment
{
private readonly Attachment _o = innerObject;
public virtual Attachment InnerObject => _o;
public string Name => _o.Name;
public abstract int ComputeWorldVertices(ISlot slot, ref float[] worldVertices);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V21;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime21;
namespace Spine.Implementations.V21.Attachments
{
internal sealed class BoundingBoxAttachment21(BoundingBoxAttachment innerObject) :
Attachment21(innerObject),
IBoundingBoxAttachment
{
private readonly BoundingBoxAttachment _o = innerObject;
public override BoundingBoxAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot21 st)
{
var length = _o.Vertices.Length;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject.Bone, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot21)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V21;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime21;
namespace Spine.Implementations.V21.Attachments
{
internal sealed class MeshAttachment21(MeshAttachment innerObject) :
Attachment21(innerObject),
IMeshAttachment
{
private readonly MeshAttachment _o = innerObject;
public override MeshAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot21 st)
{
var length = _o.Vertices.Length;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot21)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
public int[] Triangles => _o.Triangles;
public int HullLength => _o.HullLength;
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V21;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime21;
namespace Spine.Implementations.V21.Attachments
{
internal sealed class RegionAttachment21(RegionAttachment innerObject) :
Attachment21(innerObject),
IRegionAttachment
{
private readonly RegionAttachment _o = innerObject;
public override RegionAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot21 st)
{
if (worldVertices.Length < 8) worldVertices = new float[8];
_o.ComputeWorldVertices(st.InnerObject.Bone, worldVertices);
return 8;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot21)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V21;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime21;
namespace Spine.Implementations.V21.Attachments
{
internal sealed class SkinnedMeshAttachment21(SkinnedMeshAttachment innerObject) :
Attachment21(innerObject),
ISkinnedMeshAttachment
{
private readonly SkinnedMeshAttachment _o = innerObject;
public override SkinnedMeshAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot21 st)
{
var length = _o.UVs.Length;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot21)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
public int[] Triangles => _o.Triangles;
public int HullLength => _o.HullLength;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime21;
namespace Spine.Implementations.V21
{
internal sealed class Bone21(Bone innerObject, Bone21? parent = null) : IBone
{
private readonly Bone _o = innerObject;
private readonly Bone21? _parent = parent;
public Bone InnerObject => _o;
public string Name => _o.Data.Name;
public int Index => _o.Data.Index;
public IBone? Parent => _parent;
public bool Active => true; // NOTE: 3.7 及以下没有 Active 属性, 此处总是返回 true
public float Length => _o.Data.Length;
public float WorldX => _o.WorldX;
public float WorldY => _o.WorldY;
public float A => _o.M00;
public float B => _o.M01;
public float C => _o.M10;
public float D => _o.M11;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Frozen;
using System.Collections.Immutable;
using SpineRuntime21;
using Spine.Interfaces;
namespace Spine.Implementations.V21
{
internal sealed class Skeleton21 : ISkeleton
{
private readonly Skeleton _o;
private readonly SpineObjectData21 _data;
private readonly ImmutableArray<IBone> _bones;
private readonly FrozenDictionary<string, IBone> _bonesByName;
private readonly ImmutableArray<ISlot> _slots;
private readonly FrozenDictionary<string, ISlot> _slotsByName;
private Skin21? _skin;
public Skeleton21(Skeleton innerObject, SpineObjectData21 data)
{
_o = innerObject;
_data = data;
List<Bone21> bones = [];
Dictionary<string, IBone> bonesByName = [];
foreach (var b in _o.Bones)
{
var bone = new Bone21(b, b.Parent is null ? null : bones[b.Parent.Data.Index]);
bones.Add(bone);
bonesByName[bone.Name] = bone;
}
_bones = bones.Cast<IBone>().ToImmutableArray();
_bonesByName = bonesByName.ToFrozenDictionary();
List<Slot21> slots = [];
Dictionary<string, ISlot> slotsByName = [];
foreach (var s in _o.Slots)
{
var slot = new Slot21(s, _data, bones[s.Bone.Data.Index]);
slots.Add(slot);
slotsByName[slot.Name] = slot;
}
_slots = slots.Cast<ISlot>().ToImmutableArray();
_slotsByName = slotsByName.ToFrozenDictionary();
}
public Skeleton InnerObject => _o;
public string Name => _o.Data.Name;
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public float X { get => _o.X; set => _o.X = value; }
public float Y { get => _o.Y; set => _o.Y = value; }
public float ScaleX { get => _o.ScaleX; set => _o.ScaleX = value; }
public float ScaleY { get => _o.ScaleY; set => _o.ScaleY = value; }
public ImmutableArray<IBone> Bones => _bones;
public FrozenDictionary<string, IBone> BonesByName => _bonesByName;
public ImmutableArray<ISlot> Slots => _slots;
public FrozenDictionary<string, ISlot> SlotsByName => _slotsByName;
public ISkin? Skin
{
get => _skin;
set
{
if (value is null)
{
_o.Skin = null;
_skin = null;
return;
}
if (value is Skin21 sk)
{
_o.Skin = sk.InnerObject;
_skin = sk;
return;
}
throw new ArgumentException($"Received {value.GetType().Name}", nameof(value));
}
}
public IEnumerable<ISlot> IterDrawOrder() => _o.DrawOrder.Select(s => _slots[s.Data.Index]);
public void UpdateCache() => _o.UpdateCache();
public void UpdateWorldTransform(ISkeleton.Physics physics) => _o.UpdateWorldTransform();
public void SetToSetupPose() => _o.SetToSetupPose();
public void SetBonesToSetupPose() => _o.SetBonesToSetupPose();
public void SetSlotsToSetupPose() => _o.SetSlotsToSetupPose();
public void Update(float delta) => _o.Update(delta);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,42 @@
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using Spine.Utils;
using SpineRuntime21;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V21
{
internal sealed class SkeletonClipping21 : ISkeletonClipping
{
public bool IsClipping => false;
public float[] ClippedVertices { get; private set; } = [];
public int ClippedVerticesLength { get; private set; } = 0;
public int[] ClippedTriangles { get; private set; } = [];
public int ClippedTrianglesLength { get; private set; } = 0;
public float[] ClippedUVs { get; private set; } = [];
public void ClipEnd(ISlot slot) { }
public void ClipEnd() { }
public void ClipStart(ISlot slot, IClippingAttachment clippingAttachment) { }
public void ClipTriangles(float[] vertices, int verticesLength, int[] triangles, int trianglesLength, float[] uvs)
{
ClippedVertices = vertices.ToArray();
ClippedVerticesLength = verticesLength;
ClippedTriangles = triangles.ToArray();
ClippedTrianglesLength = trianglesLength;
ClippedUVs = uvs.ToArray();
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime21;
namespace Spine.Implementations.V21
{
internal sealed class Skin21 : ISkin
{
private readonly Skin _o;
/// <summary>
/// 使用指定名字创建空皮肤
/// </summary>
public Skin21(string name) => _o = new(name);
/// <summary>
/// 包装已有皮肤对象
/// </summary>
public Skin21(Skin innerObject) => _o = innerObject;
public Skin InnerObject => _o;
public string Name => _o.Name;
public void AddSkin(ISkin skin)
{
if (skin is Skin21 sk)
{
// NOTE: 3.7 及以下不支持 AddSkin
foreach (var (k, v) in sk._o.Attachments)
_o.AddAttachment(k.Key, k.Value, v);
return;
}
throw new ArgumentException($"Received {skin.GetType().Name}", nameof(skin));
}
public void Clear() => _o.Attachments.Clear();
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Utils;
using SpineRuntime21;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
namespace Spine.Implementations.V21
{
internal sealed class Slot21 : ISlot
{
private readonly Slot _o;
private readonly SpineObjectData21 _data;
private readonly Bone21 _bone;
private readonly SFML.Graphics.BlendMode _blendMode;
public Slot21(Slot innerObject, SpineObjectData21 data, Bone21 bone)
{
_o = innerObject;
_data = data;
_bone = bone;
_blendMode = _o.Data.AdditiveBlending ? SFMLBlendMode.AdditivePma : SFMLBlendMode.NormalPma; // NOTE: 2.1 没有完整的 BlendMode
}
public Slot InnerObject => _o;
public string Name => _o.Data.Name;
public int Index => _o.Data.Index;
public SFML.Graphics.BlendMode Blend => _blendMode;
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public IBone Bone => _bone;
public IAttachment? Attachment
{
get
{
if (_o.Attachment is Attachment att)
{
return _data.SlotAttachments[Name][att.Name];
}
return null;
}
set
{
if (value is null)
{
_o.Attachment = null;
return;
}
if (value is Attachments.Attachment21 att)
{
_o.Attachment = att.InnerObject;
return;
}
throw new ArgumentException($"Received {value.GetType().Name}", nameof(value));
}
}
public bool Disabled { get; set; }
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Collections.Frozen;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Utils;
using SpineRuntime21;
using Spine.Implementations.V21.Attachments;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
namespace Spine.Implementations.V21
{
[SpineImplementation(2, 1)]
internal sealed class SpineObjectData21 : SpineObjectData
{
private readonly Atlas _atlas;
private readonly SkeletonData _skeletonData;
private readonly AnimationStateData _animationStateData;
private readonly ImmutableArray<ISkin> _skins;
private readonly FrozenDictionary<string, ISkin> _skinsByName;
private readonly FrozenDictionary<string, FrozenDictionary<string, IAttachment>> _slotAttachments;
private readonly ImmutableArray<IAnimation> _animations;
private readonly FrozenDictionary<string, IAnimation> _animationsByName;
public SpineObjectData21(string skelPath, string atlasPath, TextureLoader textureLoader)
: base(skelPath, atlasPath, textureLoader)
{
// 加载 atlas
try
{
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try
{
if (Utf8Validator.IsUtf8(skelPath))
{
try
{
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
}
}
else
{
try
{
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
}
}
}
catch (Exception ex)
{
_atlas.Dispose();
_logger.Debug(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
}
// 加载动画数据
_animationStateData = new AnimationStateData(_skeletonData);
// 整理皮肤和附件
Dictionary<string, Dictionary<string, IAttachment>> slotAttachments = [];
List<ISkin> skins = [];
Dictionary<string, ISkin> skinsByName = [];
foreach (var s in _skeletonData.Skins)
{
var skin = new Skin21(s);
skins.Add(skin);
skinsByName[s.Name] = skin;
foreach (var (k, att) in s.Attachments)
{
var slotName = _skeletonData.Slots[k.Key].Name;
if (!slotAttachments.TryGetValue(slotName, out var attachments))
slotAttachments[slotName] = attachments = [];
attachments[att.Name] = att switch
{
RegionAttachment regionAtt => new RegionAttachment21(regionAtt),
MeshAttachment meshAtt => new MeshAttachment21(meshAtt),
SkinnedMeshAttachment skMeshAtt => new SkinnedMeshAttachment21(skMeshAtt),
BoundingBoxAttachment bbAtt => new BoundingBoxAttachment21(bbAtt),
_ => throw new InvalidOperationException($"Unrecognized attachment type {att.GetType().FullName}")
};
}
}
_slotAttachments = slotAttachments.ToFrozenDictionary(it => it.Key, it => it.Value.ToFrozenDictionary());
_skins = skins.ToImmutableArray();
_skinsByName = skinsByName.ToFrozenDictionary();
// 整理所有动画数据
List<IAnimation> animations = [];
Dictionary<string, IAnimation> animationsByName = [];
foreach (var a in _skeletonData.Animations)
{
var anime = new Animation21(a);
animations.Add(anime);
animationsByName[anime.Name] = anime;
}
_animations = animations.ToImmutableArray();
_animationsByName = animationsByName.ToFrozenDictionary();
}
public override string SkeletonVersion => _skeletonData.Version;
public override ImmutableArray<ISkin> Skins => _skins;
public override FrozenDictionary<string, ISkin> SkinsByName => _skinsByName;
public override FrozenDictionary<string, FrozenDictionary<string, IAttachment>> SlotAttachments => _slotAttachments;
public override float DefaultMix { get => _animationStateData.DefaultMix; set => _animationStateData.DefaultMix = value; }
public override ImmutableArray<IAnimation> Animations => _animations;
public override FrozenDictionary<string, IAnimation> AnimationsByName => _animationsByName;
protected override void DisposeAtlas() => _atlas.Dispose();
public override ISkeleton CreateSkeleton() => new Skeleton21(new(_skeletonData), this);
public override IAnimationState CreateAnimationState() => new AnimationState21(new(_animationStateData), this);
public override ISkeletonClipping CreateSkeletonClipping() => new SkeletonClipping21();
public override ISkin CreateSkin(string name) => new Skin21(name);
}
}

View File

@@ -0,0 +1,135 @@
using Spine.Interfaces;
using SpineRuntime21;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V21
{
internal sealed class TrackEntry21(TrackEntry innerObject, AnimationState21 animationState, SpineObjectData21 data): ITrackEntry
{
private readonly TrackEntry _o = innerObject;
private readonly AnimationState21 _animationState = animationState;
private readonly SpineObjectData21 _data = data;
private readonly Dictionary<IAnimationState.TrackEntryDelegate, AnimationState.TrackEntryDelegate> _eventMapping = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, int> _eventCount = [];
public TrackEntry InnerObject => _o;
#pragma warning disable CS0067
// 2.1 没有这两个事件
public event IAnimationState.TrackEntryDelegate? Interrupt;
public event IAnimationState.TrackEntryDelegate? Dispose;
#pragma warning restore CS0067
public event IAnimationState.TrackEntryDelegate? Start
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Start += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Start -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? End
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.End += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.End -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Complete
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Complete += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Complete -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public int TrackIndex { get => _o.TrackIndex; }
public IAnimation Animation { get => _data.AnimationsByName[_o.Animation.Name]; }
public ITrackEntry? Next { get { var t = _o.Next; return t is null ? null : _animationState.GetTrackEntry(t); } }
public bool Loop { get => _o.Loop; set => _o.Loop = value; }
public float TrackTime { get => _o.Time; set => _o.Time = value; }
public float TimeScale { get => _o.TimeScale; set => _o.TimeScale = value; }
public float Alpha { get => _o.Mix; set => _o.Mix = value; }
public float MixDuration { get => _o.MixDuration; set => _o.MixDuration = value; }
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,23 @@
using Spine.Interfaces;
using SpineRuntime34;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V34
{
internal sealed class Animation34(Animation innerObject) : IAnimation
{
private readonly Animation _o = innerObject;
public Animation InnerObject => _o;
public string Name => _o.Name;
public float Duration => _o.Duration;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,180 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime34;
namespace Spine.Implementations.V34
{
internal sealed class AnimationState34(AnimationState innerObject, SpineObjectData34 data) : IAnimationState
{
private readonly AnimationState _o = innerObject;
private readonly SpineObjectData34 _data = data;
private readonly Dictionary<TrackEntry, TrackEntry34> _trackEntryPool = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, AnimationState.TrackEntryDelegate> _eventMapping = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, int> _eventCount = [];
public AnimationState InnerObject => _o;
#pragma warning disable CS0067
// NOTE: 3.4 以下没有这两个事件
public event IAnimationState.TrackEntryDelegate? Interrupt;
public event IAnimationState.TrackEntryDelegate? Dispose;
#pragma warning restore CS0067
public event IAnimationState.TrackEntryDelegate? Start
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Start += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Start -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? End
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.End += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.End -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Complete
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Complete += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Complete -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public float TimeScale { get => _o.TimeScale; set => _o.TimeScale = value; }
public void Update(float delta) => _o.Update(delta);
public void Apply(ISkeleton skeleton)
{
if (skeleton is Skeleton34 skel)
{
_o.Apply(skel.InnerObject);
return;
}
throw new ArgumentException($"Received {skeleton.GetType().Name}", nameof(skeleton));
}
/// <summary>
/// 获取 <see cref="ITrackEntry"/> 对象, 不存在则创建
/// </summary>
public ITrackEntry GetTrackEntry(TrackEntry trackEntry)
{
if (!_trackEntryPool.TryGetValue(trackEntry, out var tr))
_trackEntryPool[trackEntry] = tr = new(trackEntry, this, _data);
return tr;
}
public IEnumerable<ITrackEntry?> IterTracks() => _o.Tracks.Select(t => t is null ? null : GetTrackEntry(t));
public ITrackEntry? GetCurrent(int index) { var t = _o.GetCurrent(index); return t is null ? null : GetTrackEntry(t); }
public void ClearTrack(int index) => _o.ClearTrack(index);
public void ClearTracks() => _o.ClearTracks();
public ITrackEntry SetAnimation(int trackIndex, string animationName, bool loop)
=> GetTrackEntry(_o.SetAnimation(trackIndex, animationName, loop));
public ITrackEntry SetAnimation(int trackIndex, IAnimation animation, bool loop)
{
if (animation is Animation34 anime)
return GetTrackEntry(_o.SetAnimation(trackIndex, anime.InnerObject, loop));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry SetEmptyAnimation(int trackIndex, float mixDuration) => GetTrackEntry(_o.SetEmptyAnimation(trackIndex, mixDuration));
public void SetEmptyAnimations(float mixDuration) => _o.SetEmptyAnimations(mixDuration);
public ITrackEntry AddAnimation(int trackIndex, string animationName, bool loop, float delay)
=> GetTrackEntry(_o.AddAnimation(trackIndex, animationName, loop, delay));
public ITrackEntry AddAnimation(int trackIndex, IAnimation animation, bool loop, float delay)
{
if (animation is Animation34 anime)
return GetTrackEntry(_o.AddAnimation(trackIndex, anime.InnerObject, loop, delay));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry AddEmptyAnimation(int trackIndex, float mixDuration, float delay)
=> GetTrackEntry(_o.AddEmptyAnimation(trackIndex, mixDuration, delay));
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime34;
namespace Spine.Implementations.V34.Attachments
{
internal abstract class Attachment34(Attachment innerObject) : IAttachment
{
private readonly Attachment _o = innerObject;
public virtual Attachment InnerObject => _o;
public string Name => _o.Name;
public abstract int ComputeWorldVertices(ISlot slot, ref float[] worldVertices);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V34;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime34;
namespace Spine.Implementations.V34.Attachments
{
internal sealed class BoundingBoxAttachment34(BoundingBoxAttachment innerObject) :
Attachment34(innerObject),
IBoundingBoxAttachment
{
private readonly BoundingBoxAttachment _o = innerObject;
public override BoundingBoxAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot34 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot34)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V34;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime34;
namespace Spine.Implementations.V34.Attachments
{
internal sealed class MeshAttachment34(MeshAttachment innerObject) :
Attachment34(innerObject),
IMeshAttachment
{
private readonly MeshAttachment _o = innerObject;
public override MeshAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot34 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot34)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
public int[] Triangles => _o.Triangles;
public int HullLength => _o.HullLength;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V34;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime34;
namespace Spine.Implementations.V34.Attachments
{
internal sealed class PathAttachment34(PathAttachment innerObject) :
Attachment34(innerObject),
IPathAttachment
{
private readonly PathAttachment _o = innerObject;
public override PathAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot34 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot34)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V34;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime34;
namespace Spine.Implementations.V34.Attachments
{
internal sealed class RegionAttachment34(RegionAttachment innerObject) :
Attachment34(innerObject),
IRegionAttachment
{
private readonly RegionAttachment _o = innerObject;
public override RegionAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot34 st)
{
if (worldVertices.Length < 8) worldVertices = new float[8];
_o.ComputeWorldVertices(st.InnerObject.Bone, worldVertices);
return 8;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot34)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime34;
namespace Spine.Implementations.V34
{
internal sealed class Bone34(Bone innerObject, Bone34? parent = null) : IBone
{
private readonly Bone _o = innerObject;
private readonly Bone34? _parent = parent;
public Bone InnerObject => _o;
public string Name => _o.Data.Name;
public int Index => _o.Data.Index;
public IBone? Parent => _parent;
public bool Active => true; // NOTE: 3.7 及以下没有 Active 属性, 此处总是返回 true
public float Length => _o.Data.Length;
public float WorldX => _o.WorldX;
public float WorldY => _o.WorldY;
public float A => _o.A;
public float B => _o.B;
public float C => _o.C;
public float D => _o.D;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Frozen;
using System.Collections.Immutable;
using SpineRuntime34;
using Spine.Interfaces;
namespace Spine.Implementations.V34
{
internal sealed class Skeleton34 : ISkeleton
{
private readonly Skeleton _o;
private readonly SpineObjectData34 _data;
private readonly ImmutableArray<IBone> _bones;
private readonly FrozenDictionary<string, IBone> _bonesByName;
private readonly ImmutableArray<ISlot> _slots;
private readonly FrozenDictionary<string, ISlot> _slotsByName;
private Skin34? _skin;
public Skeleton34(Skeleton innerObject, SpineObjectData34 data)
{
_o = innerObject;
_data = data;
List<Bone34> bones = [];
Dictionary<string, IBone> bonesByName = [];
foreach (var b in _o.Bones)
{
var bone = new Bone34(b, b.Parent is null ? null : bones[b.Parent.Data.Index]);
bones.Add(bone);
bonesByName[bone.Name] = bone;
}
_bones = bones.Cast<IBone>().ToImmutableArray();
_bonesByName = bonesByName.ToFrozenDictionary();
List<Slot34> slots = [];
Dictionary<string, ISlot> slotsByName = [];
foreach (var s in _o.Slots)
{
var slot = new Slot34(s, _data, bones[s.Bone.Data.Index]);
slots.Add(slot);
slotsByName[slot.Name] = slot;
}
_slots = slots.Cast<ISlot>().ToImmutableArray();
_slotsByName = slotsByName.ToFrozenDictionary();
}
public Skeleton InnerObject => _o;
public string Name => _o.Data.Name;
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public float X { get => _o.X; set => _o.X = value; }
public float Y { get => _o.Y; set => _o.Y = value; }
public float ScaleX { get => _o.ScaleX; set => _o.ScaleX = value; }
public float ScaleY { get => _o.ScaleY; set => _o.ScaleY = value; }
public ImmutableArray<IBone> Bones => _bones;
public FrozenDictionary<string, IBone> BonesByName => _bonesByName;
public ImmutableArray<ISlot> Slots => _slots;
public FrozenDictionary<string, ISlot> SlotsByName => _slotsByName;
public ISkin? Skin
{
get => _skin;
set
{
if (value is null)
{
_o.Skin = null;
_skin = null;
return;
}
if (value is Skin34 sk)
{
_o.Skin = sk.InnerObject;
_skin = sk;
return;
}
throw new ArgumentException($"Received {value.GetType().Name}", nameof(value));
}
}
public IEnumerable<ISlot> IterDrawOrder() => _o.DrawOrder.Select(s => _slots[s.Data.Index]);
public void UpdateCache() => _o.UpdateCache();
public void UpdateWorldTransform(ISkeleton.Physics physics) => _o.UpdateWorldTransform();
public void SetToSetupPose() => _o.SetToSetupPose();
public void SetBonesToSetupPose() => _o.SetBonesToSetupPose();
public void SetSlotsToSetupPose() => _o.SetSlotsToSetupPose();
public void Update(float delta) => _o.Update(delta);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,42 @@
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using Spine.Utils;
using SpineRuntime34;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V34
{
internal sealed class SkeletonClipping34 : ISkeletonClipping
{
public bool IsClipping => false;
public float[] ClippedVertices { get; private set; } = [];
public int ClippedVerticesLength { get; private set; } = 0;
public int[] ClippedTriangles { get; private set; } = [];
public int ClippedTrianglesLength { get; private set; } = 0;
public float[] ClippedUVs { get; private set; } = [];
public void ClipEnd(ISlot slot) { }
public void ClipEnd() { }
public void ClipStart(ISlot slot, IClippingAttachment clippingAttachment) { }
public void ClipTriangles(float[] vertices, int verticesLength, int[] triangles, int trianglesLength, float[] uvs)
{
ClippedVertices = vertices.ToArray();
ClippedVerticesLength = verticesLength;
ClippedTriangles = triangles.ToArray();
ClippedTrianglesLength = trianglesLength;
ClippedUVs = uvs.ToArray();
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime34;
namespace Spine.Implementations.V34
{
internal sealed class Skin34 : ISkin
{
private readonly Skin _o;
/// <summary>
/// 使用指定名字创建空皮肤
/// </summary>
public Skin34(string name) => _o = new(name);
/// <summary>
/// 包装已有皮肤对象
/// </summary>
public Skin34(Skin innerObject) => _o = innerObject;
public Skin InnerObject => _o;
public string Name => _o.Name;
public void AddSkin(ISkin skin)
{
if (skin is Skin34 sk)
{
// NOTE: 3.7 及以下不支持 AddSkin
foreach (var (k, v) in sk._o.Attachments)
_o.AddAttachment(k.slotIndex, k.name, v);
return;
}
throw new ArgumentException($"Received {skin.GetType().Name}", nameof(skin));
}
public void Clear() => _o.Attachments.Clear();
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Utils;
using SpineRuntime34;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
namespace Spine.Implementations.V34
{
internal sealed class Slot34 : ISlot
{
private readonly Slot _o;
private readonly SpineObjectData34 _data;
private readonly Bone34 _bone;
private readonly SFML.Graphics.BlendMode _blendMode;
public Slot34(Slot innerObject, SpineObjectData34 data, Bone34 bone)
{
_o = innerObject;
_data = data;
_bone = bone;
_blendMode = _o.Data.BlendMode switch
{
BlendMode.normal => SFMLBlendMode.NormalPma,
BlendMode.additive => SFMLBlendMode.AdditivePma,
BlendMode.multiply => SFMLBlendMode.MultiplyPma,
BlendMode.screen => SFMLBlendMode.ScreenPma,
_ => throw new NotImplementedException($"{_o.Data.BlendMode}"),
};
}
public Slot InnerObject => _o;
public string Name => _o.Data.Name;
public int Index => _o.Data.Index;
public SFML.Graphics.BlendMode Blend => _blendMode;
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public IBone Bone => _bone;
public IAttachment? Attachment
{
get
{
if (_o.Attachment is Attachment att)
{
return _data.SlotAttachments[Name][att.Name];
}
return null;
}
set
{
if (value is null)
{
_o.Attachment = null;
return;
}
if (value is Attachments.Attachment34 att)
{
_o.Attachment = att.InnerObject;
return;
}
throw new ArgumentException($"Received {value.GetType().Name}", nameof(value));
}
}
public bool Disabled { get; set; }
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Collections.Frozen;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Utils;
using SpineRuntime34;
using Spine.Implementations.V34.Attachments;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
namespace Spine.Implementations.V34
{
[SpineImplementation(3, 4)]
internal sealed class SpineObjectData34 : SpineObjectData
{
private readonly Atlas _atlas;
private readonly SkeletonData _skeletonData;
private readonly AnimationStateData _animationStateData;
private readonly ImmutableArray<ISkin> _skins;
private readonly FrozenDictionary<string, ISkin> _skinsByName;
private readonly FrozenDictionary<string, FrozenDictionary<string, IAttachment>> _slotAttachments;
private readonly ImmutableArray<IAnimation> _animations;
private readonly FrozenDictionary<string, IAnimation> _animationsByName;
public SpineObjectData34(string skelPath, string atlasPath, TextureLoader textureLoader)
: base(skelPath, atlasPath, textureLoader)
{
// 加载 atlas
try
{
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try
{
if (Utf8Validator.IsUtf8(skelPath))
{
try
{
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
}
}
else
{
try
{
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
}
}
}
catch (Exception ex)
{
_atlas.Dispose();
_logger.Debug(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
}
// 加载动画数据
_animationStateData = new AnimationStateData(_skeletonData);
// 整理皮肤和附件
Dictionary<string, Dictionary<string, IAttachment>> slotAttachments = [];
List<ISkin> skins = [];
Dictionary<string, ISkin> skinsByName = [];
foreach (var s in _skeletonData.Skins)
{
var skin = new Skin34(s);
skins.Add(skin);
skinsByName[s.Name] = skin;
foreach (var (k, att) in s.Attachments)
{
var slotName = _skeletonData.Slots.Items[k.slotIndex].Name;
if (!slotAttachments.TryGetValue(slotName, out var attachments))
slotAttachments[slotName] = attachments = [];
attachments[att.Name] = att switch
{
RegionAttachment regionAtt => new RegionAttachment34(regionAtt),
MeshAttachment meshAtt => new MeshAttachment34(meshAtt),
BoundingBoxAttachment bbAtt => new BoundingBoxAttachment34(bbAtt),
PathAttachment pathAtt => new PathAttachment34(pathAtt),
_ => throw new InvalidOperationException($"Unrecognized attachment type {att.GetType().FullName}")
};
}
}
_slotAttachments = slotAttachments.ToFrozenDictionary(it => it.Key, it => it.Value.ToFrozenDictionary());
_skins = skins.ToImmutableArray();
_skinsByName = skinsByName.ToFrozenDictionary();
// 整理所有动画数据
List<IAnimation> animations = [];
Dictionary<string, IAnimation> animationsByName = [];
foreach (var a in _skeletonData.Animations)
{
var anime = new Animation34(a);
animations.Add(anime);
animationsByName[anime.Name] = anime;
}
_animations = animations.ToImmutableArray();
_animationsByName = animationsByName.ToFrozenDictionary();
}
public override string SkeletonVersion => _skeletonData.Version;
public override ImmutableArray<ISkin> Skins => _skins;
public override FrozenDictionary<string, ISkin> SkinsByName => _skinsByName;
public override FrozenDictionary<string, FrozenDictionary<string, IAttachment>> SlotAttachments => _slotAttachments;
public override float DefaultMix { get => _animationStateData.DefaultMix; set => _animationStateData.DefaultMix = value; }
public override ImmutableArray<IAnimation> Animations => _animations;
public override FrozenDictionary<string, IAnimation> AnimationsByName => _animationsByName;
protected override void DisposeAtlas() => _atlas.Dispose();
public override ISkeleton CreateSkeleton() => new Skeleton34(new(_skeletonData), this);
public override IAnimationState CreateAnimationState() => new AnimationState34(new(_animationStateData), this);
public override ISkeletonClipping CreateSkeletonClipping() => new SkeletonClipping34();
public override ISkin CreateSkin(string name) => new Skin34(name);
}
}

View File

@@ -0,0 +1,135 @@
using Spine.Interfaces;
using SpineRuntime34;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V34
{
internal sealed class TrackEntry34(TrackEntry innerObject, AnimationState34 animationState, SpineObjectData34 data): ITrackEntry
{
private readonly TrackEntry _o = innerObject;
private readonly AnimationState34 _animationState = animationState;
private readonly SpineObjectData34 _data = data;
private readonly Dictionary<IAnimationState.TrackEntryDelegate, AnimationState.TrackEntryDelegate> _eventMapping = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, int> _eventCount = [];
public TrackEntry InnerObject => _o;
#pragma warning disable CS0067
// 3.4 及以下没有这两个事件
public event IAnimationState.TrackEntryDelegate? Interrupt;
public event IAnimationState.TrackEntryDelegate? Dispose;
#pragma warning restore CS0067
public event IAnimationState.TrackEntryDelegate? Start
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Start += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Start -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? End
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.End += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.End -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Complete
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Complete += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Complete -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public int TrackIndex { get => _o.TrackIndex; }
public IAnimation Animation { get => _data.AnimationsByName[_o.Animation.Name]; }
public ITrackEntry? Next { get { var t = _o.Next; return t is null ? null : _animationState.GetTrackEntry(t); } }
public bool Loop { get => _o.Loop; set => _o.Loop = value; }
public float TrackTime { get => _o.Time; set => _o.Time = value; }
public float TimeScale { get => _o.TimeScale; set => _o.TimeScale = value; }
public float Alpha { get => _o.Mix; set => _o.Mix = value; }
public float MixDuration { get => _o.MixDuration; set => _o.MixDuration = value; }
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,23 @@
using Spine.Interfaces;
using SpineRuntime35;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V35
{
internal sealed class Animation35(Animation innerObject) : IAnimation
{
private readonly Animation _o = innerObject;
public Animation InnerObject => _o;
public string Name => _o.Name;
public float Duration => _o.Duration;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,229 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime35;
namespace Spine.Implementations.V35
{
internal sealed class AnimationState35(AnimationState innerObject, SpineObjectData35 data) : IAnimationState
{
private readonly AnimationState _o = innerObject;
private readonly SpineObjectData35 _data = data;
private readonly Dictionary<TrackEntry, TrackEntry35> _trackEntryPool = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, AnimationState.TrackEntryDelegate> _eventMapping = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, int> _eventCount = [];
public AnimationState InnerObject => _o;
public event IAnimationState.TrackEntryDelegate? Start
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Start += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Start -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Interrupt
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Interrupt += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Interrupt -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? End
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.End += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.End -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Complete
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Complete += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Complete -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Dispose
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Dispose += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Dispose -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public float TimeScale { get => _o.TimeScale; set => _o.TimeScale = value; }
public void Update(float delta) => _o.Update(delta);
public void Apply(ISkeleton skeleton)
{
if (skeleton is Skeleton35 skel)
{
_o.Apply(skel.InnerObject);
return;
}
throw new ArgumentException($"Received {skeleton.GetType().Name}", nameof(skeleton));
}
/// <summary>
/// 获取 <see cref="ITrackEntry"/> 对象, 不存在则创建
/// </summary>
public ITrackEntry GetTrackEntry(TrackEntry trackEntry)
{
if (!_trackEntryPool.TryGetValue(trackEntry, out var tr))
_trackEntryPool[trackEntry] = tr = new(trackEntry, this, _data);
return tr;
}
public IEnumerable<ITrackEntry?> IterTracks() => _o.Tracks.Select(t => t is null ? null : GetTrackEntry(t));
public ITrackEntry? GetCurrent(int index) { var t = _o.GetCurrent(index); return t is null ? null : GetTrackEntry(t); }
public void ClearTrack(int index) => _o.ClearTrack(index);
public void ClearTracks() => _o.ClearTracks();
public ITrackEntry SetAnimation(int trackIndex, string animationName, bool loop)
=> GetTrackEntry(_o.SetAnimation(trackIndex, animationName, loop));
public ITrackEntry SetAnimation(int trackIndex, IAnimation animation, bool loop)
{
if (animation is Animation35 anime)
return GetTrackEntry(_o.SetAnimation(trackIndex, anime.InnerObject, loop));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry SetEmptyAnimation(int trackIndex, float mixDuration) => GetTrackEntry(_o.SetEmptyAnimation(trackIndex, mixDuration));
public void SetEmptyAnimations(float mixDuration) => _o.SetEmptyAnimations(mixDuration);
public ITrackEntry AddAnimation(int trackIndex, string animationName, bool loop, float delay)
=> GetTrackEntry(_o.AddAnimation(trackIndex, animationName, loop, delay));
public ITrackEntry AddAnimation(int trackIndex, IAnimation animation, bool loop, float delay)
{
if (animation is Animation35 anime)
return GetTrackEntry(_o.AddAnimation(trackIndex, anime.InnerObject, loop, delay));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry AddEmptyAnimation(int trackIndex, float mixDuration, float delay)
=> GetTrackEntry(_o.AddEmptyAnimation(trackIndex, mixDuration, delay));
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime35;
namespace Spine.Implementations.V35.Attachments
{
internal abstract class Attachment35(Attachment innerObject) : IAttachment
{
private readonly Attachment _o = innerObject;
public virtual Attachment InnerObject => _o;
public string Name => _o.Name;
public abstract int ComputeWorldVertices(ISlot slot, ref float[] worldVertices);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V35;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime35;
namespace Spine.Implementations.V35.Attachments
{
internal sealed class BoundingBoxAttachment35(BoundingBoxAttachment innerObject) :
Attachment35(innerObject),
IBoundingBoxAttachment
{
private readonly BoundingBoxAttachment _o = innerObject;
public override BoundingBoxAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot35 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot35)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V35;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime35;
namespace Spine.Implementations.V35.Attachments
{
internal sealed class ClippingAttachment35(ClippingAttachment innerObject) :
Attachment35(innerObject),
IClippingAttachment
{
private readonly ClippingAttachment _o = innerObject;
public override ClippingAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot35 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot35)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V35;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime35;
namespace Spine.Implementations.V35.Attachments
{
internal sealed class MeshAttachment35(MeshAttachment innerObject) :
Attachment35(innerObject),
IMeshAttachment
{
private readonly MeshAttachment _o = innerObject;
public override MeshAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot35 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot35)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
public int[] Triangles => _o.Triangles;
public int HullLength => _o.HullLength;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V35;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime35;
namespace Spine.Implementations.V35.Attachments
{
internal sealed class PathAttachment35(PathAttachment innerObject) :
Attachment35(innerObject),
IPathAttachment
{
private readonly PathAttachment _o = innerObject;
public override PathAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot35 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot35)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V35;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime35;
namespace Spine.Implementations.V35.Attachments
{
internal sealed class PointAttachment35(PointAttachment innerObject) :
Attachment35(innerObject),
IPointAttachment
{
private readonly PointAttachment _o = innerObject;
public override PointAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot35 st)
{
if (worldVertices.Length < 2) worldVertices = new float[2];
_o.ComputeWorldPosition(st.InnerObject.Bone, out worldVertices[0], out worldVertices[1]);
return 2;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot35)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V35;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime35;
namespace Spine.Implementations.V35.Attachments
{
internal sealed class RegionAttachment35(RegionAttachment innerObject) :
Attachment35(innerObject),
IRegionAttachment
{
private readonly RegionAttachment _o = innerObject;
public override RegionAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot35 st)
{
if (worldVertices.Length < 8) worldVertices = new float[8];
_o.ComputeWorldVertices(st.InnerObject.Bone, worldVertices, 0);
return 8;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot35)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime35;
namespace Spine.Implementations.V35
{
internal sealed class Bone35(Bone innerObject, Bone35? parent = null) : IBone
{
private readonly Bone _o = innerObject;
private readonly Bone35? _parent = parent;
public Bone InnerObject => _o;
public string Name => _o.Data.Name;
public int Index => _o.Data.Index;
public IBone? Parent => _parent;
public bool Active => true; // NOTE: 3.7 及以下没有 Active 属性, 此处总是返回 true
public float Length => _o.Data.Length;
public float WorldX => _o.WorldX;
public float WorldY => _o.WorldY;
public float A => _o.A;
public float B => _o.B;
public float C => _o.C;
public float D => _o.D;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Frozen;
using System.Collections.Immutable;
using SpineRuntime35;
using Spine.Interfaces;
namespace Spine.Implementations.V35
{
internal sealed class Skeleton35 : ISkeleton
{
private readonly Skeleton _o;
private readonly SpineObjectData35 _data;
private readonly ImmutableArray<IBone> _bones;
private readonly FrozenDictionary<string, IBone> _bonesByName;
private readonly ImmutableArray<ISlot> _slots;
private readonly FrozenDictionary<string, ISlot> _slotsByName;
private Skin35? _skin;
public Skeleton35(Skeleton innerObject, SpineObjectData35 data)
{
_o = innerObject;
_data = data;
List<Bone35> bones = [];
Dictionary<string, IBone> bonesByName = [];
foreach (var b in _o.Bones)
{
var bone = new Bone35(b, b.Parent is null ? null : bones[b.Parent.Data.Index]);
bones.Add(bone);
bonesByName[bone.Name] = bone;
}
_bones = bones.Cast<IBone>().ToImmutableArray();
_bonesByName = bonesByName.ToFrozenDictionary();
List<Slot35> slots = [];
Dictionary<string, ISlot> slotsByName = [];
foreach (var s in _o.Slots)
{
var slot = new Slot35(s, _data, bones[s.Bone.Data.Index]);
slots.Add(slot);
slotsByName[slot.Name] = slot;
}
_slots = slots.Cast<ISlot>().ToImmutableArray();
_slotsByName = slotsByName.ToFrozenDictionary();
}
public Skeleton InnerObject => _o;
public string Name => _o.Data.Name;
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public float X { get => _o.X; set => _o.X = value; }
public float Y { get => _o.Y; set => _o.Y = value; }
public float ScaleX { get => _o.ScaleX; set => _o.ScaleX = value; }
public float ScaleY { get => _o.ScaleY; set => _o.ScaleY = value; }
public ImmutableArray<IBone> Bones => _bones;
public FrozenDictionary<string, IBone> BonesByName => _bonesByName;
public ImmutableArray<ISlot> Slots => _slots;
public FrozenDictionary<string, ISlot> SlotsByName => _slotsByName;
public ISkin? Skin
{
get => _skin;
set
{
if (value is null)
{
_o.Skin = null;
_skin = null;
return;
}
if (value is Skin35 sk)
{
_o.Skin = sk.InnerObject;
_skin = sk;
return;
}
throw new ArgumentException($"Received {value.GetType().Name}", nameof(value));
}
}
public IEnumerable<ISlot> IterDrawOrder() => _o.DrawOrder.Select(s => _slots[s.Data.Index]);
public void UpdateCache() => _o.UpdateCache();
public void UpdateWorldTransform(ISkeleton.Physics physics) => _o.UpdateWorldTransform();
public void SetToSetupPose() => _o.SetToSetupPose();
public void SetBonesToSetupPose() => _o.SetBonesToSetupPose();
public void SetSlotsToSetupPose() => _o.SetSlotsToSetupPose();
public void Update(float delta) => _o.Update(delta);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,56 @@
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using Spine.Utils;
using SpineRuntime35;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V35
{
internal sealed class SkeletonClipping35 : ISkeletonClipping
{
private readonly SkeletonClipping _o = new();
public bool IsClipping => _o.IsClipping();
public float[] ClippedVertices => _o.ClippedVertices.Items;
public int ClippedVerticesLength => _o.ClippedVertices.Count;
public int[] ClippedTriangles => _o.ClippedTriangles.Items;
public int ClippedTrianglesLength => _o.ClippedTriangles.Count;
public float[] ClippedUVs => _o.ClippedUVs.Items;
public void ClipTriangles(float[] vertices, int verticesLength, int[] triangles, int trianglesLength, float[] uvs)
=> _o.ClipTriangles(vertices, verticesLength, triangles, trianglesLength, uvs);
public void ClipStart(ISlot slot, IClippingAttachment clippingAttachment)
{
if (slot is Slot35 st && clippingAttachment is Attachments.ClippingAttachment35 att)
{
_o.ClipStart(st.InnerObject, att.InnerObject);
return;
}
throw new ArgumentException($"Received {slot.GetType().Name} {clippingAttachment.GetType().Name}");
}
public void ClipEnd(ISlot slot)
{
if (slot is Slot35 st)
{
_o.ClipEnd(st.InnerObject);
return;
}
throw new ArgumentException($"Received {slot.GetType().Name}", nameof(slot));
}
public void ClipEnd() => _o.ClipEnd();
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime35;
namespace Spine.Implementations.V35
{
internal sealed class Skin35 : ISkin
{
private readonly Skin _o;
/// <summary>
/// 使用指定名字创建空皮肤
/// </summary>
public Skin35(string name) => _o = new(name);
/// <summary>
/// 包装已有皮肤对象
/// </summary>
public Skin35(Skin innerObject) => _o = innerObject;
public Skin InnerObject => _o;
public string Name => _o.Name;
public void AddSkin(ISkin skin)
{
if (skin is Skin35 sk)
{
// NOTE: 3.7 及以下不支持 AddSkin
foreach (var (k, v) in sk._o.Attachments)
_o.AddAttachment(k.slotIndex, k.name, v);
return;
}
throw new ArgumentException($"Received {skin.GetType().Name}", nameof(skin));
}
public void Clear() => _o.Attachments.Clear();
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Utils;
using SpineRuntime35;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
namespace Spine.Implementations.V35
{
internal sealed class Slot35 : ISlot
{
private readonly Slot _o;
private readonly SpineObjectData35 _data;
private readonly Bone35 _bone;
private readonly SFML.Graphics.BlendMode _blendMode;
public Slot35(Slot innerObject, SpineObjectData35 data, Bone35 bone)
{
_o = innerObject;
_data = data;
_bone = bone;
_blendMode = _o.Data.BlendMode switch
{
BlendMode.Normal => SFMLBlendMode.NormalPma,
BlendMode.Additive => SFMLBlendMode.AdditivePma,
BlendMode.Multiply => SFMLBlendMode.MultiplyPma,
BlendMode.Screen => SFMLBlendMode.ScreenPma,
_ => throw new NotImplementedException($"{_o.Data.BlendMode}"),
};
}
public Slot InnerObject => _o;
public string Name => _o.Data.Name;
public int Index => _o.Data.Index;
public SFML.Graphics.BlendMode Blend => _blendMode;
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public IBone Bone => _bone;
public IAttachment? Attachment
{
get
{
if (_o.Attachment is Attachment att)
{
return _data.SlotAttachments[Name][att.Name];
}
return null;
}
set
{
if (value is null)
{
_o.Attachment = null;
return;
}
if (value is Attachments.Attachment35 att)
{
_o.Attachment = att.InnerObject;
return;
}
throw new ArgumentException($"Received {value.GetType().Name}", nameof(value));
}
}
public bool Disabled { get; set; }
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,148 @@
using System;
using System.Collections.Generic;
using System.Collections.Frozen;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Utils;
using SpineRuntime35;
using Spine.Implementations.V35.Attachments;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
namespace Spine.Implementations.V35
{
[SpineImplementation(3, 5)]
internal sealed class SpineObjectData35 : SpineObjectData
{
private readonly Atlas _atlas;
private readonly SkeletonData _skeletonData;
private readonly AnimationStateData _animationStateData;
private readonly ImmutableArray<ISkin> _skins;
private readonly FrozenDictionary<string, ISkin> _skinsByName;
private readonly FrozenDictionary<string, FrozenDictionary<string, IAttachment>> _slotAttachments;
private readonly ImmutableArray<IAnimation> _animations;
private readonly FrozenDictionary<string, IAnimation> _animationsByName;
public SpineObjectData35(string skelPath, string atlasPath, TextureLoader textureLoader)
: base(skelPath, atlasPath, textureLoader)
{
// 加载 atlas
try
{
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try
{
if (Utf8Validator.IsUtf8(skelPath))
{
try
{
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
}
}
else
{
try
{
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
}
}
}
catch (Exception ex)
{
_atlas.Dispose();
_logger.Debug(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
}
// 加载动画数据
_animationStateData = new AnimationStateData(_skeletonData);
// 整理皮肤和附件
Dictionary<string, Dictionary<string, IAttachment>> slotAttachments = [];
List<ISkin> skins = [];
Dictionary<string, ISkin> skinsByName = [];
foreach (var s in _skeletonData.Skins)
{
var skin = new Skin35(s);
skins.Add(skin);
skinsByName[s.Name] = skin;
foreach (var (k, att) in s.Attachments)
{
var slotName = _skeletonData.Slots.Items[k.slotIndex].Name;
if (!slotAttachments.TryGetValue(slotName, out var attachments))
slotAttachments[slotName] = attachments = [];
attachments[att.Name] = att switch
{
RegionAttachment regionAtt => new RegionAttachment35(regionAtt),
MeshAttachment meshAtt => new MeshAttachment35(meshAtt),
ClippingAttachment clipAtt => new ClippingAttachment35(clipAtt),
BoundingBoxAttachment bbAtt => new BoundingBoxAttachment35(bbAtt),
PathAttachment pathAtt => new PathAttachment35(pathAtt),
PointAttachment ptAtt => new PointAttachment35(ptAtt),
_ => throw new InvalidOperationException($"Unrecognized attachment type {att.GetType().FullName}")
};
}
}
_slotAttachments = slotAttachments.ToFrozenDictionary(it => it.Key, it => it.Value.ToFrozenDictionary());
_skins = skins.ToImmutableArray();
_skinsByName = skinsByName.ToFrozenDictionary();
// 整理所有动画数据
List<IAnimation> animations = [];
Dictionary<string, IAnimation> animationsByName = [];
foreach (var a in _skeletonData.Animations)
{
var anime = new Animation35(a);
animations.Add(anime);
animationsByName[anime.Name] = anime;
}
_animations = animations.ToImmutableArray();
_animationsByName = animationsByName.ToFrozenDictionary();
}
public override string SkeletonVersion => _skeletonData.Version;
public override ImmutableArray<ISkin> Skins => _skins;
public override FrozenDictionary<string, ISkin> SkinsByName => _skinsByName;
public override FrozenDictionary<string, FrozenDictionary<string, IAttachment>> SlotAttachments => _slotAttachments;
public override float DefaultMix { get => _animationStateData.DefaultMix; set => _animationStateData.DefaultMix = value; }
public override ImmutableArray<IAnimation> Animations => _animations;
public override FrozenDictionary<string, IAnimation> AnimationsByName => _animationsByName;
protected override void DisposeAtlas() => _atlas.Dispose();
public override ISkeleton CreateSkeleton() => new Skeleton35(new(_skeletonData), this);
public override IAnimationState CreateAnimationState() => new AnimationState35(new(_animationStateData), this);
public override ISkeletonClipping CreateSkeletonClipping() => new SkeletonClipping35();
public override ISkin CreateSkin(string name) => new Skin35(name);
}
}

View File

@@ -0,0 +1,185 @@
using Spine.Interfaces;
using SpineRuntime35;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V35
{
internal sealed class TrackEntry35(TrackEntry innerObject, AnimationState35 animationState, SpineObjectData35 data): ITrackEntry
{
private readonly TrackEntry _o = innerObject;
private readonly AnimationState35 _animationState = animationState;
private readonly SpineObjectData35 _data = data;
private readonly Dictionary<IAnimationState.TrackEntryDelegate, AnimationState.TrackEntryDelegate> _eventMapping = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, int> _eventCount = [];
public TrackEntry InnerObject => _o;
public event IAnimationState.TrackEntryDelegate? Start
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Start += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Start -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Interrupt
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Interrupt += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Interrupt -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? End
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.End += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.End -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Complete
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Complete += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Complete -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Dispose
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Dispose += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Dispose -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public int TrackIndex { get => _o.TrackIndex; }
public IAnimation Animation { get => _data.AnimationsByName[_o.Animation.Name]; }
public ITrackEntry? Next { get { var t = _o.Next; return t is null ? null : _animationState.GetTrackEntry(t); } }
public bool Loop { get => _o.Loop; set => _o.Loop = value; }
public float TrackTime { get => _o.TrackTime; set => _o.TrackTime = value; }
public float TimeScale { get => _o.TimeScale; set => _o.TimeScale = value; }
public float Alpha { get => _o.Alpha; set => _o.Alpha = value; }
public float MixDuration { get => _o.MixDuration; set => _o.MixDuration = value; }
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,23 @@
using Spine.Interfaces;
using SpineRuntime36;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V36
{
internal sealed class Animation36(Animation innerObject) : IAnimation
{
private readonly Animation _o = innerObject;
public Animation InnerObject => _o;
public string Name => _o.Name;
public float Duration => _o.Duration;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,229 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime36;
namespace Spine.Implementations.V36
{
internal sealed class AnimationState36(AnimationState innerObject, SpineObjectData36 data) : IAnimationState
{
private readonly AnimationState _o = innerObject;
private readonly SpineObjectData36 _data = data;
private readonly Dictionary<TrackEntry, TrackEntry36> _trackEntryPool = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, AnimationState.TrackEntryDelegate> _eventMapping = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, int> _eventCount = [];
public AnimationState InnerObject => _o;
public event IAnimationState.TrackEntryDelegate? Start
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Start += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Start -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Interrupt
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Interrupt += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Interrupt -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? End
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.End += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.End -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Complete
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Complete += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Complete -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Dispose
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Dispose += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Dispose -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public float TimeScale { get => _o.TimeScale; set => _o.TimeScale = value; }
public void Update(float delta) => _o.Update(delta);
public void Apply(ISkeleton skeleton)
{
if (skeleton is Skeleton36 skel)
{
_o.Apply(skel.InnerObject);
return;
}
throw new ArgumentException($"Received {skeleton.GetType().Name}", nameof(skeleton));
}
/// <summary>
/// 获取 <see cref="ITrackEntry"/> 对象, 不存在则创建
/// </summary>
public ITrackEntry GetTrackEntry(TrackEntry trackEntry)
{
if (!_trackEntryPool.TryGetValue(trackEntry, out var tr))
_trackEntryPool[trackEntry] = tr = new(trackEntry, this, _data);
return tr;
}
public IEnumerable<ITrackEntry?> IterTracks() => _o.Tracks.Select(t => t is null ? null : GetTrackEntry(t));
public ITrackEntry? GetCurrent(int index) { var t = _o.GetCurrent(index); return t is null ? null : GetTrackEntry(t); }
public void ClearTrack(int index) => _o.ClearTrack(index);
public void ClearTracks() => _o.ClearTracks();
public ITrackEntry SetAnimation(int trackIndex, string animationName, bool loop)
=> GetTrackEntry(_o.SetAnimation(trackIndex, animationName, loop));
public ITrackEntry SetAnimation(int trackIndex, IAnimation animation, bool loop)
{
if (animation is Animation36 anime)
return GetTrackEntry(_o.SetAnimation(trackIndex, anime.InnerObject, loop));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry SetEmptyAnimation(int trackIndex, float mixDuration) => GetTrackEntry(_o.SetEmptyAnimation(trackIndex, mixDuration));
public void SetEmptyAnimations(float mixDuration) => _o.SetEmptyAnimations(mixDuration);
public ITrackEntry AddAnimation(int trackIndex, string animationName, bool loop, float delay)
=> GetTrackEntry(_o.AddAnimation(trackIndex, animationName, loop, delay));
public ITrackEntry AddAnimation(int trackIndex, IAnimation animation, bool loop, float delay)
{
if (animation is Animation36 anime)
return GetTrackEntry(_o.AddAnimation(trackIndex, anime.InnerObject, loop, delay));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry AddEmptyAnimation(int trackIndex, float mixDuration, float delay)
=> GetTrackEntry(_o.AddEmptyAnimation(trackIndex, mixDuration, delay));
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime36;
namespace Spine.Implementations.V36.Attachments
{
internal abstract class Attachment36(Attachment innerObject) : IAttachment
{
private readonly Attachment _o = innerObject;
public virtual Attachment InnerObject => _o;
public string Name => _o.Name;
public abstract int ComputeWorldVertices(ISlot slot, ref float[] worldVertices);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V36;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime36;
namespace Spine.Implementations.V36.Attachments
{
internal sealed class BoundingBoxAttachment36(BoundingBoxAttachment innerObject) :
Attachment36(innerObject),
IBoundingBoxAttachment
{
private readonly BoundingBoxAttachment _o = innerObject;
public override BoundingBoxAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot36 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot36)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V36;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime36;
namespace Spine.Implementations.V36.Attachments
{
internal sealed class ClippingAttachment36(ClippingAttachment innerObject) :
Attachment36(innerObject),
IClippingAttachment
{
private readonly ClippingAttachment _o = innerObject;
public override ClippingAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot36 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot36)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V36;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime36;
namespace Spine.Implementations.V36.Attachments
{
internal sealed class MeshAttachment36(MeshAttachment innerObject) :
Attachment36(innerObject),
IMeshAttachment
{
private readonly MeshAttachment _o = innerObject;
public override MeshAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot36 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot36)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
public int[] Triangles => _o.Triangles;
public int HullLength => _o.HullLength;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V36;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime36;
namespace Spine.Implementations.V36.Attachments
{
internal sealed class PathAttachment36(PathAttachment innerObject) :
Attachment36(innerObject),
IPathAttachment
{
private readonly PathAttachment _o = innerObject;
public override PathAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot36 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot36)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V36;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime36;
namespace Spine.Implementations.V36.Attachments
{
internal sealed class PointAttachment36(PointAttachment innerObject) :
Attachment36(innerObject),
IPointAttachment
{
private readonly PointAttachment _o = innerObject;
public override PointAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot36 st)
{
if (worldVertices.Length < 2) worldVertices = new float[2];
_o.ComputeWorldPosition(st.InnerObject.Bone, out worldVertices[0], out worldVertices[1]);
return 2;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot36)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V36;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime36;
namespace Spine.Implementations.V36.Attachments
{
internal sealed class RegionAttachment36(RegionAttachment innerObject) :
Attachment36(innerObject),
IRegionAttachment
{
private readonly RegionAttachment _o = innerObject;
public override RegionAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot36 st)
{
if (worldVertices.Length < 8) worldVertices = new float[8];
_o.ComputeWorldVertices(st.InnerObject.Bone, worldVertices, 0);
return 8;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot36)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime36;
namespace Spine.Implementations.V36
{
internal sealed class Bone36(Bone innerObject, Bone36? parent = null) : IBone
{
private readonly Bone _o = innerObject;
private readonly Bone36? _parent = parent;
public Bone InnerObject => _o;
public string Name => _o.Data.Name;
public int Index => _o.Data.Index;
public IBone? Parent => _parent;
public bool Active => true; // NOTE: 3.7 及以下没有 Active 属性, 此处总是返回 true
public float Length => _o.Data.Length;
public float WorldX => _o.WorldX;
public float WorldY => _o.WorldY;
public float A => _o.A;
public float B => _o.B;
public float C => _o.C;
public float D => _o.D;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Frozen;
using System.Collections.Immutable;
using SpineRuntime36;
using Spine.Interfaces;
namespace Spine.Implementations.V36
{
internal sealed class Skeleton36 : ISkeleton
{
private readonly Skeleton _o;
private readonly SpineObjectData36 _data;
private readonly ImmutableArray<IBone> _bones;
private readonly FrozenDictionary<string, IBone> _bonesByName;
private readonly ImmutableArray<ISlot> _slots;
private readonly FrozenDictionary<string, ISlot> _slotsByName;
private Skin36? _skin;
public Skeleton36(Skeleton innerObject, SpineObjectData36 data)
{
_o = innerObject;
_data = data;
List<Bone36> bones = [];
Dictionary<string, IBone> bonesByName = [];
foreach (var b in _o.Bones)
{
var bone = new Bone36(b, b.Parent is null ? null : bones[b.Parent.Data.Index]);
bones.Add(bone);
bonesByName[bone.Name] = bone;
}
_bones = bones.Cast<IBone>().ToImmutableArray();
_bonesByName = bonesByName.ToFrozenDictionary();
List<Slot36> slots = [];
Dictionary<string, ISlot> slotsByName = [];
foreach (var s in _o.Slots)
{
var slot = new Slot36(s, _data, bones[s.Bone.Data.Index]);
slots.Add(slot);
slotsByName[slot.Name] = slot;
}
_slots = slots.Cast<ISlot>().ToImmutableArray();
_slotsByName = slotsByName.ToFrozenDictionary();
}
public Skeleton InnerObject => _o;
public string Name => _o.Data.Name;
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public float X { get => _o.X; set => _o.X = value; }
public float Y { get => _o.Y; set => _o.Y = value; }
public float ScaleX { get => _o.ScaleX; set => _o.ScaleX = value; }
public float ScaleY { get => _o.ScaleY; set => _o.ScaleY = value; }
public ImmutableArray<IBone> Bones => _bones;
public FrozenDictionary<string, IBone> BonesByName => _bonesByName;
public ImmutableArray<ISlot> Slots => _slots;
public FrozenDictionary<string, ISlot> SlotsByName => _slotsByName;
public ISkin? Skin
{
get => _skin;
set
{
if (value is null)
{
_o.Skin = null;
_skin = null;
return;
}
if (value is Skin36 sk)
{
_o.Skin = sk.InnerObject;
_skin = sk;
return;
}
throw new ArgumentException($"Received {value.GetType().Name}", nameof(value));
}
}
public IEnumerable<ISlot> IterDrawOrder() => _o.DrawOrder.Select(s => _slots[s.Data.Index]);
public void UpdateCache() => _o.UpdateCache();
public void UpdateWorldTransform(ISkeleton.Physics physics) => _o.UpdateWorldTransform();
public void SetToSetupPose() => _o.SetToSetupPose();
public void SetBonesToSetupPose() => _o.SetBonesToSetupPose();
public void SetSlotsToSetupPose() => _o.SetSlotsToSetupPose();
public void Update(float delta) => _o.Update(delta);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,56 @@
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using Spine.Utils;
using SpineRuntime36;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V36
{
internal sealed class SkeletonClipping36 : ISkeletonClipping
{
private readonly SkeletonClipping _o = new();
public bool IsClipping => _o.IsClipping;
public float[] ClippedVertices => _o.ClippedVertices.Items;
public int ClippedVerticesLength => _o.ClippedVertices.Count;
public int[] ClippedTriangles => _o.ClippedTriangles.Items;
public int ClippedTrianglesLength => _o.ClippedTriangles.Count;
public float[] ClippedUVs => _o.ClippedUVs.Items;
public void ClipTriangles(float[] vertices, int verticesLength, int[] triangles, int trianglesLength, float[] uvs)
=> _o.ClipTriangles(vertices, verticesLength, triangles, trianglesLength, uvs);
public void ClipStart(ISlot slot, IClippingAttachment clippingAttachment)
{
if (slot is Slot36 st && clippingAttachment is Attachments.ClippingAttachment36 att)
{
_o.ClipStart(st.InnerObject, att.InnerObject);
return;
}
throw new ArgumentException($"Received {slot.GetType().Name} {clippingAttachment.GetType().Name}");
}
public void ClipEnd(ISlot slot)
{
if (slot is Slot36 st)
{
_o.ClipEnd(st.InnerObject);
return;
}
throw new ArgumentException($"Received {slot.GetType().Name}", nameof(slot));
}
public void ClipEnd() => _o.ClipEnd();
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime36;
namespace Spine.Implementations.V36
{
internal sealed class Skin36 : ISkin
{
private readonly Skin _o;
/// <summary>
/// 使用指定名字创建空皮肤
/// </summary>
public Skin36(string name) => _o = new(name);
/// <summary>
/// 包装已有皮肤对象
/// </summary>
public Skin36(Skin innerObject) => _o = innerObject;
public Skin InnerObject => _o;
public string Name => _o.Name;
public void AddSkin(ISkin skin)
{
if (skin is Skin36 sk)
{
// NOTE: 3.7 及以下不支持 AddSkin
foreach (var (k, v) in sk._o.Attachments)
_o.AddAttachment(k.slotIndex, k.name, v);
return;
}
throw new ArgumentException($"Received {skin.GetType().Name}", nameof(skin));
}
public void Clear() => _o.Attachments.Clear();
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Utils;
using SpineRuntime36;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
namespace Spine.Implementations.V36
{
internal sealed class Slot36 : ISlot
{
private readonly Slot _o;
private readonly SpineObjectData36 _data;
private readonly Bone36 _bone;
private readonly SFML.Graphics.BlendMode _blendMode;
public Slot36(Slot innerObject, SpineObjectData36 data, Bone36 bone)
{
_o = innerObject;
_data = data;
_bone = bone;
_blendMode = _o.Data.BlendMode switch
{
BlendMode.Normal => SFMLBlendMode.NormalPma,
BlendMode.Additive => SFMLBlendMode.AdditivePma,
BlendMode.Multiply => SFMLBlendMode.MultiplyPma,
BlendMode.Screen => SFMLBlendMode.ScreenPma,
_ => throw new NotImplementedException($"{_o.Data.BlendMode}"),
};
}
public Slot InnerObject => _o;
public string Name => _o.Data.Name;
public int Index => _o.Data.Index;
public SFML.Graphics.BlendMode Blend => _blendMode;
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public IBone Bone => _bone;
public IAttachment? Attachment
{
get
{
if (_o.Attachment is Attachment att)
{
return _data.SlotAttachments[Name][att.Name];
}
return null;
}
set
{
if (value is null)
{
_o.Attachment = null;
return;
}
if (value is Attachments.Attachment36 att)
{
_o.Attachment = att.InnerObject;
return;
}
throw new ArgumentException($"Received {value.GetType().Name}", nameof(value));
}
}
public bool Disabled { get; set; }
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,148 @@
using System;
using System.Collections.Generic;
using System.Collections.Frozen;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Utils;
using SpineRuntime36;
using Spine.Implementations.V36.Attachments;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
namespace Spine.Implementations.V36
{
[SpineImplementation(3, 6)]
internal sealed class SpineObjectData36 : SpineObjectData
{
private readonly Atlas _atlas;
private readonly SkeletonData _skeletonData;
private readonly AnimationStateData _animationStateData;
private readonly ImmutableArray<ISkin> _skins;
private readonly FrozenDictionary<string, ISkin> _skinsByName;
private readonly FrozenDictionary<string, FrozenDictionary<string, IAttachment>> _slotAttachments;
private readonly ImmutableArray<IAnimation> _animations;
private readonly FrozenDictionary<string, IAnimation> _animationsByName;
public SpineObjectData36(string skelPath, string atlasPath, TextureLoader textureLoader)
: base(skelPath, atlasPath, textureLoader)
{
// 加载 atlas
try
{
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try
{
if (Utf8Validator.IsUtf8(skelPath))
{
try
{
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
}
}
else
{
try
{
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
}
catch (Exception ex)
{
_logger.Debug(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
}
}
}
catch (Exception ex)
{
_atlas.Dispose();
_logger.Debug(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
}
// 加载动画数据
_animationStateData = new AnimationStateData(_skeletonData);
// 整理皮肤和附件
Dictionary<string, Dictionary<string, IAttachment>> slotAttachments = [];
List<ISkin> skins = [];
Dictionary<string, ISkin> skinsByName = [];
foreach (var s in _skeletonData.Skins)
{
var skin = new Skin36(s);
skins.Add(skin);
skinsByName[s.Name] = skin;
foreach (var (k, att) in s.Attachments)
{
var slotName = _skeletonData.Slots.Items[k.slotIndex].Name;
if (!slotAttachments.TryGetValue(slotName, out var attachments))
slotAttachments[slotName] = attachments = [];
attachments[att.Name] = att switch
{
RegionAttachment regionAtt => new RegionAttachment36(regionAtt),
MeshAttachment meshAtt => new MeshAttachment36(meshAtt),
ClippingAttachment clipAtt => new ClippingAttachment36(clipAtt),
BoundingBoxAttachment bbAtt => new BoundingBoxAttachment36(bbAtt),
PathAttachment pathAtt => new PathAttachment36(pathAtt),
PointAttachment ptAtt => new PointAttachment36(ptAtt),
_ => throw new InvalidOperationException($"Unrecognized attachment type {att.GetType().FullName}")
};
}
}
_slotAttachments = slotAttachments.ToFrozenDictionary(it => it.Key, it => it.Value.ToFrozenDictionary());
_skins = skins.ToImmutableArray();
_skinsByName = skinsByName.ToFrozenDictionary();
// 整理所有动画数据
List<IAnimation> animations = [];
Dictionary<string, IAnimation> animationsByName = [];
foreach (var a in _skeletonData.Animations)
{
var anime = new Animation36(a);
animations.Add(anime);
animationsByName[anime.Name] = anime;
}
_animations = animations.ToImmutableArray();
_animationsByName = animationsByName.ToFrozenDictionary();
}
public override string SkeletonVersion => _skeletonData.Version;
public override ImmutableArray<ISkin> Skins => _skins;
public override FrozenDictionary<string, ISkin> SkinsByName => _skinsByName;
public override FrozenDictionary<string, FrozenDictionary<string, IAttachment>> SlotAttachments => _slotAttachments;
public override float DefaultMix { get => _animationStateData.DefaultMix; set => _animationStateData.DefaultMix = value; }
public override ImmutableArray<IAnimation> Animations => _animations;
public override FrozenDictionary<string, IAnimation> AnimationsByName => _animationsByName;
protected override void DisposeAtlas() => _atlas.Dispose();
public override ISkeleton CreateSkeleton() => new Skeleton36(new(_skeletonData), this);
public override IAnimationState CreateAnimationState() => new AnimationState36(new(_animationStateData), this);
public override ISkeletonClipping CreateSkeletonClipping() => new SkeletonClipping36();
public override ISkin CreateSkin(string name) => new Skin36(name);
}
}

View File

@@ -0,0 +1,185 @@
using Spine.Interfaces;
using SpineRuntime36;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V36
{
internal sealed class TrackEntry36(TrackEntry innerObject, AnimationState36 animationState, SpineObjectData36 data): ITrackEntry
{
private readonly TrackEntry _o = innerObject;
private readonly AnimationState36 _animationState = animationState;
private readonly SpineObjectData36 _data = data;
private readonly Dictionary<IAnimationState.TrackEntryDelegate, AnimationState.TrackEntryDelegate> _eventMapping = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, int> _eventCount = [];
public TrackEntry InnerObject => _o;
public event IAnimationState.TrackEntryDelegate? Start
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Start += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Start -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Interrupt
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Interrupt += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Interrupt -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? End
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.End += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.End -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Complete
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Complete += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Complete -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Dispose
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(_animationState.GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Dispose += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Dispose -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public int TrackIndex { get => _o.TrackIndex; }
public IAnimation Animation { get => _data.AnimationsByName[_o.Animation.Name]; }
public ITrackEntry? Next { get { var t = _o.Next; return t is null ? null : _animationState.GetTrackEntry(t); } }
public bool Loop { get => _o.Loop; set => _o.Loop = value; }
public float TrackTime { get => _o.TrackTime; set => _o.TrackTime = value; }
public float TimeScale { get => _o.TimeScale; set => _o.TimeScale = value; }
public float Alpha { get => _o.Alpha; set => _o.Alpha = value; }
public float MixDuration { get => _o.MixDuration; set => _o.MixDuration = value; }
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,23 @@
using Spine.Interfaces;
using SpineRuntime37;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V37
{
internal sealed class Animation37(Animation innerObject) : IAnimation
{
private readonly Animation _o = innerObject;
public Animation InnerObject => _o;
public string Name => _o.Name;
public float Duration => _o.Duration;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,229 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime37;
namespace Spine.Implementations.V37
{
internal sealed class AnimationState37(AnimationState innerObject, SpineObjectData37 data) : IAnimationState
{
private readonly AnimationState _o = innerObject;
private readonly SpineObjectData37 _data = data;
private readonly Dictionary<TrackEntry, TrackEntry37> _trackEntryPool = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, AnimationState.TrackEntryDelegate> _eventMapping = [];
private readonly Dictionary<IAnimationState.TrackEntryDelegate, int> _eventCount = [];
public AnimationState InnerObject => _o;
public event IAnimationState.TrackEntryDelegate? Start
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Start += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Start -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Interrupt
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Interrupt += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Interrupt -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? End
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.End += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.End -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Complete
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Complete += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Complete -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public event IAnimationState.TrackEntryDelegate? Dispose
{
add
{
if (value is null) return;
if (!_eventMapping.TryGetValue(value, out var f))
{
_eventMapping[value] = f = (t) => value(GetTrackEntry(t));
_eventCount[value] = 0;
}
_o.Dispose += f;
_eventCount[value]++;
}
remove
{
if (value is null) return;
if (_eventMapping.TryGetValue(value, out var f))
{
_o.Dispose -= f;
_eventCount[value]--;
if (_eventCount[value] <= 0)
{
_eventMapping.Remove(value);
_eventCount.Remove(value);
}
}
}
}
public float TimeScale { get => _o.TimeScale; set => _o.TimeScale = value; }
public void Update(float delta) => _o.Update(delta);
public void Apply(ISkeleton skeleton)
{
if (skeleton is Skeleton37 skel)
{
_o.Apply(skel.InnerObject);
return;
}
throw new ArgumentException($"Received {skeleton.GetType().Name}", nameof(skeleton));
}
/// <summary>
/// 获取 <see cref="ITrackEntry"/> 对象, 不存在则创建
/// </summary>
public ITrackEntry GetTrackEntry(TrackEntry trackEntry)
{
if (!_trackEntryPool.TryGetValue(trackEntry, out var tr))
_trackEntryPool[trackEntry] = tr = new(trackEntry, this, _data);
return tr;
}
public IEnumerable<ITrackEntry?> IterTracks() => _o.Tracks.Select(t => t is null ? null : GetTrackEntry(t));
public ITrackEntry? GetCurrent(int index) { var t = _o.GetCurrent(index); return t is null ? null : GetTrackEntry(t); }
public void ClearTrack(int index) => _o.ClearTrack(index);
public void ClearTracks() => _o.ClearTracks();
public ITrackEntry SetAnimation(int trackIndex, string animationName, bool loop)
=> GetTrackEntry(_o.SetAnimation(trackIndex, animationName, loop));
public ITrackEntry SetAnimation(int trackIndex, IAnimation animation, bool loop)
{
if (animation is Animation37 anime)
return GetTrackEntry(_o.SetAnimation(trackIndex, anime.InnerObject, loop));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry SetEmptyAnimation(int trackIndex, float mixDuration) => GetTrackEntry(_o.SetEmptyAnimation(trackIndex, mixDuration));
public void SetEmptyAnimations(float mixDuration) => _o.SetEmptyAnimations(mixDuration);
public ITrackEntry AddAnimation(int trackIndex, string animationName, bool loop, float delay)
=> GetTrackEntry(_o.AddAnimation(trackIndex, animationName, loop, delay));
public ITrackEntry AddAnimation(int trackIndex, IAnimation animation, bool loop, float delay)
{
if (animation is Animation37 anime)
return GetTrackEntry(_o.AddAnimation(trackIndex, anime.InnerObject, loop, delay));
throw new ArgumentException($"Received {animation.GetType().Name}", nameof(animation));
}
public ITrackEntry AddEmptyAnimation(int trackIndex, float mixDuration, float delay)
=> GetTrackEntry(_o.AddEmptyAnimation(trackIndex, mixDuration, delay));
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime37;
namespace Spine.Implementations.V37.Attachments
{
internal abstract class Attachment37(Attachment innerObject) : IAttachment
{
private readonly Attachment _o = innerObject;
public virtual Attachment InnerObject => _o;
public string Name => _o.Name;
public abstract int ComputeWorldVertices(ISlot slot, ref float[] worldVertices);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V37;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime37;
namespace Spine.Implementations.V37.Attachments
{
internal sealed class BoundingBoxAttachment37(BoundingBoxAttachment innerObject) :
Attachment37(innerObject),
IBoundingBoxAttachment
{
private readonly BoundingBoxAttachment _o = innerObject;
public override BoundingBoxAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot37 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot37)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V37;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime37;
namespace Spine.Implementations.V37.Attachments
{
internal sealed class ClippingAttachment37(ClippingAttachment innerObject) :
Attachment37(innerObject),
IClippingAttachment
{
private readonly ClippingAttachment _o = innerObject;
public override ClippingAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot37 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot37)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V37;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime37;
namespace Spine.Implementations.V37.Attachments
{
internal sealed class MeshAttachment37(MeshAttachment innerObject) :
Attachment37(innerObject),
IMeshAttachment
{
private readonly MeshAttachment _o = innerObject;
public override MeshAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot37 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot37)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
public int[] Triangles => _o.Triangles;
public int HullLength => _o.HullLength;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V37;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime37;
namespace Spine.Implementations.V37.Attachments
{
internal sealed class PathAttachment37(PathAttachment innerObject) :
Attachment37(innerObject),
IPathAttachment
{
private readonly PathAttachment _o = innerObject;
public override PathAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot37 st)
{
var length = _o.WorldVerticesLength;
if (worldVertices.Length < length) worldVertices = new float[length];
_o.ComputeWorldVertices(st.InnerObject, worldVertices);
return length;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot37)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V37;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime37;
namespace Spine.Implementations.V37.Attachments
{
internal sealed class PointAttachment37(PointAttachment innerObject) :
Attachment37(innerObject),
IPointAttachment
{
private readonly PointAttachment _o = innerObject;
public override PointAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot37 st)
{
if (worldVertices.Length < 2) worldVertices = new float[2];
_o.ComputeWorldPosition(st.InnerObject.Bone, out worldVertices[0], out worldVertices[1]);
return 2;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot37)}, but received {slot.GetType().Name}", nameof(slot));
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Implementations.V37;
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using SpineRuntime37;
namespace Spine.Implementations.V37.Attachments
{
internal sealed class RegionAttachment37(RegionAttachment innerObject) :
Attachment37(innerObject),
IRegionAttachment
{
private readonly RegionAttachment _o = innerObject;
public override RegionAttachment InnerObject => _o;
public override int ComputeWorldVertices(ISlot slot, ref float[] worldVertices)
{
if (slot is Slot37 st)
{
if (worldVertices.Length < 8) worldVertices = new float[8];
_o.ComputeWorldVertices(st.InnerObject.Bone, worldVertices, 0);
return 8;
}
throw new ArgumentException($"Invalid slot type. Expected {nameof(Slot37)}, but received {slot.GetType().Name}", nameof(slot));
}
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public SFML.Graphics.Texture RendererObject => (SFML.Graphics.Texture)((AtlasRegion)_o.RendererObject).page.rendererObject;
public float[] UVs => _o.UVs;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spine.Interfaces;
using SpineRuntime37;
namespace Spine.Implementations.V37
{
internal sealed class Bone37(Bone innerObject, Bone37? parent = null) : IBone
{
private readonly Bone _o = innerObject;
private readonly Bone37? _parent = parent;
public Bone InnerObject => _o;
public string Name => _o.Data.Name;
public int Index => _o.Data.Index;
public IBone? Parent => _parent;
public bool Active => true; // NOTE: 3.7 及以下没有 Active 属性, 此处总是返回 true
public float Length => _o.Data.Length;
public float WorldX => _o.WorldX;
public float WorldY => _o.WorldY;
public float A => _o.A;
public float B => _o.B;
public float C => _o.C;
public float D => _o.D;
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Frozen;
using System.Collections.Immutable;
using SpineRuntime37;
using Spine.Interfaces;
namespace Spine.Implementations.V37
{
internal sealed class Skeleton37 : ISkeleton
{
private readonly Skeleton _o;
private readonly SpineObjectData37 _data;
private readonly ImmutableArray<IBone> _bones;
private readonly FrozenDictionary<string, IBone> _bonesByName;
private readonly ImmutableArray<ISlot> _slots;
private readonly FrozenDictionary<string, ISlot> _slotsByName;
private Skin37? _skin;
public Skeleton37(Skeleton innerObject, SpineObjectData37 data)
{
_o = innerObject;
_data = data;
List<Bone37> bones = [];
Dictionary<string, IBone> bonesByName = [];
foreach (var b in _o.Bones)
{
var bone = new Bone37(b, b.Parent is null ? null : bones[b.Parent.Data.Index]);
bones.Add(bone);
bonesByName[bone.Name] = bone;
}
_bones = bones.Cast<IBone>().ToImmutableArray();
_bonesByName = bonesByName.ToFrozenDictionary();
List<Slot37> slots = [];
Dictionary<string, ISlot> slotsByName = [];
foreach (var s in _o.Slots)
{
var slot = new Slot37(s, _data, bones[s.Bone.Data.Index]);
slots.Add(slot);
slotsByName[slot.Name] = slot;
}
_slots = slots.Cast<ISlot>().ToImmutableArray();
_slotsByName = slotsByName.ToFrozenDictionary();
}
public Skeleton InnerObject => _o;
public string Name => _o.Data.Name;
public float R { get => _o.R; set => _o.R = value; }
public float G { get => _o.G; set => _o.G = value; }
public float B { get => _o.B; set => _o.B = value; }
public float A { get => _o.A; set => _o.A = value; }
public float X { get => _o.X; set => _o.X = value; }
public float Y { get => _o.Y; set => _o.Y = value; }
public float ScaleX { get => _o.ScaleX; set => _o.ScaleX = value; }
public float ScaleY { get => _o.ScaleY; set => _o.ScaleY = value; }
public ImmutableArray<IBone> Bones => _bones;
public FrozenDictionary<string, IBone> BonesByName => _bonesByName;
public ImmutableArray<ISlot> Slots => _slots;
public FrozenDictionary<string, ISlot> SlotsByName => _slotsByName;
public ISkin? Skin
{
get => _skin;
set
{
if (value is null)
{
_o.Skin = null;
_skin = null;
return;
}
if (value is Skin37 sk)
{
_o.Skin = sk.InnerObject;
_skin = sk;
return;
}
throw new ArgumentException($"Received {value.GetType().Name}", nameof(value));
}
}
public IEnumerable<ISlot> IterDrawOrder() => _o.DrawOrder.Select(s => _slots[s.Data.Index]);
public void UpdateCache() => _o.UpdateCache();
public void UpdateWorldTransform(ISkeleton.Physics physics) => _o.UpdateWorldTransform();
public void SetToSetupPose() => _o.SetToSetupPose();
public void SetBonesToSetupPose() => _o.SetBonesToSetupPose();
public void SetSlotsToSetupPose() => _o.SetSlotsToSetupPose();
public void Update(float delta) => _o.Update(delta);
public override string ToString() => _o.ToString();
}
}

View File

@@ -0,0 +1,56 @@
using Spine.Interfaces;
using Spine.Interfaces.Attachments;
using Spine.Utils;
using SpineRuntime37;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spine.Implementations.V37
{
internal sealed class SkeletonClipping37 : ISkeletonClipping
{
private readonly SkeletonClipping _o = new();
public bool IsClipping => _o.IsClipping;
public float[] ClippedVertices => _o.ClippedVertices.Items;
public int ClippedVerticesLength => _o.ClippedVertices.Count;
public int[] ClippedTriangles => _o.ClippedTriangles.Items;
public int ClippedTrianglesLength => _o.ClippedTriangles.Count;
public float[] ClippedUVs => _o.ClippedUVs.Items;
public void ClipTriangles(float[] vertices, int verticesLength, int[] triangles, int trianglesLength, float[] uvs)
=> _o.ClipTriangles(vertices, verticesLength, triangles, trianglesLength, uvs);
public void ClipStart(ISlot slot, IClippingAttachment clippingAttachment)
{
if (slot is Slot37 st && clippingAttachment is Attachments.ClippingAttachment37 att)
{
_o.ClipStart(st.InnerObject, att.InnerObject);
return;
}
throw new ArgumentException($"Received {slot.GetType().Name} {clippingAttachment.GetType().Name}");
}
public void ClipEnd(ISlot slot)
{
if (slot is Slot37 st)
{
_o.ClipEnd(st.InnerObject);
return;
}
throw new ArgumentException($"Received {slot.GetType().Name}", nameof(slot));
}
public void ClipEnd() => _o.ClipEnd();
public override string ToString() => _o.ToString();
}
}

Some files were not shown because too many files have changed in this diff Show More