Compare commits

..

1532 commits

Author SHA1 Message Date
Actions User
eec8ee7094 [CI] Updating repo.json for 1.5.1.13
Some checks failed
.NET Build / build (push) Has been cancelled
2026-01-27 15:30:23 +00:00
Marc-Aurel Zent
13500264b7 Use iced to create AsmHooks in PapRewriter.
Some checks failed
.NET Build / build (push) Has been cancelled
2025-12-22 15:31:12 +01:00
Actions User
6ba735eefb [CI] Updating repo.json for 1.5.1.12
Some checks failed
.NET Build / build (push) Has been cancelled
2025-12-20 20:53:36 +00:00
Ottermandias
73f02851a6 Cherry pick API support for other block compression types from Luna branch. 2025-12-20 21:51:40 +01:00
Actions User
069323cfb8 [CI] Updating repo.json for 1.5.1.11
Some checks are pending
.NET Build / build (push) Waiting to run
2025-12-20 14:38:27 +00:00
Ottermandias
9aa566f521 Fix typo in new IPC providers. 2025-12-20 15:36:11 +01:00
Ottermandias
eff3784a85 Fix multi-release bug in texturearrayslicer. 2025-12-20 15:36:03 +01:00
Ottermandias
9cf7030f87 ...
Some checks failed
.NET Build / build (push) Has been cancelled
2025-12-19 01:13:08 +01:00
Actions User
deb3686df5 [CI] Updating repo.json for 1.5.1.9 2025-12-19 00:12:44 +00:00
Ottermandias
953f243caf . 2025-12-19 01:08:18 +01:00
Ottermandias
59fec5db82 Needs both versions for now due to flatsharp? 2025-12-19 01:05:50 +01:00
Ottermandias
37f3044376 Update dotnet. 2025-12-19 00:56:50 +01:00
Ottermandias
fb299d71f0 Remove unimplemented ipc. 2025-12-19 00:54:09 +01:00
Ottermandias
dbcb2e38ec Merge remote-tracking branch 'Exter-N/settings-sections' 2025-12-19 00:51:45 +01:00
Ottermandias
ebcbc5d98a Update SDK. 2025-12-19 00:51:39 +01:00
Ottermandias
febced0708 Fix bug in slicer. 2025-12-19 00:47:19 +01:00
Ottermandias
4c8ff40821 Fix private Unks.
Some checks are pending
.NET Build / build (push) Waiting to run
2025-12-18 20:47:49 +01:00
Ottermandias
7717251c6a Update to TerraFX. 2025-12-18 20:45:15 +01:00
Ottermandias
3e7511cb34 Update SDK.
Some checks are pending
.NET Build / build (push) Waiting to run
2025-12-17 18:33:10 +01:00
Karou
ccb5b01290 Api version bump and remove redundant framework thread call
Some checks failed
.NET Build / build (push) Has been cancelled
2025-12-05 13:39:19 +01:00
Actions User
5dd74297c6 [CI] Updating repo.json for 1.5.1.8
Some checks failed
.NET Build / build (push) Has been cancelled
2025-11-28 22:10:17 +00:00
Exter-N
338e3bc1a5 Update Penumbra.Api 2025-11-20 18:41:32 +01:00
Exter-N
e240a42a2c Replace GetPlugin(Delegate) stub by actual implementation 2025-11-13 19:55:32 +01:00
Exter-N
5be021b0eb Add integration settings sections 2025-11-13 19:53:50 +01:00
Karou
ce54aa5d25 Added IPC call to allow for redrawing only members of specified collections
Some checks failed
.NET Build / build (push) Has been cancelled
2025-11-03 15:15:40 +01:00
Actions User
c4b6e4e00b [CI] Updating repo.json for testing_1.5.1.7
Some checks failed
.NET Build / build (push) Has been cancelled
2025-10-23 21:50:20 +00:00
Ottermandias
912c183fc6 Improve file watcher. 2025-10-23 23:45:20 +02:00
Ottermandias
5bf901d0c4 Update actorobjectmanager when setting cutscene index.
Some checks are pending
.NET Build / build (push) Waiting to run
2025-10-23 17:30:29 +02:00
Ottermandias
cbedc878b9 Slight cleanup and autoformat. 2025-10-22 21:56:16 +02:00
Ottermandias
c8cf560fc1 Merge branch 'refs/heads/StoiaCode/fileWatcher' 2025-10-22 21:48:42 +02:00
Stoia
f05cb52da2 Add Option to notify instead of auto install.
And General Fixes
2025-10-22 18:20:44 +02:00
Ottermandias
7ed81a9823 Update OtterGui.
Some checks are pending
.NET Build / build (push) Waiting to run
2025-10-22 17:53:02 +02:00
Stoia
60aa23efcd
Merge branch 'xivdev:master' into fileWatcher 2025-10-22 14:28:08 +02:00
Ottermandias
ebbe957c95 Remove login screen log spam.
Some checks failed
.NET Build / build (push) Has been cancelled
2025-10-11 20:13:51 +02:00
Actions User
300e0e6d84 [CI] Updating repo.json for 1.5.1.6
Some checks failed
.NET Build / build (push) Has been cancelled
2025-10-07 10:45:04 +00:00
Ottermandias
049baa4fe4 Again. 2025-10-07 12:42:54 +02:00
Ottermandias
0881dfde8a Update signatures. 2025-10-07 12:27:35 +02:00
Actions User
23c0506cb8 [CI] Updating repo.json for testing_1.5.1.5
Some checks failed
.NET Build / build (push) Has been cancelled
2025-09-28 10:43:01 +00:00
Ottermandias
699745413e Make priority an int. 2025-09-28 12:40:52 +02:00
Actions User
eb53f04c6b [CI] Updating repo.json for testing_1.5.1.4
Some checks are pending
.NET Build / build (push) Waiting to run
2025-09-27 12:03:35 +00:00
Ottermandias
c6b596169c Add default constructor. 2025-09-27 14:01:21 +02:00
Actions User
a0c3e820b0 [CI] Updating repo.json for testing_1.5.1.3
Some checks are pending
.NET Build / build (push) Waiting to run
2025-09-27 11:02:39 +00:00
Ottermandias
a59689ebfe CS API update and add http API routes. 2025-09-27 13:00:18 +02:00
Exter-N
e9f67a009b Lift "shaders known" restriction for saving materials
Some checks failed
.NET Build / build (push) Has been cancelled
2025-09-19 11:18:39 +02:00
Ottermandias
97c8d82b33 Prevent default-named collection from being renamed and always put it at the top of the selector.
Some checks failed
.NET Build / build (push) Has been cancelled
2025-09-07 10:45:28 +02:00
Stoia
c3b00ff426 Integrate FileWatcher
HEAVY WIP
2025-09-06 14:22:18 +02:00
Actions User
6348c4a639 [CI] Updating repo.json for 1.5.1.2
Some checks failed
.NET Build / build (push) Has been cancelled
2025-09-02 14:25:55 +00:00
Ottermandias
5a6e06df3b git is stupid 2025-09-02 16:22:02 +02:00
Ottermandias
f5f6dd3246 Handle some TODOs. 2025-09-02 16:12:01 +02:00
Ottermandias
4e788f7c2b Update sig. 2025-09-02 11:51:59 +02:00
Ottermandias
ad1659caf6 Update libraries. 2025-09-02 11:29:58 +02:00
Ottermandias
18a6ce2a5f Merge branch 'refs/heads/Exter-N/cldapi'
Some checks are pending
.NET Build / build (push) Waiting to run
2025-09-01 15:59:26 +02:00
Ottermandias
e68e821b2a Merge branch 'master' into Exter-N/cldapi 2025-09-01 15:58:22 +02:00
Ottermandias
96764b34ca Merge branch 'refs/heads/Exter-N/restree-stuff' 2025-09-01 15:57:06 +02:00
Exter-N
2cf60b78cd Reject and warn about cloud-synced base directories 2025-08-31 06:42:45 +02:00
Exter-N
d59be1e660 Refine IsCloudSynced 2025-08-31 05:25:37 +02:00
Exter-N
5503bb32e0 CloudApi testing in Debug tab 2025-08-31 04:13:56 +02:00
Exter-N
f3ec4b2e08 Only display the file name and last dir for externals 2025-08-30 19:19:07 +02:00
Exter-N
b3379a9710 Stop redacting external paths 2025-08-30 16:55:20 +02:00
Exter-N
8c25ef4b47 Make the save button ResourceTreeViewer baseline 2025-08-30 16:53:12 +02:00
Ottermandias
912020cc3f Update for staging and wrong tooltip.
Some checks failed
.NET Build / build (push) Has been cancelled
2025-08-29 16:36:42 +02:00
Ottermandias
be8987a451 Merge branch 'master' of github.com:xivDev/Penumbra
Some checks are pending
.NET Build / build (push) Waiting to run
2025-08-28 18:52:29 +02:00
Ottermandias
f7cf5503bb Fix deleting PCP collections. 2025-08-28 18:52:06 +02:00
Ottermandias
a04a5a071c Add warning in file redirections if extension doesn't match. 2025-08-28 18:51:57 +02:00
Actions User
71e24c13c7 [CI] Updating repo.json for 1.5.1.0
Some checks failed
.NET Build / build (push) Has been cancelled
2025-08-25 08:39:42 +00:00
Ottermandias
c0120f81af 1.5.1.0 2025-08-25 10:37:38 +02:00
Ottermandias
da47c19aeb Woops, increment version. 2025-08-25 10:25:05 +02:00
Actions User
e16800f216 [CI] Updating repo.json for testing_1.5.0.10 2025-08-25 08:16:04 +00:00
Ottermandias
79a4fc5904 Fix wrong logging. 2025-08-25 10:13:48 +02:00
Ottermandias
bf90725dd2 Fix resolvecontext issue. 2025-08-25 10:13:39 +02:00
Ottermandias
a14347f73a Update temporary collection creation. 2025-08-25 10:13:31 +02:00
Actions User
1e07e43498 [CI] Updating repo.json for testing_1.5.0.9
Some checks are pending
.NET Build / build (push) Waiting to run
2025-08-24 13:51:43 +00:00
Ottermandias
f51f8a7bf8 Try to filter meta entries for relevance. 2025-08-24 15:24:57 +02:00
Exter-N
1fca78fa71 Add Kdb files to ResourceTree 2025-08-24 14:09:02 +02:00
Exter-N
c8b6325a87 Add game integrity message to On-Screen 2025-08-24 14:06:39 +02:00
Ottermandias
6079103505 Add collection PCP settings.
Some checks are pending
.NET Build / build (push) Waiting to run
2025-08-23 14:46:27 +02:00
Actions User
d302a17f1f [CI] Updating repo.json for testing_1.5.0.8
Some checks are pending
.NET Build / build (push) Waiting to run
2025-08-22 18:33:43 +00:00
Ottermandias
0d64384059 Add cleanup buttons to PCP, add option to turn off PCP IPC. 2025-08-22 20:31:40 +02:00
Ottermandias
10894d451a Add Pcp Events. 2025-08-22 18:08:22 +02:00
Actions User
fb34238530 [CI] Updating repo.json for testing_1.5.0.7 2025-08-22 13:51:50 +00:00
Ottermandias
8043e6fb6b Add option to disable PCP. 2025-08-22 15:49:15 +02:00
Ottermandias
e3b7f72893 Add initial PCP. 2025-08-22 15:44:33 +02:00
Ottermandias
b7f326e29c Fix bug with collection setting and empty collection. 2025-08-22 15:43:55 +02:00
Ottermandias
dad01e1af8 Update GameData. 2025-08-20 15:24:00 +02:00
Ottermandias
10b71930a1 Merge branch 'refs/heads/Exter-N/stockings-skin-slot' 2025-08-18 15:41:22 +02:00
Ottermandias
23257f94a4 Some cleanup and add option to disable skin material attribute scanning. 2025-08-18 15:41:10 +02:00
Ottermandias
83a36ed4cb Merge branch 'master' into Exter-N/stockings-skin-slot 2025-08-18 15:31:52 +02:00
Ottermandias
8304579d29 Add predefined tags to the multi mod selector. 2025-08-17 13:54:36 +02:00
Actions User
24cbc6c5e1 [CI] Updating repo.json for 1.5.0.6 2025-08-17 08:46:26 +00:00
Exter-N
41edc23820 Allow changing the skin mtrl suffix 2025-08-17 03:11:11 +02:00
Exter-N
aa920b5e9b Fix ImGui texture usage issue 2025-08-17 01:41:49 +02:00
Ottermandias
87ace28bcf Update OtterGui. 2025-08-16 11:56:24 +02:00
Ottermandias
5917f5fad1 Small fixes. 2025-08-13 17:42:45 +02:00
Actions User
f69c264317 [CI] Updating repo.json for 1.5.0.5 2025-08-13 14:53:11 +00:00
Ottermandias
a7246b9d98 Add PBD Post-Processor that appends EPBD data if the loaded PBD does not contain it. 2025-08-13 16:50:26 +02:00
Actions User
9aff388e21 [CI] Updating repo.json for 1.5.0.4 2025-08-12 12:53:33 +00:00
Ottermandias
091aff1b8a Merge branch 'master' of github.com:xivDev/Penumbra 2025-08-12 14:47:50 +02:00
Ottermandias
9f8185f67b Add new parameter to LoadWeapon hook. 2025-08-12 14:47:35 +02:00
Actions User
b112d75a27 [CI] Updating repo.json for 1.5.0.3 2025-08-12 10:31:13 +00:00
Ottermandias
7af81a6c18 Fix issue with removing default metadata. 2025-08-12 12:29:09 +02:00
Ottermandias
12a218bb2b Protect against empty requested paths. 2025-08-12 12:28:56 +02:00
Ottermandias
f6bac93db7 Update ChangedEquipData. 2025-08-11 19:58:24 +02:00
Actions User
155d3d49aa [CI] Updating repo.json for 1.5.0.2 2025-08-09 16:40:42 +00:00
Exter-N
9aae2210a2 Fix nullptr crashes 2025-08-09 14:57:15 +02:00
Actions User
3785a629ce [CI] Updating repo.json for 1.5.0.1 2025-08-09 11:03:24 +00:00
Ottermandias
02af52671f Need staging again ... 2025-08-09 13:00:40 +02:00
Ottermandias
391c9d727e Fix shifted timeline vfunc offset. 2025-08-09 12:51:39 +02:00
Ottermandias
ff2b2be953 Fix popups not working early. 2025-08-09 12:11:29 +02:00
Ottermandias
6242b30f93 Fix resizable child. 2025-08-09 11:58:35 +02:00
Exter-N
11cd08a9de ClientStructs-ify stuff 2025-08-09 10:29:29 +02:00
Ottermandias
46cfbcb115 Set Repo API level to 13 and remove stg from future releases. 2025-08-08 23:13:23 +02:00
Actions User
66543cc671 [CI] Updating repo.json for 1.5.0.0 2025-08-08 21:12:00 +00:00
Ottermandias
13283c9690 Fix dumb. 2025-08-08 23:08:26 +02:00
Ottermandias
bedfb22466 Use staging for release. 2025-08-08 23:04:50 +02:00
Ottermandias
13df8b2248 Update gamedata. 2025-08-08 23:02:22 +02:00
Ottermandias
93406e4d4e 1.5.0.0 2025-08-08 16:17:59 +02:00
Ridan Vandenbergh
8140d08557 Add vertex material types for usages of 2 colour attributes 2025-08-08 16:15:19 +02:00
Ridan Vandenbergh
2b36f39848 Fix basecolor texture in material export 2025-08-08 16:12:37 +02:00
Ottermandias
a69811800d Update GameData 2025-08-08 15:56:25 +02:00
Ottermandias
3f18ad50de Initial API13 / 7.3 update. 2025-08-08 00:45:24 +02:00
Ridan Vandenbergh
6689e326ee Material tab: disallow "Enable Transparency" for stockings shader 2025-08-02 00:38:24 +02:00
Passive
bdcab22a55 Cleanup methods to extension class 2025-08-02 00:16:55 +02:00
Passive
f5f4fe7259 Invalid tangent fix example 2025-08-02 00:16:55 +02:00
Sebastina
898963fea5 Allow focusing a specified mod via HTTP API under the mods tab. 2025-08-02 00:16:38 +02:00
Ottermandias
8527bfa29c Fix missing updates for OtterGui. 2025-08-02 00:13:35 +02:00
Ottermandias
baca3cdec2 Update Libs. 2025-08-02 00:08:09 +02:00
Ottermandias
dc93eba34c Add initial complex group things. 2025-08-02 00:06:25 +02:00
Ottermandias
012052daa0 Change behavior for directory names. 2025-08-02 00:06:03 +02:00
Ottermandias
a9546e31ee Update packages. 2025-08-02 00:05:27 +02:00
Actions User
a4a6283e7b [CI] Updating repo.json for testing_1.4.0.6 2025-07-14 15:12:06 +00:00
Ottermandias
00c02fd16e Fix tex file migration for small textures. 2025-07-14 17:09:07 +02:00
Ottermandias
140d150bb4 Fix character sound data. 2025-07-14 17:08:46 +02:00
Actions User
49a6d935f3 [CI] Updating repo.json for testing_1.4.0.5 2025-07-05 20:11:28 +00:00
Ottermandias
692beacc2e Merge remote-tracking branch 'Exter-N/human-skin-materials' 2025-07-05 22:04:48 +02:00
Ottermandias
a953febfba Add support for imc-toggle attributes to accessories, and fix up attributes when item swapping models. 2025-07-05 22:03:32 +02:00
Ottermandias
c0aa2e36ea Merge branch 'refs/heads/Exter-N/reslogger-tid' 2025-07-05 22:03:14 +02:00
Exter-N
278bf43b29 ClientStructs-ify ResourceTree stuff 2025-07-05 05:20:24 +02:00
Exter-N
a97d9e4953 Add Human skin material handling 2025-07-05 04:37:37 +02:00
Exter-N
30e3cd1f38 Add OS thread ID info to the Resource Logger 2025-07-04 19:41:31 +02:00
Ottermandias
62e9dc164d Add support button. 2025-06-26 14:49:28 +02:00
Actions User
9fc572ba0c [CI] Updating repo.json for testing_1.4.0.4 2025-06-15 21:47:41 +00:00
Ottermandias
3c20b541ce Make mousewheel-scrolling work for setting combos, also filters. 2025-06-15 23:20:13 +02:00
Ottermandias
1961b03d37 Fix issues with shapes and attributes with ID. 2025-06-15 23:18:46 +02:00
Ottermandias
1f4ec984b3 Use improved filesystem. 2025-06-13 17:27:56 +02:00
Ottermandias
4981b0348f BNPCs. 2025-06-13 17:27:56 +02:00
Ottermandias
a8c05fc6ee Make middle-mouse button handle temporary settings. 2025-06-13 17:27:56 +02:00
Actions User
3d05662384 [CI] Updating repo.json for testing_1.4.0.3 2025-06-08 09:38:30 +00:00
Ottermandias
973814b31b Some more BNPCs. 2025-06-08 11:36:32 +02:00
Ottermandias
a16fd85a7e Handle .tex files with broken mip map offsets on import, also remove unnecessary mipmaps (any after reaching minimum size once). 2025-06-08 11:28:12 +02:00
Ottermandias
4c0e6d2a67 Update Mod Merger for other group types. 2025-06-07 22:10:59 +02:00
Ottermandias
535694e9c8 Update some BNPC Names. 2025-06-07 22:10:17 +02:00
Ottermandias
318a41fe52 Add checking for supported features with the currently new supported features 'Atch', 'Shp' and 'Atr'. 2025-06-03 18:39:54 +02:00
Actions User
98203e4e8a [CI] Updating repo.json for testing_1.4.0.2 2025-06-01 11:06:37 +00:00
Ottermandias
6cba63ac98 Make shape names editable in models. 2025-06-01 13:04:26 +02:00
Ottermandias
b48c4f440a Make attributes and shapes completely toggleable. 2025-06-01 13:04:26 +02:00
Actions User
75f4e66dbf [CI] Updating repo.json for 1.4.0.1 2025-05-30 12:38:32 +00:00
Ottermandias
74bd1cf911 Fix checking the flags for all races and genders for specific IDs in shapes/attributes. 2025-05-30 14:36:33 +02:00
Ottermandias
ff2a9f95c4 Fix Atr and Shp not being transmitted via Mare, add improved compression but don't use it yet. 2025-05-30 14:36:07 +02:00
Ottermandias
9921c3332e Merge branch 'master' of github.com:xivDev/Penumbra 2025-05-30 14:35:24 +02:00
Ottermandias
f2927290f5 Fix exceptions when unsubscribing during event invocation. 2025-05-30 14:35:13 +02:00
Actions User
1551d9b6f3 [CI] Updating repo.json for 1.4.0.0 2025-05-28 11:56:49 +00:00
Ottermandias
5e985f4a84 1.4.0.0 2025-05-28 13:54:42 +02:00
Ottermandias
2c115eda94 Slightly improve error message when importing wrongly named atch files. 2025-05-28 13:54:23 +02:00
Ottermandias
ebe45c6a47 Update Lib. 2025-05-27 11:33:10 +02:00
Ottermandias
82fc334be7 Use dynamis for some pointers. 2025-05-23 15:17:19 +02:00
Actions User
cd56163b1b [CI] Updating repo.json for testing_1.3.6.15 2025-05-23 09:32:11 +00:00
Ottermandias
ccc2c1fd4c Fix missing other option notifications for shp/atr. 2025-05-23 11:30:10 +02:00
Ottermandias
08c9124858 Fix issue with shapes/attributes not checking the groups correctly. 2025-05-23 11:29:52 +02:00
Ottermandias
1bdbfe22c1 Update Libraries. 2025-05-23 10:50:04 +02:00
Actions User
9e7c304556 [CI] Updating repo.json for testing_1.3.6.14 2025-05-22 09:16:22 +00:00
Ottermandias
bc4f88aee9 Fix shape/attribute mask stupidity. 2025-05-22 11:14:17 +02:00
Ottermandias
400d7d0bea Slight improvements. 2025-05-22 11:13:58 +02:00
Ottermandias
ac4c75d3c3 Fix not updating meta count correctly. 2025-05-22 11:13:42 +02:00
Ottermandias
507b0a5aee Slight description update. 2025-05-21 18:07:17 +02:00
Actions User
f5db888bbd [CI] Updating repo.json for testing_1.3.6.13 2025-05-21 13:49:29 +00:00
Ottermandias
d7dee39fab Add attribute handling, rework atr and shape caches. 2025-05-21 15:45:05 +02:00
Ottermandias
3412786282 Optimize used memory by metadictionarys a bit. 2025-05-21 15:45:05 +02:00
Ottermandias
861cbc7759 Add global EQP edits to always hide horns or ears. 2025-05-21 15:45:05 +02:00
Actions User
fefa3852f7 [CI] Updating repo.json for testing_1.3.6.12 2025-05-19 15:17:54 +00:00
Ottermandias
68b68d6ce7 Fix some issues with customization IDs and supported counts. 2025-05-19 17:15:29 +02:00
Ottermandias
47b5895404 Fix issue with temp settings again. 2025-05-18 22:00:17 +02:00
Actions User
e18e4bb0e1 [CI] Updating repo.json for testing_1.3.6.11 2025-05-18 14:02:16 +00:00
Ottermandias
6e4e28fa00 Fix disabling conditional shapes. 2025-05-18 16:00:09 +02:00
Ottermandias
e326e3d809 Update shp conditions. 2025-05-18 15:52:47 +02:00
Ottermandias
fbc4c2d054 Improve option select combo. 2025-05-18 12:54:23 +02:00
Ottermandias
3078c467d0 Fix issue with empty and temporary settings. 2025-05-18 12:54:23 +02:00
Ottermandias
52927ff06b Fix clipping in meta edits. 2025-05-18 12:54:23 +02:00
Actions User
08e8b9d2a4 [CI] Updating repo.json for testing_1.3.6.10 2025-05-15 22:28:36 +00:00
Ottermandias
f1448ed947 Add conditional connector shapes. 2025-05-16 00:25:13 +02:00
Ottermandias
c0dcfdd835 Update shape string format. 2025-05-15 22:23:42 +02:00
Actions User
70295b7a6b [CI] Updating repo.json for testing_1.3.6.9 2025-05-15 15:50:16 +00:00
Ottermandias
480942339f Add draggable mod selector width. 2025-05-15 17:47:32 +02:00
Ottermandias
6ad0b4299a Add shape meta manipulations and rework attribute hook. 2025-05-15 17:46:53 +02:00
Ottermandias
0adec35848 Add initial support for custom shapes. 2025-05-15 00:26:59 +02:00
Ottermandias
0fe4a3671a Improve small issue with redraw service. 2025-05-08 23:46:25 +02:00
Caraxi
363d115be8 Add filter for temporary mods 2025-04-19 23:14:39 +02:00
Ottermandias
7595827d29 Merge branch 'master' of github.com:xivDev/Penumbra 2025-04-19 23:12:02 +02:00
Ottermandias
117724b0ae Update npc names. 2025-04-19 23:11:45 +02:00
Ottermandias
a5d221dc13 Make temporary mode checkbox more visible. 2025-04-18 00:17:07 +02:00
Ottermandias
cbebfe5e99 Fix sizing of mod panel. 2025-04-17 01:06:58 +02:00
Ottermandias
0c768979d4 Don't use DalamudPackager for no reason. 2025-04-17 01:06:22 +02:00
Ottermandias
53ef42adfa Update EST Customization identification. 2025-04-17 01:06:09 +02:00
Ottermandias
0954f50912 Update OtterGui, GameData, Namespaces. 2025-04-17 01:05:56 +02:00
Actions User
5d5fc673b1 [CI] Updating repo.json for 1.3.6.8 2025-04-10 14:42:26 +00:00
Ottermandias
2bd0c89588 Better item sort for item swap selectors. 2025-04-10 16:04:49 +02:00
Ottermandias
f03a139e0e blech 2025-04-10 00:17:23 +02:00
Ottermandias
f9b5a626cf Add some migration stuff. 2025-04-10 00:02:49 +02:00
Ottermandias
dc336569ff Add context to copy the full file path from redirections. 2025-04-10 00:02:36 +02:00
Ottermandias
0ec6a17ac7 Add context to open backup directory. 2025-04-10 00:02:21 +02:00
Ottermandias
129156a1c1 Add some more safety and better IPC for draw object storage. 2025-04-09 15:04:47 +02:00
Ottermandias
33ada1d994 Remove meta-default-value checking from TT imports, move it entirely to mod loads, and keep default-valued entries if other options actually edit the same entry. 2025-04-08 16:56:23 +02:00
Ottermandias
0afcae4504 Run API redraws on framework. 2025-04-05 18:49:30 +02:00
Ottermandias
93e60471de Update for new objectmanager. 2025-04-05 18:49:18 +02:00
Actions User
5437ab477f [CI] Updating repo.json for 1.3.6.7 2025-04-05 12:44:47 +00:00
Ottermandias
3b54485127 Maybe fix AtchCaller crashes. 2025-04-05 14:42:25 +02:00
Ottermandias
c3b2443ab5 Add Incognito modifier. 2025-04-04 22:35:23 +02:00
Actions User
2fdafc5c85 [CI] Updating repo.json for 1.3.6.6 2025-04-02 21:45:19 +00:00
Ottermandias
09c2264de4 Revert overeager BNPC Name update. 2025-04-02 23:41:08 +02:00
Ottermandias
c3be151d40 Maybe fix crash issue in AtchHook1 / issue with kept draw object links. 2025-04-02 23:37:06 +02:00
Exter-N
abb47751c8 Mtrl editor: Disregard obsolete modded ShPks 2025-03-30 20:32:03 +02:00
Exter-N
1d517103b3 Mtrl editor: Fix texture pinning 2025-03-30 20:32:03 +02:00
Actions User
fe5d1bc36e [CI] Updating repo.json for 1.3.6.5 2025-03-30 16:08:59 +00:00
Exter-N
b589103b05 Make resolvedData thread-local 2025-03-30 13:56:32 +02:00
Actions User
cc76125b1c [CI] Updating repo.json for 1.3.6.4 2025-03-29 17:07:46 +00:00
Ottermandias
f3bcc4d554 Update changelog. 2025-03-29 18:05:47 +01:00
Ottermandias
2dd6dd201c Update PAP records. 2025-03-29 18:03:57 +01:00
Exter-N
cb0214ca2f Fix material editor and improve pinning logic 2025-03-29 16:55:44 +01:00
Exter-N
5a5a1487a3 Fix texture naming in Resource Trees 2025-03-29 16:55:44 +01:00
Actions User
de408e4d58 [CI] Updating repo.json for 1.3.6.3 2025-03-28 17:33:26 +00:00
Ottermandias
a1bf26e7e8 Run HTTP redraws on framework thread. 2025-03-28 18:30:26 +01:00
Actions User
3bb7db10fb [CI] Updating repo.json for 1.3.6.2 2025-03-28 16:29:20 +00:00
Ottermandias
8a68a1bff5 Update GameData. 2025-03-28 17:25:03 +01:00
Ottermandias
01e6f58463 Add Launching IPC Event. API 5.8 2025-03-28 16:53:50 +01:00
Actions User
7498bc469f [CI] Updating repo.json for 1.3.6.1 2025-03-28 14:55:12 +00:00
Ottermandias
23ba77c107 Update build step and check for pre 7.2 shps. 2025-03-28 15:52:40 +01:00
Ottermandias
1a1d1c1840 Revert Dalamud staging on release, and update api level. 2025-03-28 14:10:52 +01:00
Actions User
b019da2a8c [CI] Updating repo.json for 1.3.6.0 2025-03-28 13:09:26 +00:00
Ottermandias
60becf0a09 Use staging build for release for now. 2025-03-28 14:06:21 +01:00
Ottermandias
974b215610 1.3.6.0 2025-03-28 13:58:11 +01:00
Ottermandias
8e191ae075 Fix offsets. 2025-03-28 13:33:43 +01:00
Ottermandias
b189ac027b Fix imgui assert. 2025-03-28 02:29:49 +01:00
Ottermandias
6cbc8bd58f Merge remote-tracking branch 'Exter-N/72' 2025-03-28 00:59:14 +01:00
Exter-N
49f077aca0 Fixes for 7.2 (ResourceTree + ShPk 13.1) 2025-03-27 22:32:07 +01:00
Ottermandias
525d1c6bf9 Update GameData. 2025-03-27 18:18:04 +01:00
Ottermandias
124b54ab04 Update GameData. 2025-03-27 16:00:30 +01:00
Ottermandias
b8b2127a5d Update STM and signatures. 2025-03-27 15:53:59 +01:00
Ottermandias
586bd9d0cc Re-add wrong dependencies. 2025-03-27 12:07:45 +01:00
Ottermandias
03bb07a9c0 Update for SDK. 2025-03-27 12:04:38 +01:00
Ottermandias
279a861582 Fix error in parser. 2025-03-16 22:17:37 +01:00
Ottermandias
82a1271281 Add option to import atch files from the mod itself via context. 2025-03-16 15:46:51 +01:00
Ottermandias
26a6cc4735 Fix clipping in changed items panel without grouping. 2025-03-16 15:46:51 +01:00
Ottermandias
61d70f7b4e Fix identification of EST changes. 2025-03-16 15:46:51 +01:00
Ottermandias
0213096c58 Add BodyHideGloveCuffs name to eqp entries. 2025-03-16 15:46:51 +01:00
Actions User
dc47a08988 [CI] Updating repo.json for testing_1.3.5.1 2025-03-13 23:20:54 +00:00
Ottermandias
83574dfeb1 Merge remote-tracking branch 'Exter-N/better-tex' 2025-03-14 00:16:33 +01:00
Ottermandias
87f44d7a88 Some minor parser fixes thanks to Anna. 2025-03-14 00:13:57 +01:00
Ottermandias
cda6a4c420 Make preferred changed item star more noticeable, and make the color configurable. 2025-03-14 00:13:01 +01:00
Exter-N
4093228e61 Improve wording of block compressions (suggested by @Theo-Asterio) 2025-03-12 23:04:57 +01:00
Exter-N
442ae960cf Add encoding support for BC1, BC4 and BC5 2025-03-12 20:03:53 +01:00
Exter-N
e7f7077e96 Simplify passing of the device (suggested by @rootdarkarchon) 2025-03-12 15:18:20 +01:00
Exter-N
e5620e17e0 Improve texture saving 2025-03-12 01:20:36 +01:00
Ottermandias
93b0996794 Add chat command to clear temporary settings. 2025-03-11 18:13:08 +01:00
Actions User
1d70be8060 [CI] Updating repo.json for 1.3.5.0 2025-03-09 22:16:58 +00:00
Ottermandias
eab98ec0e4 1.3.5.0 2025-03-09 14:41:45 +01:00
Ottermandias
861b7b78cd Merge branch 'master' of github.com:xivDev/Penumbra 2025-03-09 13:48:56 +01:00
Ottermandias
6eacc82dcd Update references. 2025-03-09 13:48:41 +01:00
Ottermandias
1afbbfef78 Update NuGet packages. 2025-03-09 13:39:41 +01:00
Ottermandias
7cf0367361 Try moving extracted folders 3 times for unknown issues. 2025-03-09 13:39:25 +01:00
Ottermandias
0b0c92eb09 Some cleanup. 2025-03-02 14:27:40 +01:00
Actions User
34d51b66aa [CI] Updating repo.json for testing_1.3.4.6 2025-03-01 21:37:03 +00:00
Ottermandias
cda9b1df65 Fix weapon identification bug. 2025-03-01 22:34:50 +01:00
Ottermandias
509f11561a Add preferred changed items to mods. 2025-03-01 22:21:36 +01:00
Ottermandias
13adbd5466 Allow configuration of the changed item display. 2025-03-01 16:56:02 +01:00
Actions User
26985e01a2 [CI] Updating repo.json for testing_1.3.4.5 2025-02-28 23:37:03 +00:00
Ottermandias
deba8ac910 Heavily improve changed item display. 2025-03-01 00:33:56 +01:00
Ottermandias
1ebe4099d6 Add ImGuiCacheService. 2025-02-27 17:51:27 +01:00
Ottermandias
c6de7ddebd Improve GamePaths and parsing, add support for identifying skeletons and phybs. 2025-02-27 13:08:41 +01:00
Ottermandias
8860d1e39a Fix an exception in incognito names in weird cutscene cases. 2025-02-27 06:01:08 +01:00
Ottermandias
2413424c8a Merge branch 'rt-more-files' 2025-02-27 05:51:43 +01:00
Ottermandias
9b25193d4e ImUtf8 and null-check cleanup. 2025-02-27 05:51:25 +01:00
Ottermandias
70844610d8 Primary constructor and some null-check cleanup. 2025-02-27 05:45:06 +01:00
Ottermandias
e4cfd674ee Probably unnecessary size optimization. 2025-02-27 05:39:19 +01:00
Ottermandias
776a93dc73 Some null-check cleanup. 2025-02-27 05:38:56 +01:00
Exter-N
514b0e7f30 Add file types to Resource Tree and require Ctrl+Shift for some quick imports 2025-02-27 00:10:24 +01:00
Actions User
4a00d82921 [CI] Updating repo.json for testing_1.3.4.4 2025-02-20 18:20:23 +00:00
Ottermandias
fdd75e2866 Use Meta Compression V1. 2025-02-20 19:17:55 +01:00
Ottermandias
b2860c1047 Merge branch 'refs/heads/adamm789/model-export' 2025-02-20 18:38:21 +01:00
Ottermandias
1f172b4632 Make default constructed models use V6 instead of V5. 2025-02-20 18:37:15 +01:00
Ottermandias
d40c59eee9 Slight cleanup. 2025-02-20 18:36:46 +01:00
Ottermandias
f8d0616acd Notify when an unhandled UV count is reached. 2025-02-20 18:36:33 +01:00
Ottermandias
31f23024a4 Notify and fail when a list of vertex usages has more than one entry where this is not expected. 2025-02-20 18:36:08 +01:00
Adam Moy
6d2b72e079 Removed irrelevant comments 2025-02-20 18:13:53 +01:00
Adam Moy
b76626ac8d Added VertexTexture3
Not sure of accuracy but followed existing pattern
2025-02-20 18:13:53 +01:00
Adam Moy
579969a9e1 Using LINQ
And also change types from using LINQ
2025-02-20 18:13:53 +01:00
Adam Moy
2f0bf19d00 Use First().Value 2025-02-20 18:13:53 +01:00
Adam Moy
ef26049c53 Consider VertexElement's UsageIndex
Allows VertexDeclarations to have multiple VertexElements of the same Type but different UsageIndex
2025-02-20 18:13:53 +01:00
Actions User
a73dee83b3 [CI] Updating repo.json for testing_1.3.4.3 2025-02-18 14:12:54 +00:00
Ottermandias
41672c31ce Update message slightly. 2025-02-18 15:10:16 +01:00
Ottermandias
a561e70410 Add option to always work in temporary settings. 2025-02-17 17:39:48 +01:00
Ottermandias
b7b9defaa6 Add context menu to clear temporary settings. 2025-02-17 17:39:48 +01:00
Actions User
79938b6dd0 [CI] Updating repo.json for testing_1.3.4.2 2025-02-15 15:50:18 +00:00
Ottermandias
40f24344af Update OtterGui. 2025-02-15 16:46:39 +01:00
Ottermandias
93e184c9a5 Add import of .atch files into metadata. 2025-02-15 16:46:39 +01:00
Ottermandias
2be5bd0611 Make EQP swaps also swap multi-slot items correctly. 2025-02-15 16:46:39 +01:00
Actions User
f89eab8b2b [CI] Updating repo.json for testing_1.3.4.1 2025-02-13 15:42:58 +00:00
Ottermandias
a9a556eb55 Add CheckCurrentChangedItemFunc, 2025-02-13 13:43:54 +01:00
Ottermandias
0af9667789 Add changed item adapters. 2025-02-12 16:44:22 +01:00
Ottermandias
60b9facea3 Cont. 2025-02-09 15:27:32 +01:00
Ottermandias
50c4207844 Give messages for unsupported file redirection types. 2025-02-09 15:12:34 +01:00
Ottermandias
9b18ffce66 Updated submodule Versions. 2025-02-06 16:58:48 +01:00
Actions User
214be98662 [CI] Updating repo.json for 1.3.4.0 2025-02-06 15:55:30 +00:00
Ottermandias
f9952ada75 1.3.4.0 2025-02-06 16:22:08 +01:00
Ottermandias
3ba2563e0b Merge branch 'master' of github.com:xivDev/Penumbra 2025-02-03 17:43:49 +01:00
Ottermandias
4cc5041f0a Improve cleanup. 2025-02-03 17:43:44 +01:00
Exter-N
f9b163e7c5 Add explanations on why paths are redacted 2025-02-03 17:13:04 +01:00
Exter-N
981c2bace4 Fix out-of-root path detection logic 2025-02-03 17:13:04 +01:00
Ottermandias
ec09a7eb0e Add initial cleaning functions, to be improved. 2025-01-31 18:46:17 +01:00
Ottermandias
7022b37043 Add some improved Mod Setting API. 2025-01-31 15:31:05 +01:00
Ottermandias
64748790cc Make limits a bit cleaner. 2025-01-30 14:06:39 +01:00
Theo
b0a8b1baa5 Bone and Material Limit updates.
Fix UI in Models tab to allow for more than 4 Materials per DT spec.
2025-01-30 13:57:43 +01:00
Actions User
ac64b4db24 [CI] Updating repo.json for testing_1.3.3.10 2025-01-25 13:01:04 +00:00
Ottermandias
e508e6158f Merge branch 'async-stuff'
# Conflicts:
#	Penumbra/Interop/Hooks/ResourceLoading/ResourceLoader.cs
2025-01-25 13:55:54 +01:00
Ottermandias
4d26a63944 Test disabling MtrlForceSync. 2025-01-25 13:55:13 +01:00
Ottermandias
30a957356a Minor changes. 2025-01-25 13:54:19 +01:00
Ottermandias
9ab8985343 Debug logging. 2025-01-25 12:38:10 +01:00
Exter-N
a3ddce0ef5 Add mechanism to handle completion of async res loads 2025-01-24 02:50:02 +01:00
Actions User
0159eb3d83 [CI] Updating repo.json for testing_1.3.3.9 2025-01-23 17:13:52 +00:00
Ottermandias
55ce633832 Try forcing IMC files to load synchronously for now. 2025-01-23 18:11:35 +01:00
Ottermandias
40168d7daf Fix issue with IPC adding mods before character utility is ready in rare cases. 2025-01-22 23:14:09 +01:00
Actions User
dcab443b2f [CI] Updating repo.json for testing_1.3.3.8 2025-01-22 16:38:33 +00:00
Ottermandias
dcc4354777 Fix clipping height in changed items tab. 2025-01-22 17:36:13 +01:00
Ottermandias
2afd6b966e Add debug logging facilities. 2025-01-22 17:36:01 +01:00
Actions User
737e74582b [CI] Updating repo.json for testing_1.3.3.7 2025-01-20 19:36:05 +00:00
Ottermandias
39c73af238 Fix stupid. 2025-01-20 20:33:35 +01:00
Actions User
9ca0145a7f [CI] Updating repo.json for testing_1.3.3.6 2025-01-20 16:48:19 +00:00
Ottermandias
0c8571fba9 Reduce and pad IMC allocations and log allocations. 2025-01-20 17:14:13 +01:00
Ottermandias
8779f4b689 Add new cutscene ENPC tracking hooks. 2025-01-20 15:36:05 +01:00
Ottermandias
7b517390b6 Fix temporary settings causing collection saves. 2025-01-20 15:30:03 +01:00
Ottermandias
7d75c7d7a5 Merge branch 'json-schema' 2025-01-20 15:13:20 +01:00
Ottermandias
4f0428832c Fix solution file for schemas. 2025-01-20 15:13:09 +01:00
Exter-N
b62563d721 Remove $id from shpk_devkit schema 2025-01-17 20:06:21 +01:00
Ottermandias
ec3ec7db4e update schema organization anf change some things. 2025-01-17 19:55:02 +01:00
Ottermandias
5f8377acaa Update mod loading structure. 2025-01-17 19:54:40 +01:00
Exter-N
3b8aac8eca Add schema for Material Development Kit files 2025-01-17 18:50:00 +01:00
Exter-N
a1931a93fb Add drafts of JSON schemas 2025-01-17 01:45:37 +01:00
Actions User
df148b556a [CI] Updating repo.json for testing_1.3.3.5 2025-01-16 16:25:18 +00:00
Ottermandias
bdc2da95c4 Make mods write empty containers again for now. 2025-01-16 17:22:25 +01:00
Actions User
1462891bd3 [CI] Updating repo.json for testing_1.3.3.4 2025-01-15 17:05:31 +00:00
Ottermandias
d2a8cec01f Merge branch 'combining' 2025-01-15 17:44:58 +01:00
Ottermandias
795fa7336e Update with workable prototype. 2025-01-15 17:44:22 +01:00
Ottermandias
e77fa18c61 Start for combining groups. 2025-01-15 14:25:15 +01:00
Ottermandias
9559bd7358 Improve RSP Identifier ToString. 2025-01-14 15:20:37 +01:00
Ottermandias
9c25fab183 Increase API minor version. 2025-01-14 14:41:32 +01:00
Ottermandias
cc981eba15 Fix used dye channel in material editor previews. 2025-01-14 14:34:34 +01:00
Ottermandias
30a4b90e84 Add IPC for querying temporary settings. 2025-01-14 14:34:18 +01:00
Ottermandias
82689467aa Add counts to multi mod selection. 2025-01-12 00:03:36 +01:00
Ottermandias
415e15f3b1 Fix another issue with temporary mod settings. 2025-01-11 21:12:21 +01:00
Actions User
3687c99ee6 [CI] Updating repo.json for testing_1.3.3.3 2025-01-11 17:02:43 +00:00
Ottermandias
6ea38eac0a Share PeSigScanner and use in RenderTargetHdrEnabler because of ReShade. 2025-01-11 17:59:50 +01:00
Actions User
7f52777fd4 [CI] Updating repo.json for testing_1.3.3.2 2025-01-11 14:58:57 +00:00
Ottermandias
2753c786fc Only put out warnings if the path is rooted. 2025-01-11 15:55:14 +01:00
Ottermandias
7b2e82b27f Add some HDR related debug data and support info. 2025-01-11 15:22:04 +01:00
Ottermandias
aebd22ed64 Merge branch 'rt-hdr' 2025-01-11 14:21:12 +01:00
Actions User
c99a7884bb [CI] Updating repo.json for 1.3.3.1 2025-01-11 12:49:05 +00:00
Ottermandias
e73b3e85bd Autoformat and remove nagging. 2025-01-11 13:46:44 +01:00
Ottermandias
0758739666 Cleanup UI code. 2025-01-11 13:46:08 +01:00
Ottermandias
d4e6688369 Fix issue when empty settings are turned temporary. 2025-01-11 13:26:51 +01:00
Actions User
e6872cff64 [CI] Updating repo.json for 1.3.3.0 2025-01-10 19:00:27 +00:00
Ottermandias
b83564bce8 1.3.3.0 2025-01-10 19:55:33 +01:00
Exter-N
e8300fc5c8 Improve RT-HDR texture comments 2025-01-09 20:42:48 +01:00
Exter-N
f07780cf7b Add RenderTargetHdrEnabler 2025-01-08 20:02:14 +01:00
Ottermandias
349241d0ab Better attribution of authors in item swap. 2025-01-07 16:49:19 +01:00
Ottermandias
1845c4b89b Merge branch 'master' of github.com:xivDev/Penumbra 2025-01-07 16:11:38 +01:00
Ottermandias
756537c776 Add Turn Permanent button for temporary settings and improve buttons, make secure. 2025-01-07 16:11:26 +01:00
Ottermandias
9a457a1a95 Add debug panel to check changed item identification for paths. 2025-01-07 16:11:05 +01:00
Ottermandias
af7a8fbddd Fix bug with atch counter. 2025-01-07 16:10:37 +01:00
N. Lo.
0eed5f1707 Add a watched plugin to Support Info 2025-01-06 17:56:58 +01:00
Actions User
6374362b28 [CI] Updating repo.json for testing_1.3.2.2 2024-12-31 17:05:32 +00:00
Ottermandias
7da5d73b47 Keep enabled and priority at the top of settings, add button to turn temporary. 2024-12-31 17:56:58 +01:00
Ottermandias
a2258e6160 Add some temporary context menu things. 2024-12-31 17:54:16 +01:00
Ottermandias
dbef1cccb2 Fix stuff after submodule update. 2024-12-31 17:10:09 +01:00
Ottermandias
653f6269b7 Update submodule. 2024-12-31 16:38:15 +01:00
Ottermandias
a5d8baebca Merge branch 'TempSettings' 2024-12-31 16:36:59 +01:00
Ottermandias
cff482a2ed Allow non-locking, negative identifier-locks 2024-12-31 16:36:46 +01:00
Ottermandias
5f9cbe9ab1 Current State. 2024-12-31 15:40:25 +01:00
Ottermandias
282189ef6d Current State. 2024-12-31 15:40:25 +01:00
Ottermandias
98a89bb2b4 Current state. 2024-12-31 15:40:25 +01:00
Ottermandias
67305d507a Extract ModCollectionIdentity. 2024-12-31 15:40:24 +01:00
Ottermandias
fbbfe5e00d Extract collection counters. 2024-12-31 15:40:24 +01:00
Ottermandias
7a2691b942 Add colors for temporary settings. 2024-12-31 15:40:24 +01:00
Ottermandias
50b5eeb700 Add FullModSettings struct. 2024-12-31 15:40:24 +01:00
Ottermandias
2483f3dcdf Add Temporary Settings class 2024-12-31 15:40:24 +01:00
Ottermandias
0e2364497f Maybe fix mtrl file issues. 2024-12-30 00:33:46 +01:00
Ottermandias
25d0a2c9a8 Fix issue with ring IMCs in resource tree. 2024-12-29 23:04:43 +01:00
Actions User
f24056ea31 [CI] Updating repo.json for testing_1.3.2.1 2024-12-25 23:08:52 +00:00
Ottermandias
b3883c1306 Add handling for cached TMBs. 2024-12-26 00:06:51 +01:00
Ottermandias
f679e0ccee Fix some imgui assertions. 2024-12-25 22:22:30 +01:00
Ottermandias
d5e575423b Merge branch 'master' of github.com:xivDev/Penumbra 2024-12-17 18:04:34 +01:00
Ottermandias
18288815b2 Add partial copying of color and colordye tables. 2024-12-17 18:04:17 +01:00
Ottermandias
cc97ea0ce9 Add an option to automatically select the collection assigned to the current character on login. 2024-12-16 17:52:57 +01:00
Actions User
b5a469c524 [CI] Updating repo.json for 1.3.2.0 2024-12-13 17:13:38 +00:00
Ottermandias
510b9a5f1f 1.3.2.0 2024-12-13 18:11:17 +01:00
Ottermandias
5db3d53994 Small improvements. 2024-12-13 17:56:27 +01:00
Ottermandias
08ff9b679e Add changing mod settings to command / macro API. 2024-12-13 17:48:54 +01:00
Ottermandias
22c3b3b629 Again. 2024-12-13 15:43:09 +01:00
Ottermandias
4cc7d1930b Update GameData. 2024-12-09 21:30:00 +01:00
Ottermandias
01db37cbd4 Add Copy for paths, update npc names 2024-12-09 21:22:30 +01:00
Actions User
e9014fe4c3 [CI] Updating repo.json for testing_1.3.1.6 2024-12-05 19:38:51 +00:00
Ottermandias
1434ad6190 Add context menu copying for paths in advanced editing. 2024-12-05 20:36:03 +01:00
Ottermandias
22541b3fd8 Update variables drawer. 2024-12-05 20:36:03 +01:00
Actions User
b377ca372c [CI] Updating repo.json for testing_1.3.1.5 2024-11-29 16:35:08 +00:00
Ottermandias
d7095af89b Add jumping to mods in OnScreen tab. 2024-11-29 17:33:05 +01:00
Ottermandias
8b9f59426e No V1 Meta yet... wait until next version ban or API increase. 2024-11-27 23:07:08 +01:00
Ottermandias
97d7ea7759 tmp 2024-11-27 22:51:14 +01:00
Ottermandias
9787e5a852 Fix some meta issues. 2024-11-27 18:49:04 +01:00
Ottermandias
242c0ee38f Add testing to IPC Meta. 2024-11-27 18:41:16 +01:00
Ottermandias
c8ad4bc106 Use meta transfer v1. 2024-11-27 18:01:53 +01:00
Ottermandias
ac2631384f Fix mod reload of atch manipulations. 2024-11-27 18:01:53 +01:00
Ottermandias
0aa8a44b8d Fix meta manipulation copy/paste. 2024-11-27 18:01:52 +01:00
Ottermandias
8242cde15c Don't spam logs. 2024-11-27 18:01:52 +01:00
Actions User
28250a9304 [CI] Updating repo.json for testing_1.3.1.4 2024-11-26 16:11:29 +00:00
Ottermandias
10279fdc18 fix inverted hook logic. 2024-11-26 17:09:14 +01:00
Ottermandias
b1be868a6a Atch stuff. 2024-11-26 17:09:14 +01:00
Ottermandias
65538868c3 Add Artemis 2024-11-26 17:09:14 +01:00
Actions User
cc49bdcb36 [CI] Updating repo.json for 1.3.1.3 2024-11-26 01:02:41 +00:00
Ottermandias
d2a015f32a Ughhhhhhhhhh 2024-11-26 01:58:44 +01:00
Ottermandias
d0e0ae46e6 Push an ID in itemselector. 2024-11-25 17:46:14 +01:00
Ottermandias
9822ab4128 Add some debug helper output for SeFileDescriptor. 2024-11-25 16:59:07 +01:00
Ottermandias
25aac1a03e Fix CalculateHeight. 2024-11-23 13:58:00 +01:00
Actions User
5a46361d4f [CI] Updating repo.json for 1.3.1.2 2024-11-22 18:16:51 +00:00
Ottermandias
17d8826ae9 This time correctly, maybe? 2024-11-22 19:13:01 +01:00
Actions User
22be9f2d07 [CI] Updating repo.json for 1.3.1.1 2024-11-22 16:34:25 +00:00
Ottermandias
06ba0ba956 Fix glasses issue with resource trees. 2024-11-22 17:32:00 +01:00
Ottermandias
234130cf86
Update repo.json 2024-11-22 14:44:00 +01:00
Actions User
977cb2196a [CI] Updating repo.json for 1.3.1.0 2024-11-22 13:29:57 +00:00
Ottermandias
37332c432b 1.3.1.0 2024-11-22 12:36:30 +01:00
Ottermandias
ee48ea0166 Some stashed changes already applied. 2024-11-22 00:43:36 +01:00
Ottermandias
f2bdaf1b49 Circumvent rsf not existing. 2024-11-22 00:35:17 +01:00
Ottermandias
9e72432682 Merge branch 'master' of github.com:xivDev/Penumbra 2024-11-20 18:08:36 +01:00
Ottermandias
ce75471e51 Fix issue with resetting GEQP parameters on reload (again?) 2024-11-20 18:08:24 +01:00
Actions User
688b84141f [CI] Updating repo.json for testing_1.3.0.4 2024-11-20 09:46:01 +00:00
Ottermandias
3beef61c6f Some debug vis improvements, disable .atch file modding for the moment until modular .atch file modding is implemented. 2024-11-20 10:44:09 +01:00
Ottermandias
11d0cfd1e2 Merge branch 'master' of github.com:xivDev/Penumbra 2024-11-18 20:14:35 +01:00
Ottermandias
8a53313c33 Add .atch file debugging. 2024-11-18 20:14:06 +01:00
Actions User
0928d712c9 [CI] Updating repo.json for testing_1.3.0.3 2024-11-17 23:30:41 +00:00
Ottermandias
41718d8f8f Fix screen actor indices. 2024-11-18 00:28:42 +01:00
Ottermandias
7ab5299f7a Add SCD handling and crc cache visualization. 2024-11-18 00:28:42 +01:00
Actions User
597380355a [CI] Updating repo.json for testing_1.3.0.2 2024-11-17 21:02:11 +00:00
Ottermandias
a864ac1965 1.3.0.2 2024-11-17 22:00:07 +01:00
Ottermandias
83e5feb7db Update OtterGui. 2024-11-17 14:30:47 +01:00
Ottermandias
5599f12753 Further fixes. 2024-11-17 14:28:33 +01:00
Ottermandias
e3a1ae6938 Current state. 2024-11-17 00:50:39 +01:00
Actions User
c54141be54 [CI] Updating repo.json for testing_1.3.0.1 2024-11-04 12:59:01 +00:00
Ottermandias
7dfc564a4c Add path resolving / est handling for kdb and bnmb files. 2024-11-04 13:55:45 +01:00
Ottermandias
d50fbf5a1c Merge remote-tracking branch 'origin/master' 2024-10-30 20:48:26 +01:00
Ottermandias
ed717c69f9 Make temporary collection always respect ownership. 2024-10-30 20:48:16 +01:00
Ottermandias
c4f6038d1e Make temporary collection always respect ownership. 2024-10-30 20:40:10 +01:00
Ottermandias
2358eb378d Fix issue with characters in login screen, maybe. 2024-10-30 17:31:38 +01:00
Ottermandias
7e6ea5008c Maybe fix other issue with left rings and resource trees. 2024-10-30 17:31:24 +01:00
Ottermandias
69971c12af Fix EQP entries for earring hiding. 2024-10-19 19:23:58 +02:00
Actions User
71101ef553 [CI] Updating repo.json for 1.3.0.0 2024-10-18 14:26:25 +00:00
Ottermandias
472d803141 1.3.0.0 2024-10-18 16:24:30 +02:00
Ottermandias
9ddb011545 Fix issue with long mod titles in the merge mods tab. 2024-10-18 16:03:08 +02:00
Ottermandias
339d1f8caf Update GameData 2024-10-13 14:41:27 +02:00
Actions User
9bd1f86a1d [CI] Updating repo.json for testing_1.2.1.9 2024-10-13 11:57:07 +00:00
Ottermandias
50db83146a Maybe fix left finger resource nodes. 2024-10-13 13:55:07 +02:00
Actions User
a54e45f9c3 [CI] Updating repo.json for testing_1.2.1.8 2024-10-12 13:15:18 +00:00
Ottermandias
e646b48afa Add swaps to and from Glasses. 2024-10-12 15:13:22 +02:00
Ottermandias
97b310ca3f Fix issue with meta file not being saved synchronously on creation. 2024-10-12 15:13:06 +02:00
Ottermandias
db2ce1328f Enable VFX for the glasses slot. 2024-10-11 18:19:12 +02:00
Ottermandias
1d5a7a41ab Remove BonusItem from use and update ResourceTree a bit. 2024-10-11 16:35:47 +02:00
Ottermandias
2c5ffc1bc5 Add delete and single add button and fix child sizes. 2024-10-10 16:50:12 +02:00
Actions User
40c772a9da [CI] Updating repo.json for testing_1.2.1.7 2024-10-09 16:49:59 +00:00
Ottermandias
4a0c996ff6 Fix some off-by-one errors with the import progress reports, add test implementation for pbd editing. 2024-10-09 18:47:30 +02:00
Ottermandias
2e424a693d Update GameData 2024-10-07 16:18:58 +02:00
Actions User
c4b59295cb [CI] Updating repo.json for testing_1.2.1.6 2024-10-06 12:54:51 +00:00
Ottermandias
740816f3a6 Fix accessory VFX change not working. 2024-10-06 14:51:52 +02:00
Ottermandias
df0526e6e5 Fix readoing and displaying DemiHuman IMC Identifiers. 2024-10-06 14:23:36 +02:00
Ottermandias
76c0264cbe Reenable model IO for testing. 2024-10-06 14:05:13 +02:00
ackwell
a1a880a0f4 Fix hair.shpk 2024-10-06 14:02:56 +02:00
ackwell
3b21de35cc Fix iris.shpk 2024-10-06 14:02:56 +02:00
ackwell
efd08ae053 Add charactertattoo.shpk support 2024-10-06 14:02:56 +02:00
ackwell
8468ed2c07 Fix skin.shpk 2024-10-06 14:02:56 +02:00
ackwell
8fa0875ec6 Fix character*.shpk exports 2024-10-06 14:02:56 +02:00
Passive
4719f413b6 Fix adjustment switch 2024-10-06 14:02:56 +02:00
Passive
5258c600b7 Rework AdjustByteArray 2024-10-06 14:02:56 +02:00
Passive
3e90524b06 Remove old impl comments 2024-10-06 14:02:56 +02:00
Passive
9c6498e028 Conditionally still check for weights1 even if weights0 is 0 2024-10-06 14:02:56 +02:00
Passive
9de6b3a905 Vector4 to float array 2024-10-06 14:02:56 +02:00
Passive
fecdee05bd Cleanup 2024-10-06 14:02:56 +02:00
Passive
8084f48144 Init support for DT model i/o 2024-10-06 14:02:56 +02:00
Ottermandias
389c42e68f Update GameData. 2024-10-06 13:02:28 +02:00
Ottermandias
776b4e9efb Update obsolete properties from CS. 2024-10-06 11:58:06 +02:00
Ottermandias
caf4382e1f Update BNPCs 2024-10-06 11:58:06 +02:00
Actions User
22aca49112 [CI] Updating repo.json for testing_1.2.1.5 2024-09-22 19:47:34 +00:00
Ottermandias
af2a14826c Add potential hidden priorities. 2024-09-19 22:50:00 +02:00
Ottermandias
9b958a9d37 Update actions. 2024-09-16 23:16:43 +02:00
Ottermandias
00fbb2686b Add option to apply only attributes from IMC group. 2024-09-16 22:54:14 +02:00
Actions User
ac1ea124d9 [CI] Updating repo.json for testing_1.2.1.4 2024-09-09 14:53:17 +00:00
Ottermandias
26371d42f7 Be less dumb. 2024-09-09 16:51:29 +02:00
Actions User
10ce5da8c9 [CI] Updating repo.json for testing_1.2.1.3 2024-09-09 13:42:42 +00:00
Ottermandias
0c6d777c75 Allow copying paths out of the resource logger. 2024-09-09 14:10:54 +02:00
Ottermandias
bd59591ed8 Add display of ImportDate and allow resetting it, add button to open local data json. 2024-09-08 23:42:19 +02:00
Ottermandias
22cbecc6a4 Add Page to mod group data for TT interop. 2024-09-08 22:48:15 +02:00
Ottermandias
1b17404876 Fix small issue with changed item tooltips. 2024-08-31 20:52:08 +02:00
Ottermandias
6b858dc5ac Hmpf. 2024-08-31 20:52:08 +02:00
Ottermandias
75858a61b5 Fix MetaManipulations not resetting count when clearing. 2024-08-31 20:52:08 +02:00
Ottermandias
04582ba00b Add CustomArmor to UI events. 2024-08-31 20:52:08 +02:00
Ottermandias
fb144d0b74 Cleanup. 2024-08-31 20:52:08 +02:00
Actions User
ff3e5410aa [CI] Updating repo.json for testing_1.2.1.2 2024-08-29 19:18:17 +00:00
Ottermandias
176001195b Improve mod filters. 2024-08-29 21:13:33 +02:00
Ottermandias
2a7d2ef0d5 Allow reading BC6. 2024-08-29 18:58:30 +02:00
Ottermandias
de3644e9e1 Make BC4 textures importable. 2024-08-29 18:46:37 +02:00
Ottermandias
5c5e45114f Make loading mods for advanced editing async. 2024-08-29 18:38:37 +02:00
Ottermandias
e5ff9cee9e Stop raising errors when compressing the deleted files after updating Heliosphere mods. 2024-08-29 18:38:09 +02:00
Ottermandias
f5e6132462 Delete default meta entries from archives and api added mods if not configured otherwise. 2024-08-29 17:47:51 +02:00
Ottermandias
f8e3b6777f Add DeleteDefaultValues on general dicts. 2024-08-28 23:10:59 +02:00
Ottermandias
f043311882 Fix vulnerability warning. 2024-08-28 23:10:22 +02:00
Ottermandias
4117d45d15 Use ReadWriteDictionary as base for meta changes. 2024-08-28 18:33:01 +02:00
Ottermandias
6d408ba695 Clip meta changes. 2024-08-28 18:29:58 +02:00
Ottermandias
4970e57131 Improve tooltip of file redirections tab. 2024-08-28 18:29:12 +02:00
Ottermandias
d713d5a112 Improve handling of mod selection. 2024-08-28 18:28:49 +02:00
Ottermandias
a3c22f2826 Fix ordering of meta entries. 2024-08-28 15:49:07 +02:00
Ottermandias
233a999650 Add button to remove default-valued meta entries. 2024-08-28 15:48:42 +02:00
Ottermandias
3e2c9177a7 Prepare API for new meta format. 2024-08-28 15:48:02 +02:00
Ottermandias
ded910d8a1 Add Targa export. 2024-08-26 21:21:38 +02:00
Ottermandias
c4853434c8 Whatever. 2024-08-26 18:25:43 +02:00
Ottermandias
f3346c5d7e Add Targa support. 2024-08-26 18:20:29 +02:00
Ottermandias
726340e4f8 Meh. 2024-08-24 20:45:18 +02:00
Ottermandias
a2237773e3 Update packages. 2024-08-24 20:43:21 +02:00
Ottermandias
3549283769 Order meta entries. 2024-08-24 20:43:21 +02:00
Ottermandias
96f0479b53 Some cleanup. 2024-08-24 20:43:21 +02:00
Actions User
1da095be99 [CI] Updating repo.json for 1.2.1.1 2024-08-12 19:00:43 +00:00
Ottermandias
bedf5dab79 Make collection resolver not cache early resolved actors that aren't characters. 2024-08-12 20:58:17 +02:00
Ottermandias
bb9dd184a3 Fix order of gender and model in EQDP drawer. 2024-08-12 20:57:52 +02:00
Ottermandias
3135d5e7e6 Make collection combo mousewheel-scrollable with ctrl. 2024-08-12 20:57:38 +02:00
Ottermandias
6e351aa68b Make mods added via API migrate models if enabled. 2024-08-12 20:57:16 +02:00
Ottermandias
8ee326853d Update GameData. 2024-08-11 23:24:18 +02:00
Ottermandias
5663822b2b Merge branch 'master' of github.com:xivDev/Penumbra 2024-08-11 23:22:58 +02:00
Ottermandias
47268ab377 Prevent loading crashy shpks. 2024-08-11 23:22:42 +02:00
Ottermandias
6b0b1629bd Move GuidExtensions to OtterGui (unused atm) 2024-08-11 23:22:05 +02:00
N. Lo.
7710d92496 Add another plugin to Copy Support Info 2024-08-10 20:39:53 +02:00
Ottermandias
a27ce6b0a7 Update non-testing DalamudApiLevel. 2024-08-10 12:23:25 +02:00
Actions User
5c9e158da3 [CI] Updating repo.json for 1.2.1.0 2024-08-10 10:01:17 +00:00
Ottermandias
ccce087b87 Update GameData. 2024-08-10 11:59:18 +02:00
Ottermandias
7ba7a6e319 API 5.3 2024-08-10 11:55:30 +02:00
Ottermandias
421fde70b0 Addendum 2024-08-09 23:57:42 +02:00
Ottermandias
741141f227 Woops. 2024-08-09 23:52:12 +02:00
Ottermandias
1b671b95ab 1.2.1.0 2024-08-09 23:04:07 +02:00
Ottermandias
b5f7f03e11 Update BNPC Names. 2024-08-09 22:46:34 +02:00
Ottermandias
6c0d8ea889 Merge branch 'master' of github.com:xivDev/Penumbra 2024-08-09 22:29:04 +02:00
Ottermandias
e44b450548 Disable model import/export for now. 2024-08-09 22:17:23 +02:00
Actions User
465e65e8fe [CI] Updating repo.json for testing_1.2.0.23 2024-08-08 23:17:52 +00:00
Ottermandias
a52a43bd86 Minor cleanup. 2024-08-09 01:15:05 +02:00
Ottermandias
b3d841a8ec Merge remote-tracking branch 'Exter-N/shader-stuff' 2024-08-09 01:08:31 +02:00
Exter-N
c265b917b4 "This is how you end up on a list." 2024-08-09 01:03:46 +02:00
Exter-N
03e9dc55df Use read-only MMIO for legacy ShPk ban 2024-08-08 23:19:44 +02:00
Exter-N
fb58a9c271 Add/improve ShaderReplacementFixer hooks 2024-08-08 23:19:18 +02:00
Actions User
d630a3dff4 [CI] Updating repo.json for testing_1.2.0.22 2024-08-07 14:47:58 +00:00
Ottermandias
1648bfe424 Merge branch 'dt-shmod' 2024-08-07 16:45:28 +02:00
Ottermandias
fe4a046cc9 Make ChatWarningService part of the MessageService. 2024-08-07 16:37:58 +02:00
Ottermandias
f0c034c84d Merge branch 'master' into dt-shmod
# Conflicts:
#	Penumbra/Communication/MtrlLoaded.cs
2024-08-07 15:45:24 +02:00
Ottermandias
df58ac7e92 Fix ref. 2024-08-07 15:44:21 +02:00
Ottermandias
b8a3a854bd Merge remote-tracking branch 'Exter-N/patch-1' 2024-08-06 17:13:17 +02:00
Ottermandias
a40a5d343f Merge remote-tracking branch 'Exter-N/single-row-highlight' 2024-08-06 17:13:02 +02:00
N. Lo.
2bf08c8c89
Fix dye template combo (aka "git gud") 2024-08-06 13:05:21 +02:00
Exter-N
1187efa243 Reinstate single-row CT highlight 2024-08-05 23:02:34 +02:00
Exter-N
0d1ed6a926 No, ImGui, these buttons aren't the same. 2024-08-05 09:51:52 +02:00
N. Lo.
f68e919421 Fix LiveCTPreviewer instantiation 2024-08-05 08:41:49 +02:00
Exter-N
a36f9ccec7 Improve ResourceTree display with new function 2024-08-05 03:45:02 +02:00
Exter-N
dba85f5da3 Sanity check ShPk mods, ban incompatible ones 2024-08-05 03:43:18 +02:00
Exter-N
700fef4f04 Move hook to MaterialResourceHandle.Load (inlining my beloathed) 2024-08-05 03:41:35 +02:00
Actions User
1b5553284c [CI] Updating repo.json for testing_1.2.0.21 2024-08-04 22:44:50 +00:00
Ottermandias
2534f119e9 Make StainService deal with early-loading. 2024-08-05 00:42:04 +02:00
Ottermandias
a585976190 Make ImcChecker threadsafe. 2024-08-05 00:42:04 +02:00
Actions User
0064c4c96e [CI] Updating repo.json for testing_1.2.0.20 2024-08-04 21:23:13 +00:00
Ottermandias
e91e0b23f8 Unused usings. 2024-08-04 23:18:18 +02:00
Ottermandias
0dbf718340 Merge remote-tracking branch 'Exter-N/support-info-mdf' 2024-08-04 22:54:02 +02:00
Ottermandias
6d42673aa4 Update GameData. 2024-08-04 22:52:53 +02:00
Ottermandias
f2094c2c58 Merge branch 'dtme' 2024-08-04 22:48:41 +02:00
Ottermandias
f8b034c42d Auto-formatting, generous application of ImUtf8, minor cleanups. 2024-08-04 22:48:15 +02:00
Exter-N
f3ab1ddbb4 Add game data file status to support info 2024-08-04 22:32:31 +02:00
Ottermandias
c8e859ae05 Fixups. 2024-08-04 15:41:40 +02:00
Ottermandias
728a081419 Merge remote-tracking branch 'Exter-N/dtme' into dtme 2024-08-04 15:38:32 +02:00
Ottermandias
30d10d5a26 Merge branch 'master' into dtme
# Conflicts:
#	Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.ColorTable.cs
#	Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.MtrlTab.cs
2024-08-04 15:36:17 +02:00
Ottermandias
d90c3dd1af Update row type names. 2024-08-04 15:35:27 +02:00
Exter-N
ee086e3e76 Update GameData 2024-08-04 00:57:39 +02:00
Ottermandias
a6ee4c96ea Merge branch 'rt-dt' 2024-08-04 00:00:49 +02:00
Ottermandias
da3f3b8df3 Start rework of identified objects. 2024-08-03 22:45:44 +02:00
Exter-N
75e3ef72f3 RT: Fix Facewear 2024-08-03 20:27:41 +02:00
Exter-N
243593e30f RT: Fix VPR offhand material paths 2024-08-03 20:27:38 +02:00
Exter-N
c849e31034 RT: Use SpanTextWriter to assemble paths 2024-08-03 19:48:42 +02:00
Exter-N
c01aa000fb Optimize I/O of ShPk for ResourceTree generation 2024-08-03 17:55:19 +02:00
Exter-N
5323add662 Improve ShPk tab 2024-08-03 17:55:19 +02:00
Exter-N
f4fe3605f0 DT material editor, new color tables 2024-08-03 17:55:19 +02:00
Exter-N
36ab9573ae DT material editor, main part 2024-08-03 17:55:19 +02:00
Exter-N
450751e43f DT material editor, supporting components 2024-08-03 17:55:19 +02:00
Exter-N
e8182f285e Update StainService for DT 2024-08-03 17:55:15 +02:00
Exter-N
59b3859f11 Minor upgrades to follow dependencies 2024-08-03 17:51:13 +02:00
Exter-N
60986c78f8 Update GameData 2024-08-03 17:51:11 +02:00
Exter-N
069b28272b Add TextureArraySlicer 2024-08-03 17:51:11 +02:00
Actions User
4454ac48da [CI] Updating repo.json for testing_1.2.0.19 2024-08-03 13:18:14 +00:00
Ottermandias
6241187431 Fix span constructors going over boundaries for ByteStrings. 2024-08-03 15:15:27 +02:00
Actions User
f3e7271157 [CI] Updating repo.json for testing_1.2.0.18 2024-08-02 12:48:57 +00:00
Ottermandias
d903f1b8c3 Update GetResourceSync and GetResourceAsync function signatures for testing, including unused stack parameters. 2024-08-01 22:18:26 +02:00
Ottermandias
5e9c7f7eac Fix IMC import sanity check. 2024-08-01 22:17:56 +02:00
Ottermandias
1e1637f0e7 Test IMC group toggling off. 2024-08-01 17:14:46 +02:00
Ottermandias
7579eaacbe Meh. 2024-08-01 17:14:28 +02:00
Ottermandias
73b9d1fca0 Meh. 2024-08-01 16:49:22 +02:00
Ottermandias
a308fb9f77 Allow hook overrides. 2024-08-01 16:40:37 +02:00
Ottermandias
9e15865a99 Fix some further issues with empty byte strings. 2024-08-01 16:37:31 +02:00
Ottermandias
67a220f821 Add context menu to change mod state from Collections tab. 2024-07-31 23:24:59 +02:00
Ottermandias
4b9870f090 Fix some OtterGui changes. 2024-07-31 23:09:37 +02:00
Ottermandias
d247f83e1d Use CiByteString for anything path-related. 2024-07-30 18:54:08 +02:00
Ottermandias
9d128a4d83 Fix potential threading issue on launch. 2024-07-30 18:54:08 +02:00
Ottermandias
70281c576e Update Submodules. 2024-07-30 18:54:08 +02:00
Ottermandias
5270ad4d0d Update ImageSharp 2024-07-30 18:54:08 +02:00
Ottermandias
8518240bf9 Improve knowledge window somewhat. 2024-07-30 18:54:08 +02:00
Ottermandias
7ceaeb826f Move Material Reassignment to the back (and shoot it) 2024-07-30 18:54:08 +02:00
Actions User
ee801b637e [CI] Updating repo.json for testing_1.2.0.17 2024-07-29 07:46:20 +00:00
Ottermandias
5512e0cad2 Revert no-lowercasing for the moment. 2024-07-29 09:43:15 +02:00
Ottermandias
3754f57132 Reinstate spacebar heating 2024-07-29 09:43:15 +02:00
Actions User
e52b027545 [CI] Updating repo.json for testing_1.2.0.16 2024-07-28 22:03:19 +00:00
Ottermandias
d30d418afe Remove a ToLower when resolving paths. 2024-07-28 23:56:28 +02:00
Actions User
5d50523c72 [CI] Updating repo.json for testing_1.2.0.15 2024-07-28 12:12:56 +00:00
Ottermandias
af0bbeb8bf Force saving to be synchronous. 2024-07-28 13:48:11 +02:00
Ottermandias
4806f8dc3e Do not force loaded game paths to lowercase. 2024-07-28 13:43:01 +02:00
Ottermandias
bb4665c367 Remove unused params. 2024-07-28 12:58:17 +02:00
Ottermandias
d0c4d6984c Dispose collection caches on plugin disposal. 2024-07-28 12:57:59 +02:00
Ottermandias
19166d8cf4 Add rudimentary start for knowledge window. 2024-07-28 01:11:52 +02:00
Ottermandias
a1a7487897 Remove Update Bibo Button. 2024-07-28 01:11:20 +02:00
Ottermandias
cbf5baf65c Remove Material Reassignment Tab from advanced editing due to being obsolete. 2024-07-28 01:09:48 +02:00
Ottermandias
6f3d9eb272 Fix bug in EquipmentSwap 2024-07-28 01:09:11 +02:00
Ottermandias
f143601aa0 Do not replace paths when mods are not enabled. 2024-07-28 01:08:58 +02:00
Ottermandias
3ffe6151ff Add ToString for InternalEqpEntry. 2024-07-28 01:08:41 +02:00
Ottermandias
246f4f65f5 Make items changed in a mod sort before other items for item swap, also color them. 2024-07-26 18:42:48 +02:00
Ottermandias
72f2834dfd Add some resource flags. 2024-07-24 15:11:59 +02:00
Ottermandias
c501d0b365 Fix card actor identification. 2024-07-24 15:11:59 +02:00
Actions User
30f9233862 [CI] Updating repo.json for testing_1.2.0.14 2024-07-22 18:56:35 +00:00
Ottermandias
df33557477 Cleanup. 2024-07-22 20:54:24 +02:00
Ottermandias
528e3226b5 Merge remote-tracking branch 'refs/remotes/pmgr/master' 2024-07-22 20:43:58 +02:00
Ottermandias
a4cd5695fb Fix some stuff. 2024-07-22 20:41:57 +02:00
pmgr
ca648f98a1 Fix for pap weirdness, hopefully 2024-07-22 19:37:57 +01:00
Actions User
29dce8f3ab [CI] Updating repo.json for testing_1.2.0.13 2024-07-22 13:16:22 +00:00
Ottermandias
1501bd4fbf Fix negative matching on folders with no matches. 2024-07-22 12:41:20 +02:00
Ottermandias
cec28a1823 Provide actual hook names. 2024-07-21 23:49:27 +02:00
Ottermandias
07382537a0 Merge branch 'refs/heads/pmgr/master' 2024-07-21 23:26:21 +02:00
Ottermandias
ceaa9ca29a Some further cleanup. 2024-07-21 23:26:09 +02:00
Ottermandias
ee5a21f7a2 Add pap requested event, some cleanup. 2024-07-21 22:58:24 +02:00
Ottermandias
0db70c89b1 Some cleanup of PeSigScanner. 2024-07-21 22:58:03 +02:00
Ottermandias
8351b74b21 Update GameData and packages. 2024-07-21 22:23:31 +02:00
pmgr
8c34c18643 Add scuffed pap handling 2024-07-21 16:34:27 +01:00
Actions User
48ab98bee6 [CI] Updating repo.json for testing_1.2.0.12 2024-07-20 22:53:37 +00:00
Ottermandias
c3b7ddad28 Create newly added mods in import folder instead of moving them. 2024-07-21 00:48:48 +02:00
Ottermandias
5b1c0cf0e3 Fix direction of furniture redrawing. 2024-07-21 00:21:41 +02:00
Ottermandias
e2313ba925 Fix field. 2024-07-21 00:21:27 +02:00
Ottermandias
258f7e9732 Reinstate the inlined ApricotSoundPlay hook one layer hup. 2024-07-21 00:13:43 +02:00
Ottermandias
a4548bbf04 Apply unprioritized mod groups in reverse order. 2024-07-21 00:11:13 +02:00
Ottermandias
f533ae6667 Some cleanup. 2024-07-19 17:33:54 +02:00
Ottermandias
1a8d194e05 Merge branch 'master' of github.com:xivDev/Penumbra 2024-07-19 14:24:41 +02:00
Ottermandias
f978b35b76 Make ResourceTrees work with UseNoMods. 2024-07-19 14:24:29 +02:00
Actions User
defba19b2d [CI] Updating repo.json for testing_1.2.0.11 2024-07-17 16:36:04 +00:00
Ottermandias
5abbd8b110 Hook UpdateRender despite per-frame calls. 2024-07-17 18:34:03 +02:00
Ottermandias
9bba1e2b31 Remove log spamming. 2024-07-17 18:06:05 +02:00
Actions User
6d0562180a [CI] Updating repo.json for testing_1.2.0.10 2024-07-17 16:05:28 +00:00
Ottermandias
e7c786b239 Add and rework hooks around EST entries. 2024-07-17 18:02:48 +02:00
Ottermandias
1922353ba3 Update GameData. 2024-07-17 02:01:59 +02:00
Actions User
c9379b6d60 [CI] Updating repo.json for testing_1.2.0.9 2024-07-16 23:38:11 +00:00
Ottermandias
4824a96ab0 Enable Mtrl Restore and Cleanup again. 2024-07-17 01:36:04 +02:00
Actions User
ad877e68e6 [CI] Updating repo.json for testing_1.2.0.8 2024-07-16 22:51:33 +00:00
Ottermandias
67a35b9abb stupid 2024-07-17 00:49:40 +02:00
Ottermandias
eb784dddf0 Fix missing file display. 2024-07-17 00:40:49 +02:00
Ottermandias
89cbb3f60d Update GameData. 2024-07-16 23:02:17 +02:00
Ottermandias
519b3d4891 Update GameData. 2024-07-16 22:37:01 +02:00
Actions User
78af40d507 [CI] Updating repo.json for testing_1.2.0.7 2024-07-16 20:27:30 +00:00
Ottermandias
c98bee67a5 Update GameData. 2024-07-16 22:25:28 +02:00
Ottermandias
d952d83adf Fix redrawing while fishing while sitting. 2024-07-16 22:06:09 +02:00
Ottermandias
12dfaaef99 Fix broken mods being deleted instead of removed. Fix tags crashing when null instead of empty. 2024-07-16 22:06:09 +02:00
Ottermandias
9c781f8563 Disable material migration for now 2024-07-16 22:06:09 +02:00
Actions User
07c3be641d [CI] Updating repo.json for testing_1.2.0.6 2024-07-14 18:41:39 +00:00
Ottermandias
e46fcc4af1 Gracefully deal with invalid offhand IMCs. 2024-07-14 20:38:54 +02:00
Ottermandias
d6f61f06cb Add TestingDalamudApiLevel 2024-07-12 22:15:00 +02:00
Actions User
d815266ed7 [CI] Updating repo.json for testing_1.2.0.5 2024-07-12 15:56:58 +00:00
Ottermandias
94a05afbe0 Make the import popup closeable by clicking outside if it is finished. 2024-07-12 17:54:47 +02:00
Ottermandias
22af545e8d Add image strings to groups and mods to keep them in the json on saves. 2024-07-12 17:37:55 +02:00
Ottermandias
40be298d67 Add automatic reduplication for ui files in pmps, test. 2024-07-12 17:37:19 +02:00
Ottermandias
6beb2416dc Merge branch 'master' of github.com:xivDev/Penumbra 2024-07-12 16:24:56 +02:00
Ottermandias
24597d7dc0 Fix mod normalization skipping the default submod. 2024-07-12 16:20:17 +02:00
Actions User
34cbf37c32 [CI] Updating repo.json for testing_1.2.0.4 2024-07-10 23:43:04 +00:00
Ottermandias
380dd0cffb Fix texture writing. 2024-07-11 01:40:45 +02:00
Ottermandias
1be75444cd Update BNPC Names 2024-07-10 12:51:55 +02:00
Actions User
e2112202a0 [CI] Updating repo.json for testing_1.2.0.3 2024-07-09 16:38:39 +00:00
Ottermandias
37ffe52869 Fix issue with file substitutions. 2024-07-09 18:36:45 +02:00
Ottermandias
baa439d246 Fix enable/disable draw offsets. 2024-07-09 18:31:31 +02:00
Actions User
806e001bad [CI] Updating repo.json for testing_1.2.0.2 2024-07-09 16:11:41 +00:00
Ottermandias
3b980c1a49 Fix two import bugs. 2024-07-09 18:09:44 +02:00
Actions User
1efd493834 [CI] Updating repo.json for testing_1.2.0.1 2024-07-09 15:52:40 +00:00
Ottermandias
3c417d7aec Fix extraction of pmp failing 2024-07-09 17:48:42 +02:00
Ottermandias
c2517499f2
Update repo.json 2024-07-09 17:04:27 +02:00
Actions User
56502f19f9 [CI] Updating repo.json for testing_1.2.0.0 2024-07-09 14:55:15 +00:00
Ottermandias
a0a3435918 Remove not-yet-existing CS requirement. 2024-07-09 16:50:48 +02:00
Ottermandias
b677a14cef Update. 2024-07-09 16:34:31 +02:00
Ottermandias
710f39768b Disable the required ShadersKnown for the time being. 2024-07-08 15:00:37 +02:00
Ottermandias
f89eea721f Update game data. 2024-07-08 14:59:35 +02:00
Ottermandias
585601efd4 Merge branch 'refs/heads/Exter-N/srf7'
# Conflicts:
#	Penumbra/Interop/Hooks/HookSettings.cs
2024-07-08 14:57:37 +02:00
Ottermandias
56e284a99e Add some migration things. 2024-07-08 14:55:49 +02:00
Ottermandias
0d939b12f4 Add model update button. 2024-07-07 16:17:12 +02:00
Ottermandias
4f0f3721a6 Update animation hooks. 2024-07-07 16:16:58 +02:00
Ottermandias
68135f3757 Update Gamedata 2024-07-07 16:15:51 +02:00
Exter-N
41d271213e Update ShaderReplacementFixer for 7.0 2024-07-05 23:59:22 +02:00
Ottermandias
1284037554 Fix some hooks. 2024-07-05 14:39:03 +02:00
Ottermandias
4026dd5867 Change texture handling. 2024-07-05 12:14:31 +02:00
Ottermandias
9fb8090781 Current state. 2024-07-03 17:29:49 +02:00
Ottermandias
431933e9c1 Revert repo API version. 2024-07-02 18:27:53 +02:00
Ottermandias
221b18751d Some updates. 2024-07-02 17:08:27 +02:00
Ottermandias
c2e74ed382 Improve signatures. 2024-06-25 22:50:52 +02:00
Ottermandias
b07af32dee Fix doubled hook. 2024-06-22 23:04:16 +02:00
Actions User
045abc787d [CI] Updating repo.json for testing_1.1.1.5 2024-06-20 12:53:23 +00:00
Ottermandias
ab1e11aba1 Improve support info a bit. 2024-06-20 14:51:17 +02:00
Ottermandias
8cd8efa723 Fix RSP scaling for NPC values. 2024-06-20 14:24:43 +02:00
Actions User
f686a0ff09 [CI] Updating repo.json for testing_1.1.1.4 2024-06-19 20:37:08 +00:00
Ottermandias
29f8c91306 Make meta hooks respect Enable Mod setting and fix EQP composition. 2024-06-19 22:34:59 +02:00
Ottermandias
a90e253c73
Update repo.json 2024-06-19 13:54:17 +02:00
Actions User
90124e83df [CI] Updating repo.json for testing_1.1.1.3 2024-06-19 11:51:55 +00:00
Ottermandias
819afc518c Merge branch 'meta_rework' 2024-06-18 22:05:15 +02:00
Ottermandias
e05dbe9885 Make everything services. 2024-06-18 21:59:04 +02:00
Ottermandias
cf1dcfcb7c Improve Path preprocessing. 2024-06-18 18:33:37 +02:00
Ottermandias
f9c45a2f3f Clean unused functions. 2024-06-18 17:57:12 +02:00
Ottermandias
03d3c38ad5 Improve Imc Handling. 2024-06-18 17:52:34 +02:00
Ottermandias
d7a8c9415b Use specific counter for Imc. 2024-06-17 23:11:42 +02:00
Ottermandias
be729afd4b Some cleanup 2024-06-17 16:39:10 +02:00
Ottermandias
91d9e465ed Improve eqdp. 2024-06-17 14:51:10 +02:00
Ottermandias
600fd2ecd3 Get rid off EQDP files 2024-06-17 14:51:10 +02:00
Ottermandias
9ecc4ab46d Remove CMP file. 2024-06-17 14:51:10 +02:00
Ottermandias
ebef4ff650 No EST files anymore. 2024-06-17 14:51:10 +02:00
Ottermandias
943207cae8 Make GMP independent of file, cleanup unused functions. 2024-06-17 14:51:10 +02:00
Ottermandias
c53f29c257 Fix unnecessary EST file creations. 2024-06-17 14:51:10 +02:00
Ottermandias
a7b90639c6 Some fixes. 2024-06-17 14:51:10 +02:00
Ottermandias
a61a96f1ef Make GmpEntry readonly. 2024-06-17 14:51:10 +02:00
Ottermandias
30b32fdcd2 Fix EQDP bug. 2024-06-17 14:51:10 +02:00
Ottermandias
ad0c64d4ac Change Eqp hook to not need eqp files anymore. 2024-06-17 14:51:10 +02:00
Ottermandias
e33512cf7f Fix issue, remove IMetaCache. 2024-06-17 14:51:10 +02:00
Ottermandias
4ca49598f8 Small improvement. 2024-06-17 14:51:09 +02:00
Ottermandias
3170edfeb6 Get rid off all MetaManipulation things. 2024-06-17 14:51:09 +02:00
Ottermandias
361082813b tmp 2024-06-17 14:51:09 +02:00
Ottermandias
196ca2ce39 Remove all usages of Add(MetaManipulation) 2024-06-17 14:51:09 +02:00
Ottermandias
d9b63320f0 Some small fixes, parse directly into MetaDictionary. 2024-06-17 14:51:09 +02:00
Ottermandias
0445ed0ef9 Remove TryGetValue(MetaManipulation) from MetaDictionary. 2024-06-17 14:51:09 +02:00
Ottermandias
5ca9e63a2a Use internal entries. 2024-06-17 14:51:09 +02:00
Ottermandias
e0339160e9 Start removing MetaManipulation functions. 2024-06-17 14:51:09 +02:00
Ottermandias
13156a58e9 Remove unused functions. 2024-06-17 14:51:09 +02:00
Ottermandias
94fdd848b7 Expand on MetaDictionary to use separate dictionaries. 2024-06-17 14:51:09 +02:00
Ottermandias
d7b60206d7 Improve meta manipulation handling a bit. 2024-06-17 14:51:09 +02:00
Ottermandias
250c4034e0 Improve root directory behavior and AddMods. 2024-06-17 14:50:49 +02:00
Ottermandias
b3f8762494 Fix some crash handler issues 2024-06-17 14:50:44 +02:00
Ottermandias
ec207bdba2 Force saves independent of manipulations for swaps and merges. 2024-06-15 20:49:15 +02:00
Ottermandias
b1a0590382 Make modmerger file lookup case insensitive. 2024-06-15 20:49:15 +02:00
Actions User
532e8a0936 [CI] Updating repo.json for 1.1.1.1 2024-06-14 12:11:16 +00:00
Ottermandias
2346b7588a Fix GMP bug. 2024-06-14 13:39:25 +02:00
Ottermandias
447735f609 Add a configuration to disable showing mods in the lobby and at the aesthetician. 2024-06-11 16:32:38 +02:00
Actions User
c8ea33f8dd [CI] Updating repo.json for 1.1.1.0 2024-06-11 10:52:49 +00:00
Ottermandias
863a7edf0e Add changelog. 2024-06-11 12:50:13 +02:00
Ottermandias
30a87e3f40 Update valid world check. 2024-06-11 12:28:33 +02:00
Ottermandias
ecd5752d16 Make imc attribute letter tooltip appear on disabled. 2024-06-11 12:27:33 +02:00
Ottermandias
f7adc83d63 Fix issue with preview of file in advanced model editing. 2024-06-11 12:27:22 +02:00
Ottermandias
f6b35497c5 Change path comparison for AddMod. 2024-06-11 12:27:10 +02:00
Ottermandias
f51fc2cafd Allow root directory overwriting with case sensitivity. 2024-06-11 12:27:03 +02:00
Ottermandias
159942f29c Add by-name identification in the lobby. 2024-06-11 12:26:54 +02:00
Ottermandias
e884b269a9 Add a version field to mod group files. 2024-06-11 12:26:11 +02:00
Ottermandias
de0309bfa7 Fix issue with ImcGroup settings and IPC. 2024-06-11 12:25:21 +02:00
Actions User
102e7335a7 [CI] Updating repo.json for testing_1.1.0.3 2024-06-07 14:40:25 +00:00
Ottermandias
50a7e7efb7 Add more filter options. 2024-06-07 16:34:09 +02:00
Ottermandias
2e9f184454 Introduce Identifiers and strong entry types for each meta manipulation and use them in the manipulations. 2024-06-06 17:26:25 +02:00
Ottermandias
ceed8531af Fix GMP Entry edit. 2024-06-06 16:49:39 +02:00
Ottermandias
03bfbcc309 Fidx wrong group 2024-06-05 10:36:38 +02:00
Ottermandias
afdffa4f2c Merge branch 'master' of github.com:xivDev/Penumbra 2024-06-04 15:53:43 +02:00
Ottermandias
48dd4bcadb Bleh. 2024-06-04 15:53:35 +02:00
ackwell
87fec7783e Fix blend weight adjustment getting stuck on near-bounds values 2024-06-04 09:36:46 +02:00
Ottermandias
699ae8e1fb Fix issue with collection settings being set to negative value for some reason. 2024-06-03 17:47:11 +02:00
Ottermandias
aeb2db9f5d Add tooltip to global eqp condition. 2024-06-03 17:46:45 +02:00
Ottermandias
63b3a02e95 Fix issue with crash handler and collections not saving on rename. 2024-06-03 17:45:22 +02:00
Ottermandias
b63935e81e Fix issue with accessory vfx hook. 2024-06-02 12:09:05 +02:00
Ottermandias
05d010a281 Add some functionality to allow an IMC group to add apply to all variants. 2024-06-02 12:08:49 +02:00
Ottermandias
137b752196 Fix Dye Preview not applying. 2024-06-02 01:53:29 +02:00
Ottermandias
3b81dd89c8 Merge branch 'restree-blurb' 2024-06-02 01:04:08 +02:00
Ottermandias
3deda68eec Small updates. 2024-06-02 01:03:51 +02:00
Exter-N
3b26e97231 Merge branch 'master' into restree-blurb 2024-06-02 00:05:16 +02:00
Actions User
2e6473dc09 [CI] Updating repo.json for 1.1.0.2 2024-06-01 21:44:53 +00:00
Ottermandias
ef9d81c061 Fix mod merger. 2024-06-01 23:42:17 +02:00
Ottermandias
cfa58ee196 Fix global EQP rings checking bracelets instead. 2024-06-01 23:42:04 +02:00
Ottermandias
e7cf9d35c9 Add GetChangedItems for Mods. 2024-06-01 23:33:21 +02:00
Ottermandias
5101b73fdc Fix issue with creating unnamed collections. 2024-06-01 20:28:50 +02:00
Actions User
aba68cfb92 [CI] Updating repo.json for 1.1.0.1 2024-06-01 16:18:13 +00:00
Ottermandias
331b7fbc1d Fix other options displaying the same option multiple times. 2024-06-01 18:14:21 +02:00
Ottermandias
24d4e9fac6 Fix collections not being added on creation. 2024-06-01 18:14:21 +02:00
Actions User
b79600ea14 [CI] Updating repo.json for 1.1.0.0 2024-06-01 09:54:26 +00:00
Ottermandias
ce11bec985 Use strings for global eqp. 2024-05-31 22:55:22 +02:00
Ottermandias
f61bd8bb8a Update Changelog and improve metamanipulation display in advanced editing. 2024-05-31 19:37:24 +02:00
Ottermandias
67bb95f6e6 Update submodules. 2024-05-31 17:00:40 +02:00
Ottermandias
81fdbf6ccf Small cleanup. 2024-05-31 16:59:51 +02:00
Exter-N
c7046ec006 ResourceTree: Add name/path filter 2024-05-31 01:20:50 +02:00
Exter-N
f4bdbcac53 Make Resource Trees honor Incognito Mode 2024-05-30 23:09:26 +02:00
Exter-N
a6661f15e8 Display the additional path data in ResourceTree 2024-05-30 20:46:04 +02:00
Ottermandias
b2e1bff782 Consolidate path-data encoding into a single file and make it neater. 2024-05-30 17:18:46 +02:00
Actions User
09742e2e50 [CI] Updating repo.json for testing_1.0.3.2 2024-05-28 10:56:23 +00:00
Ottermandias
8891ea0570 Fix imc identifiers setting equip slot to something where they should not. 2024-05-28 12:53:02 +02:00
Ottermandias
f5d6ac8bdb Fix Remove Assignment being visible for base and interface. 2024-05-28 12:51:28 +02:00
Ottermandias
5d1b17f96d Fix mdl imports not being savable. 2024-05-28 12:51:12 +02:00
Ottermandias
255d11974f Fix IMC Stupid. 2024-05-28 11:20:36 +02:00
Actions User
eb2a9b8109 [CI] Updating repo.json for testing_1.0.3.1 2024-05-27 22:13:55 +00:00
Ottermandias
b30de460e7 Fix ColorTable preview with legacy color tables. 2024-05-28 00:12:01 +02:00
Ottermandias
f11cefcec1 Fix best match fullpath returning broken FullPath instead of nullopt. 2024-05-28 00:12:01 +02:00
Actions User
fe266dca31 [CI] Updating repo.json for testing_1.0.3.0 2024-05-27 15:45:29 +00:00
Ottermandias
ca777ba1bf Update GameData. 2024-05-27 17:43:13 +02:00
Ottermandias
1d230050c2 Fix typo and rename geqp options. 2024-05-26 15:41:27 +02:00
Ottermandias
cd133bddbb Update Changelog. 2024-05-26 14:50:22 +02:00
Ottermandias
ed083f2a4c Add support for Global EQP Changes. 2024-05-26 13:30:35 +02:00
Ottermandias
f9527970cb Fix missing ID push for imc attributes. 2024-05-25 00:43:02 +02:00
Ottermandias
e32e314863 Add initial changelog for next release. 2024-05-24 17:51:47 +02:00
Ottermandias
bad1f45ab9 Use different hooking method for EQP entries. 2024-05-24 17:34:56 +02:00
Ottermandias
4743acf767 Make IMC handling even better. 2024-05-24 16:15:04 +02:00
Ottermandias
65627b5002 Fix a weird age-old bug apparently? 2024-05-24 16:14:48 +02:00
Ottermandias
125e5628ec Fix fuckup. 2024-05-23 23:24:37 +02:00
Ottermandias
992cdff58d Improve some IMC things. 2024-05-23 22:31:39 +02:00
Ottermandias
fca1bf9d94 Add ImcIdentifier. 2024-05-23 22:30:42 +02:00
Ottermandias
7df9ddcb99 Re-Add button to open default mod json. 2024-05-23 17:25:27 +02:00
Ottermandias
dfdd5167a8 Remove auto descriptions from newly generated option groups. 2024-05-23 17:24:42 +02:00
Ottermandias
c06d5b0871 Update for new gamedata. 2024-05-23 16:57:16 +02:00
Ottermandias
2585de8b21 Cleanup group drawing somewhat. 2024-05-21 22:01:20 +02:00
Ottermandias
e85b84dafe Add the option to omit mch offhands from changed items. 2024-05-21 18:24:21 +02:00
Ottermandias
bb56faa288 Improvements. 2024-05-20 18:28:40 +02:00
Ottermandias
df6eb3fdd2 Add some early support for IMC groups. 2024-05-16 18:30:40 +02:00
Ottermandias
d47d31b665 achieve feature parity... I think. 2024-05-14 18:10:59 +02:00
Ottermandias
32dbf419e2 Fix single group default options not applying. 2024-05-09 19:58:35 +02:00
Ottermandias
bbbf65eb4c Fix bug preventing deduplication. 2024-05-09 15:49:49 +02:00
Ottermandias
1f2f66b114 Meh. 2024-05-04 11:34:02 +02:00
Ottermandias
d8dad91e89 Oop, not yet. 2024-05-04 11:24:01 +02:00
Ottermandias
97166379a7 Merge remote-tracking branch 'ackwell/mdl-io-triage-6' 2024-05-04 11:20:59 +02:00
Ottermandias
d72008b4b9 Merge remote-tracking branch 'ackwell/mdl-io-triage-6' 2024-05-04 11:19:17 +02:00
Ottermandias
2a5df2dfb0 Create permanent backup before migrating collections. 2024-05-04 11:19:07 +02:00
ackwell
7553b5da8a Fix float imprecision on blend weights 2024-05-04 04:01:28 +10:00
Ottermandias
36fc251d5b Fix a bunch of issues. 2024-05-03 18:52:52 +02:00
ackwell
46a111d152 Fix marker 2024-05-03 22:42:28 +10:00
ackwell
9063d131ba Use validation logic for new material field 2024-05-03 21:41:35 +10:00
ackwell
078688454a Show an invalid material count 2024-05-03 21:17:54 +10:00
ackwell
c96adcf557 Prevent saving invalid files 2024-05-03 21:15:00 +10:00
ackwell
2e76148fba Ensure materials end in .mtrl 2024-05-03 21:14:40 +10:00
Ottermandias
9084b43e3e Update GameData. 2024-04-28 12:01:54 +02:00
Ottermandias
cff6172453 Move editors into folder. 2024-04-27 00:07:10 +02:00
Ottermandias
1e5ed1c414 Now that was a lot of work. 2024-04-26 18:43:45 +02:00
ackwell
616db0dcc3 Add mesh vertex element readout 2024-04-26 21:23:31 +10:00
Ottermandias
297be487b5 More cleanup on groups. 2024-04-26 10:57:09 +02:00
Ottermandias
e40c4999b6 Improve collection migration maybe. 2024-04-26 10:56:36 +02:00
Ottermandias
a72be22d3b Make sure HS image does not displace the settings entirely. 2024-04-26 10:56:06 +02:00
Ottermandias
06953c175d mooooore 2024-04-25 18:18:57 +02:00
Ottermandias
0fd14ffefc More cleanup. 2024-04-25 18:14:21 +02:00
Ottermandias
72db023804 Some cleanup. 2024-04-25 17:58:32 +02:00
ackwell
c1472d5f65 Merge remote-tracking branch 'upstream/master' into mdl-io-triage-6 2024-04-25 21:30:38 +10:00
Ottermandias
cd76c31d8c Fix stack overflow. 2024-04-24 23:41:55 +02:00
Ottermandias
514121d8c1 Reorder stuff. 2024-04-24 23:28:12 +02:00
Ottermandias
6b1743b776 This sucks so hard... 2024-04-24 23:04:04 +02:00
Ottermandias
07afbfb229 Rework options, pre-submod types. 2024-04-23 17:41:55 +02:00
Ottermandias
792a04337f Add a try-catch when scanning for mods. 2024-04-23 15:50:09 +02:00
Ottermandias
e21c9fb6d1 Fix some IPC stuff. 2024-04-23 15:11:09 +02:00
Ottermandias
b34114400f Fix Havok ANSI / UTF8 Issue. 2024-04-23 15:10:16 +02:00
Ottermandias
c276f922a5 Update API. 2024-04-22 18:22:03 +02:00
ackwell
1bc3bb17c9 Fix havok parsing for non-ANSI user paths
Also improve parsing because otter is better at c# than me
2024-04-22 23:45:30 +10:00
ackwell
cc2f72b73d Use bg/ for absolute path example 2024-04-20 20:55:04 +10:00
ackwell
11acd7d3f4 Prevent import failure when no materials are present 2024-04-20 20:53:55 +10:00
ackwell
4a6d94f0fb Avoid inclusion of zero-weighted bones in name mapping 2024-04-20 20:02:43 +10:00
Ottermandias
b99a809eba Remove OptionPriority from general option groups. 2024-04-20 11:26:12 +02:00
Ottermandias
f86f29b44a Some fixes. 2024-04-20 11:03:50 +02:00
Ottermandias
2d5afde612 Fix group priority writing. 2024-04-20 11:02:30 +02:00
Ottermandias
9f4c6767f8 Remove ISubMod. 2024-04-19 18:28:25 +02:00
Ottermandias
8fc7de64d9 Start group rework. 2024-04-19 17:55:28 +02:00
ackwell
ceb3d39a9a Normalise _FFXIV_COLOR values
Fixes xivdev/Penumbra#411
2024-04-20 01:22:03 +10:00
Ottermandias
75cfffeba7 Oops. 2024-04-19 15:51:23 +02:00
Ottermandias
624dd40d58 Handle writing. 2024-04-19 15:46:52 +02:00
Ottermandias
ef1bbb6d9d I don't know what I'm doing 2024-04-19 15:40:12 +02:00
ackwell
aeb7bd5431 Ensure materials contain at least one / 2024-04-19 00:34:08 +10:00
ackwell
dbfaf37800 Export to .glb 2024-04-18 21:47:07 +10:00
ackwell
fd1f9b95d6 Add Single2 support for UVs 2024-04-18 21:23:18 +10:00
Ottermandias
1641166d6e Disable IPC listeners by default. 2024-04-17 18:15:26 +02:00
Ottermandias
0fa62f40d7 Add Versions provider. 2024-04-17 16:57:23 +02:00
Ottermandias
aeccf2b1c6 Update Submodules. 2024-04-14 15:38:14 +02:00
Ottermandias
d4183a03c0 Fix bug with new empty collections. 2024-04-14 15:00:48 +02:00
Ottermandias
94b53ce7fa Meh. 2024-04-13 16:06:04 +02:00
Ottermandias
42ad941ec2 Add GetCollectionsByIdentifier. 2024-04-13 16:05:44 +02:00
Ottermandias
6b5321dad8 Test subscription like before but without primary constructor. 2024-04-12 14:46:26 +02:00
Ottermandias
d9bd05c9ec Fix issue with Hex viewer. 2024-04-12 14:45:25 +02:00
Ottermandias
d5ed4a38e4 Fix2? 2024-04-12 14:39:12 +02:00
Ottermandias
e4f9150c9f Fix? 2024-04-12 14:30:47 +02:00
Ottermandias
791583e183 Silence readme warnings. 2024-04-12 12:51:33 +02:00
Ottermandias
1ef9346eab Allow renaming of collection. 2024-04-12 12:42:16 +02:00
Ottermandias
ba8999914f Rework API, use Collection ID in crash handler, use collection GUIDs in more places. 2024-04-12 12:33:57 +02:00
Ottermandias
793ed4f0a7 With explicit null-termination, maybe? 2024-04-12 00:02:09 +02:00
Ottermandias
eb0e7e2f5f Update ocealots code #1. 2024-04-11 21:25:00 +02:00
ocealot
45b1c55b67 Add accessory vfxs 2024-04-11 21:06:13 +02:00
Ottermandias
c0ee80629d Allow right click to paste into filter as long as it is unfocused. 2024-04-09 16:05:55 +02:00
Ottermandias
7280c4b2f7 Selector improvements. 2024-04-09 15:20:38 +02:00
Ottermandias
21a55b95d9 Add rename mod field. 2024-04-09 15:19:44 +02:00
Ottermandias
e94cdaec46 Some more. 2024-04-05 23:19:41 +02:00
Ottermandias
b1ca073276 Turn Settings and Priority into their own types. 2024-04-05 16:35:55 +02:00
Ottermandias
77bf441e62 Update Open Settings and Main UI. 2024-04-05 15:29:19 +02:00
Ottermandias
6e7512c13e Add Punchline. 2024-04-05 14:53:30 +02:00
Ottermandias
a65009dfb0 Fix issue with merging and deduplicating. 2024-04-01 13:59:09 +02:00
Ottermandias
5cebddb0ab Update OtterGui. 2024-03-30 14:59:31 +01:00
Ottermandias
e830a6b180 Merge remote-tracking branch 'Exter-N/adv-edit-improvements' 2024-03-30 14:06:18 +01:00
Exter-N
b4b813fe5e Advanced Editing minor improvements 2024-03-29 20:05:25 +01:00
Ottermandias
8fa49137b1 Merge branch 'master' of github.com:xivDev/Penumbra 2024-03-29 14:44:25 +01:00
Ottermandias
de239578cc Fix weird exception. 2024-03-29 14:44:08 +01:00
Actions User
a39419288c [CI] Updating repo.json for testing_1.0.2.6 2024-03-28 18:36:31 +00:00
Ottermandias
47c5187ad9 Derp. 2024-03-28 19:34:30 +01:00
Ottermandias
b04cb343dd Make setting for crash handler. 2024-03-28 19:32:10 +01:00
Ottermandias
a31bdb66c8 Merge branch 'pbd-modding' 2024-03-28 18:14:36 +01:00
Ottermandias
1ba5011bfa Small changes. 2024-03-28 18:13:07 +01:00
Ottermandias
e793e7793b Fix model import resetting dirty flag. 2024-03-28 15:24:37 +01:00
Exter-N
3066bf84d5 Where did these usings even come from? 2024-03-26 02:32:33 +01:00
Exter-N
efdd5a824b Make human.pbd moddable 2024-03-26 02:29:07 +01:00
Actions User
12532dee28 [CI] Updating repo.json for testing_1.0.2.5 2024-03-22 14:17:47 +00:00
Ottermandias
4175a582b8 Add IPC Providers because I'm still a fucking moron. 2024-03-22 15:15:50 +01:00
Actions User
78a3ff177f [CI] Updating repo.json for testing_1.0.2.4 2024-03-22 13:46:45 +00:00
Ottermandias
6792ed4f94 Remove the fucking test I'm a fucking moron. 2024-03-22 14:44:48 +01:00
Ottermandias
8dcd0451ba
Update repo.json 2024-03-22 13:43:38 +01:00
Ottermandias
d0d35a7938
Update repo.json 2024-03-22 13:39:46 +01:00
Actions User
aabd988a77 [CI] Updating repo.json for testing_1.2.1.2 2024-03-22 12:38:55 +00:00
Ottermandias
d171cea627 Remove DI Reference. 2024-03-22 13:36:55 +01:00
Ottermandias
26730efc1b Update OtterGui 2024-03-22 13:31:38 +01:00
Ottermandias
ca95b9c14c PackageVersion. 2024-03-22 00:55:53 +01:00
Ottermandias
5ea140db98 Add new draw events. 2024-03-22 00:45:52 +01:00
Ottermandias
8fded88813 Update. 2024-03-21 23:50:55 +01:00
Ottermandias
1a9239a358 Test improving object manager. 2024-03-21 23:02:16 +01:00
Actions User
cc88738e3e [CI] Updating repo.json for testing_1.0.2.2 2024-03-21 20:33:37 +00:00
Ottermandias
0436a3705c Merge branch 'refs/heads/AeAstralis/vertCount' 2024-03-21 21:31:44 +01:00
Ottermandias
72979a9743 Remarked changes. 2024-03-21 21:31:30 +01:00
Ottermandias
f3ceb9034e Make crashhandler somewhat more stable, support multi boxing maybe? 2024-03-21 20:27:55 +01:00
Ottermandias
c55d6966cd Update Internal csproj. 2024-03-21 14:29:05 +01:00
Exter-N
739b5b5ad6 CS-ify ShaderReplacementFixer and ModelRenderer 2024-03-21 12:41:24 +01:00
AeAstralis
0ad769e08e
Add tri count per LoD to models tab
Adds the tri count of each LoD on the selected model to the Models tab under
Advanced Editing.
2024-03-20 22:40:01 -04:00
Actions User
384b8fd489 [CI] Updating repo.json for testing_1.0.2.1 2024-03-20 21:40:54 +00:00
Ottermandias
978f41a4d9 Make some stuff safer maybe. 2024-03-20 22:38:53 +01:00
Actions User
fda77b49cd [CI] Updating repo.json for testing_1.0.2.0 2024-03-20 17:22:25 +00:00
Ottermandias
e8fffa47a0 1.0.2.0 2024-03-20 18:20:08 +01:00
Ottermandias
6cb4f7ac8a Update GameData. 2024-03-20 17:35:45 +01:00
Ottermandias
26f3742b31 Update GameData. 2024-03-20 15:27:51 +01:00
Ottermandias
c8216b0acc Use ObjectManager, Actor and Model. 2024-03-19 22:52:20 +01:00
Ottermandias
5b9309a311 Merge branch 'refs/heads/AeAstralis/tagging' 2024-03-19 21:02:04 +01:00
Ottermandias
0e50a8a9e5 More future proof structure for tags. 2024-03-19 21:01:48 +01:00
Ottermandias
52c1708dd2 Change predefined tag handling. 2024-03-19 20:45:16 +01:00
Ottermandias
2e2d3e173e Merge branch 'master' into AeAstralis/tagging 2024-03-19 18:31:45 +01:00
Ottermandias
fe6e1edecc Fix a game object table warning. 2024-03-19 18:31:02 +01:00
Ottermandias
a6e08a1865 Rename ServiceManagerA. 2024-03-19 18:30:00 +01:00
Ottermandias
02f2bf1bc1 Update actions. 2024-03-19 17:38:02 +01:00
Ottermandias
43d356967c Merge branch 'master' into AeAstralis/tagging 2024-03-19 17:35:34 +01:00
Ottermandias
05b7234748 Update to .net8. 2024-03-19 17:35:05 +01:00
Ottermandias
0f89e24377 Improve tag button positioning. 2024-03-18 17:12:30 +01:00
Ottermandias
c34cc4638c Merge branch 'master' into AeAstralis/tagging 2024-03-18 16:51:21 +01:00
Ottermandias
9f7b95746d Use default task scheduler. 2024-03-18 16:50:26 +01:00
Ottermandias
0ec440c388 Fix reloading mods not fixing settings, add some messages on IPC. 2024-03-18 16:41:40 +01:00
Ottermandias
19526dd92d Help marker position. 2024-03-17 14:09:01 +01:00
Ottermandias
814aa92e19 Move tags before advanced. 2024-03-17 14:08:14 +01:00
Ottermandias
038c230427 Rename to Predefined. 2024-03-17 13:59:40 +01:00
Ottermandias
b725d919bb Merge branch 'master' into AeAstralis/tagging 2024-03-17 13:36:15 +01:00
Ottermandias
ceb3bbc5c3 Fix issue with compressed file sizes. 2024-03-17 13:34:49 +01:00
Ottermandias
7cb50030f9 Fix some stuff, add versions. 2024-03-16 16:58:02 +01:00
Ottermandias
c1a9c798ae auto format. 2024-03-16 16:22:07 +01:00
Ottermandias
50f81cc889 Skip locals init. 2024-03-16 16:21:23 +01:00
Ottermandias
4fc763c9aa Keep first empty option in its desired location. 2024-03-16 16:21:06 +01:00
Ottermandias
8318a4bd84 Compatibility fix. 2024-03-16 16:20:46 +01:00
Ottermandias
e08e9c4d13 Add crash handler stuff. 2024-03-16 16:20:34 +01:00
Ottermandias
312fc1df9a Merge branch 'master' into AeAstralis/tagging 2024-03-09 22:50:29 +01:00
Ottermandias
9ba6e4d0af Update API. 2024-03-09 22:49:28 +01:00
Exter-N
29c93f46a0 Add characterglass.shpk to the skin.shpk fixer 2024-03-09 22:32:41 +01:00
Ottermandias
da423b7464 Make lack of Root Directory louder. 2024-03-08 18:13:51 +01:00
ackwell
5c6e0701d9 Simplify EID handling because IDFK at this point 2024-03-02 23:48:55 +01:00
ackwell
a4bd015836 Fix index offset mis-cast causing overflow 2024-03-02 23:48:55 +01:00
ackwell
1cee1c24ec Skip degenerate triangles targeted by shape keys 2024-03-02 23:48:55 +01:00
ackwell
c1cdb28bb5 Use named enum values for vertex decl mismatch error 2024-03-02 23:48:55 +01:00
AeAstralis
282f6d4855
Migrate shared tag to own config, address comments
Migrates the configuration for shared tags to a separate config file, and
addresses CR feedback.
2024-03-01 21:03:34 -05:00
AeAstralis
334be441f8
Update OtterGui to 97ac353
Updates OtterGui to 97ac3538536a17e980027f783ec5e5167b371f71 to include change
that xivdev/Penumbra#399 is dependent on.
2024-03-01 18:04:03 -05:00
AeAstralis
7128326ab9
Add shared tag system for tagging individual mods
Adds a new system of shared tags that are saved in the Penumbra config, and can
then be 1-click added or removed to/from mods via a popup menu. The use case for
this new system is to allow users to more easily re-use tags and to allow them
to quickly tag individual mods.

Shared tags can be added/removed/modified via a new Tags section of the main
Penumbra Settings tab. Once any shared tags have been saved, they can be added
via a new tags button that shows up in the Description and Edit Mod tabs, to the
right of the existing + button that already existed for typing in new tags.

Shared tags have the same restrictions as regular mod tags, and the application
of shared tags should respect the same limits as application of normal tags.

Signed-off-by: AeAstralis <causal_inverse@fastmail.com>
2024-03-01 17:40:45 -05:00
Actions User
0220257efa [CI] Updating repo.json for 1.0.1.0 2024-03-01 13:37:51 +00:00
Ottermandias
af6100dfe4 Mawp. 2024-03-01 14:35:51 +01:00
Actions User
1d74001281 [CI] Updating repo.json for testing_1.0.0.8 2024-02-24 13:27:11 +00:00
Ottermandias
a89aafb310 Let's do this one more time. 2024-02-24 14:24:50 +01:00
Ottermandias
7b0be25f6e Add even more setting changed events and add auto-player-redraw on saving files. 2024-02-24 14:04:46 +01:00
Actions User
883580d465 [CI] Updating repo.json for 1.0.0.7 2024-02-24 11:09:19 +00:00
Ottermandias
1000841f69 Add some settingchanged events. 2024-02-24 12:06:57 +01:00
Ottermandias
add4b8aa83 Misc. 2024-02-23 21:44:49 +01:00
Ottermandias
529788d2e5 Change font pushes. 2024-02-20 16:36:12 +01:00
Actions User
90665c615f [CI] Updating repo.json for 1.0.0.6 2024-02-18 13:48:18 +00:00
Ottermandias
a2bf477481 Cleanup. 2024-02-18 14:46:22 +01:00
Ottermandias
31bc5ec6f9 Make settings change invoke on Temporary Mods. 2024-02-18 13:03:56 +01:00
Ottermandias
80ce6fe21f Use new font functionality. 2024-02-18 12:59:06 +01:00
Ottermandias
2e0e125913 Fix issue with renaming mods with open advanced window. 2024-02-17 13:35:49 +01:00
Actions User
06cf6ce752 [CI] Updating repo.json for 1.0.0.5 2024-02-13 12:42:23 +00:00
Ottermandias
a0ac0dfcfa Bit more update. 2024-02-13 00:22:44 +01:00
Ottermandias
d2bfcefb89 Update Combos. 2024-02-12 23:32:45 +01:00
Ottermandias
95d5d6c4b0 Update submodules. 2024-02-12 23:30:41 +01:00
Ottermandias
a5f0c2f943 Fix exception with empty option groups. 2024-01-29 13:27:12 +01:00
Actions User
4610686a70 [CI] Updating repo.json for 1.0.0.4 2024-01-27 18:10:34 +00:00
Ottermandias
e321cbdf96 Update API minor Version. 2024-01-27 19:07:51 +01:00
Ottermandias
8a0d217977 Merge branch 'mdl-io-triage-4' 2024-01-27 19:05:14 +01:00
Ottermandias
1e4570bd79 Slight cleanup. 2024-01-27 19:05:05 +01:00
Ottermandias
076dab924f Reuse same list for warnings and exceptions. 2024-01-27 18:58:26 +01:00
Ottermandias
5a80e65d3b Add SetCutsceneParentIndex. 2024-01-27 18:51:16 +01:00
ackwell
e9628afaf8 Include specular factor in character material export 2024-01-27 18:35:26 +11:00
ackwell
1649da70a8 Fix Blender 3.6 support for custom colour attribute 2024-01-27 17:56:32 +11:00
ackwell
72775a80bf Ignore invalid attributes on export 2024-01-27 14:08:56 +11:00
ackwell
6693a1e0ba Clear errors/warnings before starting IO 2024-01-27 13:53:56 +11:00
Ottermandias
b543d9fc1d Merge branch 'mdl-io-triage-3' 2024-01-23 23:23:17 +01:00
Ottermandias
a159ef28c3 Cleanup 2024-01-23 23:23:03 +01:00
ackwell
b2bd31a166 Import all primitives of a mesh 2024-01-24 01:54:56 +11:00
ackwell
8487661bc8 Increase imported vertex precision 2024-01-23 21:27:44 +11:00
Ottermandias
6c93cc20df Woops2 2024-01-22 17:24:08 +01:00
Ottermandias
7b1e28c2cf Woops. 2024-01-22 17:08:38 +01:00
Ottermandias
77762734d7 Some Cleanup. 2024-01-22 16:59:51 +01:00
Ottermandias
056d734c4a Merge remote-tracking branch 'Exter-N/csify' 2024-01-22 16:55:11 +01:00
Ottermandias
a2eaa3ed7f Merge remote-tracking branch 'ackwell/mdl-io-color-attribute' 2024-01-22 16:54:52 +01:00
Ottermandias
b79fbc7653 Some cleanup. 2024-01-22 16:54:05 +01:00
Ottermandias
363b220613 Some improvements of the cutscene service. 2024-01-22 16:54:05 +01:00
ackwell
d76411e66c Fix bounding box calculations for models offset from the origin 2024-01-23 00:40:29 +11:00
Exter-N
c2e5499aef ClientStructs-ify some stuff 2024-01-22 01:51:42 +01:00
Exter-N
b5a71ed7b3 Add locale environment variables to support info 2024-01-21 22:25:27 +01:00
Exter-N
4183e29249 Increase version. (Cargo Cult'd from Glamourer) 2024-01-21 22:25:01 +01:00
ackwell
8167907d91 The other two 2024-01-22 00:34:16 +11:00
ackwell
ca393267f6 Spike custom vertex attribute handling 2024-01-22 00:04:11 +11:00
Actions User
38d855684b [CI] Updating repo.json for 1.0.0.3 2024-01-20 15:09:07 +00:00
Ottermandias
964ddc2572 Merge branch 'mdl-io-warnings' 2024-01-20 16:07:01 +01:00
Ottermandias
7db9599511 Auto-format and stuff. 2024-01-20 16:06:33 +01:00
Ottermandias
fff9fb00f8 Merge branch 'master' into mdl-io-warnings
# Conflicts:
#	Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs
2024-01-20 15:39:25 +01:00
Ottermandias
edad7d9ec9 Update persistent links. 2024-01-20 13:47:03 +01:00
Ottermandias
3debd47064 stupid. 2024-01-20 13:33:51 +01:00
Ottermandias
1e33a8bb22 Merge branch 'mdl-io-triage-2' 2024-01-20 13:17:23 +01:00
Ottermandias
153b1e0d83 Meep 2024-01-20 13:17:12 +01:00
Ottermandias
c752835d2c Make CopySettings save even for unused settings. 2024-01-20 13:12:15 +01:00
ackwell
de08862a88 Add documentation links 2024-01-20 21:28:36 +11:00
ackwell
655d1722c1 Fail soft on invalid attribute masks 2024-01-20 19:16:19 +11:00
ackwell
c11519c95e Fix further content expanding other sections 2024-01-20 15:32:44 +11:00
ackwell
ae409c2cd1 Fix shape value offset handling 2024-01-20 15:31:27 +11:00
ackwell
0d3dde7df3 Tweaks 2024-01-20 01:09:26 +11:00
ackwell
cbd99f833a Allow export of missing bones with warnings 2024-01-20 00:03:58 +11:00
ackwell
0486d049b0 Make material export fallible 2024-01-19 22:20:54 +11:00
ackwell
aa01acd76a Move off messager 2024-01-19 19:41:00 +11:00
ackwell
6da725350a Wire up notifier through import 2024-01-19 02:56:01 +11:00
ackwell
6f3be39cb9 Wire up notifications through export 2024-01-19 02:11:50 +11:00
ackwell
5c15a3a4ff Set up notifier infrastructure 2024-01-19 02:09:43 +11:00
Actions User
8c763d5379 [CI] Updating repo.json for 1.0.0.2 2024-01-17 16:24:57 +00:00
Ottermandias
65af4267f0 Fix variant path generation (2), file was unsaved :/ 2024-01-17 14:46:44 +01:00
ackwell
202f6e4728 Fix file path resolution for file swaps 2024-01-17 14:44:05 +01:00
ackwell
2c5f22047a Generate white vertex colours if missing 2024-01-17 14:44:05 +01:00
ackwell
107f6706d3 i am immensely vain 2024-01-17 14:44:05 +01:00
ackwell
b089bbca37 Merge element ids and flags 2024-01-17 14:44:05 +01:00
ackwell
4b81b065aa Calculate primary BoundingBox 2024-01-17 14:44:05 +01:00
Ottermandias
eb02d2a7a7 Fix variant path generation. 2024-01-17 14:37:49 +01:00
Ottermandias
fdd0145975 Update OtterGui. 2024-01-17 12:14:58 +01:00
Ottermandias
bbac3daf01 Update BNPCs. 2024-01-17 12:14:29 +01:00
Actions User
0b50593acd [CI] Updating repo.json for 1.0.0.1 2024-01-16 17:24:05 +00:00
Ottermandias
e5ddae585c Update Submodules. 2024-01-16 18:21:52 +01:00
Actions User
8509ccba30 [CI] Updating repo.json for 1.0.0.0 2024-01-16 15:39:56 +00:00
Ottermandias
da1b9e9e90 Cleanup, fix tangent/normal mixup. 2024-01-16 16:34:57 +01:00
Ottermandias
47e6e70272 Merge remote-tracking branch 'ackwell/mdl-import-tangent-calc' 2024-01-16 16:16:28 +01:00
Ottermandias
0ff7e49e4d Prepare changelog. 2024-01-16 16:16:11 +01:00
ackwell
5e794b73ba Consider normal morphs for morphed bitangent calculations 2024-01-17 01:40:19 +11:00
ackwell
ea04cc554f Fix up export a little 2024-01-17 00:22:13 +11:00
ackwell
9fae88934d Calculate missing tangents on import, convert all to bitangents for use 2024-01-17 00:17:22 +11:00
Ottermandias
b53a2f1def Some further cleanup. 2024-01-14 19:28:51 +01:00
Ottermandias
70e72f5790 Update OtterGui and maybe handle dependency issues. 2024-01-14 19:28:51 +01:00
Actions User
f147e66953 [CI] Updating repo.json for testing_0.8.3.7 2024-01-14 13:17:42 +00:00
Ottermandias
965f8efd80 Add function that handles prepending DX11 dashes. 2024-01-14 14:15:13 +01:00
Actions User
574a129772 [CI] Updating repo.json for testing_0.8.3.6 2024-01-14 12:37:57 +00:00
Ottermandias
4749769dd4 Merge branch 'mdl-export-materials' 2024-01-14 13:35:57 +01:00
Ottermandias
3b9d841014 Minor cleanup. 2024-01-14 13:35:46 +01:00
Ottermandias
7c83e30e9f Merge branch 'master' into mdl-export-materials 2024-01-14 13:17:36 +01:00
Ottermandias
65fbf13afe Parsing... 2024-01-14 13:16:30 +01:00
ackwell
ec92f93d22 Improve material and texture path resolution 2024-01-14 22:36:33 +11:00
ackwell
0e50cc9c47 Handle character mask R same as other shaders 2024-01-14 22:27:23 +11:00
ackwell
9ff3227cf4 Cleanup pass 2024-01-14 20:12:17 +11:00
ackwell
5e6ca8b22c Improve fallback handling 2024-01-14 17:37:34 +11:00
ackwell
a6788c6dd3 Add hair and iris support 2024-01-14 17:30:13 +11:00
ackwell
b5d4b31301 Add skin.shpk support 2024-01-14 12:35:26 +11:00
ackwell
f71096f8b0 Handle mask ambient occlusion 2024-01-14 00:38:28 +11:00
Ottermandias
2d8b7efc00 Some cleanup. 2024-01-13 14:10:30 +01:00
ackwell
ca58c81bce Add characterglass support 2024-01-14 00:06:16 +11:00
ackwell
2fa7272762 Add support for explicit diffuse + specular textures 2024-01-13 23:52:26 +11:00
ackwell
e8fd452b8f Improve file reading 2024-01-13 22:16:47 +11:00
ackwell
db2081f14d More refactors of operation, extract specular color 2024-01-13 21:36:42 +11:00
ackwell
4572cb83f0 Move table calcs into struct 2024-01-13 20:48:46 +11:00
ackwell
74ffc56d6c Fix errors with same name expanding together 2024-01-13 20:48:15 +11:00
ackwell
96f40b7ddc Expand to more general-purpose transform codepath 2024-01-13 20:33:45 +11:00
ackwell
509b4c8866 Wire up normals and opacity 2024-01-13 17:05:57 +11:00
ackwell
c8e58c08a0 Compose character diffuse 2024-01-13 16:11:51 +11:00
ackwell
c6642c4fa3 Spike material export workflow 2024-01-13 11:32:26 +11:00
Ottermandias
91cea50f02 Move more hooks in own classes. 2024-01-11 15:31:32 +01:00
Actions User
be588e2fa3 [CI] Updating repo.json for testing_0.8.3.5 2024-01-11 12:33:42 +00:00
Ottermandias
4a6e7fccec Fix scrolling weirdness. 2024-01-11 13:31:33 +01:00
Ottermandias
63fff56a60 Merge remote-tracking branch 'ackwell/mdl-name-io' 2024-01-11 12:47:23 +01:00
ackwell
b81f3f423c Cleanup pass 2024-01-11 21:54:52 +11:00
ackwell
2e473a62f4 Sneak a small one in 2024-01-11 21:28:52 +11:00
ackwell
edcffb9d9f Allow keeping existing mdl attributes 2024-01-11 21:26:34 +11:00
ackwell
a0e9e2ead3 Merge branch 'master' into mdl-name-io 2024-01-11 20:39:44 +11:00
ackwell
dada03905f Import attributes 2024-01-11 18:54:53 +11:00
Ottermandias
0c5d47e3d1 Make Save-in-Place require modifier. 2024-01-10 22:40:10 +01:00
Ottermandias
7f7b35f370 Fix issue with RSP values. 2024-01-10 21:20:19 +01:00
Ottermandias
401704712e Merge remote-tracking branch 'ackwell/mdl-error-messaging' 2024-01-10 16:28:34 +01:00
Ottermandias
4b198ef1e4 Misc 2024-01-10 16:27:11 +01:00
ackwell
182550ce15 Export attributes 2024-01-11 00:34:18 +11:00
ackwell
64aed56f7c Allow keeping existing mdl materials 2024-01-10 22:39:48 +11:00
ackwell
d2f93f8562 Import material names 2024-01-10 20:33:24 +11:00
ackwell
3cd438bb5d Export material names 2024-01-10 01:17:47 +11:00
ackwell
ec114b3f6a Prevent import of models with too many shape values 2024-01-10 00:03:32 +11:00
ackwell
c3ba8a2231 Improve error messaging 2024-01-09 01:24:31 +11:00
Ottermandias
36cbca4684 Add icons to import/export headers. 2024-01-08 13:52:52 +01:00
Actions User
025e3798a7 [CI] Updating repo.json for testing_0.8.3.4 2024-01-07 22:25:53 +00:00
Ottermandias
e344bd4258 Merge branch 'mdl-import' 2024-01-07 23:23:42 +01:00
Ottermandias
8c7c7e20a0 Update OtterGui 2024-01-07 23:23:25 +01:00
Ottermandias
b0f61e6929 Auto formatting, some cleanup, some initialization changes. 2024-01-07 23:22:48 +01:00
Ottermandias
a2b92f1296 Some rework, add drag & drop. 2024-01-07 23:03:52 +01:00
Ottermandias
4c18b747b1 Merge branch 'master' into mdl-import
# Conflicts:
#	Penumbra/Import/Models/ModelManager.cs
#	Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs
2024-01-07 15:30:54 +01:00
Ottermandias
2e935a6378 Update GameData. 2024-01-07 15:14:58 +01:00
Ottermandias
2f6905cf35 Minimal cleanup. 2024-01-07 14:42:16 +01:00
ackwell
3f8ac1e8d0 Add support for body and head slot EST 2024-01-07 21:56:21 +11:00
ackwell
8bc71fb1b3 Fix viera ears 2024-01-07 20:47:44 +11:00
ackwell
0440324432 Genericise est logic to handle face 2024-01-07 20:16:15 +11:00
ackwell
aa7f0bace9 Wire up hair EST resolution 2024-01-07 19:49:13 +11:00
ackwell
b62bc44564 Clean up model import UI/wiring 2024-01-07 11:29:31 +11:00
ackwell
1a88cefd52 Merge branch 'master' into mdl-import 2024-01-07 10:10:39 +11:00
Ottermandias
981721ae85 Fix issue with unloaded Message Service. 2024-01-06 23:26:59 +01:00
Actions User
9311f80455 [CI] Updating repo.json for testing_0.8.3.3 2024-01-06 17:49:43 +00:00
Ottermandias
fe92ac34f0 Merge branch 'mdl-export' 2024-01-06 18:41:50 +01:00
Ottermandias
677c9bd801 Some cleanup and using new features / intellisense recommendations. 2024-01-06 18:37:52 +01:00
Ottermandias
51bb9cf7cd Use existing game path functionality for sklb resolving, some cleanup. 2024-01-06 18:26:30 +01:00
ackwell
13d594ca87 Clean up models 2024-01-06 23:13:34 +11:00
ackwell
1a1c662364 Clean up meshes 2024-01-06 20:40:39 +11:00
ackwell
6de3077afa Clean up submeshes 2024-01-06 16:37:41 +11:00
ackwell
b5b3e1b1f2 Tidy up vertex attributes 2024-01-06 11:55:37 +11:00
Ottermandias
c33545acdf Rework game path selection a bit. 2024-01-05 19:02:50 +01:00
Ottermandias
55f38865e3 Memorize last selected mod and state of advanced editing window. 2024-01-05 18:13:03 +01:00
Ottermandias
306a9c217a Fix FileDialog being drawn multiple times. 2024-01-05 14:51:41 +01:00
Ottermandias
1b98626a61 Merge branch 'master' into mdl-export
# Conflicts:
#	Penumbra/Services/ServiceManagerA.cs
#	Penumbra/UI/AdvancedWindow/ModEditWindow.cs
#	Penumbra/packages.lock.json
2024-01-05 14:31:14 +01:00
Ottermandias
41d900ff51 Update GameData. 2024-01-05 14:27:05 +01:00
Ottermandias
3f1234373d Merge branch 'dev' 2024-01-05 14:25:21 +01:00
ackwell
70a09264a8 Bone table imports 2024-01-05 22:35:36 +11:00
ackwell
6641f5425b Add morph handling for normal/tangent 2024-01-05 20:13:39 +11:00
ackwell
acaa49fec5 Add shape key support 2024-01-05 15:32:31 +11:00
ackwell
4e8695e7a4 Spike submeshes 2024-01-05 01:03:54 +11:00
ackwell
79de6f1714 Basic multi mesh handling 2024-01-04 23:33:54 +11:00
ackwell
b3fe538219 Split vertex attribute logic into seperate file 2024-01-04 21:47:48 +11:00
ackwell
b7edf521b6 SuzanneWalker 2024-01-04 19:35:42 +11:00
ackwell
e8e87cc6cb Whoops 2024-01-02 14:36:24 +11:00
ackwell
655e2fd2ca Flesh out skeleton path resolution a bit 2024-01-02 14:36:18 +11:00
ackwell
d85cbd8051 Add UV2 support 2024-01-02 12:41:14 +11:00
ackwell
215f807483 Fix oversight in bone index mapping generation 2024-01-01 23:52:37 +11:00
ackwell
f71d922198 Merge remote-tracking branch 'upstream/master' into mdl-export 2024-01-01 14:47:57 +11:00
ackwell
bb9e7cac07 Clean up UI 2024-01-01 14:21:38 +11:00
ackwell
73ff3642fc Async game path resolution 2024-01-01 13:30:04 +11:00
ackwell
9f981a3e52 Render export errors 2024-01-01 13:10:50 +11:00
ackwell
a059942bb2 Clean up + docs 2024-01-01 12:57:56 +11:00
ackwell
08ed3ca447 Handle mesh skeleton edge cases 2024-01-01 11:31:38 +11:00
ackwell
518117b25a Add submeshless support 2024-01-01 11:01:31 +11:00
Ottermandias
bc068f9913 Fix offsets. 2024-01-01 00:48:20 +01:00
Ottermandias
68c782f0b9 Move all meta hooks to own classes. 2024-01-01 00:17:15 +01:00
Ottermandias
da019e729d Move all animation and game event hooks to own classes. 2023-12-31 15:10:30 +01:00
ackwell
dc845b766e Clean up top-level conversion utilities. 2024-01-01 00:57:27 +11:00
ackwell
f1379af92c Add UV export 2024-01-01 00:38:24 +11:00
ackwell
551c25a64c Move a few things to export subdir 2024-01-01 00:18:03 +11:00
ackwell
6a2b802196 Add shape key names 2023-12-31 17:11:08 +11:00
ackwell
989915ddbe Add initial shape key support 2023-12-31 16:10:20 +11:00
ackwell
309f0351fa Build indices for entire mesh 2023-12-31 15:33:37 +11:00
Ottermandias
81cdcad72e Improve automatic service detection. 2023-12-30 14:38:52 +01:00
ackwell
f7a2c17415 Quick submesh implementation 2023-12-30 18:31:15 +11:00
ackwell
727fa3c183 Initial pass on skinned mesh output 2023-12-30 17:07:34 +11:00
Actions User
697b5fac65 [CI] Updating repo.json for testing_0.8.3.2 2023-12-29 17:20:11 +00:00
Ottermandias
b5c69b2946 Merge branch 'dev'
# Conflicts:
#	Penumbra/UI/AdvancedWindow/ModEditWindow.cs
2023-12-29 18:14:38 +01:00
ackwell
695c18439d Hook up rudimentary skeleton resolution for equipment models 2023-12-30 02:41:19 +11:00
ackwell
18fd36d2d7 Bit of cleanup 2023-12-29 23:49:55 +11:00
ackwell
71fc901798 Resolve mdl game paths 2023-12-29 19:16:42 +11:00
ackwell
d7cac3e09a Clean up and refactor skeleton logic 2023-12-29 03:06:48 +11:00
ackwell
d646c5e4b5 Resolve skeleton path 2023-12-28 16:49:44 +11:00
ackwell
635d606112 Initial skeleton tests 2023-12-28 15:51:20 +11:00
ackwell
bc24110c9f Move mesh logic to new file, export all meshes 2023-12-28 02:15:14 +11:00
ackwell
ca46e7482f Flesh out geometry handling 2023-12-28 00:44:19 +11:00
ackwell
81425b458e Use vertex element enums 2023-12-27 17:25:14 +11:00
ackwell
b7472f722e poc submesh position export 2023-12-27 16:17:39 +11:00
ackwell
ed283afe2c async is a great idea lets do more of that 2023-12-27 01:44:24 +11:00
ackwell
df43083101 export per example 2023-12-27 01:21:26 +11:00
Ottermandias
f8331bc4d8 Fix the mod panels header not resetting data when a selected mod updates. 2023-12-24 14:36:21 +01:00
Ottermandias
28752e2630 Fix issues with EQDP files for invalid characters. 2023-12-24 14:35:59 +01:00
Ottermandias
19866c5638 Merge branch 'mdl-attributes' 2023-12-22 15:19:01 +01:00
Ottermandias
a001fcf24f Some cleanup. 2023-12-22 15:18:43 +01:00
Ottermandias
dc583cb8e2 Update gamedata. 2023-12-22 14:24:41 +01:00
Ottermandias
4aa19e49d5 Add filtering mods by changed item categories. 2023-12-22 14:22:03 +01:00
ackwell
b22470ac79 Finish up mesh material combos 2023-12-23 00:12:59 +11:00
ackwell
a581495c7e Flesh out material wiring 2023-12-22 23:49:50 +11:00
ackwell
829016a1c4 Spike improved UI 2023-12-22 23:16:23 +11:00
ackwell
72f57d292b group meshes by lod 2023-12-22 03:34:20 +11:00
Ottermandias
2051197c65 Change again. 2023-12-21 15:20:39 +01:00
Ottermandias
c138c39c06 Change CharacterWeapon names. 2023-12-21 15:12:41 +01:00
Ottermandias
bb382459eb Merge branch 'master' into dev 2023-12-21 13:27:14 +01:00
ackwell
17e6838422 Swap to tree nodes for more compact UX 2023-12-21 20:56:15 +11:00
ackwell
7ef50f7bb4 Add material list to further content 2023-12-21 20:56:14 +11:00
ackwell
28246244cd Move persitence logic to tab file 2023-12-21 20:56:14 +11:00
ackwell
f04b295989 Scaffold tab file 2023-12-21 20:56:14 +11:00
ackwell
27123f2a64 Inline submesh UI, fix visual offset 2023-12-21 20:56:14 +11:00
ackwell
8ba20218c6 whoops 2023-12-21 20:56:13 +11:00
ackwell
49b63d2208 Draw the rest of the owl 2023-12-21 20:56:13 +11:00
ackwell
2a0e6ce1aa WIP .mdl updates 2023-12-21 20:56:13 +11:00
Actions User
6d89ea5a71 [CI] Updating repo.json for 0.8.3.1 2023-12-21 09:43:40 +00:00
Ottermandias
969ba38ffe Prevent layer editing. 2023-12-21 10:41:09 +01:00
Ottermandias
f022d2be64 Rework DalamudServices, 2023-12-20 18:47:30 +01:00
Ottermandias
d8f5851e0c Move signatures and add Footsteps. 2023-12-20 16:43:30 +01:00
Ottermandias
5d28904bdf Update for GameData changes. 2023-12-20 16:39:26 +01:00
Ottermandias
6dc5916f2b Fix some issues. 2023-12-18 17:02:08 +01:00
Ottermandias
b494892d62 Update for changed GameData. 2023-12-18 16:50:52 +01:00
Ottermandias
7d612df951 Update for changed GameData. 2023-12-17 11:51:24 +01:00
Ottermandias
3305250482 Misc. 2023-12-14 14:24:05 +01:00
Ottermandias
0514e72d47 Update sizing for option groups. 2023-12-13 20:47:18 +01:00
Ottermandias
173b4d7306 Respect ascii setting for group names. 2023-12-12 21:05:16 +01:00
Actions User
76cb09b3b5 [CI] Updating repo.json for 0.8.3.0 2023-12-10 14:43:34 +00:00
Ottermandias
54776c45ea 0.8.3.0 2023-12-10 15:41:38 +01:00
Ottermandias
59ea1f2dd6 Add option to clear non-ascii symbols from paths again. 2023-12-10 15:41:26 +01:00
Ottermandias
b14cd26e4e Merge branch 'master' of github.com:xivDev/Penumbra 2023-12-10 15:10:47 +01:00
Ottermandias
bb742463e9 Wait for saves to finish when the file might be read immediately after saving. 2023-12-10 15:10:43 +01:00
Ottermandias
a9f36c6aef Fix inverted percentage, skill. 2023-12-10 15:09:37 +01:00
Actions User
7128f237da [CI] Updating repo.json for testing_0.8.2.3 2023-12-01 15:31:41 +00:00
Ottermandias
a0328aab35 Compile releases from release dalamud, not staging. 2023-12-01 16:29:44 +01:00
Actions User
e0fa8c9285 [CI] Updating repo.json for testing_0.8.2.2 2023-12-01 13:35:51 +00:00
Ottermandias
2c1ce66011 Update Penumbra.Api. 2023-12-01 14:32:13 +01:00
Ottermandias
222a0e5f77 Merge branch 'refs/heads/WorkingRobot/master' 2023-12-01 14:31:00 +01:00
Ottermandias
07e20fb670 Test not redrawing while the fishing rod is out. 2023-12-01 13:49:29 +01:00
Asriel Camora
b595a0da0f
Replace ResourceTree IEnumerables with lists 2023-11-30 10:01:49 -08:00
Asriel Camora
eb0e334437
Add ResourceTree ipc disposes 2023-11-30 09:53:16 -08:00
Ottermandias
e497414cb7 Auto-Formatting and some imgui layouting. 2023-11-29 18:00:30 +01:00
Ottermandias
e0749bb791 Merge remote-tracking branch 'Exter-N/rt-filtering' 2023-11-29 17:47:58 +01:00
Ottermandias
909778c5b4 Merge branch 'editor-highlight-player-paths' 2023-11-29 17:33:10 +01:00
Ottermandias
3d9f8355d2 Make braces clear for scoped using. 2023-11-29 17:32:59 +01:00
Ottermandias
4aa1388b34 Update actions for recursive submodules. 2023-11-29 17:30:57 +01:00
Ottermandias
b3c757c37b Merge branch 'master' into editor-highlight-player-paths 2023-11-29 17:29:09 +01:00
Ottermandias
b727220775 Update OtterGui. 2023-11-29 17:27:09 +01:00
Ottermandias
1101a7a986 Make sure the SubstitutionProvider is initialized before the interface. 2023-11-29 17:23:37 +01:00
Exter-N
18d38a9974 Mod Edit Window: Highlight paths of files on player 2023-11-29 14:31:47 +01:00
Asriel Camora
bb3d3657ed
Add ResourceTree ipc tests 2023-11-28 12:33:37 -08:00
Asriel Camora
d647a62e82
Add ResourceTree ipc structure 2023-11-28 12:33:19 -08:00
Asriel Camora
0f03e0484c
Add ipc GetPlayerResourceTrees, change ipc resource node to be nested 2023-11-28 10:46:03 -08:00
Asriel Camora
73af509885
Add GetGameObjectResourceTrees ipc method 2023-11-28 10:28:37 -08:00
Exter-N
5ebab472b8 Import from Screen: Add option selector 2023-11-26 21:26:35 +01:00
Exter-N
d05f369a94 ResourceTree: Adjustments on filtering 2023-11-26 20:56:35 +01:00
Exter-N
5e76ab3b84 ResourceTree: Add filtering to the UI 2023-11-26 20:18:36 +01:00
Ottermandias
a408b8918c Make hooks not leak. 2023-11-25 18:30:43 +01:00
Actions User
43c6b52d0b [CI] Updating repo.json for 0.8.2.1 2023-11-22 14:27:30 +00:00
Exter-N
a6f7fd623c ResourceTree: Fix model path resolving 2023-11-22 15:24:57 +01:00
Actions User
4204262236 [CI] Updating repo.json for 0.8.2.0 2023-11-22 14:20:25 +00:00
Ottermandias
8a67521511 0.8.2.0 2023-11-22 15:18:10 +01:00
Ottermandias
55ddafea4b 0.8.2.0 2023-11-22 15:16:13 +01:00
Actions User
357b11eb25 [CI] Updating repo.json for testing_0.8.1.10 2023-11-18 12:17:35 +00:00
Ottermandias
85500f0e9d Improve Multi Mod selection. 2023-11-18 13:15:33 +01:00
Ottermandias
3e6967002b Allow filtering for none in certain cases. 2023-11-18 13:15:14 +01:00
Exter-N
d84715ad27 Fix stain preview (√ + order) 2023-11-17 23:53:40 +01:00
Ottermandias
69c493b9d6 Morp. 2023-11-17 17:09:11 +01:00
Ottermandias
908239bf13 Meep. 2023-11-17 16:53:42 +01:00
Ottermandias
ea65296ab7 Add EphemeralConfig. 2023-11-17 16:51:09 +01:00
Ottermandias
dc1c8f42c0 Improve Color Preview. 2023-11-17 15:46:54 +01:00
Ottermandias
2fd8c98147 Add furniture to redraw bar and help, improve redraw bar slightly. 2023-11-17 15:25:44 +01:00
Ottermandias
c88f1a7b1c Add color preview for dye template selection. 2023-11-17 15:25:44 +01:00
Actions User
7e8cd719fd [CI] Updating repo.json for testing_0.8.1.9 2023-11-17 12:11:06 +00:00
Ottermandias
806561b95a Merge branch 'rt-rework' 2023-11-17 13:09:04 +01:00
Ottermandias
8caba8c339 Update GameData again. 2023-11-16 21:16:38 +01:00
Exter-N
63ca044586 Update GameData 2023-11-16 05:48:30 +01:00
Exter-N
3d38495f92 Merge branch 'master' into rt-rework 2023-11-15 20:06:28 +01:00
Exter-N
acfd5d2484 Update Penumbra.GameData
Also remove a check that, if it was still valid, would always be false with the new changes.
2023-11-15 20:04:30 +01:00
Ottermandias
aee942468e Only allow redrawing furniture inside. 2023-11-15 18:34:24 +01:00
Ottermandias
d026ca888f Add Furniture Redrawing despite crash. 2023-11-15 16:10:22 +01:00
Ottermandias
ab902cbe9e Fix issue with ring identification 2023-11-15 16:10:22 +01:00
Exter-N
13044763cb Redraw player ornament, allow redrawing by index 2023-11-15 15:46:10 +01:00
Exter-N
cb43fed9d3 ResourceTree: Handle monster MTRL 2023-11-14 21:14:01 +01:00
Exter-N
60551c8739 ResourceTree: Are we fast yet? 2023-11-14 20:38:21 +01:00
Exter-N
b2bf6eb0f7 ResourceTree: Handle weapon MTRL special cases 2023-11-13 07:44:48 +01:00
Exter-N
4e26f09109 Merge branch 'master' into rt-rework 2023-11-12 22:47:25 +01:00
Ottermandias
51dba221c4 Add option to open window at game start instead of coupling it with debug mode 2023-11-11 21:09:59 +01:00
Actions User
b5377a961f [CI] Updating repo.json for 0.8.1.8 2023-11-11 13:18:07 +00:00
HoloWise
da880bd76c Fix broken tooltips 2023-11-11 14:11:42 +01:00
Ottermandias
5a64eadb5c Update Stain Data. 2023-11-11 13:59:59 +01:00
Ottermandias
50a7015bc5 Update BNPC Data. 2023-11-11 13:58:14 +01:00
Exter-N
fd163f8f66 ResourceTree: WIP - Path resolution 2023-11-04 18:30:36 +01:00
Exter-N
2852562a03 ResourceTree: Use ResolveXXXPath where possible 2023-11-03 20:30:29 +01:00
Exter-N
c024d7e826 Merge branch 'master' into HEAD 2023-11-03 20:30:23 +01:00
Ottermandias
7dabb3c647 Add some Redrawing Debug UI. 2023-11-03 15:23:48 +01:00
Exter-N
79c43fe7b1 PathResolving: Better function signatures? (names + types + TMB param count + dedupe) 2023-11-03 13:22:07 +01:00
Ottermandias
69a4e2b52e Fix Linking changed items not working. 2023-11-03 12:59:42 +01:00
Exter-N
da54222bb1 ResourceTree: Add EID files 2023-11-02 20:59:09 +01:00
Exter-N
57f8587a43 ResourceTree: Use both game path and resource handle as keys for dedup 2023-11-02 01:18:20 +01:00
Exter-N
28a396470b ResourceTree: De-inline GlobalResolveContext in ResolveContext 2023-11-02 01:11:48 +01:00
Exter-N
3da20f2d89 ResourceTree: Rework Internal flag, improve null checks, simplify 2023-11-02 01:08:02 +01:00
Exter-N
db9bfb00a3 ResourceTree: Show SKP files out of Debug 2023-11-01 03:07:33 +01:00
Exter-N
5085aa500c ResourceTree: Use DrawObject as equipment source + CS-ify a bit more 2023-11-01 03:07:33 +01:00
Exter-N
00dc5f48b1 ClientStructs-ify a few things 2023-11-01 03:07:33 +01:00
Actions User
6375faa758 [CI] Updating repo.json for 0.8.1.7 2023-10-31 11:23:59 +00:00
Ottermandias
8e63452e84 Use some CS sigs. 2023-10-31 11:32:40 +01:00
Ottermandias
06e06b81e9 Support correct handling of offhands in changed items. 2023-10-28 01:13:18 +02:00
Ottermandias
c76a9ace24 Update API Nuget. 2023-10-22 15:40:39 +02:00
Actions User
8fd755c5e6 [CI] Updating repo.json for 0.8.1.6 2023-10-22 13:40:09 +00:00
Ottermandias
2cb92d817a Fix directory rename not updating paths in advanced window. 2023-10-22 15:37:52 +02:00
Ottermandias
25e9a99799 Fix portraits not respecting card settings. 2023-10-22 15:37:34 +02:00
Ottermandias
f910dcf1e0 Add ReverseResolvePlayerPathsAsync. 2023-10-22 15:36:47 +02:00
Ottermandias
f2ef0e15d3 Draw associated BNPCs in debug tab. 2023-10-17 19:42:55 +02:00
Actions User
23f46438a2 [CI] Updating repo.json for 0.8.1.5 2023-10-16 13:13:05 +00:00
Ottermandias
5e79a13708 Expand tooltip for Wait for Plugins on Startup. 2023-10-16 15:10:41 +02:00
Ottermandias
5d2fc72883 Update submodules. 2023-10-16 15:06:38 +02:00
Haselnussbomber
3c59a57ab0 Disable window sounds in ImportPopup 2023-10-10 22:00:05 +02:00
Ottermandias
c24a40fd9f Add support for middle-clicking mods. 2023-10-10 18:02:04 +02:00
Actions User
f5822cf2c8 [CI] Updating repo.json for 0.8.1.4 2023-10-09 22:18:33 +00:00
Ottermandias
4bdc8f126d Make ActorData great again. 2023-10-09 00:10:45 +02:00
Actions User
764ef76e1a [CI] Updating repo.json for 0.8.1.3 2023-10-08 13:08:02 +00:00
Ottermandias
3699923938 Improve save logging. 2023-10-08 15:03:24 +02:00
Ottermandias
4378c826f0 Add some log statements. 2023-10-08 13:19:01 +02:00
Actions User
717ddba8d2 [CI] Updating repo.json for 0.8.1.2 2023-10-07 13:34:11 +00:00
Ottermandias
9871421632 0.8.1.2 2023-10-07 15:31:18 +02:00
Ottermandias
7cdd8656ef Maybe fix issue with individual assignments sometimes getting eaten. 2023-10-06 16:21:39 +02:00
Ottermandias
2d007c189f Fix deletion in selector. 2023-10-06 16:21:39 +02:00
Actions User
9fda19d4c0 [CI] Updating repo.json for 0.8.1.1 2023-10-05 19:25:42 +00:00
Ottermandias
110298f280 Increment Changelog Version. 2023-10-05 21:23:02 +02:00
Ottermandias
422324b6d7 Revert stupid changes due to ResourceCategory change. 2023-10-05 21:22:09 +02:00
Ottermandias
48863c1b64 Merge branch 'master' of github.com:xivDev/Penumbra 2023-10-05 20:31:52 +02:00
Ottermandias
de3a74bbe8 Change SubModules to https 2023-10-05 20:29:34 +02:00
Actions User
3b593103ba [CI] Updating repo.json for 0.8.1.0 2023-10-05 16:33:35 +00:00
Ottermandias
dd587350ea Update changelog discord export. 2023-10-05 18:30:57 +02:00
Ottermandias
52d38eda3a 0.8.1.0 Changelog 2023-10-05 18:21:47 +02:00
Ottermandias
779d6b37a5 Improved messaging. 2023-10-05 18:21:16 +02:00
Ottermandias
19c4c3b50e Merge remote-tracking branch 'Exter-N/stuff-for-65' 2023-10-05 17:57:00 +02:00
Exter-N
c487fb12ec CS-ify LiveMaterialPreviewer and add new shpk name 2023-10-05 17:50:38 +02:00
Ottermandias
8b5437c2c7 Remove CS temp fix. 2023-10-05 17:39:38 +02:00
Ottermandias
73b4227310 Fix slash commands. 2023-10-05 16:23:17 +02:00
Actions User
30a55d401f [CI] Updating repo.json for testing_0.8.0.4 2023-10-04 20:06:28 +00:00
Ottermandias
0aeb407a01 Update CopyCharacterEvent. 2023-10-04 22:02:32 +02:00
Actions User
53f1efa88b [CI] Updating repo.json for testing_0.8.0.3 2023-10-04 18:33:22 +00:00
Ottermandias
069929ce24 Some updates. 2023-10-04 20:30:38 +02:00
Actions User
c21cbcdcd3 [CI] Updating repo.json for testing_0.8.0.2 2023-10-04 14:20:40 +00:00
Ottermandias
8e0877659f Update LoadCharacterSound. 2023-10-04 16:17:13 +02:00
Ottermandias
83ab8e8003 Temporarily fix ShaderPackage.MaterialElement. 2023-10-04 16:17:13 +02:00
Actions User
a18ace433a [CI] Updating repo.json for testing_0.8.0.1 2023-10-04 12:37:47 +00:00
Ottermandias
58b5c44157 Fix an issue with memory locations that suddenly caused issues? 2023-10-04 14:35:03 +02:00
Ottermandias
5fefdfa33b Fix error in log about existing command. 2023-10-04 14:03:51 +02:00
Ottermandias
fb591429d6 Update Sigs. 2023-10-04 03:19:05 +02:00
Ottermandias
e5427858e0 Add support for ActorIdentifier.FromUserString returning multiple identifiers. 2023-10-03 01:43:18 +02:00
Ottermandias
3d2ce1f4bb Use ClientStructs hook for CalculateHeight. 2023-10-02 23:25:15 +02:00
Ottermandias
95746e7450 Merge branch 'API9' 2023-10-02 23:23:56 +02:00
Ottermandias
5394bdc535 Update Submodules. 2023-10-02 23:23:26 +02:00
Ottermandias
8f16aa7ee9 Fix collection button ids. 2023-10-02 23:21:07 +02:00
Ottermandias
0dc06a1733 Add multi deletion to mod selector. 2023-09-29 02:18:44 +02:00
Ottermandias
4e40ed3be4 Merge remote-tracking branch 'Exter-N/allow-intentional-zero-gloss' into API9 2023-09-28 18:13:07 +02:00
Ottermandias
21d503a8cd Update for API 9 2023-09-28 18:12:27 +02:00
Ottermandias
50f6de7809 Update API Level. 2023-09-28 17:26:39 +02:00
Ottermandias
c09568e406 Oops. 2023-09-27 15:59:42 +02:00
Ottermandias
929db5c1a4 Make renaming search paths in context more clear. 2023-09-27 15:52:42 +02:00
Exter-N
6799bdbb03 Material Editor: Allow intentional 0 gloss 2023-09-27 03:15:18 +02:00
Actions User
6ca8ad2385 [CI] Updating repo.json for 0.8.0.0 2023-09-26 13:46:33 +00:00
Ottermandias
efdebeca54 Add 0.8.0.0 Changelog 2023-09-26 15:36:49 +02:00
Ottermandias
677d44442b Enable reset of substitutions. 2023-09-26 14:18:45 +02:00
Ottermandias
6130929985 Update API. 2023-09-26 14:16:09 +02:00
Actions User
4c73453b4c [CI] Updating repo.json for testing_0.7.3.13 2023-09-23 12:30:49 +00:00
Ottermandias
8aebd441a1 Add option to disable conflicts from conflict panel. 2023-09-23 14:25:47 +02:00
Ottermandias
2c0650614f Merge branch 'mtrl-preview-extension' 2023-09-21 02:16:22 +02:00
Ottermandias
3f439bacb2 Extract remaining global usings for System libs. 2023-09-21 02:15:23 +02:00
Ottermandias
11bf0d2998 Optimize ResourceTree somewhat. 2023-09-21 02:06:45 +02:00
Ottermandias
40b6c6022a Add automatic restore from backup for sort_order and active_collections for now. 2023-09-20 18:51:17 +02:00
Exter-N
69388689ac Material Editor: Extend live preview. 2023-09-20 01:53:10 +02:00
Actions User
5a24d9155b [CI] Updating repo.json for testing_0.7.3.12 2023-09-19 19:52:53 +00:00
Ottermandias
1760efb477 Fix ambiguous reference for no fucking reason. 2023-09-19 21:50:43 +02:00
Ottermandias
348480ed68 Update OtterGui. 2023-09-19 21:46:15 +02:00
Ottermandias
c29d0a5a4c Remove some allocations from resource tree. 2023-09-19 21:44:49 +02:00
Ottermandias
89c7095843 Merge branch 'restree-bulk-reverse' 2023-09-19 21:25:36 +02:00
Ottermandias
808d7ab017 Add CalculateHeight Hook 2023-09-19 20:18:53 +02:00
Exter-N
f02a37b939 ResourceTree: Reverse-resolve in bulk 2023-09-19 01:32:31 +02:00
Actions User
69012e5ecd [CI] Updating repo.json for testing_0.7.3.11 2023-09-18 17:51:30 +00:00
Ottermandias
5067ab2bb2 Add load state to resource watcher. 2023-09-18 18:18:23 +02:00
Ottermandias
5506dcc3f3 Api nuget version. 2023-09-18 17:20:19 +02:00
Ottermandias
fee99dd17e Fix params bug. 2023-09-18 17:18:11 +02:00
Ottermandias
4ffb69ea31 Remove enums folder from csproj?! 2023-09-18 17:14:42 +02:00
Ottermandias
3905d5b976 Rename ResourceType file. 2023-09-18 17:14:16 +02:00
Ottermandias
ea79469abd Move IPC Arguments around. 2023-09-18 17:06:16 +02:00
Exter-N
a241b933ca ResourceTree: Avoid enumerating the whole object table in some cases 2023-09-18 17:02:11 +02:00
Exter-N
22966e648d ResourceTree IPC: Remove mergeSameCollection. 2023-09-18 17:02:11 +02:00
Exter-N
d7205344eb ResourceTree improvements + IPC
- Moves ResourceType enum out of GameData as discussed on Discord ;
- Adds new color coding for local player and non-networked objects on On-Screen ;
- Adds ResourceTree-related IPC ;
- Fixes #342.
2023-09-18 17:02:08 +02:00
Ottermandias
2b4a01df06 Make line endings explicit in editorconfig and share in sub projects, also apply editorconfig everywhere and move some namespaces. 2023-09-18 17:01:21 +02:00
Ottermandias
53adb6fa54 Use System global usings. 2023-09-15 14:15:52 +02:00
Ottermandias
25cdc00404 Merge branch 'color-table' 2023-09-15 14:00:44 +02:00
Ottermandias
916ff0cbb2 Auto Formatting. 2023-09-15 14:00:30 +02:00
Ottermandias
50d7619dde GameData Commit. 2023-09-15 13:57:39 +02:00
Exter-N
28c2af4266 Material Editor: Split ColorTable apart from ColorSet 2023-09-15 13:38:47 +02:00
Ottermandias
652b2e99d2 Add key checks to restoring from backup or deleting backups. 2023-09-15 01:07:01 +02:00
Ottermandias
c5ef7bf46c Add Compacting to API AddMod. 2023-09-15 01:07:01 +02:00
Actions User
470c1317ed [CI] Updating repo.json for testing_0.7.3.10 2023-09-14 15:26:36 +00:00
Ottermandias
4e704770cb Add Filesystem Compression as a toggle and button. Also some auto-formatting. 2023-09-14 17:24:20 +02:00
Actions User
e26873934b [CI] Updating repo.json for testing_0.7.3.9 2023-09-13 18:11:56 +00:00
Ottermandias
7431db2a08 Fix click check for selectables. 2023-09-13 20:09:09 +02:00
Actions User
b352373a52 [CI] Updating repo.json for testing_0.7.3.8 2023-09-13 15:09:13 +00:00
Ottermandias
d21cba4669 Allow drag & drop of multiple mods or folders with Control. 2023-09-13 17:06:35 +02:00
Actions User
4fdb89ce62 [CI] Updating repo.json for testing_0.7.3.7 2023-09-11 14:26:51 +00:00
Ottermandias
8eaf14d932 Add Player and Interface to quick select collections and rework their tooltips and names slightly. 2023-09-11 16:24:07 +02:00
Ottermandias
569fa06e18 Fix CS update creating ambiguous reference. 2023-09-08 14:04:14 +02:00
Ottermandias
40eb0c81b8 Update GameData for new parsing. 2023-09-08 13:59:53 +02:00
Ottermandias
ed243df4f3 Fix changed item flags for emotes. 2023-09-08 13:59:53 +02:00
Actions User
4bd3fd357f [CI] Updating repo.json for testing_0.7.3.6 2023-09-06 19:19:57 +00:00
Ottermandias
6cc89f3e7c Add Emotes to Changed Items. 2023-09-06 21:15:12 +02:00
Actions User
a890258cf5 [CI] Updating repo.json for testing_0.7.3.5 2023-09-05 12:51:00 +00:00
Ottermandias
1cb74aeb9a Merge branch 'fix/skin-fixer-rc' 2023-09-05 14:48:18 +02:00
Ottermandias
0e0733dab0 Some formatting, use ConcurrentSet explicitly for clarity. 2023-09-05 14:48:06 +02:00
Exter-N
32608ea45b Skin Fixer: Switch to a passive approach.
Do not load skin.shpk for ourselves as it causes a race condition.
Instead, inspect the materials' ShPk names.
2023-09-05 12:53:53 +02:00
Exter-N
94a0a3902c Resource Tree: Use /s for game actual paths 2023-09-03 22:04:11 +02:00
Ottermandias
176956a1f8 Merge branch 'restree-less-io' 2023-09-03 13:13:54 +02:00
Ottermandias
2a2fa3bf1d Some auto-formatting and ROS iteration for lookups. 2023-09-03 13:13:35 +02:00
Exter-N
cca626449d Resource Tree: Fix shared model fold state 2023-09-03 05:50:51 +02:00
Exter-N
a17a1e9576 Resource Tree: Make skp child of sklb 2023-09-02 17:59:13 +02:00
Exter-N
30c622c085 Resource Tree: Add ChangedItem-like icons, make UI prettier 2023-09-02 17:59:13 +02:00
Exter-N
db521dd21c Resource Tree: Deduplicate nodes, add skp 2023-09-02 17:59:13 +02:00
Exter-N
ccc0b51a99 Resource Tree: Improve mtrl and sklb support 2023-09-02 17:59:09 +02:00
Actions User
ecfe88faa6 [CI] Updating repo.json for testing_0.7.3.4 2023-09-02 14:00:06 +00:00
Ottermandias
052811049e Merge remote-tracking branch 'Exter-N/material-editor-adjustments' 2023-09-02 15:56:08 +02:00
Ottermandias
0741ce0ce7 Fix variant gamepath. 2023-09-02 15:55:06 +02:00
Ottermandias
b985833aaa Check for drawObject != null before invoking draw object created event. 2023-09-02 15:54:11 +02:00
Exter-N
1b490510c7 Fix compiler warning 2023-09-01 19:09:38 +02:00
Exter-N
5899a59e06 Material editor: Vector field spacing 2023-09-01 18:46:40 +02:00
Exter-N
686c53d919 Material editor: Customizable highlight color 2023-09-01 18:46:31 +02:00
Exter-N
233a865c78 Material editor: use a SafeHandle for texture swapping 2023-09-01 17:57:01 +02:00
Ottermandias
0dbe9b59c2 Cleanup 2023-09-01 17:31:46 +02:00
Ottermandias
6f760426c7 Fix newtonsoft not playing well with records with strings. 2023-09-01 17:31:46 +02:00
Actions User
af4373ce50 [CI] Updating repo.json for testing_0.7.3.3 2023-08-31 16:36:03 +00:00
Ottermandias
82cecdaf7d Merge branch 'feature/material-editor-2099' 2023-08-31 18:32:43 +02:00
Ottermandias
616a4635d1 Fix slash direction in material path. 2023-08-31 18:32:18 +02:00
Ottermandias
a768b039a8 Restructure Live Preview. 2023-08-31 18:25:29 +02:00
Ottermandias
e5e555b981 Auto-formatting and some cleanup. 2023-08-31 17:12:39 +02:00
Ottermandias
ff01276869 Small cleanup in ResolveContext. 2023-08-31 01:11:57 +02:00
Ottermandias
5023fafc19 Some formatting in Materials.Shpk. 2023-08-31 01:01:10 +02:00
Ottermandias
2ac997610d Remove Finalize from FileEditor. 2023-08-31 01:00:46 +02:00
Ottermandias
8695e89792 Merge branch 'master' into feature/material-editor-2099 2023-08-31 00:49:49 +02:00
Ottermandias
5ba993cd6f Merge branch 'feature/skin-shpk-fixer' 2023-08-30 20:53:07 +02:00
Ottermandias
6d3e930440 Use better event in SkinFixer and some cleanup. 2023-08-30 20:52:39 +02:00
Exter-N
f238049750 Skin Fixer: Fix potential ref leak + add SRH
`SafeResourceHandle` wraps a `ResourceHandle*` with auto `IncRef` / `DecRef`, to further help prevent leaks.
2023-08-30 19:16:22 +02:00
Ottermandias
600f5987cd Slight restructuring. 2023-08-30 17:25:26 +02:00
Exter-N
38a22c5298 Textures: Simplify away _targetPixels 2023-08-30 02:53:37 +02:00
Exter-N
5346abaadf Material editor: tear down previewers bound to a CharacterBase that goes away 2023-08-30 01:51:43 +02:00
Exter-N
bb8d9441f4 Material editor: tweak colorset highlighting
Make the frequency framerate-independent, set it to 1 Hz, and decrease the dynamic range.

Thanks @StoiaCode for feedback!
2023-08-30 01:14:20 +02:00
Exter-N
848e4ff8a6 Textures: Refactor resizing code 2023-08-29 03:25:54 +02:00
Exter-N
598f3db06a Textures: PR #327 feedback 2023-08-29 00:42:59 +02:00
Exter-N
f54146ada4 Textures: PR #327 feedback 2023-08-28 03:30:21 +02:00
Exter-N
ffb8f0e8d3 Material editor: Allow negatives again with R²G²B²
There seems to be people using it.
2023-08-28 03:06:18 +02:00
Exter-N
6c0864c8b9 Textures: Add a matrix preset that drops alpha 2023-08-28 01:54:14 +02:00
Exter-N
ec14efb789 Skin Fixer: Make resolving skin.shpk for new draw objects async 2023-08-27 04:04:14 +02:00
Exter-N
ead88f9fa6 Skin Fixer (fixes modding of skin.shpk) 2023-08-27 03:45:05 +02:00
Exter-N
99b43bf577 Textures: Automatic resizing 2023-08-26 13:49:48 +02:00
Exter-N
792707a6e3 Textures: Renumber CombineOps.
Positive values in this enum also double as indices into the labels and tooltip arrays.

(confirmed skill issue moment)
2023-08-26 13:44:34 +02:00
Ottermandias
4f71065d67 Merge remote-tracking branch 'refs/remotes/Exter-N/feature/texture-stuff'
# Conflicts:
#	Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs
2023-08-25 18:07:04 +02:00
Exter-N
781bbb3d26 Textures: Un-merge save buttons, make ignore unselectable 2023-08-25 17:59:18 +02:00
Ottermandias
87c5164367 Small cleanup, auto-formatting. 2023-08-25 17:57:57 +02:00
Exter-N
afd7aab37d Update GameData 2023-08-25 17:46:53 +02:00
Exter-N
42b874413d Add a few texture manipulation tools. 2023-08-25 06:37:24 +02:00
Exter-N
9364ecccd2 Material editor: better color constants 2023-08-25 06:17:54 +02:00
Exter-N
b8d09ab660 Material editor 2099 2023-08-25 01:19:39 +02:00
Exter-N
f64fdd2b26 Material editor: live-preview changes 2023-08-24 05:52:13 +02:00
Exter-N
ccca2f1434 Material editor: improve color accuracy 2023-08-24 05:52:13 +02:00
Ottermandias
3530e139d1 Add some unnamed mounts to actor identification. 2023-08-23 18:47:22 +02:00
Ottermandias
a6ae580b9f Explain comment. 2023-08-23 18:42:19 +02:00
Actions User
3a8bf5dfa1 [CI] Updating repo.json for 0.7.3.2 2023-08-22 13:21:39 +00:00
Ottermandias
00adaca32e Keep the texture alive during write. 2023-08-22 15:18:59 +02:00
Ottermandias
bc6e9d1d84 Update DirectXTex/OtterTex 2023-08-22 15:18:30 +02:00
Ottermandias
ad830dc56e Disable UI for textures when converting. 2023-08-22 14:18:36 +02:00
Actions User
ebaa42f311 [CI] Updating repo.json for 0.7.3.1 2023-08-18 18:37:27 +00:00
Ottermandias
4c611530f3 Temporarily not use dalamud function because it is not available in release yet. 2023-08-18 20:34:23 +02:00
Actions User
82ba2cd16a [CI] Updating repo.json for 0.7.3.0 2023-08-18 18:07:12 +00:00
Ottermandias
635d5e05ce 0.7.3.0 2023-08-18 20:05:15 +02:00
Ottermandias
53b36f2597 Add drag & drop to texture import. 2023-08-18 17:16:38 +02:00
Ottermandias
0c07d4bec6 Cleanup. 2023-08-16 20:13:34 +02:00
Ottermandias
04b76ddee1 Add support for the DalamudSubstitutionProvider for textures. 2023-08-16 17:25:06 +02:00
Ottermandias
cf3810a1b8 Add filter to texturedrawer. 2023-08-13 14:30:06 +02:00
Ottermandias
af536b3423 Update some Dalamud Services. 2023-08-10 18:10:33 +02:00
Ottermandias
09ca32f33d Add DalamudSubstitutionProvider 2023-08-10 18:10:33 +02:00
Actions User
df808187e2 [CI] Updating repo.json for testing_0.7.2.7 2023-08-10 15:07:04 +00:00
Ottermandias
e615ffcf3d Increment API 2023-08-10 17:01:55 +02:00
Ottermandias
6e11b36401 Add Texture Conversion IPC and use texture tasks. 2023-08-10 16:55:43 +02:00
Ottermandias
af93c2aca9 Revert CS change. 2023-08-10 14:32:02 +02:00
Ottermandias
e24a535a93 Initial Texture rework. 2023-08-08 01:10:57 +02:00
Ottermandias
2f836426d6 Temporary fix for broken CS offset. 2023-08-04 17:01:59 +02:00
Ottermandias
2a7ccb952d Fix missing scaling for item combos. 2023-08-04 17:01:59 +02:00
Ottermandias
0e252d489a Update SharpCompress. 2023-08-04 17:01:59 +02:00
Actions User
af0edf3002 [CI] Updating repo.json for testing_0.7.2.6 2023-08-01 18:40:28 +00:00
Ottermandias
01b88950bf Fix shit. 2023-08-01 20:38:03 +02:00
Actions User
622af4e7e9 [CI] Updating repo.json for testing_0.7.2.5 2023-08-01 15:45:07 +00:00
Ottermandias
930931a846 Fix ChangeCustomize not loading decals from collections. 2023-08-01 17:39:41 +02:00
Ottermandias
2da6a33a62 Some texfile formatting. 2023-08-01 13:12:07 +02:00
Ottermandias
a95877b9e4 Add priority display to mod selector. 2023-08-01 13:12:07 +02:00
Actions User
3738b5f8f0 [CI] Updating repo.json for testing_0.7.2.4 2023-07-30 11:27:53 +00:00
Ottermandias
4df616e4c0 Fix CustomItem recognition. 2023-07-30 13:23:03 +02:00
Ottermandias
1d5e050de6 Move some classes. 2023-07-29 02:46:43 +02:00
Ottermandias
ef916fc93c Add backup option for failure to load option groups. 2023-07-29 02:46:30 +02:00
Ottermandias
18b6b87e6b Use strongly typed ids in most places. 2023-07-29 02:22:31 +02:00
Ottermandias
dccd347432 Fix some EquipItem stuff. 2023-07-25 17:24:00 +02:00
Ottermandias
ec1dee8871 Add GameData as submodule. 2023-07-25 15:56:38 +02:00
Ottermandias
b8c9a98ba2 Remove local GameData 2023-07-25 15:52:39 +02:00
Ottermandias
8d7c779439 Fix dumb. 2023-07-25 15:41:38 +02:00
Ottermandias
a6d68ddd5a Add some known models to identification. 2023-07-24 01:40:56 +02:00
Ottermandias
96e6ff0fbf Fix potential crash in decref. 2023-07-24 01:40:56 +02:00
Ottermandias
4f2a14c9ee Change some item data. 2023-07-24 01:40:56 +02:00
Actions User
774f93f962 [CI] Updating repo.json for testing_0.7.2.3 2023-07-18 22:48:42 +00:00
Ottermandias
27c9523bd7 Small Changes. 2023-07-19 00:44:21 +02:00
Ottermandias
808dabf600 Add DragDropManager. 2023-07-19 00:44:21 +02:00
Ottermandias
344defca8e Typo. 2023-07-19 00:44:21 +02:00
Actions User
65fc029218 [CI] Updating repo.json for 0.7.2.2 2023-07-12 23:07:33 +00:00
Ottermandias
c3b106e359 Remove outdated file. 2023-07-13 00:45:01 +02:00
Ottermandias
62f71df28c Some further small Glamourer changes, increment versioning of gamedata stuff. 2023-07-13 00:43:41 +02:00
Ottermandias
0fb9e77c3c Fix gloss and bug. 2023-07-12 13:11:18 +02:00
Ottermandias
9e0c38169f Glamourer-related changes. 2023-07-12 02:45:40 +02:00
Ottermandias
a7ace8a8c8 Oops. 2023-07-07 00:51:57 +02:00
Ottermandias
64668e0e03 Improve save service. 2023-07-07 00:46:42 +02:00
Ottermandias
4626c2176f Fix multiple options with same label. 2023-07-07 00:46:42 +02:00
Ottermandias
2bc7eb165e Add toggle for the Changed Item category filter. 2023-07-07 00:46:42 +02:00
Actions User
0521cf0d18 [CI] Updating repo.json for 0.7.2.1 2023-07-05 22:53:38 +00:00
Ottermandias
6e7805d58f Fix handling of decals overall. 2023-07-06 00:51:16 +02:00
Ottermandias
e3a608fe0e Fix DecalReverter using wrong variables. 2023-07-06 00:51:16 +02:00
Ottermandias
a6b929c207 Remove GPose condition from timeline loading restrictions. 2023-07-06 00:51:16 +02:00
Actions User
869be0cb95 [CI] Updating repo.json for 0.7.2.0 2023-07-05 14:43:34 +00:00
Ottermandias
93e1b7acb9 Add Changelog. 2023-07-05 16:40:57 +02:00
Ottermandias
81dae22936 Fix some stupidly introduced ambiguities. 2023-07-05 16:18:49 +02:00
Ottermandias
823b195cb1 Update ONE new BNPC Name. 2023-07-05 16:14:53 +02:00
Ottermandias
00bc17c57a Move some stuff to shared things, improve some filesystem rename handling. 2023-07-05 16:13:11 +02:00
Ottermandias
8ea6893fc3 Fix some ToDos, parallelization problems. 2023-07-03 16:39:34 +02:00
Ottermandias
0ed94676ed Update BNPC names. 2023-06-23 01:10:45 +02:00
Ottermandias
0d343c3bab Fix crashes when drawing folders containing %. 2023-06-22 18:11:14 +02:00
Ottermandias
0690c0c53c Small Glamourer stuff. 2023-06-22 18:11:14 +02:00
Exter-N
f88b5761ba Remove null-terminator that was actually useless 2023-06-21 00:42:32 +02:00
Exter-N
22cb33e49e Fix -- texture prefixing in ResourceTree 2023-06-21 00:42:32 +02:00
Ottermandias
895e70555d Fix parameters of EnableDraw 2023-06-20 17:11:47 +02:00
Actions User
5805d5c798 [CI] Updating repo.json for testing_0.7.1.11 2023-06-18 21:51:31 +00:00
650 changed files with 57865 additions and 51222 deletions

View file

@ -1,21 +1,31 @@
[*.proto]
indent_style=tab
indent_size=tab
tab_width=4
[*.{asax,ascx,aspx,axaml,cs,cshtml,css,htm,html,js,jsx,master,paml,razor,skin,ts,tsx,vb,xaml,xamlx,xoml}]
indent_style=space
indent_size=4
tab_width=4
[*.{appxmanifest,axml,build,config,csproj,dbml,discomap,dtd,json,jsproj,lsproj,njsproj,nuspec,proj,props,resjson,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]
indent_style=space
indent_size=2
tab_width=2
# Standard properties
charset = utf-8
end_of_line = lf
insert_final_newline = true
csharp_indent_labels = one_less_than_current
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_prefer_top_level_statements = true:silent
[*]
# Microsoft .NET properties
csharp_indent_braces=false
csharp_indent_switch_labels=true
@ -3566,30 +3576,18 @@ resharper_xaml_xaml_xamarin_forms_data_type_and_binding_context_type_mismatched_
resharper_xaml_x_key_attribute_disallowed_highlighting=error
resharper_xml_doc_comment_syntax_problem_highlighting=warning
resharper_xunit_xunit_test_with_console_output_highlighting=warning
# Standard properties
end_of_line= crlf
csharp_indent_labels = one_less_than_current
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_implicitly_typed_lambda_expression = true:suggestion
csharp_style_expression_bodied_methods = true:silent
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_unbound_generic_type_in_nameof = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_expression_bodied_constructors = true:silent
csharp_style_expression_bodied_operators = true:silent
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
csharp_style_expression_bodied_properties = true:silent
[*.{cshtml,htm,html,proto,razor}]
indent_style=tab
@ -3601,6 +3599,21 @@ indent_style=space
indent_size=4
tab_width=4
[ "*.proto" ]
indent_style=tab
indent_size=tab
tab_width=4
[*.{asax,ascx,aspx,axaml,cs,cshtml,css,htm,html,js,jsx,master,paml,razor,skin,ts,tsx,vb,xaml,xamlx,xoml}]
indent_style=space
indent_size=4
tab_width=4
[*.{appxmanifest,axml,build,config,csproj,dbml,discomap,dtd,json,jsproj,lsproj,njsproj,nuspec,proj,props,resjson,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]
indent_style=space
indent_size=2
tab_width=2
[*.{appxmanifest,asax,ascx,aspx,axaml,axml,build,c,c++,cc,cginc,compute,config,cp,cpp,cs,cshtml,csproj,css,cu,cuh,cxx,dbml,discomap,dtd,h,hh,hlsl,hlsli,hlslinc,hpp,htm,html,hxx,inc,inl,ino,ipp,js,json,jsproj,jsx,lsproj,master,mpp,mq4,mq5,mqh,njsproj,nuspec,paml,proj,props,proto,razor,resjson,resw,resx,skin,StyleCop,targets,tasks,tpp,ts,tsx,usf,ush,vb,vbproj,xaml,xamlx,xml,xoml,xsd}]
indent_style=space
indent_size= 4
@ -3621,3 +3634,4 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
insert_final_newline = true

View file

@ -10,13 +10,15 @@ jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
with:
submodules: true
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v5
with:
dotnet-version: '7.x.x'
dotnet-version: |
10.x.x
9.x.x
- name: Restore dependencies
run: dotnet restore
- name: Download Dalamud
@ -29,7 +31,7 @@ jobs:
- name: Archive
run: Compress-Archive -Path Penumbra/bin/Release/* -DestinationPath Penumbra.zip
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2.2.1
uses: actions/upload-artifact@v4
with:
path: |
./Penumbra/bin/Release/*

View file

@ -9,13 +9,15 @@ jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
with:
submodules: true
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v5
with:
dotnet-version: '7.x.x'
dotnet-version: |
10.x.x
9.x.x
- name: Restore dependencies
run: dotnet restore
- name: Download Dalamud
@ -37,7 +39,7 @@ jobs:
- name: Archive
run: Compress-Archive -Path Penumbra/bin/Release/* -DestinationPath Penumbra.zip
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2.2.1
uses: actions/upload-artifact@v4
with:
path: |
./Penumbra/bin/Release/*

View file

@ -9,13 +9,15 @@ jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
with:
submodules: true
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v5
with:
dotnet-version: '7.x.x'
dotnet-version: |
10.x.x
9.x.x
- name: Restore dependencies
run: dotnet restore
- name: Download Dalamud
@ -37,7 +39,7 @@ jobs:
- name: Archive
run: Compress-Archive -Path Penumbra/bin/Debug/* -DestinationPath Penumbra.zip
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2.2.1
uses: actions/upload-artifact@v4
with:
path: |
./Penumbra/bin/Debug/*

10
.gitmodules vendored
View file

@ -1,12 +1,16 @@
[submodule "OtterGui"]
path = OtterGui
url = git@github.com:Ottermandias/OtterGui.git
url = https://github.com/Ottermandias/OtterGui.git
branch = main
[submodule "Penumbra.Api"]
path = Penumbra.Api
url = git@github.com:Ottermandias/Penumbra.Api.git
url = https://github.com/Ottermandias/Penumbra.Api.git
branch = main
[submodule "Penumbra.String"]
path = Penumbra.String
url = git@github.com:Ottermandias/Penumbra.String.git
url = https://github.com/Ottermandias/Penumbra.String.git
branch = main
[submodule "Penumbra.GameData"]
path = Penumbra.GameData
url = https://github.com/Ottermandias/Penumbra.GameData.git
branch = main

@ -1 +1 @@
Subproject commit a79abe203da2673f71a4e31422c6058375fb8dec
Subproject commit ff1e6543845e3b8c53a5f8b240bc38faffb1b3bf

@ -1 +1 @@
Subproject commit 983c98f74e7cd052b21f6ca35ef0ceaa9b388964
Subproject commit 52a3216a525592205198303df2844435e382cf87

View file

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
namespace Penumbra.CrashHandler.Buffers;
/// <summary> The types of currently hooked and relevant animation loading functions. </summary>
public enum AnimationInvocationType : int
{
PapLoad,
ActionLoad,
ScheduleClipUpdate,
LoadTimelineResources,
LoadCharacterVfx,
LoadCharacterSound,
ApricotSoundPlay,
LoadAreaVfx,
CharacterBaseLoadAnimation,
}
/// <summary> The full crash entry for an invoked vfx function. </summary>
public record struct VfxFuncInvokedEntry(
double Age,
DateTimeOffset Timestamp,
int ThreadId,
string InvocationType,
string CharacterName,
string CharacterAddress,
Guid CollectionId) : ICrashDataEntry;
/// <summary> Only expose the write interface for the buffer. </summary>
public interface IAnimationInvocationBufferWriter
{
/// <summary> Write a line into the buffer with the given data. </summary>
/// <param name="characterAddress"> The address of the related character, if known. </param>
/// <param name="characterName"> The name of the related character, anonymized or relying on index if unavailable, if known. </param>
/// <param name="collectionId"> The GUID of the associated collection. </param>
/// <param name="type"> The type of VFX func called. </param>
public void WriteLine(nint characterAddress, ReadOnlySpan<byte> characterName, Guid collectionId, AnimationInvocationType type);
}
internal sealed class AnimationInvocationBuffer : MemoryMappedBuffer, IAnimationInvocationBufferWriter, IBufferReader
{
private const int _version = 1;
private const int _lineCount = 64;
private const int _lineCapacity = 128;
private const string _name = "Penumbra.AnimationInvocation";
public void WriteLine(nint characterAddress, ReadOnlySpan<byte> characterName, Guid collectionId, AnimationInvocationType type)
{
var accessor = GetCurrentLineLocking();
lock (accessor)
{
accessor.Write(0, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
accessor.Write(8, Environment.CurrentManagedThreadId);
accessor.Write(12, (int)type);
accessor.Write(16, characterAddress);
var span = GetSpan(accessor, 24, 16);
collectionId.TryWriteBytes(span);
accessor.SafeMemoryMappedViewHandle.ReleasePointer();
span = GetSpan(accessor, 40);
WriteSpan(characterName, span);
accessor.SafeMemoryMappedViewHandle.ReleasePointer();
}
}
public uint TotalCount
=> TotalWrittenLines;
public IEnumerable<JsonObject> GetLines(DateTimeOffset crashTime)
{
var lineCount = (int)CurrentLineCount;
for (var i = lineCount - 1; i >= 0; --i)
{
var line = GetLine(i);
var timestamp = DateTimeOffset.FromUnixTimeMilliseconds(BitConverter.ToInt64(line));
var thread = BitConverter.ToInt32(line[8..]);
var type = (AnimationInvocationType)BitConverter.ToInt32(line[12..]);
var address = BitConverter.ToUInt64(line[16..]);
var collectionId = new Guid(line[24..40]);
var characterName = ReadString(line[40..]);
yield return new JsonObject()
{
[nameof(VfxFuncInvokedEntry.Age)] = (crashTime - timestamp).TotalSeconds,
[nameof(VfxFuncInvokedEntry.Timestamp)] = timestamp,
[nameof(VfxFuncInvokedEntry.ThreadId)] = thread,
[nameof(VfxFuncInvokedEntry.InvocationType)] = ToName(type),
[nameof(VfxFuncInvokedEntry.CharacterName)] = characterName,
[nameof(VfxFuncInvokedEntry.CharacterAddress)] = address.ToString("X"),
[nameof(VfxFuncInvokedEntry.CollectionId)] = collectionId,
};
}
}
public static IBufferReader CreateReader(int pid)
=> new AnimationInvocationBuffer(false, pid);
public static IAnimationInvocationBufferWriter CreateWriter(int pid)
=> new AnimationInvocationBuffer(pid);
private AnimationInvocationBuffer(bool writer, int pid)
: base($"{_name}_{pid}_{_version}", _version)
{ }
private AnimationInvocationBuffer(int pid)
: base($"{_name}_{pid}_{_version}", _version, _lineCount, _lineCapacity)
{ }
private static string ToName(AnimationInvocationType type)
=> type switch
{
AnimationInvocationType.PapLoad => "PAP Load",
AnimationInvocationType.ActionLoad => "Action Load",
AnimationInvocationType.ScheduleClipUpdate => "Schedule Clip Update",
AnimationInvocationType.LoadTimelineResources => "Load Timeline Resources",
AnimationInvocationType.LoadCharacterVfx => "Load Character VFX",
AnimationInvocationType.LoadCharacterSound => "Load Character Sound",
AnimationInvocationType.ApricotSoundPlay => "Apricot Sound Play",
AnimationInvocationType.LoadAreaVfx => "Load Area VFX",
AnimationInvocationType.CharacterBaseLoadAnimation => "Load Animation (CharacterBase)",
_ => $"Unknown ({(int)type})",
};
}

View file

@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
namespace Penumbra.CrashHandler.Buffers;
/// <summary> Only expose the write interface for the buffer. </summary>
public interface ICharacterBaseBufferWriter
{
/// <summary> Write a line into the buffer with the given data. </summary>
/// <param name="characterAddress"> The address of the related character, if known. </param>
/// <param name="characterName"> The name of the related character, anonymized or relying on index if unavailable, if known. </param>
/// <param name="collectionId"> The GUID of the associated collection. </param>
public void WriteLine(nint characterAddress, ReadOnlySpan<byte> characterName, Guid collectionId);
}
/// <summary> The full crash entry for a loaded character base. </summary>
public record struct CharacterLoadedEntry(
double Age,
DateTimeOffset Timestamp,
int ThreadId,
string CharacterName,
string CharacterAddress,
Guid CollectionId) : ICrashDataEntry;
internal sealed class CharacterBaseBuffer : MemoryMappedBuffer, ICharacterBaseBufferWriter, IBufferReader
{
private const int _version = 1;
private const int _lineCount = 10;
private const int _lineCapacity = 128;
private const string _name = "Penumbra.CharacterBase";
public void WriteLine(nint characterAddress, ReadOnlySpan<byte> characterName, Guid collectionId)
{
var accessor = GetCurrentLineLocking();
lock (accessor)
{
accessor.Write(0, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
accessor.Write(8, Environment.CurrentManagedThreadId);
accessor.Write(12, characterAddress);
var span = GetSpan(accessor, 20, 16);
collectionId.TryWriteBytes(span);
accessor.SafeMemoryMappedViewHandle.ReleasePointer();
span = GetSpan(accessor, 36);
WriteSpan(characterName, span);
accessor.SafeMemoryMappedViewHandle.ReleasePointer();
}
}
public IEnumerable<JsonObject> GetLines(DateTimeOffset crashTime)
{
var lineCount = (int)CurrentLineCount;
for (var i = lineCount - 1; i >= 0; --i)
{
var line = GetLine(i);
var timestamp = DateTimeOffset.FromUnixTimeMilliseconds(BitConverter.ToInt64(line));
var thread = BitConverter.ToInt32(line[8..]);
var address = BitConverter.ToUInt64(line[12..]);
var collectionId = new Guid(line[20..36]);
var characterName = ReadString(line[36..]);
yield return new JsonObject
{
[nameof(CharacterLoadedEntry.Age)] = (crashTime - timestamp).TotalSeconds,
[nameof(CharacterLoadedEntry.Timestamp)] = timestamp,
[nameof(CharacterLoadedEntry.ThreadId)] = thread,
[nameof(CharacterLoadedEntry.CharacterName)] = characterName,
[nameof(CharacterLoadedEntry.CharacterAddress)] = address.ToString("X"),
[nameof(CharacterLoadedEntry.CollectionId)] = collectionId,
};
}
}
public uint TotalCount
=> TotalWrittenLines;
public static IBufferReader CreateReader(int pid)
=> new CharacterBaseBuffer(false, pid);
public static ICharacterBaseBufferWriter CreateWriter(int pid)
=> new CharacterBaseBuffer(pid);
private CharacterBaseBuffer(bool writer, int pid)
: base($"{_name}_{pid}_{_version}", _version)
{ }
private CharacterBaseBuffer(int pid)
: base($"{_name}_{pid}_{_version}", _version, _lineCount, _lineCapacity)
{ }
}

View file

@ -0,0 +1,220 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Numerics;
using System.Text;
namespace Penumbra.CrashHandler.Buffers;
public class MemoryMappedBuffer : IDisposable
{
private const int MinHeaderLength = 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
private readonly MemoryMappedFile _file;
private readonly MemoryMappedViewAccessor _header;
private readonly MemoryMappedViewAccessor[] _lines = [];
public readonly int Version;
public readonly uint LineCount;
public readonly uint LineCapacity;
private readonly uint _lineMask;
private bool _disposed;
protected uint CurrentLineCount
{
get => _header.ReadUInt32(16);
set => _header.Write(16, value);
}
protected uint CurrentLinePosition
{
get => _header.ReadUInt32(20);
set => _header.Write(20, value);
}
public uint TotalWrittenLines
{
get => _header.ReadUInt32(24);
protected set => _header.Write(24, value);
}
public MemoryMappedBuffer(string mapName, int version, uint lineCount, uint lineCapacity)
{
Version = version;
LineCount = BitOperations.RoundUpToPowerOf2(Math.Clamp(lineCount, 2, int.MaxValue >> 3));
LineCapacity = BitOperations.RoundUpToPowerOf2(Math.Clamp(lineCapacity, 2, int.MaxValue >> 3));
_lineMask = LineCount - 1;
var fileName = Encoding.UTF8.GetBytes(mapName);
var headerLength = (uint)(4 + 4 + 4 + 4 + 4 + 4 + 4 + fileName.Length + 1);
headerLength = (headerLength & 0b111) > 0 ? (headerLength & ~0b111u) + 0b1000 : headerLength;
var capacity = LineCount * LineCapacity + headerLength;
_file = MemoryMappedFile.CreateNew(mapName, capacity, MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.None,
HandleInheritability.Inheritable);
_header = _file.CreateViewAccessor(0, headerLength);
_header.Write(0, headerLength);
_header.Write(4, Version);
_header.Write(8, LineCount);
_header.Write(12, LineCapacity);
_header.WriteArray(28, fileName, 0, fileName.Length);
_header.Write(fileName.Length + 28, (byte)0);
_lines = Enumerable.Range(0, (int)LineCount).Select(i
=> _file.CreateViewAccessor(headerLength + i * LineCapacity, LineCapacity, MemoryMappedFileAccess.ReadWrite))
.ToArray();
}
public MemoryMappedBuffer(string mapName, int? expectedVersion = null, uint? expectedMinLineCount = null,
uint? expectedMinLineCapacity = null)
{
_lines = [];
_file = MemoryMappedFile.OpenExisting(mapName, MemoryMappedFileRights.ReadWrite, HandleInheritability.Inheritable);
using var headerLine = _file.CreateViewAccessor(0, 4, MemoryMappedFileAccess.Read);
var headerLength = headerLine.ReadUInt32(0);
if (headerLength < MinHeaderLength)
Throw($"Map {mapName} did not contain a valid header.");
_header = _file.CreateViewAccessor(0, headerLength, MemoryMappedFileAccess.ReadWrite);
Version = _header.ReadInt32(4);
LineCount = _header.ReadUInt32(8);
LineCapacity = _header.ReadUInt32(12);
_lineMask = LineCount - 1;
if (expectedVersion.HasValue && expectedVersion.Value != Version)
Throw($"Map {mapName} has version {Version} instead of {expectedVersion.Value}.");
if (LineCount < expectedMinLineCount)
Throw($"Map {mapName} has line count {LineCount} but line count >= {expectedMinLineCount.Value} is required.");
if (LineCapacity < expectedMinLineCapacity)
Throw($"Map {mapName} has line capacity {LineCapacity} but line capacity >= {expectedMinLineCapacity.Value} is required.");
var name = ReadString(GetSpan(_header, 28));
if (name != mapName)
Throw($"Map {mapName} does not contain its map name at the expected location.");
_lines = Enumerable.Range(0, (int)LineCount).Select(i
=> _file.CreateViewAccessor(headerLength + i * LineCapacity, LineCapacity, MemoryMappedFileAccess.ReadWrite))
.ToArray();
[DoesNotReturn]
void Throw(string text)
{
_file.Dispose();
_header?.Dispose();
_disposed = true;
throw new Exception(text);
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
_disposed = true;
}
protected static string ReadString(Span<byte> span)
{
if (span.IsEmpty)
throw new Exception("String from empty span requested.");
var termination = span.IndexOf((byte)0);
if (termination < 0)
throw new Exception("String in span is not terminated.");
return Encoding.UTF8.GetString(span[..termination]);
}
protected static int WriteString(string text, Span<byte> span)
{
var bytes = Encoding.UTF8.GetBytes(text);
var source = (Span<byte>)bytes;
var length = source.Length + 1;
if (length > span.Length)
source = source[..(span.Length - 1)];
source.CopyTo(span);
span[bytes.Length] = 0;
return source.Length + 1;
}
protected static int WriteSpan(ReadOnlySpan<byte> input, Span<byte> span)
{
var length = input.Length + 1;
if (length > span.Length)
input = input[..(span.Length - 1)];
input.CopyTo(span);
span[input.Length] = 0;
return input.Length + 1;
}
protected Span<byte> GetLine(int i)
{
if (i < 0 || i > LineCount)
return null;
lock (_header)
{
var lineIdx = (CurrentLinePosition + i) & _lineMask;
if (lineIdx > CurrentLineCount)
return null;
return GetSpan(_lines[lineIdx]);
}
}
protected MemoryMappedViewAccessor GetCurrentLineLocking()
{
MemoryMappedViewAccessor view;
lock (_header)
{
var currentLineCount = CurrentLineCount;
if (currentLineCount == LineCount)
{
var currentLinePos = CurrentLinePosition;
view = _lines[currentLinePos]!;
CurrentLinePosition = (currentLinePos + 1) & _lineMask;
}
else
{
view = _lines[currentLineCount];
++CurrentLineCount;
}
++TotalWrittenLines;
_header.Flush();
}
return view;
}
protected static Span<byte> GetSpan(MemoryMappedViewAccessor accessor, int offset = 0)
=> GetSpan(accessor, offset, (int)accessor.Capacity - offset);
protected static unsafe Span<byte> GetSpan(MemoryMappedViewAccessor accessor, int offset, int size)
{
byte* ptr = null;
accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr);
size = Math.Min(size, (int)accessor.Capacity - offset);
if (size < 0)
return [];
var span = new Span<byte>(ptr + offset + accessor.PointerOffset, size);
return span;
}
protected void Dispose(bool disposing)
{
if (_disposed)
return;
_header?.Dispose();
foreach (var line in _lines)
line?.Dispose();
_file?.Dispose();
}
~MemoryMappedBuffer()
=> Dispose(false);
}

View file

@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
namespace Penumbra.CrashHandler.Buffers;
/// <summary> Only expose the write interface for the buffer. </summary>
public interface IModdedFileBufferWriter
{
/// <summary> Write a line into the buffer with the given data. </summary>
/// <param name="characterAddress"> The address of the related character, if known. </param>
/// <param name="characterName"> The name of the related character, anonymized or relying on index if unavailable, if known. </param>
/// <param name="collectionId"> The GUID of the associated collection. </param>
/// <param name="requestedFileName"> The file name as requested by the game. </param>
/// <param name="actualFileName"> The actual modded file name loaded. </param>
public void WriteLine(nint characterAddress, ReadOnlySpan<byte> characterName, Guid collectionId, ReadOnlySpan<byte> requestedFileName,
ReadOnlySpan<byte> actualFileName);
}
/// <summary> The full crash entry for a loaded modded file. </summary>
public record struct ModdedFileLoadedEntry(
double Age,
DateTimeOffset Timestamp,
int ThreadId,
string CharacterName,
string CharacterAddress,
Guid CollectionId,
string RequestedFileName,
string ActualFileName) : ICrashDataEntry;
internal sealed class ModdedFileBuffer : MemoryMappedBuffer, IModdedFileBufferWriter, IBufferReader
{
private const int _version = 1;
private const int _lineCount = 128;
private const int _lineCapacity = 1024;
private const string _name = "Penumbra.ModdedFile";
public void WriteLine(nint characterAddress, ReadOnlySpan<byte> characterName, Guid collectionId, ReadOnlySpan<byte> requestedFileName,
ReadOnlySpan<byte> actualFileName)
{
var accessor = GetCurrentLineLocking();
lock (accessor)
{
accessor.Write(0, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
accessor.Write(8, Environment.CurrentManagedThreadId);
accessor.Write(12, characterAddress);
var span = GetSpan(accessor, 20, 16);
collectionId.TryWriteBytes(span);
accessor.SafeMemoryMappedViewHandle.ReleasePointer();
span = GetSpan(accessor, 36, 80);
WriteSpan(characterName, span);
accessor.SafeMemoryMappedViewHandle.ReleasePointer();
span = GetSpan(accessor, 116, 260);
WriteSpan(requestedFileName, span);
accessor.SafeMemoryMappedViewHandle.ReleasePointer();
span = GetSpan(accessor, 376);
WriteSpan(actualFileName, span);
accessor.SafeMemoryMappedViewHandle.ReleasePointer();
}
}
public uint TotalCount
=> TotalWrittenLines;
public IEnumerable<JsonObject> GetLines(DateTimeOffset crashTime)
{
var lineCount = (int)CurrentLineCount;
for (var i = lineCount - 1; i >= 0; --i)
{
var line = GetLine(i);
var timestamp = DateTimeOffset.FromUnixTimeMilliseconds(BitConverter.ToInt64(line));
var thread = BitConverter.ToInt32(line[8..]);
var address = BitConverter.ToUInt64(line[12..]);
var collectionId = new Guid(line[20..36]);
var characterName = ReadString(line[36..]);
var requestedFileName = ReadString(line[116..]);
var actualFileName = ReadString(line[376..]);
yield return new JsonObject()
{
[nameof(ModdedFileLoadedEntry.Age)] = (crashTime - timestamp).TotalSeconds,
[nameof(ModdedFileLoadedEntry.Timestamp)] = timestamp,
[nameof(ModdedFileLoadedEntry.ThreadId)] = thread,
[nameof(ModdedFileLoadedEntry.CharacterName)] = characterName,
[nameof(ModdedFileLoadedEntry.CharacterAddress)] = address.ToString("X"),
[nameof(ModdedFileLoadedEntry.CollectionId)] = collectionId,
[nameof(ModdedFileLoadedEntry.RequestedFileName)] = requestedFileName,
[nameof(ModdedFileLoadedEntry.ActualFileName)] = actualFileName,
};
}
}
public static IBufferReader CreateReader(int pid)
=> new ModdedFileBuffer(false, pid);
public static IModdedFileBufferWriter CreateWriter(int pid)
=> new ModdedFileBuffer(pid);
private ModdedFileBuffer(bool writer, int pid)
: base($"{_name}_{pid}_{_version}", _version)
{ }
private ModdedFileBuffer(int pid)
: base($"{_name}_{pid}_{_version}", _version, _lineCount, _lineCapacity)
{ }
}

View file

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using Penumbra.CrashHandler.Buffers;
namespace Penumbra.CrashHandler;
/// <summary> A base entry for crash data. </summary>
public interface ICrashDataEntry
{
/// <summary> The timestamp of the event. </summary>
DateTimeOffset Timestamp { get; }
/// <summary> The thread invoking the event. </summary>
int ThreadId { get; }
/// <summary> The age of the event compared to the crash. (Redundantly with the timestamp) </summary>
double Age { get; }
}
/// <summary> A full set of crash data. </summary>
public class CrashData
{
/// <summary> The mode this data was obtained - manually or from a crash. </summary>
public string Mode { get; set; } = "Unknown";
/// <summary> The time this crash data was generated. </summary>
public DateTimeOffset CrashTime { get; set; } = DateTimeOffset.UnixEpoch;
/// <summary> Penumbra's Version when this crash data was created. </summary>
public string Version { get; set; } = string.Empty;
/// <summary> The Game's Version when this crash data was created. </summary>
public string GameVersion { get; set; } = string.Empty;
/// <summary> The FFXIV process ID when this data was generated. </summary>
public int ProcessId { get; set; } = 0;
/// <summary> The FFXIV Exit Code (if any) when this data was generated. </summary>
public int ExitCode { get; set; } = 0;
/// <summary> The total amount of characters loaded during this session. </summary>
public int TotalCharactersLoaded { get; set; } = 0;
/// <summary> The total amount of modded files loaded during this session. </summary>
public int TotalModdedFilesLoaded { get; set; } = 0;
/// <summary> The total amount of vfx functions invoked during this session. </summary>
public int TotalVFXFuncsInvoked { get; set; } = 0;
/// <summary> The last character loaded before this crash data was generated. </summary>
public CharacterLoadedEntry? LastCharacterLoaded
=> LastCharactersLoaded.Count == 0 ? default : LastCharactersLoaded[0];
/// <summary> The last modded file loaded before this crash data was generated. </summary>
public ModdedFileLoadedEntry? LastModdedFileLoaded
=> LastModdedFilesLoaded.Count == 0 ? default : LastModdedFilesLoaded[0];
/// <summary> The last vfx function invoked before this crash data was generated. </summary>
public VfxFuncInvokedEntry? LastVfxFuncInvoked
=> LastVFXFuncsInvoked.Count == 0 ? default : LastVFXFuncsInvoked[0];
/// <summary> A collection of the last few characters loaded before this crash data was generated. </summary>
public List<CharacterLoadedEntry> LastCharactersLoaded { get; set; } = [];
/// <summary> A collection of the last few modded files loaded before this crash data was generated. </summary>
public List<ModdedFileLoadedEntry> LastModdedFilesLoaded { get; set; } = [];
/// <summary> A collection of the last few vfx functions invoked before this crash data was generated. </summary>
public List<VfxFuncInvokedEntry> LastVFXFuncsInvoked { get; set; } = [];
}

View file

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Nodes;
using Penumbra.CrashHandler.Buffers;
namespace Penumbra.CrashHandler;
public interface IBufferReader
{
public uint TotalCount { get; }
public IEnumerable<JsonObject> GetLines(DateTimeOffset crashTime);
}
public sealed class GameEventLogReader(int pid) : IDisposable
{
public readonly (IBufferReader Reader, string TypeSingular, string TypePlural)[] Readers =
[
(CharacterBaseBuffer.CreateReader(pid), "CharacterLoaded", "CharactersLoaded"),
(ModdedFileBuffer.CreateReader(pid), "ModdedFileLoaded", "ModdedFilesLoaded"),
(AnimationInvocationBuffer.CreateReader(pid), "VFXFuncInvoked", "VFXFuncsInvoked"),
];
public void Dispose()
{
foreach (var (reader, _, _) in Readers)
(reader as IDisposable)?.Dispose();
}
public JsonObject Dump(string mode, int processId, int exitCode, string version, string gameVersion)
{
var crashTime = DateTimeOffset.UtcNow;
var obj = new JsonObject
{
[nameof(CrashData.Mode)] = mode,
[nameof(CrashData.CrashTime)] = DateTimeOffset.UtcNow,
[nameof(CrashData.ProcessId)] = processId,
[nameof(CrashData.ExitCode)] = exitCode,
[nameof(CrashData.Version)] = version,
[nameof(CrashData.GameVersion)] = gameVersion,
};
foreach (var (reader, singular, _) in Readers)
obj["Last" + singular] = reader.GetLines(crashTime).FirstOrDefault();
foreach (var (reader, _, plural) in Readers)
{
obj["Total" + plural] = reader.TotalCount;
var array = new JsonArray();
foreach (var file in reader.GetLines(crashTime))
array.Add(file);
obj["Last" + plural] = array;
}
return obj;
}
}

View file

@ -0,0 +1,18 @@
using System;
using Penumbra.CrashHandler.Buffers;
namespace Penumbra.CrashHandler;
public sealed class GameEventLogWriter(int pid) : IDisposable
{
public readonly ICharacterBaseBufferWriter CharacterBase = CharacterBaseBuffer.CreateWriter(pid);
public readonly IModdedFileBufferWriter FileLoaded = ModdedFileBuffer.CreateWriter(pid);
public readonly IAnimationInvocationBufferWriter AnimationFuncInvoked = AnimationInvocationBuffer.CreateWriter(pid);
public void Dispose()
{
(CharacterBase as IDisposable)?.Dispose();
(FileLoaded as IDisposable)?.Dispose();
(AnimationFuncInvoked as IDisposable)?.Dispose();
}
}

View file

@ -0,0 +1,18 @@
<Project Sdk="Dalamud.NET.Sdk/14.0.1">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup>
<Use_DalamudPackager>false</Use_DalamudPackager>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,41 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text.Json;
namespace Penumbra.CrashHandler;
public class CrashHandler
{
public static void Main(string[] args)
{
if (args.Length < 4 || !int.TryParse(args[1], out var pid))
return;
try
{
using var reader = new GameEventLogReader(pid);
var parent = Process.GetProcessById(pid);
using var handle = parent.SafeHandle;
parent.WaitForExit();
int exitCode;
try
{
exitCode = parent.ExitCode;
}
catch
{
exitCode = -1;
}
var obj = reader.Dump("Crash", pid, exitCode, args[2], args[3]);
using var fs = File.Open(args[0], FileMode.Create);
using var w = new Utf8JsonWriter(fs, new JsonWriterOptions { Indented = true });
obj.WriteTo(w, new JsonSerializerOptions() { WriteIndented = true });
}
catch (Exception ex)
{
File.WriteAllText(args[0], $"{DateTime.UtcNow} {pid} {ex}");
}
}
}

View file

@ -0,0 +1,13 @@
{
"version": 1,
"dependencies": {
"net10.0-windows7.0": {
"DotNet.ReproducibleBuilds": {
"type": "Direct",
"requested": "[1.2.39, )",
"resolved": "1.2.39",
"contentHash": "fcFN01tDTIQqDuTwr1jUQK/geofiwjG5DycJQOnC72i1SsLAk1ELe+apBOuZ11UMQG8YKFZG1FgvjZPbqHyatg=="
}
}
}
}

1
Penumbra.GameData Submodule

@ -0,0 +1 @@
Subproject commit 0e973ed6eace6afd31cd298f8c58f76fa8d5ef60

File diff suppressed because it is too large Load diff

View file

@ -1,222 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Dalamud.Game.ClientState.Objects.Enums;
using Newtonsoft.Json.Linq;
using Penumbra.String;
namespace Penumbra.GameData.Actors;
[StructLayout(LayoutKind.Explicit)]
public readonly struct ActorIdentifier : IEquatable<ActorIdentifier>
{
public static ActorManager? Manager;
public static readonly ActorIdentifier Invalid = new(IdentifierType.Invalid, 0, 0, 0, ByteString.Empty);
public enum RetainerType : ushort
{
Both = 0,
Bell = 1,
Mannequin = 2,
}
// @formatter:off
[FieldOffset( 0 )] public readonly IdentifierType Type; // All
[FieldOffset( 1 )] public readonly ObjectKind Kind; // Npc, Owned
[FieldOffset( 2 )] public readonly ushort HomeWorld; // Player, Owned
[FieldOffset( 2 )] public readonly ushort Index; // NPC
[FieldOffset( 2 )] public readonly RetainerType Retainer; // Retainer
[FieldOffset( 2 )] public readonly ScreenActor Special; // Special
[FieldOffset( 4 )] public readonly uint DataId; // Owned, NPC
[FieldOffset( 8 )] public readonly ByteString PlayerName; // Player, Owned
// @formatter:on
public ActorIdentifier CreatePermanent()
=> new(Type, Kind, Index, DataId, PlayerName.IsEmpty || PlayerName.IsOwned ? PlayerName : PlayerName.Clone());
public bool Equals(ActorIdentifier other)
{
if (Type != other.Type)
return false;
return Type switch
{
IdentifierType.Player => HomeWorld == other.HomeWorld && PlayerName.EqualsCi(other.PlayerName),
IdentifierType.Retainer => PlayerName.EqualsCi(other.PlayerName),
IdentifierType.Owned => HomeWorld == other.HomeWorld && PlayerName.EqualsCi(other.PlayerName) && Manager.DataIdEquals(this, other),
IdentifierType.Special => Special == other.Special,
IdentifierType.Npc => Manager.DataIdEquals(this, other)
&& (Index == other.Index || Index == ushort.MaxValue || other.Index == ushort.MaxValue),
IdentifierType.UnkObject => PlayerName.EqualsCi(other.PlayerName) && Index == other.Index,
_ => false,
};
}
public override bool Equals(object? obj)
=> obj is ActorIdentifier other && Equals(other);
public static bool operator ==(ActorIdentifier lhs, ActorIdentifier rhs)
=> lhs.Equals(rhs);
public static bool operator !=(ActorIdentifier lhs, ActorIdentifier rhs)
=> !lhs.Equals(rhs);
public bool IsValid
=> Type is not (IdentifierType.UnkObject or IdentifierType.Invalid);
public string Incognito(string? name)
{
name ??= ToString();
if (Type is not (IdentifierType.Player or IdentifierType.Owned))
return name;
var parts = name.Split(' ', 3);
return string.Join(" ",
parts.Length != 3 ? parts.Select(n => $"{n[0]}.") : parts[..2].Select(n => $"{n[0]}.").Append(parts[2]));
}
public override string ToString()
=> Manager?.ToString(this)
?? Type switch
{
IdentifierType.Player => $"{PlayerName} ({HomeWorld})",
IdentifierType.Retainer => $"{PlayerName} (Retainer)",
IdentifierType.Owned => $"{PlayerName}s {Kind.ToName()} {DataId} ({HomeWorld})",
IdentifierType.Special => Special.ToName(),
IdentifierType.Npc =>
Index == ushort.MaxValue
? $"{Kind.ToName()} #{DataId}"
: $"{Kind.ToName()} #{DataId} at {Index}",
IdentifierType.UnkObject => PlayerName.IsEmpty
? $"Unknown Object at {Index}"
: $"{PlayerName} at {Index}",
_ => "Invalid",
};
public override int GetHashCode()
=> Type switch
{
IdentifierType.Player => HashCode.Combine(IdentifierType.Player, PlayerName, HomeWorld),
IdentifierType.Retainer => HashCode.Combine(IdentifierType.Player, PlayerName),
IdentifierType.Owned => HashCode.Combine(IdentifierType.Owned, Kind, PlayerName, HomeWorld, DataId),
IdentifierType.Special => HashCode.Combine(IdentifierType.Special, Special),
IdentifierType.Npc => HashCode.Combine(IdentifierType.Npc, Kind, DataId),
IdentifierType.UnkObject => HashCode.Combine(IdentifierType.UnkObject, PlayerName, Index),
_ => 0,
};
internal ActorIdentifier(IdentifierType type, ObjectKind kind, ushort index, uint data, ByteString playerName)
{
Type = type;
Kind = kind;
Special = (ScreenActor)index;
HomeWorld = Index = index;
DataId = data;
PlayerName = playerName;
}
public JObject ToJson()
{
var ret = new JObject { { nameof(Type), Type.ToString() } };
switch (Type)
{
case IdentifierType.Player:
ret.Add(nameof(PlayerName), PlayerName.ToString());
ret.Add(nameof(HomeWorld), HomeWorld);
return ret;
case IdentifierType.Retainer:
ret.Add(nameof(PlayerName), PlayerName.ToString());
return ret;
case IdentifierType.Owned:
ret.Add(nameof(PlayerName), PlayerName.ToString());
ret.Add(nameof(HomeWorld), HomeWorld);
ret.Add(nameof(Kind), Kind.ToString());
ret.Add(nameof(DataId), DataId);
return ret;
case IdentifierType.Special:
ret.Add(nameof(Special), Special.ToString());
return ret;
case IdentifierType.Npc:
ret.Add(nameof(Kind), Kind.ToString());
if (Index != ushort.MaxValue)
ret.Add(nameof(Index), Index);
ret.Add(nameof(DataId), DataId);
return ret;
case IdentifierType.UnkObject:
ret.Add(nameof(PlayerName), PlayerName.ToString());
ret.Add(nameof(Index), Index);
return ret;
}
return ret;
}
}
public static class ActorManagerExtensions
{
public static bool DataIdEquals(this ActorManager? manager, ActorIdentifier lhs, ActorIdentifier rhs)
{
if (lhs.Kind != rhs.Kind)
return false;
if (lhs.DataId == rhs.DataId)
return true;
if (manager == null)
return lhs.Kind == rhs.Kind && lhs.DataId == rhs.DataId || lhs.DataId == uint.MaxValue || rhs.DataId == uint.MaxValue;
var dict = lhs.Kind switch
{
ObjectKind.MountType => manager.Data.Mounts,
ObjectKind.Companion => manager.Data.Companions,
(ObjectKind)15 => manager.Data.Ornaments, // TODO: CS Update
ObjectKind.BattleNpc => manager.Data.BNpcs,
ObjectKind.EventNpc => manager.Data.ENpcs,
_ => new Dictionary<uint, string>(),
};
return dict.TryGetValue(lhs.DataId, out var lhsName)
&& dict.TryGetValue(rhs.DataId, out var rhsName)
&& lhsName.Equals(rhsName, StringComparison.OrdinalIgnoreCase);
}
public static string ToName(this ObjectKind kind)
=> kind switch
{
ObjectKind.None => "Unknown",
ObjectKind.BattleNpc => "Battle NPC",
ObjectKind.EventNpc => "Event NPC",
ObjectKind.MountType => "Mount",
ObjectKind.Companion => "Companion",
(ObjectKind)15 => "Accessory", // TODO: CS update
_ => kind.ToString(),
};
public static string ToName(this IdentifierType type)
=> type switch
{
IdentifierType.Player => "Player",
IdentifierType.Retainer => "Retainer (Bell)",
IdentifierType.Owned => "Owned NPC",
IdentifierType.Special => "Special Actor",
IdentifierType.Npc => "NPC",
IdentifierType.UnkObject => "Unknown Object",
_ => "Invalid",
};
/// <summary>
/// Fixed names for special actors.
/// </summary>
public static string ToName(this ScreenActor actor)
=> actor switch
{
ScreenActor.CharacterScreen => "Character Screen Actor",
ScreenActor.ExamineScreen => "Examine Screen Actor",
ScreenActor.FittingRoom => "Fitting Room Actor",
ScreenActor.DyePreview => "Dye Preview Actor",
ScreenActor.Portrait => "Portrait Actor",
_ => "Invalid",
};
}

View file

@ -1,406 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using Dalamud;
using Dalamud.Data;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.Gui;
using Dalamud.Plugin;
using Dalamud.Utility;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Excel.GeneratedSheets;
using Lumina.Text;
using Penumbra.GameData.Data;
using Penumbra.GameData.Structs;
using Penumbra.String;
using Character = FFXIVClientStructs.FFXIV.Client.Game.Character.Character;
using ObjectKind = Dalamud.Game.ClientState.Objects.Enums.ObjectKind;
namespace Penumbra.GameData.Actors;
public sealed partial class ActorManager : IDisposable
{
public sealed class ActorManagerData : DataSharer
{
/// <summary> Worlds available for players. </summary>
public IReadOnlyDictionary<ushort, string> Worlds { get; }
/// <summary> Valid Mount names in title case by mount id. </summary>
public IReadOnlyDictionary<uint, string> Mounts { get; }
/// <summary> Valid Companion names in title case by companion id. </summary>
public IReadOnlyDictionary<uint, string> Companions { get; }
/// <summary> Valid ornament names by id. </summary>
public IReadOnlyDictionary<uint, string> Ornaments { get; }
/// <summary> Valid BNPC names in title case by BNPC Name id. </summary>
public IReadOnlyDictionary<uint, string> BNpcs { get; }
/// <summary> Valid ENPC names in title case by ENPC id. </summary>
public IReadOnlyDictionary<uint, string> ENpcs { get; }
public ActorManagerData(DalamudPluginInterface pluginInterface, DataManager gameData, ClientLanguage language)
: base(pluginInterface, language, 1)
{
var worldTask = TryCatchDataAsync("Worlds", CreateWorldData(gameData));
var mountsTask = TryCatchDataAsync("Mounts", CreateMountData(gameData));
var companionsTask = TryCatchDataAsync("Companions", CreateCompanionData(gameData));
var ornamentsTask = TryCatchDataAsync("Ornaments", CreateOrnamentData(gameData));
var bNpcsTask = TryCatchDataAsync("BNpcs", CreateBNpcData(gameData));
var eNpcsTask = TryCatchDataAsync("ENpcs", CreateENpcData(gameData));
Worlds = worldTask.Result;
Mounts = mountsTask.Result;
Companions = companionsTask.Result;
Ornaments = ornamentsTask.Result;
BNpcs = bNpcsTask.Result;
ENpcs = eNpcsTask.Result;
}
/// <summary>
/// Return the world name including the Any World option.
/// </summary>
public string ToWorldName(ushort worldId)
=> worldId == ushort.MaxValue ? "Any World" : Worlds.TryGetValue(worldId, out var name) ? name : "Invalid";
/// <summary>
/// Return the world id corresponding to the given name.
/// </summary>
/// <returns>ushort.MaxValue if the name is empty, 0 if it is not a valid world, or the worlds id.</returns>
public ushort ToWorldId(string worldName)
=> worldName.Length != 0
? Worlds.FirstOrDefault(kvp => string.Equals(kvp.Value, worldName, StringComparison.OrdinalIgnoreCase), default).Key
: ushort.MaxValue;
/// <summary>
/// Convert a given ID for a certain ObjectKind to a name.
/// </summary>
/// <returns>Invalid or a valid name.</returns>
public string ToName(ObjectKind kind, uint dataId)
=> TryGetName(kind, dataId, out var ret) ? ret : "Invalid";
/// <summary>
/// Convert a given ID for a certain ObjectKind to a name.
/// </summary>
public bool TryGetName(ObjectKind kind, uint dataId, [NotNullWhen(true)] out string? name)
{
name = null;
return kind switch
{
ObjectKind.MountType => Mounts.TryGetValue(dataId, out name),
ObjectKind.Companion => Companions.TryGetValue(dataId, out name),
(ObjectKind)15 => Ornaments.TryGetValue(dataId, out name), // TODO: CS Update
ObjectKind.BattleNpc => BNpcs.TryGetValue(dataId, out name),
ObjectKind.EventNpc => ENpcs.TryGetValue(dataId, out name),
_ => false,
};
}
protected override void DisposeInternal()
{
DisposeTag("Worlds");
DisposeTag("Mounts");
DisposeTag("Companions");
DisposeTag("Ornaments");
DisposeTag("BNpcs");
DisposeTag("ENpcs");
}
private Action<Dictionary<ushort, string>> CreateWorldData(DataManager gameData)
=> d =>
{
foreach (var w in gameData.GetExcelSheet<World>(Language)!.Where(w => w.IsPublic && !w.Name.RawData.IsEmpty))
d.TryAdd((ushort)w.RowId, string.Intern(w.Name.ToDalamudString().TextValue));
};
private Action<Dictionary<uint, string>> CreateMountData(DataManager gameData)
=> d =>
{
foreach (var m in gameData.GetExcelSheet<Mount>(Language)!.Where(m => m.Singular.RawData.Length > 0 && m.Order >= 0))
d.TryAdd(m.RowId, ToTitleCaseExtended(m.Singular, m.Article));
};
private Action<Dictionary<uint, string>> CreateCompanionData(DataManager gameData)
=> d =>
{
foreach (var c in gameData.GetExcelSheet<Companion>(Language)!.Where(c
=> c.Singular.RawData.Length > 0 && c.Order < ushort.MaxValue))
d.TryAdd(c.RowId, ToTitleCaseExtended(c.Singular, c.Article));
};
private Action<Dictionary<uint, string>> CreateOrnamentData(DataManager gameData)
=> d =>
{
foreach (var o in gameData.GetExcelSheet<Ornament>(Language)!.Where(o => o.Singular.RawData.Length > 0))
d.TryAdd(o.RowId, ToTitleCaseExtended(o.Singular, o.Article));
};
private Action<Dictionary<uint, string>> CreateBNpcData(DataManager gameData)
=> d =>
{
foreach (var n in gameData.GetExcelSheet<BNpcName>(Language)!.Where(n => n.Singular.RawData.Length > 0))
d.TryAdd(n.RowId, ToTitleCaseExtended(n.Singular, n.Article));
};
private Action<Dictionary<uint, string>> CreateENpcData(DataManager gameData)
=> d =>
{
foreach (var n in gameData.GetExcelSheet<ENpcResident>(Language)!.Where(e => e.Singular.RawData.Length > 0))
d.TryAdd(n.RowId, ToTitleCaseExtended(n.Singular, n.Article));
};
private static string ToTitleCaseExtended(SeString s, sbyte article)
{
if (article == 1)
return string.Intern(s.ToDalamudString().ToString());
var sb = new StringBuilder(s.ToDalamudString().ToString());
var lastSpace = true;
for (var i = 0; i < sb.Length; ++i)
{
if (sb[i] == ' ')
{
lastSpace = true;
}
else if (lastSpace)
{
lastSpace = false;
sb[i] = char.ToUpperInvariant(sb[i]);
}
}
return string.Intern(sb.ToString());
}
}
public readonly ActorManagerData Data;
public ActorManager(DalamudPluginInterface pluginInterface, ObjectTable objects, ClientState state, Dalamud.Game.Framework framework,
DataManager gameData, GameGui gameGui,
Func<ushort, short> toParentIdx)
: this(pluginInterface, objects, state, framework, gameData, gameGui, gameData.Language, toParentIdx)
{ }
public ActorManager(DalamudPluginInterface pluginInterface, ObjectTable objects, ClientState state, Dalamud.Game.Framework framework,
DataManager gameData, GameGui gameGui,
ClientLanguage language, Func<ushort, short> toParentIdx)
{
_framework = framework;
_objects = objects;
_gameGui = gameGui;
_clientState = state;
_toParentIdx = toParentIdx;
Data = new ActorManagerData(pluginInterface, gameData, language);
ActorIdentifier.Manager = this;
SignatureHelper.Initialise(this);
}
public unsafe ActorIdentifier GetCurrentPlayer()
{
var address = (Character*)_objects.GetObjectAddress(0);
return address == null
? ActorIdentifier.Invalid
: CreateIndividualUnchecked(IdentifierType.Player, new ByteString(address->GameObject.Name), address->HomeWorld,
ObjectKind.None, uint.MaxValue);
}
public ActorIdentifier GetInspectPlayer()
{
var addon = _gameGui.GetAddonByName("CharacterInspect", 1);
if (addon == IntPtr.Zero)
return ActorIdentifier.Invalid;
return CreatePlayer(InspectName, InspectWorldId);
}
public unsafe bool ResolvePartyBannerPlayer(ScreenActor type, out ActorIdentifier id)
{
id = ActorIdentifier.Invalid;
var module = Framework.Instance()->GetUiModule()->GetAgentModule();
if (module == null)
return false;
var agent = (AgentBannerInterface*)module->GetAgentByInternalId(AgentId.BannerParty);
if (agent == null || !agent->AgentInterface.IsAgentActive())
agent = (AgentBannerInterface*)module->GetAgentByInternalId(AgentId.BannerMIP);
if (agent == null || !agent->AgentInterface.IsAgentActive())
return false;
var idx = (ushort)type - (ushort)ScreenActor.CharacterScreen;
var character = agent->Character(idx);
if (character == null)
return true;
var name = new ByteString(character->Name1.StringPtr);
id = CreatePlayer(name, (ushort)character->WorldId);
return true;
}
private unsafe bool SearchPlayerCustomize(Character* character, int idx, out ActorIdentifier id)
{
var other = (Character*)_objects.GetObjectAddress(idx);
if (other == null || !CustomizeData.ScreenActorEquals((CustomizeData*)character->DrawData.CustomizeData.Data, (CustomizeData*)other->DrawData.CustomizeData.Data))
{
id = ActorIdentifier.Invalid;
return false;
}
id = FromObject(&other->GameObject, out _, false, true, false);
return true;
}
private unsafe ActorIdentifier SearchPlayersCustomize(Character* gameObject, int idx1, int idx2, int idx3)
=> SearchPlayerCustomize(gameObject, idx1, out var ret)
|| SearchPlayerCustomize(gameObject, idx2, out ret)
|| SearchPlayerCustomize(gameObject, idx3, out ret)
? ret
: ActorIdentifier.Invalid;
private unsafe ActorIdentifier SearchPlayersCustomize(Character* gameObject)
{
static bool Compare(Character* a, Character* b)
{
var data1 = (CustomizeData*)a->DrawData.CustomizeData.Data;
var data2 = (CustomizeData*)b->DrawData.CustomizeData.Data;
var equals = CustomizeData.ScreenActorEquals(data1, data2);
return equals;
}
for (var i = 0; i < (int)ScreenActor.CutsceneStart; i += 2)
{
var obj = (GameObject*)_objects.GetObjectAddress(i);
if (obj != null
&& obj->ObjectKind is (byte)ObjectKind.Player
&& Compare(gameObject, (Character*)obj))
return FromObject(obj, out _, false, true, false);
}
return ActorIdentifier.Invalid;
}
public unsafe bool ResolveMahjongPlayer(ScreenActor type, out ActorIdentifier id)
{
id = ActorIdentifier.Invalid;
if (_clientState.TerritoryType != 831 && _gameGui.GetAddonByName("EmjIntro") == IntPtr.Zero)
return false;
var obj = (Character*)_objects.GetObjectAddress((int)type);
if (obj == null)
return false;
id = type switch
{
ScreenActor.CharacterScreen => GetCurrentPlayer(),
ScreenActor.ExamineScreen => SearchPlayersCustomize(obj, 2, 4, 6),
ScreenActor.FittingRoom => SearchPlayersCustomize(obj, 4, 2, 6),
ScreenActor.DyePreview => SearchPlayersCustomize(obj, 6, 2, 4),
_ => ActorIdentifier.Invalid,
};
return true;
}
public unsafe bool ResolvePvPBannerPlayer(ScreenActor type, out ActorIdentifier id)
{
id = ActorIdentifier.Invalid;
if (!_clientState.IsPvPExcludingDen)
return false;
var addon = (AtkUnitBase*)_gameGui.GetAddonByName("PvPMap");
if (addon == null || addon->IsVisible)
return false;
var obj = (Character*)_objects.GetObjectAddress((int)type);
if (obj == null)
return false;
id = type switch
{
ScreenActor.CharacterScreen => SearchPlayersCustomize(obj),
ScreenActor.ExamineScreen => SearchPlayersCustomize(obj),
ScreenActor.FittingRoom => SearchPlayersCustomize(obj),
ScreenActor.DyePreview => SearchPlayersCustomize(obj),
ScreenActor.Portrait => SearchPlayersCustomize(obj),
_ => ActorIdentifier.Invalid,
};
return true;
}
public unsafe ActorIdentifier GetCardPlayer()
{
var agent = AgentCharaCard.Instance();
if (agent == null || agent->Data == null)
return ActorIdentifier.Invalid;
var worldId = *(ushort*)((byte*)agent->Data + Offsets.AgentCharaCardDataWorldId);
return CreatePlayer(new ByteString(agent->Data->Name.StringPtr), worldId);
}
public ActorIdentifier GetGlamourPlayer()
{
var addon = _gameGui.GetAddonByName("MiragePrismMiragePlate", 1);
return addon == IntPtr.Zero ? ActorIdentifier.Invalid : GetCurrentPlayer();
}
public void Dispose()
{
Data.Dispose();
if (ActorIdentifier.Manager == this)
ActorIdentifier.Manager = null;
}
~ActorManager()
=> Dispose();
private readonly Dalamud.Game.Framework _framework;
private readonly ObjectTable _objects;
private readonly ClientState _clientState;
private readonly GameGui _gameGui;
private readonly Func<ushort, short> _toParentIdx;
[Signature(Sigs.InspectTitleId, ScanType = ScanType.StaticAddress)]
private static unsafe ushort* _inspectTitleId = null!;
[Signature(Sigs.InspectWorldId, ScanType = ScanType.StaticAddress)]
private static unsafe ushort* _inspectWorldId = null!;
private static unsafe ushort InspectTitleId
=> *_inspectTitleId;
private static unsafe ByteString InspectName
=> new((byte*)(_inspectWorldId + 1));
private static unsafe ushort InspectWorldId
=> *_inspectWorldId;
public static readonly IReadOnlySet<uint> MannequinIds = new HashSet<uint>()
{
1026228u,
1026229u,
1026986u,
1026987u,
1026988u,
1026989u,
1032291u,
1032292u,
1032293u,
1032294u,
1033046u,
1033047u,
1033658u,
1033659u,
1007137u,
// TODO: Female Hrothgar
};
}

View file

@ -1,590 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json.Linq;
using Penumbra.String;
using Character = FFXIVClientStructs.FFXIV.Client.Game.Character.Character;
namespace Penumbra.GameData.Actors;
public partial class ActorManager
{
/// <summary>
/// Try to create an ActorIdentifier from a already parsed JObject <paramref name="data"/>.
/// </summary>
/// <param name="data">A parsed JObject</param>
/// <returns>ActorIdentifier.Invalid if the JObject can not be converted, a valid ActorIdentifier otherwise.</returns>
public ActorIdentifier FromJson(JObject? data)
{
if (data == null)
return ActorIdentifier.Invalid;
var type = data[nameof(ActorIdentifier.Type)]?.ToObject<IdentifierType>() ?? IdentifierType.Invalid;
switch (type)
{
case IdentifierType.Player:
{
var name = ByteString.FromStringUnsafe(data[nameof(ActorIdentifier.PlayerName)]?.ToObject<string>(), false);
var homeWorld = data[nameof(ActorIdentifier.HomeWorld)]?.ToObject<ushort>() ?? 0;
return CreatePlayer(name, homeWorld);
}
case IdentifierType.Retainer:
{
var name = ByteString.FromStringUnsafe(data[nameof(ActorIdentifier.PlayerName)]?.ToObject<string>(), false);
return CreateRetainer(name, 0);
}
case IdentifierType.Owned:
{
var name = ByteString.FromStringUnsafe(data[nameof(ActorIdentifier.PlayerName)]?.ToObject<string>(), false);
var homeWorld = data[nameof(ActorIdentifier.HomeWorld)]?.ToObject<ushort>() ?? 0;
var kind = data[nameof(ActorIdentifier.Kind)]?.ToObject<ObjectKind>() ?? ObjectKind.CardStand;
var dataId = data[nameof(ActorIdentifier.DataId)]?.ToObject<uint>() ?? 0;
return CreateOwned(name, homeWorld, kind, dataId);
}
case IdentifierType.Special:
{
var special = data[nameof(ActorIdentifier.Special)]?.ToObject<ScreenActor>() ?? 0;
return CreateSpecial(special);
}
case IdentifierType.Npc:
{
var index = data[nameof(ActorIdentifier.Index)]?.ToObject<ushort>() ?? ushort.MaxValue;
var kind = data[nameof(ActorIdentifier.Kind)]?.ToObject<ObjectKind>() ?? ObjectKind.CardStand;
var dataId = data[nameof(ActorIdentifier.DataId)]?.ToObject<uint>() ?? 0;
return CreateNpc(kind, dataId, index);
}
case IdentifierType.UnkObject:
{
var index = data[nameof(ActorIdentifier.Index)]?.ToObject<ushort>() ?? ushort.MaxValue;
var name = ByteString.FromStringUnsafe(data[nameof(ActorIdentifier.PlayerName)]?.ToObject<string>(), false);
return CreateIndividualUnchecked(IdentifierType.UnkObject, name, index, ObjectKind.None, 0);
}
default: return ActorIdentifier.Invalid;
}
}
/// <summary>
/// Use stored data to convert an ActorIdentifier to a string.
/// </summary>
public string ToString(ActorIdentifier id)
{
return id.Type switch
{
IdentifierType.Player => id.HomeWorld != _clientState.LocalPlayer?.HomeWorld.Id
? $"{id.PlayerName} ({Data.ToWorldName(id.HomeWorld)})"
: id.PlayerName.ToString(),
IdentifierType.Retainer => id.PlayerName.ToString(),
IdentifierType.Owned => id.HomeWorld != _clientState.LocalPlayer?.HomeWorld.Id
? $"{id.PlayerName} ({Data.ToWorldName(id.HomeWorld)})'s {Data.ToName(id.Kind, id.DataId)}"
: $"{id.PlayerName}s {Data.ToName(id.Kind, id.DataId)}",
IdentifierType.Special => id.Special.ToName(),
IdentifierType.Npc =>
id.Index == ushort.MaxValue
? Data.ToName(id.Kind, id.DataId)
: $"{Data.ToName(id.Kind, id.DataId)} at {id.Index}",
IdentifierType.UnkObject => id.PlayerName.IsEmpty
? $"Unknown Object at {id.Index}"
: $"{id.PlayerName} at {id.Index}",
_ => "Invalid",
};
}
private unsafe FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* HandleCutscene(
FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* main)
{
if (main == null)
return null;
if (main->ObjectIndex is >= (ushort)ScreenActor.CutsceneStart and < (ushort)ScreenActor.CutsceneEnd)
{
var parentIdx = _toParentIdx(main->ObjectIndex);
if (parentIdx >= 0)
return (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)_objects.GetObjectAddress(parentIdx);
}
return main;
}
public class IdentifierParseError : Exception
{
public IdentifierParseError(string reason)
: base(reason)
{ }
}
public ActorIdentifier FromUserString(string userString)
{
if (userString.Length == 0)
throw new IdentifierParseError("The identifier string was empty.");
var split = userString.Split('|', 3, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
if (split.Length < 2)
throw new IdentifierParseError($"The identifier string {userString} does not contain a type and a value.");
IdentifierType type;
var playerName = ByteString.Empty;
ushort worldId = 0;
var kind = ObjectKind.Player;
var objectId = 0u;
(ByteString, ushort) ParsePlayer(string player)
{
var parts = player.Split('@', 2, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
if (!VerifyPlayerName(parts[0]))
throw new IdentifierParseError($"{parts[0]} is not a valid player name.");
if (!ByteString.FromString(parts[0], out var p))
throw new IdentifierParseError($"The player string {parts[0]} contains invalid symbols.");
var world = parts.Length == 2
? Data.ToWorldId(parts[1])
: ushort.MaxValue;
if (!VerifyWorld(world))
throw new IdentifierParseError($"{parts[1]} is not a valid world name.");
return (p, world);
}
(ObjectKind, uint) ParseNpc(string npc)
{
var split = npc.Split(':', 2, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
if (split.Length != 2)
throw new IdentifierParseError("NPCs need to be specified by '[Object Type]:[NPC Name]'.");
static bool FindDataId(string name, IReadOnlyDictionary<uint, string> data, out uint dataId)
{
var kvp = data.FirstOrDefault(kvp => kvp.Value.Equals(name, StringComparison.OrdinalIgnoreCase),
new KeyValuePair<uint, string>(uint.MaxValue, string.Empty));
dataId = kvp.Key;
return kvp.Value.Length > 0;
}
switch (split[0].ToLowerInvariant())
{
case "m":
case "mount":
return FindDataId(split[1], Data.Mounts, out var id)
? (ObjectKind.MountType, id)
: throw new IdentifierParseError($"Could not identify a Mount named {split[1]}.");
case "c":
case "companion":
case "minion":
case "mini":
return FindDataId(split[1], Data.Companions, out id)
? (ObjectKind.Companion, id)
: throw new IdentifierParseError($"Could not identify a Minion named {split[1]}.");
case "a":
case "o":
case "accessory":
case "ornament":
// TODO: Objectkind ornament.
return FindDataId(split[1], Data.Ornaments, out id)
? ((ObjectKind)15, id)
: throw new IdentifierParseError($"Could not identify an Accessory named {split[1]}.");
case "e":
case "enpc":
case "eventnpc":
case "event npc":
return FindDataId(split[1], Data.ENpcs, out id)
? (ObjectKind.EventNpc, id)
: throw new IdentifierParseError($"Could not identify an Event NPC named {split[1]}.");
case "b":
case "bnpc":
case "battlenpc":
case "battle npc":
return FindDataId(split[1], Data.BNpcs, out id)
? (ObjectKind.BattleNpc, id)
: throw new IdentifierParseError($"Could not identify a Battle NPC named {split[1]}.");
default: throw new IdentifierParseError($"The argument {split[0]} is not a valid NPC Type.");
}
}
switch (split[0].ToLowerInvariant())
{
case "p":
case "player":
type = IdentifierType.Player;
(playerName, worldId) = ParsePlayer(split[1]);
break;
case "r":
case "retainer":
type = IdentifierType.Retainer;
if (!VerifyRetainerName(split[1]))
throw new IdentifierParseError($"{split[1]} is not a valid player name.");
if (!ByteString.FromString(split[1], out playerName))
throw new IdentifierParseError($"The retainer string {split[1]} contains invalid symbols.");
break;
case "n":
case "npc":
type = IdentifierType.Npc;
(kind, objectId) = ParseNpc(split[1]);
break;
case "o":
case "owned":
if (split.Length < 3)
throw new IdentifierParseError(
"Owned NPCs need a NPC and a player, separated by '|', but only one was provided.");
type = IdentifierType.Owned;
(kind, objectId) = ParseNpc(split[1]);
(playerName, worldId) = ParsePlayer(split[2]);
break;
default:
throw new IdentifierParseError(
$"{split[0]} is not a valid identifier type. Valid types are [P]layer, [R]etainer, [N]PC, or [O]wned");
}
return CreateIndividualUnchecked(type, playerName, worldId, kind, objectId);
}
/// <summary>
/// Compute an ActorIdentifier from a GameObject. If check is true, the values are checked for validity.
/// </summary>
public unsafe ActorIdentifier FromObject(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* actor,
out FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* owner, bool allowPlayerNpc, bool check, bool withoutIndex)
{
owner = null;
if (actor == null)
return ActorIdentifier.Invalid;
actor = HandleCutscene(actor);
var idx = actor->ObjectIndex;
if (idx is >= (ushort)ScreenActor.CharacterScreen and <= (ushort)ScreenActor.Card8)
return CreateIndividualUnchecked(IdentifierType.Special, ByteString.Empty, idx, ObjectKind.None, uint.MaxValue);
var kind = (ObjectKind)actor->ObjectKind;
switch (kind)
{
case ObjectKind.Player:
{
var name = new ByteString(actor->Name);
var homeWorld = ((Character*)actor)->HomeWorld;
return check
? CreatePlayer(name, homeWorld)
: CreateIndividualUnchecked(IdentifierType.Player, name, homeWorld, ObjectKind.None, uint.MaxValue);
}
case ObjectKind.BattleNpc:
{
var ownerId = actor->OwnerID;
// 952 -> 780 is a special case for chocobos because they have NameId == 0 otherwise.
var nameId = actor->DataID == 952 ? 780 : ((Character*)actor)->NameID;
if (ownerId != 0xE0000000)
{
owner = HandleCutscene(
(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)(_objects.SearchById(ownerId)?.Address ?? IntPtr.Zero));
if (owner == null)
return ActorIdentifier.Invalid;
var name = new ByteString(owner->Name);
var homeWorld = ((Character*)owner)->HomeWorld;
return check
? CreateOwned(name, homeWorld, ObjectKind.BattleNpc, nameId)
: CreateIndividualUnchecked(IdentifierType.Owned, name, homeWorld, ObjectKind.BattleNpc, nameId);
}
// Hack to support Anamnesis changing ObjectKind for NPC faces.
if (nameId == 0 && allowPlayerNpc)
{
var name = new ByteString(actor->Name);
if (!name.IsEmpty)
{
var homeWorld = ((Character*)actor)->HomeWorld;
return check
? CreatePlayer(name, homeWorld)
: CreateIndividualUnchecked(IdentifierType.Player, name, homeWorld, ObjectKind.None, uint.MaxValue);
}
}
var index = withoutIndex ? ushort.MaxValue : actor->ObjectIndex;
return check
? CreateNpc(ObjectKind.BattleNpc, nameId, index)
: CreateIndividualUnchecked(IdentifierType.Npc, ByteString.Empty, index, ObjectKind.BattleNpc, nameId);
}
case ObjectKind.EventNpc:
{
var dataId = actor->DataID;
// Special case for squadron that is also in the game functions, cf. E8 ?? ?? ?? ?? 89 87 ?? ?? ?? ?? 4C 89 BF
if (dataId == 0xF845D)
dataId = actor->GetNpcID();
if (MannequinIds.Contains(dataId))
{
static ByteString Get(byte* ptr)
=> ptr == null ? ByteString.Empty : new ByteString(ptr);
var retainerName = Get(actor->Name);
var actualName = _framework.IsInFrameworkUpdateThread ? Get(actor->GetName()) : ByteString.Empty;
if (!actualName.Equals(retainerName))
{
var ident = check
? CreateRetainer(retainerName, ActorIdentifier.RetainerType.Mannequin)
: CreateIndividualUnchecked(IdentifierType.Retainer, retainerName, (ushort)ActorIdentifier.RetainerType.Mannequin,
ObjectKind.EventNpc, dataId);
if (ident.IsValid)
return ident;
}
}
var index = withoutIndex ? ushort.MaxValue : actor->ObjectIndex;
return check
? CreateNpc(ObjectKind.EventNpc, dataId, index)
: CreateIndividualUnchecked(IdentifierType.Npc, ByteString.Empty, index, ObjectKind.EventNpc, dataId);
}
case ObjectKind.MountType:
case ObjectKind.Companion:
case (ObjectKind)15: // TODO: CS Update
{
owner = HandleCutscene(
(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)_objects.GetObjectAddress(actor->ObjectIndex - 1));
if (owner == null)
return ActorIdentifier.Invalid;
var dataId = GetCompanionId(actor, (Character*)owner);
var name = new ByteString(owner->Name);
var homeWorld = ((Character*)owner)->HomeWorld;
return check
? CreateOwned(name, homeWorld, kind, dataId)
: CreateIndividualUnchecked(IdentifierType.Owned, name, homeWorld, kind, dataId);
}
case ObjectKind.Retainer:
{
var name = new ByteString(actor->Name);
return check
? CreateRetainer(name, ActorIdentifier.RetainerType.Bell)
: CreateIndividualUnchecked(IdentifierType.Retainer, name, (ushort)ActorIdentifier.RetainerType.Bell, ObjectKind.None,
uint.MaxValue);
}
default:
{
var name = new ByteString(actor->Name);
var index = withoutIndex ? ushort.MaxValue : actor->ObjectIndex;
return CreateIndividualUnchecked(IdentifierType.UnkObject, name, index, ObjectKind.None, 0);
}
}
}
/// <summary>
/// Obtain the current companion ID for an object by its actor and owner.
/// </summary>
private unsafe uint GetCompanionId(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* actor,
Character* owner) // TODO: CS Update
{
return (ObjectKind)actor->ObjectKind switch
{
ObjectKind.MountType => owner->Mount.MountId,
(ObjectKind)15 => owner->Ornament.OrnamentId,
ObjectKind.Companion => actor->DataID,
_ => actor->DataID,
};
}
public unsafe ActorIdentifier FromObject(GameObject? actor, out FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* owner,
bool allowPlayerNpc, bool check, bool withoutIndex)
=> FromObject((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)(actor?.Address ?? IntPtr.Zero), out owner, allowPlayerNpc,
check, withoutIndex);
public unsafe ActorIdentifier FromObject(GameObject? actor, bool allowPlayerNpc, bool check, bool withoutIndex)
=> FromObject(actor, out _, allowPlayerNpc, check, withoutIndex);
public ActorIdentifier CreateIndividual(IdentifierType type, ByteString name, ushort homeWorld, ObjectKind kind, uint dataId)
=> type switch
{
IdentifierType.Player => CreatePlayer(name, homeWorld),
IdentifierType.Retainer => CreateRetainer(name, (ActorIdentifier.RetainerType)homeWorld),
IdentifierType.Owned => CreateOwned(name, homeWorld, kind, dataId),
IdentifierType.Special => CreateSpecial((ScreenActor)homeWorld),
IdentifierType.Npc => CreateNpc(kind, dataId, homeWorld),
IdentifierType.UnkObject => CreateIndividualUnchecked(IdentifierType.UnkObject, name, homeWorld, ObjectKind.None, 0),
_ => ActorIdentifier.Invalid,
};
/// <summary>
/// Only use this if you are sure the input is valid.
/// </summary>
public ActorIdentifier CreateIndividualUnchecked(IdentifierType type, ByteString name, ushort homeWorld, ObjectKind kind, uint dataId)
=> new(type, kind, homeWorld, dataId, name);
public ActorIdentifier CreatePlayer(ByteString name, ushort homeWorld)
{
if (!VerifyWorld(homeWorld) || !VerifyPlayerName(name.Span))
return ActorIdentifier.Invalid;
return new ActorIdentifier(IdentifierType.Player, ObjectKind.Player, homeWorld, 0, name);
}
public ActorIdentifier CreateRetainer(ByteString name, ActorIdentifier.RetainerType type)
{
if (!VerifyRetainerName(name.Span))
return ActorIdentifier.Invalid;
return new ActorIdentifier(IdentifierType.Retainer, ObjectKind.Retainer, (ushort)type, 0, name);
}
public ActorIdentifier CreateSpecial(ScreenActor actor)
{
if (!VerifySpecial(actor))
return ActorIdentifier.Invalid;
return new ActorIdentifier(IdentifierType.Special, ObjectKind.Player, (ushort)actor, 0, ByteString.Empty);
}
public ActorIdentifier CreateNpc(ObjectKind kind, uint data, ushort index = ushort.MaxValue)
{
if (!VerifyIndex(index) || !VerifyNpcData(kind, data))
return ActorIdentifier.Invalid;
return new ActorIdentifier(IdentifierType.Npc, kind, index, data, ByteString.Empty);
}
public ActorIdentifier CreateOwned(ByteString ownerName, ushort homeWorld, ObjectKind kind, uint dataId)
{
if (!VerifyWorld(homeWorld) || !VerifyPlayerName(ownerName.Span) || !VerifyOwnedData(kind, dataId))
return ActorIdentifier.Invalid;
return new ActorIdentifier(IdentifierType.Owned, kind, homeWorld, dataId, ownerName);
}
/// <summary> Checks SE naming rules. </summary>
public static bool VerifyPlayerName(ReadOnlySpan<byte> name)
{
// Total no more than 20 characters + space.
if (name.Length is < 5 or > 21)
return false;
// Forename and surname, no more spaces.
var splitIndex = name.IndexOf((byte)' ');
if (splitIndex < 0 || name[(splitIndex + 1)..].IndexOf((byte)' ') >= 0)
return false;
return CheckNamePart(name[..splitIndex], 2, 15) && CheckNamePart(name[(splitIndex + 1)..], 2, 15);
}
/// <summary> Checks SE naming rules. </summary>
public static bool VerifyPlayerName(ReadOnlySpan<char> name)
{
// Total no more than 20 characters + space.
if (name.Length is < 5 or > 21)
return false;
// Forename and surname, no more spaces.
var splitIndex = name.IndexOf(' ');
if (splitIndex < 0 || name[(splitIndex + 1)..].IndexOf(' ') >= 0)
return false;
return CheckNamePart(name[..splitIndex], 2, 15) && CheckNamePart(name[(splitIndex + 1)..], 2, 15);
}
/// <summary> Checks SE naming rules. </summary>
public static bool VerifyRetainerName(ReadOnlySpan<byte> name)
=> CheckNamePart(name, 3, 20);
/// <summary> Checks SE naming rules. </summary>
public static bool VerifyRetainerName(ReadOnlySpan<char> name)
=> CheckNamePart(name, 3, 20);
private static bool CheckNamePart(ReadOnlySpan<char> part, int minLength, int maxLength)
{
// Each name part at least 2 and at most 15 characters for players, and at least 3 and at most 20 characters for retainers.
if (part.Length < minLength || part.Length > maxLength)
return false;
// Each part starting with capitalized letter.
if (part[0] is < 'A' or > 'Z')
return false;
// Every other symbol needs to be lowercase letter, hyphen or apostrophe.
var last = '\0';
for (var i = 1; i < part.Length; ++i)
{
var current = part[i];
if (current is not ('\'' or '-' or (>= 'a' and <= 'z')))
return false;
// Hyphens can not be used in succession, after or before apostrophes or as the last symbol.
if (last is '\'' && current is '-')
return false;
if (last is '-' && current is '-' or '\'')
return false;
last = current;
}
return true;
}
private static bool CheckNamePart(ReadOnlySpan<byte> part, int minLength, int maxLength)
{
// Each name part at least 2 and at most 15 characters for players, and at least 3 and at most 20 characters for retainers.
if (part.Length < minLength || part.Length > maxLength)
return false;
// Each part starting with capitalized letter.
if (part[0] is < (byte)'A' or > (byte)'Z')
return false;
// Every other symbol needs to be lowercase letter, hyphen or apostrophe.
var last = (byte)'\0';
for (var i = 1; i < part.Length; ++i)
{
var current = part[i];
if (current is not ((byte)'\'' or (byte)'-' or (>= (byte)'a' and <= (byte)'z')))
return false;
// Hyphens can not be used in succession, after or before apostrophes or as the last symbol.
if (last is (byte)'\'' && current is (byte)'-')
return false;
if (last is (byte)'-' && current is (byte)'-' or (byte)'\'')
return false;
last = current;
}
return true;
}
/// <summary> Checks if the world is a valid public world or ushort.MaxValue (any world). </summary>
public bool VerifyWorld(ushort worldId)
=> worldId == ushort.MaxValue || Data.Worlds.ContainsKey(worldId);
/// <summary> Verify that the enum value is a specific actor and return the name if it is. </summary>
public static bool VerifySpecial(ScreenActor actor)
=> actor is >= ScreenActor.CharacterScreen and <= ScreenActor.Card8;
/// <summary> Verify that the object index is a valid index for an NPC. </summary>
public bool VerifyIndex(ushort index)
{
return index switch
{
ushort.MaxValue => true,
< 200 => index % 2 == 0,
> (ushort)ScreenActor.Card8 => index < _objects.Length,
_ => false,
};
}
/// <summary> Verify that the object kind is a valid owned object, and the corresponding data Id. </summary>
public bool VerifyOwnedData(ObjectKind kind, uint dataId)
{
return kind switch
{
ObjectKind.MountType => Data.Mounts.ContainsKey(dataId),
ObjectKind.Companion => Data.Companions.ContainsKey(dataId),
(ObjectKind)15 => Data.Ornaments.ContainsKey(dataId), // TODO: CS Update
ObjectKind.BattleNpc => Data.BNpcs.ContainsKey(dataId),
_ => false,
};
}
public bool VerifyNpcData(ObjectKind kind, uint dataId)
=> kind switch
{
ObjectKind.MountType => Data.Mounts.ContainsKey(dataId),
ObjectKind.Companion => Data.Companions.ContainsKey(dataId),
(ObjectKind)15 => Data.Ornaments.ContainsKey(dataId), // TODO: CS Update
ObjectKind.BattleNpc => Data.BNpcs.ContainsKey(dataId),
ObjectKind.EventNpc => Data.ENpcs.ContainsKey(dataId),
_ => false,
};
}

View file

@ -1,91 +0,0 @@
using FFXIVClientStructs.FFXIV.Client.System.String;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
namespace Penumbra;
[StructLayout( LayoutKind.Explicit )]
public unsafe struct AgentBannerInterface
{
[FieldOffset( 0x0 )] public AgentInterface AgentInterface;
[FieldOffset( 0x28 )] public BannerInterfaceStorage* Data;
public BannerInterfaceStorage.CharacterData* Character( int idx )
=> idx switch
{
_ when Data == null => null,
0 => &Data->Character1,
1 => &Data->Character2,
2 => &Data->Character3,
3 => &Data->Character4,
4 => &Data->Character5,
5 => &Data->Character6,
6 => &Data->Character7,
7 => &Data->Character8,
_ => null,
};
}
[StructLayout(LayoutKind.Explicit)]
public unsafe struct AgentBannerParty
{
public static AgentBannerParty* Instance() => ( AgentBannerParty* )Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId( AgentId.BannerParty );
[FieldOffset( 0x0 )] public AgentBannerInterface AgentBannerInterface;
}
[StructLayout( LayoutKind.Explicit )]
public unsafe struct AgentBannerMIP
{
public static AgentBannerMIP* Instance() => ( AgentBannerMIP* )Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId( AgentId.BannerMIP );
[FieldOffset( 0x0 )] public AgentBannerInterface AgentBannerInterface;
}
// Client::UI::Agent::AgentBannerInterface::Storage
// destructed in Client::UI::Agent::AgentBannerInterface::dtor
[StructLayout( LayoutKind.Explicit, Size = 0x3B30 )]
public unsafe struct BannerInterfaceStorage
{
// vtable: 48 8D 05 ?? ?? ?? ?? 48 89 01 48 8B F9 7E
// dtor: E8 ?? ?? ?? ?? 48 83 EF ?? 75 ?? BA ?? ?? ?? ?? 48 8B CE E8 ?? ?? ?? ?? 48 89 7D
[StructLayout( LayoutKind.Explicit, Size = 0x760 )]
public struct CharacterData
{
[FieldOffset( 0x000 )] public void** VTable;
[FieldOffset( 0x018 )] public Utf8String Name1;
[FieldOffset( 0x080 )] public Utf8String Name2;
[FieldOffset( 0x0E8 )] public Utf8String UnkString1;
[FieldOffset( 0x150 )] public Utf8String UnkString2;
[FieldOffset( 0x1C0 )] public Utf8String Job;
[FieldOffset( 0x238 )] public uint WorldId;
[FieldOffset( 0x240 )] public Utf8String UnkString3;
[FieldOffset( 0x2B0 )] public void* CharaView;
[FieldOffset( 0x5D0 )] public AtkTexture AtkTexture;
[FieldOffset( 0x6E0 )] public Utf8String Title;
[FieldOffset( 0x750 )] public void* SomePointer;
}
[FieldOffset( 0x0000 )] public void* Agent; // AgentBannerParty, maybe other Banner agents
[FieldOffset( 0x0008 )] public UIModule* UiModule;
[FieldOffset( 0x0010 )] public uint Unk1; // Maybe count or bitfield, but probably not
[FieldOffset( 0x0014 )] public uint Unk2;
[FieldOffset( 0x0020 )] public CharacterData Character1;
[FieldOffset( 0x0780 )] public CharacterData Character2;
[FieldOffset( 0x0EE0 )] public CharacterData Character3;
[FieldOffset( 0x1640 )] public CharacterData Character4;
[FieldOffset( 0x1DA0 )] public CharacterData Character5;
[FieldOffset( 0x2500 )] public CharacterData Character6;
[FieldOffset( 0x2C60 )] public CharacterData Character7;
[FieldOffset( 0x33C0 )] public CharacterData Character8;
[FieldOffset( 0x3B20 )] public long Unk3;
[FieldOffset( 0x3B28 )] public long Unk4;
}

View file

@ -1,12 +0,0 @@
namespace Penumbra.GameData.Actors;
public enum IdentifierType : byte
{
Invalid,
Player,
Owned,
Special,
Npc,
Retainer,
UnkObject,
};

View file

@ -1,17 +0,0 @@
namespace Penumbra.GameData.Actors;
public enum ScreenActor : ushort
{
CutsceneStart = 200,
GPosePlayer = 201,
CutsceneEnd = 240,
CharacterScreen = CutsceneEnd,
ExamineScreen = 241,
FittingRoom = 242,
DyePreview = 243,
Portrait = 244,
Card6 = 245,
Card7 = 246,
Card8 = 247,
ScreenEnd = Card8 + 1,
}

File diff suppressed because it is too large Load diff

View file

@ -1,92 +0,0 @@
using System;
using System.Threading.Tasks;
using Dalamud;
using Dalamud.Logging;
using Dalamud.Plugin;
namespace Penumbra.GameData.Data;
/// <summary>
/// A container base class that shares data through Dalamud but cares about the used language and version.
/// Inheritors should dispose their Dalamud Shares in DisposeInternal via DisposeTag and add them in their constructor via TryCatchData.
/// </summary>
public abstract class DataSharer : IDisposable
{
protected readonly DalamudPluginInterface PluginInterface;
protected readonly int Version;
protected readonly ClientLanguage Language;
private bool _disposed;
protected DataSharer(DalamudPluginInterface pluginInterface, ClientLanguage language, int version)
{
PluginInterface = pluginInterface;
Language = language;
Version = version;
}
protected virtual void DisposeInternal()
{ }
public void Dispose()
{
if (_disposed)
return;
DisposeInternal();
GC.SuppressFinalize(this);
_disposed = true;
}
~DataSharer()
=> Dispose();
protected void DisposeTag(string tag)
=> PluginInterface.RelinquishData(GetVersionedTag(tag, Language, Version));
protected T TryCatchData<T>(string tag, Func<T> func) where T : class
{
try
{
return PluginInterface.GetOrCreateData(GetVersionedTag(tag, Language, Version), func);
}
catch (Exception ex)
{
PluginLog.Error($"Error creating shared data for {tag}:\n{ex}");
return func();
}
}
protected Task<T> TryCatchDataAsync<T>(string tag, Action<T> fill) where T : class, new()
{
tag = GetVersionedTag(tag, Language, Version);
if (PluginInterface.TryGetData<T>(tag, out var data))
return Task.FromResult(data);
T ret = new();
return Task.Run(() =>
{
fill(ret);
return ret;
});
}
public static void DisposeTag(DalamudPluginInterface pi, string tag, ClientLanguage language, int version)
=> pi.RelinquishData(GetVersionedTag(tag, language, version));
public static T TryCatchData<T>(DalamudPluginInterface pi, string tag, ClientLanguage language, int version, Func<T> func)
where T : class
{
try
{
return pi.GetOrCreateData(GetVersionedTag(tag, language, version), func);
}
catch (Exception ex)
{
PluginLog.Error($"Error creating shared actor data for {tag}:\n{ex}");
return func();
}
}
private static string GetVersionedTag(string tag, ClientLanguage language, int version)
=> $"Penumbra.GameData.{tag}.{language}.V{version}";
}

View file

@ -1,463 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Penumbra.GameData.Interop;
using Penumbra.String;
namespace Penumbra.GameData.Data;
public partial class DisassembledShader
{
public struct ResourceBinding
{
public string Name;
public ResourceType Type;
public Format Format;
public ResourceDimension Dimension;
public uint Slot;
public uint Elements;
public uint RegisterCount;
public VectorComponents[] Used;
public VectorComponents UsedDynamically;
}
// Abbreviated using the uppercased first char of their name
public enum ResourceType : byte
{
Unspecified = 0,
ConstantBuffer = 0x43, // 'C'
Sampler = 0x53, // 'S'
Texture = 0x54, // 'T'
Uav = 0x55, // 'U'
}
// Abbreviated using the uppercased first and last char of their name
public enum Format : ushort
{
Unspecified = 0,
NotApplicable = 0x4E41, // 'NA'
Int = 0x4954, // 'IT'
Int4 = 0x4934, // 'I4'
Float = 0x4654, // 'FT'
Float4 = 0x4634, // 'F4'
}
// Abbreviated using the uppercased first and last char of their name
public enum ResourceDimension : ushort
{
Unspecified = 0,
NotApplicable = 0x4E41, // 'NA'
TwoD = 0x3244, // '2D'
ThreeD = 0x3344, // '3D'
Cube = 0x4345, // 'CE'
}
public struct InputOutput
{
public string Name;
public uint Index;
public VectorComponents Mask;
public uint Register;
public string SystemValue;
public Format Format;
public VectorComponents Used;
}
[Flags]
public enum VectorComponents : byte
{
X = 1,
Y = 2,
Z = 4,
W = 8,
All = 15,
}
public enum ShaderStage : byte
{
Unspecified = 0,
Pixel = 0x50, // 'P'
Vertex = 0x56, // 'V'
}
[GeneratedRegex(@"\s(\w+)(?:\[\d+\])?;\s*//\s*Offset:\s*0\s*Size:\s*(\d+)$", RegexOptions.Multiline | RegexOptions.NonBacktracking)]
private static partial Regex ResourceBindingSizeRegex();
[GeneratedRegex(@"c(\d+)(?:\[([^\]]+)\])?(?:\.([wxyz]+))?", RegexOptions.NonBacktracking)]
private static partial Regex Sm3ConstantBufferUsageRegex();
[GeneratedRegex(@"^\s*texld\S*\s+[^,]+,[^,]+,\s*s(\d+)", RegexOptions.NonBacktracking)]
private static partial Regex Sm3TextureUsageRegex();
[GeneratedRegex(@"cb(\d+)\[([^\]]+)\]\.([wxyz]+)", RegexOptions.NonBacktracking)]
private static partial Regex Sm5ConstantBufferUsageRegex();
[GeneratedRegex(@"^\s*sample_\S*\s+[^.]+\.([wxyz]+),[^,]+,\s*t(\d+)\.([wxyz]+)", RegexOptions.NonBacktracking)]
private static partial Regex Sm5TextureUsageRegex();
private static readonly char[] Digits = Enumerable.Range(0, 10).Select(c => (char)('0' + c)).ToArray();
public readonly ByteString RawDisassembly;
public readonly uint ShaderModel;
public readonly ShaderStage Stage;
public readonly string BufferDefinitions;
public readonly ResourceBinding[] ResourceBindings;
public readonly InputOutput[] InputSignature;
public readonly InputOutput[] OutputSignature;
public readonly IReadOnlyList<ByteString> Instructions;
public DisassembledShader(ByteString rawDisassembly)
{
RawDisassembly = rawDisassembly;
var lines = rawDisassembly.Split((byte) '\n');
Instructions = lines.FindAll(ln => !ln.StartsWith("//"u8) && ln.Length > 0);
var shaderModel = Instructions[0].Trim().Split((byte) '_');
Stage = (ShaderStage)(byte)char.ToUpper((char) shaderModel[0][0]);
ShaderModel = (uint.Parse(shaderModel[1].ToString()) << 8) | uint.Parse(shaderModel[2].ToString());
var header = PreParseHeader(lines.Take(lines.IndexOf(Instructions[0])).Select(l => l.ToString()).ToArray());
switch (ShaderModel >> 8)
{
case 3:
ParseSm3Header(header, out BufferDefinitions, out ResourceBindings, out InputSignature, out OutputSignature);
ParseSm3ResourceUsage(Instructions, ResourceBindings);
break;
case 5:
ParseSm5Header(header, out BufferDefinitions, out ResourceBindings, out InputSignature, out OutputSignature);
ParseSm5ResourceUsage(Instructions, ResourceBindings);
break;
default: throw new NotImplementedException();
}
}
public ResourceBinding? GetResourceBindingByName(ResourceType type, string name)
=> ResourceBindings.FirstOrNull(b => b.Type == type && b.Name == name);
public ResourceBinding? GetResourceBindingBySlot(ResourceType type, uint slot)
=> ResourceBindings.FirstOrNull(b => b.Type == type && b.Slot == slot);
public static DisassembledShader Disassemble(ReadOnlySpan<byte> shaderBlob)
=> new(D3DCompiler.Disassemble(shaderBlob));
private static void ParseSm3Header(Dictionary<string, string[]> header, out string bufferDefinitions,
out ResourceBinding[] resourceBindings, out InputOutput[] inputSignature, out InputOutput[] outputSignature)
{
bufferDefinitions = header.TryGetValue("Parameters", out var rawParameters)
? string.Join('\n', rawParameters)
: string.Empty;
if (header.TryGetValue("Registers", out var rawRegisters))
{
var (_, registers) = ParseTable(rawRegisters);
resourceBindings = Array.ConvertAll(registers, register =>
{
var type = (ResourceType)(byte)char.ToUpper(register[1][0]);
if (type == ResourceType.Sampler)
type = ResourceType.Texture;
var size = uint.Parse(register[2]);
return new ResourceBinding
{
Name = register[0],
Type = type,
Format = Format.Unspecified,
Dimension = ResourceDimension.Unspecified,
Slot = uint.Parse(register[1][1..]),
Elements = 1,
RegisterCount = size,
Used = new VectorComponents[size],
};
});
}
else
{
resourceBindings = Array.Empty<ResourceBinding>();
}
inputSignature = Array.Empty<InputOutput>();
outputSignature = Array.Empty<InputOutput>();
}
private static void ParseSm3ResourceUsage(IReadOnlyList<ByteString> instructions, ResourceBinding[] resourceBindings)
{
var cbIndices = new Dictionary<uint, int>();
var tIndices = new Dictionary<uint, int>();
{
var i = 0;
foreach (var binding in resourceBindings)
{
switch (binding.Type)
{
case ResourceType.ConstantBuffer:
for (var j = 0u; j < binding.RegisterCount; j++)
cbIndices[binding.Slot + j] = i;
break;
case ResourceType.Texture:
tIndices[binding.Slot] = i;
break;
}
++i;
}
}
foreach (var instruction in instructions)
{
var trimmed = instruction.Trim();
if (trimmed.StartsWith("def"u8) || trimmed.StartsWith("dcl"u8))
continue;
var instructionString = instruction.ToString();
foreach (Match cbMatch in Sm3ConstantBufferUsageRegex().Matches(instructionString))
{
var buffer = uint.Parse(cbMatch.Groups[1].Value);
if (cbIndices.TryGetValue(buffer, out var i))
{
var swizzle = cbMatch.Groups[3].Success ? ParseVectorComponents(cbMatch.Groups[3].Value) : VectorComponents.All;
if (cbMatch.Groups[2].Success)
resourceBindings[i].UsedDynamically |= swizzle;
else
resourceBindings[i].Used[buffer - resourceBindings[i].Slot] |= swizzle;
}
}
var tMatch = Sm3TextureUsageRegex().Match(instructionString);
if (tMatch.Success)
{
var texture = uint.Parse(tMatch.Groups[1].Value);
if (tIndices.TryGetValue(texture, out var i))
resourceBindings[i].Used[0] = VectorComponents.All;
}
}
}
private static void ParseSm5Header(Dictionary<string, string[]> header, out string bufferDefinitions,
out ResourceBinding[] resourceBindings, out InputOutput[] inputSignature, out InputOutput[] outputSignature)
{
if (header.TryGetValue("Resource Bindings", out var rawResBindings))
{
var (head, resBindings) = ParseTable(rawResBindings);
resourceBindings = Array.ConvertAll(resBindings, binding =>
{
var type = (ResourceType)(byte)char.ToUpper(binding[1][0]);
return new ResourceBinding
{
Name = binding[0],
Type = type,
Format = (Format)(((byte)char.ToUpper(binding[2][0]) << 8) | (byte)char.ToUpper(binding[2][^1])),
Dimension = (ResourceDimension)(((byte)char.ToUpper(binding[3][0]) << 8) | (byte)char.ToUpper(binding[3][^1])),
Slot = uint.Parse(binding[4][binding[4].IndexOfAny(Digits)..]),
Elements = uint.Parse(binding[5]),
RegisterCount = type == ResourceType.Texture ? 1u : 0u,
Used = type == ResourceType.Texture ? new VectorComponents[1] : Array.Empty<VectorComponents>(),
};
});
}
else
{
resourceBindings = Array.Empty<ResourceBinding>();
}
if (header.TryGetValue("Buffer Definitions", out var rawBufferDefs))
{
bufferDefinitions = string.Join('\n', rawBufferDefs);
foreach (Match match in ResourceBindingSizeRegex().Matches(bufferDefinitions))
{
var name = match.Groups[1].Value;
var bytesSize = uint.Parse(match.Groups[2].Value);
var pos = Array.FindIndex(resourceBindings, binding => binding.Type == ResourceType.ConstantBuffer && binding.Name == name);
if (pos >= 0)
{
resourceBindings[pos].RegisterCount = (bytesSize + 0xF) >> 4;
resourceBindings[pos].Used = new VectorComponents[resourceBindings[pos].RegisterCount];
}
}
}
else
{
bufferDefinitions = string.Empty;
}
static InputOutput ParseInputOutput(string[] inOut)
=> new()
{
Name = inOut[0],
Index = uint.Parse(inOut[1]),
Mask = ParseVectorComponents(inOut[2]),
Register = uint.Parse(inOut[3]),
SystemValue = string.Intern(inOut[4]),
Format = (Format)(((byte)char.ToUpper(inOut[5][0]) << 8) | (byte)char.ToUpper(inOut[5][^1])),
Used = ParseVectorComponents(inOut[6]),
};
if (header.TryGetValue("Input signature", out var rawInputSig))
{
var (_, inputSig) = ParseTable(rawInputSig);
inputSignature = Array.ConvertAll(inputSig, ParseInputOutput);
}
else
{
inputSignature = Array.Empty<InputOutput>();
}
if (header.TryGetValue("Output signature", out var rawOutputSig))
{
var (_, outputSig) = ParseTable(rawOutputSig);
outputSignature = Array.ConvertAll(outputSig, ParseInputOutput);
}
else
{
outputSignature = Array.Empty<InputOutput>();
}
}
private static void ParseSm5ResourceUsage(IReadOnlyList<ByteString> instructions, ResourceBinding[] resourceBindings)
{
var cbIndices = new Dictionary<uint, int>();
var tIndices = new Dictionary<uint, int>();
{
var i = 0;
foreach (var binding in resourceBindings)
{
switch (binding.Type)
{
case ResourceType.ConstantBuffer:
cbIndices[binding.Slot] = i;
break;
case ResourceType.Texture:
tIndices[binding.Slot] = i;
break;
}
++i;
}
}
foreach (var instruction in instructions)
{
var trimmed = instruction.Trim();
if (trimmed.StartsWith("def"u8) || trimmed.StartsWith("dcl"u8))
continue;
var instructionString = instruction.ToString();
foreach (Match cbMatch in Sm5ConstantBufferUsageRegex().Matches(instructionString))
{
var buffer = uint.Parse(cbMatch.Groups[1].Value);
if (cbIndices.TryGetValue(buffer, out var i))
{
var swizzle = ParseVectorComponents(cbMatch.Groups[3].Value);
if (int.TryParse(cbMatch.Groups[2].Value, out var vector))
{
if (vector < resourceBindings[i].Used.Length)
resourceBindings[i].Used[vector] |= swizzle;
}
else
{
resourceBindings[i].UsedDynamically |= swizzle;
}
}
}
var tMatch = Sm5TextureUsageRegex().Match(instructionString);
if (tMatch.Success)
{
var texture = uint.Parse(tMatch.Groups[2].Value);
if (tIndices.TryGetValue(texture, out var i))
{
var outSwizzle = ParseVectorComponents(tMatch.Groups[1].Value);
var rawInSwizzle = tMatch.Groups[3].Value;
var inSwizzle = new StringBuilder(4);
if ((outSwizzle & VectorComponents.X) != 0)
inSwizzle.Append(rawInSwizzle[0]);
if ((outSwizzle & VectorComponents.Y) != 0)
inSwizzle.Append(rawInSwizzle[1]);
if ((outSwizzle & VectorComponents.Z) != 0)
inSwizzle.Append(rawInSwizzle[2]);
if ((outSwizzle & VectorComponents.W) != 0)
inSwizzle.Append(rawInSwizzle[3]);
resourceBindings[i].Used[0] |= ParseVectorComponents(inSwizzle.ToString());
}
}
}
}
private static VectorComponents ParseVectorComponents(string components)
{
components = components.ToUpperInvariant();
return (components.Contains('X') ? VectorComponents.X : 0)
| (components.Contains('Y') ? VectorComponents.Y : 0)
| (components.Contains('Z') ? VectorComponents.Z : 0)
| (components.Contains('W') ? VectorComponents.W : 0);
}
private static Dictionary<string, string[]> PreParseHeader(ReadOnlySpan<string> header)
{
var sections = new Dictionary<string, string[]>();
void AddSection(string name, ReadOnlySpan<string> section)
{
while (section.Length > 0 && section[0].Length <= 3)
section = section[1..];
while (section.Length > 0 && section[^1].Length <= 3)
section = section[..^1];
sections.Add(name, Array.ConvertAll(section.ToArray(), ln => ln.Length <= 3 ? string.Empty : ln[3..]));
}
var lastSectionName = "";
var lastSectionStart = 0;
for (var i = 1; i < header.Length - 1; ++i)
{
string current;
if (header[i - 1].Length <= 3 && header[i + 1].Length <= 3 && (current = header[i].TrimEnd()).EndsWith(':'))
{
AddSection(lastSectionName, header[lastSectionStart..(i - 1)]);
lastSectionName = current[3..^1];
lastSectionStart = i + 2;
++i; // The next line cannot match
}
}
AddSection(lastSectionName, header[lastSectionStart..]);
return sections;
}
private static (string[], string[][]) ParseTable(ReadOnlySpan<string> lines)
{
var columns = new List<Range>();
{
var dashLine = lines[1];
for (var i = 0; true; /* this part intentionally left blank */)
{
var start = dashLine.IndexOf('-', i);
if (start < 0)
break;
var end = dashLine.IndexOf(' ', start + 1);
if (end < 0)
{
columns.Add(start..dashLine.Length);
break;
}
else
{
columns.Add(start..end);
i = end + 1;
}
}
}
var headers = new string[columns.Count];
{
var headerLine = lines[0];
for (var i = 0; i < columns.Count; ++i)
headers[i] = headerLine[columns[i]].Trim();
}
var data = new List<string[]>();
foreach (var line in lines[2..])
{
var row = new string[columns.Count];
for (var i = 0; i < columns.Count; ++i)
row[i] = line[columns[i]].Trim();
data.Add(row);
}
return (headers, data.ToArray());
}
}

View file

@ -1,56 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Dalamud;
using Dalamud.Data;
using Dalamud.Plugin;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using PseudoEquipItem = System.ValueTuple<string, uint, ushort, ushort, ushort, byte, byte>;
namespace Penumbra.GameData.Data;
internal sealed class EquipmentIdentificationList : KeyList<PseudoEquipItem>
{
private const string Tag = "EquipmentIdentification";
public EquipmentIdentificationList(DalamudPluginInterface pi, ClientLanguage language, DataManager gameData)
: base(pi, Tag, language, ObjectIdentification.IdentificationVersion, CreateEquipmentList(gameData, language))
{ }
public IEnumerable<EquipItem> Between(SetId modelId, EquipSlot slot = EquipSlot.Unknown, byte variant = 0)
{
if (slot == EquipSlot.Unknown)
return Between(ToKey(modelId, 0, 0), ToKey(modelId, (EquipSlot)0xFF, 0xFF)).Select(e => (EquipItem)e);
if (variant == 0)
return Between(ToKey(modelId, slot, 0), ToKey(modelId, slot, 0xFF)).Select(e => (EquipItem)e);
return Between(ToKey(modelId, slot, variant), ToKey(modelId, slot, variant)).Select(e => (EquipItem)e);
}
public void Dispose(DalamudPluginInterface pi, ClientLanguage language)
=> DataSharer.DisposeTag(pi, Tag, language, ObjectIdentification.IdentificationVersion);
public static ulong ToKey(SetId modelId, EquipSlot slot, byte variant)
=> ((ulong)modelId << 32) | ((ulong)slot << 16) | variant;
public static ulong ToKey(EquipItem i)
=> ToKey(i.ModelId, i.Type.ToSlot(), i.Variant);
protected override IEnumerable<ulong> ToKeys(PseudoEquipItem i)
{
yield return ToKey(i);
}
protected override bool ValidKey(ulong key)
=> key != 0;
protected override int ValueKeySelector(PseudoEquipItem data)
=> (int)data.Item2;
private static IEnumerable<PseudoEquipItem> CreateEquipmentList(DataManager gameData, ClientLanguage language)
{
var items = gameData.GetExcelSheet<Item>(language)!;
return items.Where(i => ((EquipSlot)i.EquipSlotCategory.Row).IsEquipmentPiece()).Select(i => (PseudoEquipItem)EquipItem.FromArmor(i));
}
}

View file

@ -1,306 +0,0 @@
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Dalamud.Logging;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData.Data;
public class GamePathParser : IGamePathParser
{
/// <summary> Obtain basic information about a file path. </summary>
public GameObjectInfo GetFileInfo(string path)
{
path = path.ToLowerInvariant().Replace('\\', '/');
var (fileType, objectType, match) = ParseGamePath(path);
if (match is not { Success: true })
return new GameObjectInfo
{
FileType = fileType,
ObjectType = objectType,
};
try
{
var groups = match.Groups;
switch (objectType)
{
case ObjectType.Accessory: return HandleEquipment(fileType, groups);
case ObjectType.Equipment: return HandleEquipment(fileType, groups);
case ObjectType.Weapon: return HandleWeapon(fileType, groups);
case ObjectType.Map: return HandleMap(fileType, groups);
case ObjectType.Monster: return HandleMonster(fileType, groups);
case ObjectType.DemiHuman: return HandleDemiHuman(fileType, groups);
case ObjectType.Character: return HandleCustomization(fileType, groups);
case ObjectType.Icon: return HandleIcon(fileType, groups);
}
}
catch (Exception e)
{
PluginLog.Error($"Could not parse {path}:\n{e}");
}
return new GameObjectInfo
{
FileType = fileType,
ObjectType = objectType,
};
}
/// <summary> Get the key of a VFX symbol. </summary>
/// <returns>The lower-case key or an empty string if no match is found.</returns>
public string VfxToKey(string path)
{
var match = GamePaths.Vfx.Tmb().Match(path);
if (match.Success)
return match.Groups["key"].Value.ToLowerInvariant();
match = GamePaths.Vfx.Pap().Match(path);
return match.Success ? match.Groups["key"].Value.ToLowerInvariant() : string.Empty;
}
/// <summary> Obtain the ObjectType from a given path.</summary>
public ObjectType PathToObjectType(string path)
{
if (path.Length == 0)
return ObjectType.Unknown;
var folders = path.Split('/');
if (folders.Length < 2)
return ObjectType.Unknown;
return folders[0] switch
{
CharacterFolder => folders[1] switch
{
EquipmentFolder => ObjectType.Equipment,
AccessoryFolder => ObjectType.Accessory,
WeaponFolder => ObjectType.Weapon,
PlayerFolder => ObjectType.Character,
DemiHumanFolder => ObjectType.DemiHuman,
MonsterFolder => ObjectType.Monster,
CommonFolder => ObjectType.Character,
_ => ObjectType.Unknown,
},
UiFolder => folders[1] switch
{
IconFolder => ObjectType.Icon,
LoadingFolder => ObjectType.LoadingScreen,
MapFolder => ObjectType.Map,
InterfaceFolder => ObjectType.Interface,
_ => ObjectType.Unknown,
},
CommonFolder => folders[1] switch
{
FontFolder => ObjectType.Font,
_ => ObjectType.Unknown,
},
HousingFolder => ObjectType.Housing,
WorldFolder1 => folders[1] switch
{
HousingFolder => ObjectType.Housing,
_ => ObjectType.World,
},
WorldFolder2 => ObjectType.World,
VfxFolder => ObjectType.Vfx,
_ => ObjectType.Unknown,
};
}
private const string CharacterFolder = "chara";
private const string EquipmentFolder = "equipment";
private const string PlayerFolder = "human";
private const string WeaponFolder = "weapon";
private const string AccessoryFolder = "accessory";
private const string DemiHumanFolder = "demihuman";
private const string MonsterFolder = "monster";
private const string CommonFolder = "common";
private const string UiFolder = "ui";
private const string IconFolder = "icon";
private const string LoadingFolder = "loadingimage";
private const string MapFolder = "map";
private const string InterfaceFolder = "uld";
private const string FontFolder = "font";
private const string HousingFolder = "hou";
private const string VfxFolder = "vfx";
private const string WorldFolder1 = "bgcommon";
private const string WorldFolder2 = "bg";
private (FileType, ObjectType, Match?) ParseGamePath(string path)
{
if (!Names.ExtensionToFileType.TryGetValue(Path.GetExtension(path), out var fileType))
fileType = FileType.Unknown;
var objectType = PathToObjectType(path);
static Match TestCharacterTextures(string path)
{
var regexes = new Regex[]
{
GamePaths.Character.Tex.Regex(),
GamePaths.Character.Tex.FolderRegex(),
GamePaths.Character.Tex.SkinRegex(),
GamePaths.Character.Tex.CatchlightRegex(),
GamePaths.Character.Tex.DecalRegex(),
};
foreach (var regex in regexes)
{
var match = regex.Match(path);
if (match.Success)
return match;
}
return Match.Empty;
}
var match = (fileType, objectType) switch
{
(FileType.Font, ObjectType.Font) => GamePaths.Font.Regex().Match(path),
(FileType.Imc, ObjectType.Weapon) => GamePaths.Weapon.Imc.Regex().Match(path),
(FileType.Imc, ObjectType.Monster) => GamePaths.Monster.Imc.Regex().Match(path),
(FileType.Imc, ObjectType.DemiHuman) => GamePaths.DemiHuman.Imc.Regex().Match(path),
(FileType.Imc, ObjectType.Equipment) => GamePaths.Equipment.Imc.Regex().Match(path),
(FileType.Imc, ObjectType.Accessory) => GamePaths.Accessory.Imc.Regex().Match(path),
(FileType.Model, ObjectType.Weapon) => GamePaths.Weapon.Mdl.Regex().Match(path),
(FileType.Model, ObjectType.Monster) => GamePaths.Monster.Mdl.Regex().Match(path),
(FileType.Model, ObjectType.DemiHuman) => GamePaths.DemiHuman.Mdl.Regex().Match(path),
(FileType.Model, ObjectType.Equipment) => GamePaths.Equipment.Mdl.Regex().Match(path),
(FileType.Model, ObjectType.Accessory) => GamePaths.Accessory.Mdl.Regex().Match(path),
(FileType.Model, ObjectType.Character) => GamePaths.Character.Mdl.Regex().Match(path),
(FileType.Material, ObjectType.Weapon) => GamePaths.Weapon.Mtrl.Regex().Match(path),
(FileType.Material, ObjectType.Monster) => GamePaths.Monster.Mtrl.Regex().Match(path),
(FileType.Material, ObjectType.DemiHuman) => GamePaths.DemiHuman.Mtrl.Regex().Match(path),
(FileType.Material, ObjectType.Equipment) => GamePaths.Equipment.Mtrl.Regex().Match(path),
(FileType.Material, ObjectType.Accessory) => GamePaths.Accessory.Mtrl.Regex().Match(path),
(FileType.Material, ObjectType.Character) => GamePaths.Character.Mtrl.Regex().Match(path),
(FileType.Texture, ObjectType.Weapon) => GamePaths.Weapon.Tex.Regex().Match(path),
(FileType.Texture, ObjectType.Monster) => GamePaths.Monster.Tex.Regex().Match(path),
(FileType.Texture, ObjectType.DemiHuman) => GamePaths.DemiHuman.Tex.Regex().Match(path),
(FileType.Texture, ObjectType.Equipment) => GamePaths.Equipment.Tex.Regex().Match(path),
(FileType.Texture, ObjectType.Accessory) => GamePaths.Accessory.Tex.Regex().Match(path),
(FileType.Texture, ObjectType.Character) => TestCharacterTextures(path),
(FileType.Texture, ObjectType.Icon) => GamePaths.Icon.Regex().Match(path),
(FileType.Texture, ObjectType.Map) => GamePaths.Map.Regex().Match(path),
_ => Match.Empty,
};
return (fileType, objectType, match.Success ? match : null);
}
private static GameObjectInfo HandleEquipment(FileType fileType, GroupCollection groups)
{
var setId = ushort.Parse(groups["id"].Value);
if (fileType == FileType.Imc)
return GameObjectInfo.Equipment(fileType, setId);
var gr = Names.GenderRaceFromCode(groups["race"].Value);
var slot = Names.SuffixToEquipSlot[groups["slot"].Value];
if (fileType == FileType.Model)
return GameObjectInfo.Equipment(fileType, setId, gr, slot);
var variant = byte.Parse(groups["variant"].Value);
return GameObjectInfo.Equipment(fileType, setId, gr, slot, variant);
}
private static GameObjectInfo HandleWeapon(FileType fileType, GroupCollection groups)
{
var weaponId = ushort.Parse(groups["weapon"].Value);
var setId = ushort.Parse(groups["id"].Value);
if (fileType is FileType.Imc or FileType.Model)
return GameObjectInfo.Weapon(fileType, setId, weaponId);
var variant = byte.Parse(groups["variant"].Value);
return GameObjectInfo.Weapon(fileType, setId, weaponId, variant);
}
private static GameObjectInfo HandleMonster(FileType fileType, GroupCollection groups)
{
var monsterId = ushort.Parse(groups["monster"].Value);
var bodyId = ushort.Parse(groups["id"].Value);
if (fileType is FileType.Imc or FileType.Model)
return GameObjectInfo.Monster(fileType, monsterId, bodyId);
var variant = byte.Parse(groups["variant"].Value);
return GameObjectInfo.Monster(fileType, monsterId, bodyId, variant);
}
private static GameObjectInfo HandleDemiHuman(FileType fileType, GroupCollection groups)
{
var demiHumanId = ushort.Parse(groups["id"].Value);
var equipId = ushort.Parse(groups["equip"].Value);
if (fileType == FileType.Imc)
return GameObjectInfo.DemiHuman(fileType, demiHumanId, equipId);
var slot = Names.SuffixToEquipSlot[groups["slot"].Value];
if (fileType == FileType.Model)
return GameObjectInfo.DemiHuman(fileType, demiHumanId, equipId, slot);
var variant = byte.Parse(groups["variant"].Value);
return GameObjectInfo.DemiHuman(fileType, demiHumanId, equipId, slot, variant);
}
private static GameObjectInfo HandleCustomization(FileType fileType, GroupCollection groups)
{
if (groups["catchlight"].Success)
return GameObjectInfo.Customization(fileType, CustomizationType.Iris);
if (groups["skin"].Success)
return GameObjectInfo.Customization(fileType, CustomizationType.Skin);
var id = ushort.Parse(groups["id"].Value);
if (groups["location"].Success)
{
var tmpType = groups["location"].Value == "face" ? CustomizationType.DecalFace
: groups["location"].Value == "equip" ? CustomizationType.DecalEquip : CustomizationType.Unknown;
return GameObjectInfo.Customization(fileType, tmpType, id);
}
var gr = Names.GenderRaceFromCode(groups["race"].Value);
var bodySlot = Names.StringToBodySlot[groups["type"].Value];
var type = groups["slot"].Success
? Names.SuffixToCustomizationType[groups["slot"].Value]
: CustomizationType.Skin;
if (fileType == FileType.Material)
{
var variant = groups["variant"].Success ? byte.Parse(groups["variant"].Value) : (byte)0;
return GameObjectInfo.Customization(fileType, type, id, gr, bodySlot, variant);
}
return GameObjectInfo.Customization(fileType, type, id, gr, bodySlot);
}
private static GameObjectInfo HandleIcon(FileType fileType, GroupCollection groups)
{
var hq = groups["hq"].Success;
var hr = groups["hr"].Success;
var id = uint.Parse(groups["id"].Value);
if (!groups["lang"].Success)
return GameObjectInfo.Icon(fileType, id, hq, hr);
var language = groups["lang"].Value switch
{
"en" => Dalamud.ClientLanguage.English,
"ja" => Dalamud.ClientLanguage.Japanese,
"de" => Dalamud.ClientLanguage.German,
"fr" => Dalamud.ClientLanguage.French,
_ => Dalamud.ClientLanguage.English,
};
return GameObjectInfo.Icon(fileType, id, hq, hr, language);
}
private static GameObjectInfo HandleMap(FileType fileType, GroupCollection groups)
{
var map = Encoding.ASCII.GetBytes(groups["id"].Value);
var variant = byte.Parse(groups["variant"].Value);
if (groups["suffix"].Success)
{
var suffix = Encoding.ASCII.GetBytes(groups["suffix"].Value)[0];
return GameObjectInfo.Map(fileType, map[0], map[1], map[2], map[3], variant, suffix);
}
return GameObjectInfo.Map(fileType, map[0], map[1], map[2], map[3], variant);
}
}

View file

@ -1,408 +0,0 @@
using System.Text.RegularExpressions;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData.Data;
public static partial class GamePaths
{
[GeneratedRegex(@"c(?'racecode'\d{4})")]
public static partial Regex RaceCodeParser();
public static GenderRace ParseRaceCode(string path)
{
var match = RaceCodeParser().Match(path);
return match.Success
? Names.GenderRaceFromCode(match.Groups["racecode"].Value)
: GenderRace.Unknown;
}
public static partial class Monster
{
public static partial class Imc
{
[GeneratedRegex(@"chara/monster/m(?'monster'\d{4})/obj/body/b(?'id'\d{4})/b\k'id'\.imc")]
public static partial Regex Regex();
public static string Path(SetId monsterId, SetId bodyId)
=> $"chara/monster/m{monsterId.Value:D4}/obj/body/b{bodyId.Value:D4}/b{bodyId.Value:D4}.imc";
}
public static partial class Mdl
{
[GeneratedRegex(@"chara/monster/m(?'monster'\d{4})/obj/body/b(?'id'\d{4})/model/m\k'monster'b\k'id'\.mdl")]
public static partial Regex Regex();
public static string Path(SetId monsterId, SetId bodyId)
=> $"chara/monster/m{monsterId.Value:D4}/obj/body/b{bodyId.Value:D4}/model/m{monsterId.Value:D4}b{bodyId.Value:D4}.mdl";
}
public static partial class Mtrl
{
[GeneratedRegex(
@"chara/monster/m(?'monster'\d{4})/obj/body/b(?'id'\d{4})/material/v(?'variant'\d{4})/mt_m\k'monster'b\k'id'_[a-z]+\.mtrl")]
public static partial Regex Regex();
public static string Path(SetId monsterId, SetId bodyId, byte variant, string suffix)
=> $"chara/monster/m{monsterId.Value:D4}/obj/body/b{bodyId.Value:D4}/material/v{variant:D4}/mt_m{monsterId.Value:D4}b{bodyId.Value:D4}_{suffix}.mtrl";
}
public static partial class Tex
{
[GeneratedRegex(
@"chara/monster/m(?'monster'\d{4})/obj/body/b(?'id'\d{4})/texture/v(?'variant'\d{2})_m\k'monster'b\k'id'(_[a-z])?_[a-z]\.tex")]
public static partial Regex Regex();
public static string Path(SetId monsterId, SetId bodyId, byte variant, char suffix1, char suffix2 = '\0')
=> $"chara/monster/m{monsterId.Value:D4}/obj/body/b{bodyId.Value:D4}/texture/v{variant:D2}_m{monsterId.Value:D4}b{bodyId.Value:D4}{(suffix2 != '\0' ? $"_{suffix2}" : string.Empty)}_{suffix1}.tex";
}
public static partial class Sklb
{
public static string Path(SetId monsterId)
=> $"chara/monster/m{monsterId.Value:D4}/skeleton/base/b0001/skl_m{monsterId.Value:D4}b0001.sklb";
}
public static partial class Skp
{
public static string Path(SetId monsterId)
=> $"chara/monster/m{monsterId.Value:D4}/skeleton/base/b0001/skl_m{monsterId.Value:D4}b0001.skp";
}
public static partial class Eid
{
public static string Path(SetId monsterId)
=> $"chara/monster/m{monsterId.Value:D4}/skeleton/base/b0001/eid_m{monsterId.Value:D4}b0001.eid";
}
}
public static partial class Weapon
{
public static partial class Imc
{
[GeneratedRegex(@"chara/weapon/w(?'id'\d{4})/obj/body/b(?'weapon'\d{4})/b\k'weapon'\.imc")]
public static partial Regex Regex();
public static string Path(SetId weaponId, SetId bodyId)
=> $"chara/weapon/w{weaponId.Value:D4}/obj/body/b{bodyId.Value:D4}/b{bodyId.Value:D4}.imc";
}
public static partial class Mdl
{
[GeneratedRegex(@"chara/weapon/w(?'id'\d{4})/obj/body/b(?'weapon'\d{4})/model/w\k'id'b\k'weapon'\.mdl")]
public static partial Regex Regex();
public static string Path(SetId weaponId, SetId bodyId)
=> $"chara/weapon/w{weaponId.Value:D4}/obj/body/b{bodyId.Value:D4}/model/w{weaponId.Value:D4}b{bodyId.Value:D4}.mdl";
}
public static partial class Mtrl
{
[GeneratedRegex(
@"chara/weapon/w(?'id'\d{4})/obj/body/b(?'weapon'\d{4})/material/v(?'variant'\d{4})/mt_w\k'id'b\k'weapon'_[a-z]+\.mtrl")]
public static partial Regex Regex();
public static string Path(SetId weaponId, SetId bodyId, byte variant, string suffix)
=> $"chara/weapon/w{weaponId.Value:D4}/obj/body/b{bodyId.Value:D4}/material/v{variant:D4}/mt_w{weaponId.Value:D4}b{bodyId.Value:D4}_{suffix}.mtrl";
}
public static partial class Tex
{
[GeneratedRegex(
@"chara/weapon/w(?'id'\d{4})/obj/body/b(?'weapon'\d{4})/texture/v(?'variant'\d{2})_w\k'id'b\k'weapon'(_[a-z])?_[a-z]\.tex")]
public static partial Regex Regex();
public static string Path(SetId weaponId, SetId bodyId, byte variant, char suffix1, char suffix2 = '\0')
=> $"chara/weapon/w{weaponId.Value:D4}/obj/body/b{bodyId.Value:D4}/texture/v{variant:D2}_w{weaponId.Value:D4}b{bodyId.Value:D4}{(suffix2 != '\0' ? $"_{suffix2}" : string.Empty)}_{suffix1}.tex";
}
}
public static partial class DemiHuman
{
public static partial class Imc
{
[GeneratedRegex(@"chara/demihuman/d(?'id'\d{4})/obj/equipment/e(?'equip'\d{4})/e\k'equip'\.imc")]
public static partial Regex Regex();
public static string Path(SetId demiId, SetId equipId)
=> $"chara/demihuman/d{demiId.Value:D4}/obj/equipment/e{equipId.Value:D4}/e{equipId.Value:D4}.imc";
}
public static partial class Mdl
{
[GeneratedRegex(@"chara/demihuman/d(?'id'\d{4})/obj/equipment/e(?'equip'\d{4})/model/d\k'id'e\k'equip'_(?'slot'[a-z]{3})\.mdl")]
public static partial Regex Regex();
public static string Path(SetId demiId, SetId equipId, EquipSlot slot)
=> $"chara/demihuman/d{demiId.Value:D4}/obj/equipment/e{equipId.Value:D4}/model/d{demiId.Value:D4}e{equipId.Value:D4}_{slot.ToSuffix()}.mdl";
}
public static partial class Mtrl
{
[GeneratedRegex(
@"chara/demihuman/d(?'id'\d{4})/obj/equipment/e(?'equip'\d{4})/material/v(?'variant'\d{4})/mt_d\k'id'e\k'equip'_(?'slot'[a-z]{3})_[a-z]+\.mtrl")]
public static partial Regex Regex();
public static string Path(SetId demiId, SetId equipId, EquipSlot slot, byte variant, string suffix)
=> $"chara/demihuman/d{demiId.Value:D4}/obj/equipment/e{equipId.Value:D4}/material/v{variant:D4}/mt_d{demiId.Value:D4}e{equipId.Value:D4}_{slot.ToSuffix()}_{suffix}.mtrl";
}
public static partial class Tex
{
[GeneratedRegex(
@"chara/demihuman/d(?'id'\d{4})/obj/equipment/e(?'equip'\d{4})/texture/v(?'variant'\d{2})_d\k'id'e\k'equip'_(?'slot'[a-z]{3})(_[a-z])?_[a-z]\.tex")]
public static partial Regex Regex();
public static string Path(SetId demiId, SetId equipId, EquipSlot slot, byte variant, char suffix1, char suffix2 = '\0')
=> $"chara/demihuman/d{demiId.Value:D4}/obj/equipment/e{equipId.Value:D4}/texture/v{variant:D2}_d{demiId.Value:D4}e{equipId.Value:D4}_{slot.ToSuffix()}{(suffix2 != '\0' ? $"_{suffix2}" : string.Empty)}_{suffix1}.tex";
}
}
public static partial class Equipment
{
public static partial class Imc
{
[GeneratedRegex(@"chara/equipment/e(?'id'\d{4})/e\k'id'\.imc")]
public static partial Regex Regex();
public static string Path(SetId equipId)
=> $"chara/equipment/e{equipId.Value:D4}/e{equipId.Value:D4}.imc";
}
public static partial class Mdl
{
[GeneratedRegex(@"chara/equipment/e(?'id'\d{4})/model/c(?'race'\d{4})e\k'id'_(?'slot'[a-z]{3})\.mdl")]
public static partial Regex Regex();
public static string Path(SetId equipId, GenderRace raceCode, EquipSlot slot)
=> $"chara/equipment/e{equipId.Value:D4}/model/c{raceCode.ToRaceCode()}e{equipId.Value:D4}_{slot.ToSuffix()}.mdl";
}
public static partial class Mtrl
{
[GeneratedRegex(
@"chara/equipment/e(?'id'\d{4})/material/v(?'variant'\d{4})/mt_c(?'race'\d{4})e\k'id'_(?'slot'[a-z]{3})_[a-z]+\.mtrl")]
public static partial Regex Regex();
public static string Path(SetId equipId, GenderRace raceCode, EquipSlot slot, byte variant, string suffix)
=> $"{FolderPath(equipId, variant)}/mt_c{raceCode.ToRaceCode()}e{equipId.Value:D4}_{slot.ToSuffix()}_{suffix}.mtrl";
public static string FolderPath(SetId equipId, byte variant)
=> $"chara/equipment/e{equipId.Value:D4}/material/v{variant:D4}";
}
public static partial class Tex
{
[GeneratedRegex(
@"chara/equipment/e(?'id'\d{4})/texture/v(?'variant'\d{2})_c(?'race'\d{4})e\k'id'_(?'slot'[a-z]{3})(_[a-z])?_[a-z]\.tex")]
public static partial Regex Regex();
public static string Path(SetId equipId, GenderRace raceCode, EquipSlot slot, byte variant, char suffix1, char suffix2 = '\0')
=> $"chara/equipment/e{equipId.Value:D4}/texture/v{variant:D2}_c{raceCode.ToRaceCode()}e{equipId.Value:D4}_{slot.ToSuffix()}{(suffix2 != '\0' ? $"_{suffix2}" : string.Empty)}_{suffix1}.tex";
}
public static partial class Avfx
{
[GeneratedRegex(@"chara/equipment/e(?'id'\d{4})/vfx/eff/ve(?'variant'\d{4})\.avfx")]
public static partial Regex Regex();
public static string Path(SetId equipId, byte effectId)
=> $"chara/equipment/e{equipId.Value:D4}/vfx/eff/ve{effectId:D4}.avfx";
}
public static partial class Decal
{
[GeneratedRegex(@"chara/common/texture/decal_equip/-decal_(?'decalId'\d{3})\.tex")]
public static partial Regex Regex();
public static string Path(byte decalId)
=> $"chara/common/texture/decal_equip/-decal_{decalId:D3}.tex";
}
}
public static partial class Accessory
{
public static partial class Imc
{
[GeneratedRegex(@"chara/accessory/a(?'id'\d{4})/a\k'id'\.imc")]
public static partial Regex Regex();
public static string Path(SetId accessoryId)
=> $"chara/accessory/a{accessoryId.Value:D4}/a{accessoryId.Value:D4}.imc";
}
public static partial class Mdl
{
[GeneratedRegex(@"chara/accessory/a(?'id'\d{4})/model/c(?'race'\d{4})a\k'id'_(?'slot'[a-z]{3})\.mdl")]
public static partial Regex Regex();
public static string Path(SetId accessoryId, GenderRace raceCode, EquipSlot slot)
=> $"chara/accessory/a{accessoryId.Value:D4}/model/c{raceCode.ToRaceCode()}a{accessoryId.Value:D4}_{slot.ToSuffix()}.mdl";
}
public static partial class Mtrl
{
[GeneratedRegex(
@"chara/accessory/a(?'id'\d{4})/material/v(?'variant'\d{4})/mt_c(?'race'\d{4})a\k'id'_(?'slot'[a-z]{3})_[a-z]+\.mtrl")]
public static partial Regex Regex();
public static string Path(SetId accessoryId, GenderRace raceCode, EquipSlot slot, byte variant, string suffix)
=> $"{FolderPath(accessoryId, variant)}/c{raceCode.ToRaceCode()}a{accessoryId.Value:D4}_{slot.ToSuffix()}_{suffix}.mtrl";
public static string FolderPath(SetId accessoryId, byte variant)
=> $"chara/accessory/a{accessoryId.Value:D4}/material/v{variant:D4}";
}
public static partial class Tex
{
[GeneratedRegex(
@"chara/accessory/a(?'id'\d{4})/texture/v(?'variant'\d{2})_c(?'race'\d{4})a\k'id'_(?'slot'[a-z]{3})(_[a-z])?_[a-z]\.tex")]
public static partial Regex Regex();
public static string Path(SetId accessoryId, GenderRace raceCode, EquipSlot slot, byte variant, char suffix1, char suffix2 = '\0')
=> $"chara/accessory/a{accessoryId.Value:D4}/texture/v{variant:D2}_c{raceCode.ToRaceCode()}a{accessoryId.Value:D4}_{slot.ToSuffix()}{(suffix2 != '\0' ? $"_{suffix2}" : string.Empty)}_{suffix1}.tex";
}
}
public static partial class Skeleton
{
public static partial class Phyb
{
public static string Path(GenderRace raceCode, string slot, SetId slotId)
=> $"chara/human/c{raceCode.ToRaceCode()}/skeleton/{slot}/{slot[0]}{slotId.Value:D4}/phy_c{raceCode.ToRaceCode()}{slot[0]}{slotId.Value:D4}.phyb";
}
public static partial class Sklb
{
public static string Path(GenderRace raceCode, string slot, SetId slotId)
=> $"chara/human/c{raceCode.ToRaceCode()}/skeleton/{slot}/{slot[0]}{slotId.Value:D4}/skl_c{raceCode.ToRaceCode()}{slot[0]}{slotId.Value:D4}.sklb";
}
}
public static partial class Character
{
public static partial class Mdl
{
[GeneratedRegex(
@"chara/human/c(?'race'\d{4})/obj/(?'type'[a-z]+)/(?'typeabr'[a-z])(?'id'\d{4})/model/c\k'race'\k'typeabr'\k'id'_(?'slot'[a-z]{3})\.mdl")]
public static partial Regex Regex();
public static string Path(GenderRace raceCode, BodySlot slot, SetId slotId, CustomizationType type)
=> $"chara/human/c{raceCode.ToRaceCode()}/obj/{slot.ToSuffix()}/{slot.ToAbbreviation()}{slotId.Value:D4}/model/c{raceCode.ToRaceCode()}{slot.ToAbbreviation()}{slotId.Value:D4}_{type.ToSuffix()}.mdl";
}
public static partial class Mtrl
{
[GeneratedRegex(
@"chara/human/c(?'race'\d{4})/obj/(?'type'[a-z]+)/(?'typeabr'[a-z])(?'id'\d{4})/material(/v(?'variant'\d{4}))?/mt_c\k'race'\k'typeabr'\k'id'(_(?'slot'[a-z]{3}))?_[a-z]+\.mtrl")]
public static partial Regex Regex();
public static string FolderPath(GenderRace raceCode, BodySlot slot, SetId slotId, byte variant = byte.MaxValue)
=> $"chara/human/c{raceCode.ToRaceCode()}/obj/{slot.ToSuffix()}/{slot.ToAbbreviation()}{slotId.Value:D4}/material{(variant != byte.MaxValue ? $"/v{variant:D4}" : string.Empty)}";
public static string HairPath(GenderRace raceCode, SetId slotId, string fileName, out GenderRace actualGr)
{
actualGr = MaterialHandling.GetGameGenderRace(raceCode, slotId);
var folder = FolderPath(actualGr, BodySlot.Hair, slotId, 1);
return actualGr == raceCode
? $"{folder}{fileName}"
: $"{folder}/mt_c{actualGr.ToRaceCode()}{fileName[9..]}";
}
public static string TailPath(GenderRace raceCode, SetId slotId, string fileName, byte variant, out SetId actualSlotId)
{
switch (raceCode)
{
case GenderRace.HrothgarMale:
case GenderRace.HrothgarFemale:
case GenderRace.HrothgarMaleNpc:
case GenderRace.HrothgarFemaleNpc:
var folder = FolderPath(raceCode, BodySlot.Tail, 1, variant == byte.MaxValue ? (byte)1 : variant);
actualSlotId = 1;
return $"{folder}{fileName}";
default:
actualSlotId = slotId;
return $"{FolderPath(raceCode, BodySlot.Tail, slotId, variant)}{fileName}";
}
}
public static string Path(GenderRace raceCode, BodySlot slot, SetId slotId, string fileName,
out GenderRace actualGr, out SetId actualSlotId, byte variant = byte.MaxValue)
{
switch (slot)
{
case BodySlot.Hair:
actualSlotId = slotId;
return HairPath(raceCode, slotId, fileName, out actualGr);
case BodySlot.Tail:
actualGr = raceCode;
return TailPath(raceCode, slotId, fileName, variant, out actualSlotId);
default:
actualSlotId = slotId;
actualGr = raceCode;
return $"{FolderPath(raceCode, slot, slotId, variant)}{fileName}";
}
}
}
public static partial class Tex
{
[GeneratedRegex(
@"chara/human/c(?'race'\d{4})/obj/(?'type'[a-z]+)/(?'typeabr'[a-z])(?'id'\d{4})/texture/(?'minus'(--)?)(v(?'variant'\d{2})_)?c\k'race'\k'typeabr'\k'id'(_(?'slot'[a-z]{3}))?(_[a-z])?_[a-z]\.tex")]
public static partial Regex Regex();
public static string Path(GenderRace raceCode, BodySlot slot, SetId slotId, char suffix1, bool minus = false,
CustomizationType type = CustomizationType.Unknown, byte variant = byte.MaxValue, char suffix2 = '\0')
=> $"chara/human/c{raceCode.ToRaceCode()}/obj/{slot.ToSuffix()}/{slot.ToAbbreviation()}{slotId.Value:D4}/texture/"
+ (minus ? "--" : string.Empty)
+ (variant != byte.MaxValue ? $"v{variant:D2}_" : string.Empty)
+ $"c{raceCode.ToRaceCode()}{slot.ToAbbreviation()}{slotId.Value:D4}{(type != CustomizationType.Unknown ? $"_{type.ToSuffix()}" : string.Empty)}{(suffix2 != '\0' ? $"_{suffix2}" : string.Empty)}_{suffix1}.tex";
[GeneratedRegex(@"chara/common/texture/(?'catchlight'catchlight)(.*)\.tex")]
public static partial Regex CatchlightRegex();
[GeneratedRegex(@"chara/common/texture/skin(?'skin'.*)\.tex")]
public static partial Regex SkinRegex();
[GeneratedRegex(@"chara/common/texture/decal_(?'location'[a-z]+)/[-_]?decal_(?'id'\d+).tex")]
public static partial Regex DecalRegex();
[GeneratedRegex(@"chara/human/c(?'race'\d{4})/obj/(?'type'[a-z]+)/(?'typeabr'[a-z])(?'id'\d{4})/texture")]
public static partial Regex FolderRegex();
}
}
public static partial class Icon
{
[GeneratedRegex(@"ui/icon/(?'group'\d*)(/(?'lang'[a-z]{2}))?(/(?'hq'hq))?/(?'id'\d*)(?'hr'_hr1)?\.tex")]
public static partial Regex Regex();
}
public static partial class Map
{
[GeneratedRegex(@"ui/map/(?'id'[a-z0-9]{4})/(?'variant'\d{2})/\k'id'\k'variant'(?'suffix'[a-z])?(_[a-z])?\.tex")]
public static partial Regex Regex();
}
public static partial class Font
{
[GeneratedRegex(@"common/font/(?'fontname'.*)_(?'id'\d\d)(_lobby)?\.fdt")]
public static partial Regex Regex();
}
public static partial class Vfx
{
[GeneratedRegex(@"chara[\/]action[\/](?'key'[^\s]+?)\.tmb", RegexOptions.IgnoreCase)]
public static partial Regex Tmb();
[GeneratedRegex(@"chara[\/]human[\/]c0101[\/]animation[\/]a0001[\/][^\s]+?[\/](?'key'[^\s]+?)\.pap", RegexOptions.IgnoreCase)]
public static partial Regex Pap();
}
public static partial class Shader
{
public static string ShpkPath(string name)
=> $"shader/sm5/shpk/{name}";
}
}

View file

@ -1,179 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Dalamud;
using Dalamud.Data;
using Dalamud.Plugin;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using PseudoEquipItem = System.ValueTuple<string, uint, ushort, ushort, ushort, byte, byte>;
namespace Penumbra.GameData.Data;
public sealed class ItemData : DataSharer, IReadOnlyDictionary<FullEquipType, IReadOnlyList<EquipItem>>
{
private readonly IReadOnlyDictionary<uint, PseudoEquipItem> _mainItems;
private readonly IReadOnlyDictionary<uint, PseudoEquipItem> _offItems;
private readonly IReadOnlyList<IReadOnlyList<PseudoEquipItem>> _byType;
private static IReadOnlyList<IReadOnlyList<PseudoEquipItem>> CreateItems(DataManager dataManager, ClientLanguage language)
{
var tmp = Enum.GetValues<FullEquipType>().Select(_ => new List<EquipItem>(1024)).ToArray();
var itemSheet = dataManager.GetExcelSheet<Item>(language)!;
foreach (var item in itemSheet.Where(i => i.Name.RawData.Length > 1))
{
var type = item.ToEquipType();
if (type.IsWeapon())
{
if (item.ModelMain != 0)
tmp[(int)type].Add(EquipItem.FromMainhand(item));
if (item.ModelSub != 0)
tmp[(int)type.Offhand()].Add(EquipItem.FromOffhand(item));
}
else if (type != FullEquipType.Unknown)
{
tmp[(int)type].Add(EquipItem.FromArmor(item));
}
}
var ret = new IReadOnlyList<PseudoEquipItem>[tmp.Length];
ret[0] = Array.Empty<PseudoEquipItem>();
for (var i = 1; i < tmp.Length; ++i)
ret[i] = tmp[i].OrderBy(item => item.Name).Select(s => (PseudoEquipItem)s).ToArray();
return ret;
}
private static IReadOnlyDictionary<uint, PseudoEquipItem> CreateMainItems(IReadOnlyList<IReadOnlyList<PseudoEquipItem>> items)
{
var dict = new Dictionary<uint, PseudoEquipItem>(1024 * 4);
foreach (var type in Enum.GetValues<FullEquipType>().Where(v => !FullEquipTypeExtensions.OffhandTypes.Contains(v)))
{
var list = items[(int)type];
foreach (var item in list)
dict.TryAdd(item.Item2, item);
}
dict.TrimExcess();
return dict;
}
private static IReadOnlyDictionary<uint, PseudoEquipItem> CreateOffItems(IReadOnlyList<IReadOnlyList<PseudoEquipItem>> items)
{
var dict = new Dictionary<uint, PseudoEquipItem>(128);
foreach (var type in FullEquipTypeExtensions.OffhandTypes)
{
var list = items[(int)type];
foreach (var item in list)
dict.TryAdd(item.Item2, item);
}
dict.TrimExcess();
return dict;
}
public ItemData(DalamudPluginInterface pluginInterface, DataManager dataManager, ClientLanguage language)
: base(pluginInterface, language, 1)
{
_byType = TryCatchData("ItemList", () => CreateItems(dataManager, language));
_mainItems = TryCatchData("ItemDictMain", () => CreateMainItems(_byType));
_offItems = TryCatchData("ItemDictOff", () => CreateOffItems(_byType));
}
protected override void DisposeInternal()
{
DisposeTag("ItemList");
DisposeTag("ItemDictMain");
DisposeTag("ItemDictOff");
}
public IEnumerator<KeyValuePair<FullEquipType, IReadOnlyList<EquipItem>>> GetEnumerator()
{
for (var i = 1; i < _byType.Count; ++i)
yield return new KeyValuePair<FullEquipType, IReadOnlyList<EquipItem>>((FullEquipType)i, new EquipItemList(_byType[i]));
}
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
public int Count
=> _byType.Count - 1;
public bool ContainsKey(FullEquipType key)
=> (int)key < _byType.Count && key != FullEquipType.Unknown;
public bool TryGetValue(FullEquipType key, out IReadOnlyList<EquipItem> value)
{
if (ContainsKey(key))
{
value = new EquipItemList(_byType[(int)key]);
return true;
}
value = Array.Empty<EquipItem>();
return false;
}
public IReadOnlyList<EquipItem> this[FullEquipType key]
=> TryGetValue(key, out var ret) ? ret : throw new IndexOutOfRangeException();
public bool ContainsKey(uint key, bool main = true)
=> main ? _mainItems.ContainsKey(key) : _offItems.ContainsKey(key);
public bool TryGetValue(uint key, out EquipItem value)
{
if (_mainItems.TryGetValue(key, out var v))
{
value = v;
return true;
}
value = default;
return false;
}
public IEnumerable<(uint, EquipItem)> AllItems(bool main)
=> (main ? _mainItems : _offItems).Select(i => (i.Key, (EquipItem)i.Value));
public bool TryGetValue(uint key, bool main, out EquipItem value)
{
var dict = main ? _mainItems : _offItems;
if (dict.TryGetValue(key, out var v))
{
value = v;
return true;
}
value = default;
return false;
}
public IEnumerable<FullEquipType> Keys
=> Enum.GetValues<FullEquipType>().Skip(1);
public IEnumerable<IReadOnlyList<EquipItem>> Values
=> _byType.Skip(1).Select(l => (IReadOnlyList<EquipItem>)new EquipItemList(l));
private readonly struct EquipItemList : IReadOnlyList<EquipItem>
{
private readonly IReadOnlyList<PseudoEquipItem> _items;
public EquipItemList(IReadOnlyList<PseudoEquipItem> items)
=> _items = items;
public IEnumerator<EquipItem> GetEnumerator()
=> _items.Select(i => (EquipItem)i).GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
public int Count
=> _items.Count;
public EquipItem this[int index]
=> _items[index];
}
}

View file

@ -1,101 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Dalamud;
using Dalamud.Plugin;
namespace Penumbra.GameData.Data;
/// <summary>
/// A list sorting objects based on a key which then allows efficiently finding all objects between a pair of keys via binary search.
/// </summary>
public abstract class KeyList<T>
{
private readonly List<(ulong Key, T Data)> _list;
public IReadOnlyList<(ulong Key, T Data)> List
=> _list;
/// <summary>
/// Iterate over all objects between the given minimal and maximal keys (inclusive).
/// </summary>
protected IEnumerable<T> Between(ulong minKey, ulong maxKey)
{
var (minIdx, maxIdx) = GetMinMax(minKey, maxKey);
if (minIdx < 0)
yield break;
for (var i = minIdx; i <= maxIdx; ++i)
yield return _list[i].Data;
}
private (int MinIdx, int MaxIdx) GetMinMax(ulong minKey, ulong maxKey)
{
var idx = _list.BinarySearch((minKey, default!), ListComparer);
var minIdx = idx;
if (minIdx < 0)
{
minIdx = ~minIdx;
if (minIdx == _list.Count || _list[minIdx].Key > maxKey)
return (-1, -1);
idx = minIdx;
}
else
{
while (minIdx > 0 && _list[minIdx - 1].Key >= minKey)
--minIdx;
}
if (_list[minIdx].Key < minKey || _list[minIdx].Key > maxKey)
return (-1, -1);
var maxIdx = _list.BinarySearch(idx, _list.Count - idx, (maxKey, default!), ListComparer);
if (maxIdx < 0)
{
maxIdx = ~maxIdx;
return maxIdx > minIdx ? (minIdx, maxIdx - 1) : (-1, -1);
}
while (maxIdx < _list.Count - 1 && _list[maxIdx + 1].Key <= maxKey)
++maxIdx;
if (_list[maxIdx].Key < minKey || _list[maxIdx].Key > maxKey)
return (-1, -1);
return (minIdx, maxIdx);
}
/// <summary>
/// The function turning an object to (potentially multiple) keys. Only used during construction.
/// </summary>
protected abstract IEnumerable<ulong> ToKeys(T data);
/// <summary>
/// Whether a returned key is valid. Only used during construction.
/// </summary>
protected abstract bool ValidKey(ulong key);
/// <summary>
/// How multiple items with the same key should be sorted.
/// </summary>
protected abstract int ValueKeySelector(T data);
protected KeyList(DalamudPluginInterface pi, string tag, ClientLanguage language, int version, IEnumerable<T> data)
{
_list = DataSharer.TryCatchData(pi, tag, language, version,
() => data.SelectMany(d => ToKeys(d).Select(k => (k, d)))
.Where(p => ValidKey(p.k))
.OrderBy(p => p.k)
.ThenBy(p => ValueKeySelector(p.d))
.ToList());
}
private class Comparer : IComparer<(ulong, T)>
{
public int Compare((ulong, T) x, (ulong, T) y)
=> x.Item1.CompareTo(y.Item1);
}
private static readonly Comparer ListComparer = new();
}

View file

@ -1,32 +0,0 @@
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData.Data;
public static class MaterialHandling
{
public static GenderRace GetGameGenderRace(GenderRace actualGr, SetId hairId)
{
// Hrothgar do not share hairstyles.
if (actualGr is GenderRace.HrothgarFemale or GenderRace.HrothgarMale)
return actualGr;
// Some hairstyles are miqo'te specific but otherwise shared.
if (hairId.Value is >= 101 and <= 115)
{
if (actualGr is GenderRace.MiqoteFemale or GenderRace.MiqoteMale)
return actualGr;
return actualGr.Split().Item1 == Gender.Female ? GenderRace.MidlanderFemale : GenderRace.MidlanderMale;
}
// All hairstyles above 116 are shared except for Hrothgar
if (hairId.Value is >= 116 and <= 200)
return actualGr.Split().Item1 == Gender.Female ? GenderRace.MidlanderFemale : GenderRace.MidlanderMale;
return actualGr;
}
public static bool IsSpecialCase(GenderRace gr, SetId hairId)
=> gr is GenderRace.MidlanderMale or GenderRace.MidlanderFemale && hairId.Value is >= 101 and <= 200;
}

View file

@ -1,52 +0,0 @@
using System.Collections.Generic;
using Dalamud;
using Dalamud.Data;
using Dalamud.Plugin;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData.Data;
internal sealed class ModelIdentificationList : KeyList<ModelChara>
{
private const string Tag = "ModelIdentification";
public ModelIdentificationList(DalamudPluginInterface pi, ClientLanguage language, DataManager gameData)
: base(pi, Tag, language, ObjectIdentification.IdentificationVersion, CreateModelList(gameData, language))
{ }
public IEnumerable<ModelChara> Between(CharacterBase.ModelType type, SetId modelId, byte modelBase = 0, byte variant = 0)
{
if (modelBase == 0)
return Between(ToKey(type, modelId, 0, 0), ToKey(type, modelId, 0xFF, 0xFF));
if (variant == 0)
return Between(ToKey(type, modelId, modelBase, 0), ToKey(type, modelId, modelBase, 0xFF));
return Between(ToKey(type, modelId, modelBase, variant), ToKey(type, modelId, modelBase, variant));
}
public void Dispose(DalamudPluginInterface pi, ClientLanguage language)
=> DataSharer.DisposeTag(pi, Tag, language, ObjectIdentification.IdentificationVersion);
public static ulong ToKey(CharacterBase.ModelType type, SetId model, byte modelBase, byte variant)
=> ((ulong)type << 32) | ((ulong)model << 16) | ((ulong)modelBase << 8) | variant;
private static ulong ToKey(ModelChara row)
=> ToKey((CharacterBase.ModelType)row.Type, row.Model, row.Base, row.Variant);
protected override IEnumerable<ulong> ToKeys(ModelChara row)
{
yield return ToKey(row);
}
protected override bool ValidKey(ulong key)
=> key != 0;
protected override int ValueKeySelector(ModelChara data)
=> (int)data.RowId;
private static IEnumerable<ModelChara> CreateModelList(DataManager gameData, ClientLanguage language)
=> gameData.GetExcelSheet<ModelChara>(language)!;
}

View file

@ -1,325 +0,0 @@
using System;
using System.Collections.Concurrent;
using Dalamud;
using Dalamud.Data;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Plugin;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Penumbra.GameData.Actors;
using Action = Lumina.Excel.GeneratedSheets.Action;
using ObjectType = Penumbra.GameData.Enums.ObjectType;
namespace Penumbra.GameData.Data;
internal sealed class ObjectIdentification : DataSharer, IObjectIdentifier
{
public const int IdentificationVersion = 1;
public IGamePathParser GamePathParser { get; } = new GamePathParser();
public readonly IReadOnlyList<IReadOnlyList<uint>> BnpcNames;
public readonly IReadOnlyList<IReadOnlyList<(string Name, ObjectKind Kind)>> ModelCharaToObjects;
public readonly IReadOnlyDictionary<string, IReadOnlyList<Action>> Actions;
private readonly ActorManager.ActorManagerData _actorData;
private readonly EquipmentIdentificationList _equipment;
private readonly WeaponIdentificationList _weapons;
private readonly ModelIdentificationList _modelIdentifierToModelChara;
public ObjectIdentification(DalamudPluginInterface pluginInterface, DataManager dataManager, ClientLanguage language)
: base(pluginInterface, language, IdentificationVersion)
{
_actorData = new ActorManager.ActorManagerData(pluginInterface, dataManager, language);
_equipment = new EquipmentIdentificationList(pluginInterface, language, dataManager);
_weapons = new WeaponIdentificationList(pluginInterface, language, dataManager);
Actions = TryCatchData("Actions", () => CreateActionList(dataManager));
_modelIdentifierToModelChara = new ModelIdentificationList(pluginInterface, language, dataManager);
BnpcNames = TryCatchData("BNpcNames", NpcNames.CreateNames);
ModelCharaToObjects = TryCatchData("ModelObjects", () => CreateModelObjects(_actorData, dataManager, language));
}
public void Identify(IDictionary<string, object?> set, string path)
{
if (path.EndsWith(".pap", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".tmb", StringComparison.OrdinalIgnoreCase))
{
if (IdentifyVfx(set, path))
return;
}
var info = GamePathParser.GetFileInfo(path);
IdentifyParsed(set, info);
}
public Dictionary<string, object?> Identify(string path)
{
Dictionary<string, object?> ret = new();
Identify(ret, path);
return ret;
}
public IEnumerable<EquipItem> Identify(SetId setId, WeaponType weaponType, ushort variant, EquipSlot slot)
=> slot switch
{
EquipSlot.MainHand => _weapons.Between(setId, weaponType, (byte)variant),
EquipSlot.OffHand => _weapons.Between(setId, weaponType, (byte)variant),
_ => _equipment.Between(setId, slot, (byte)variant),
};
protected override void DisposeInternal()
{
_actorData.Dispose();
_weapons.Dispose(PluginInterface, Language);
_equipment.Dispose(PluginInterface, Language);
DisposeTag("Actions");
DisposeTag("Models");
_modelIdentifierToModelChara.Dispose(PluginInterface, Language);
DisposeTag("BNpcNames");
DisposeTag("ModelObjects");
}
private IReadOnlyDictionary<string, IReadOnlyList<Action>> CreateActionList(DataManager gameData)
{
var sheet = gameData.GetExcelSheet<Action>(Language)!;
var storage = new ConcurrentDictionary<string, ConcurrentBag<Action>>();
void AddAction(string? key, Action action)
{
if (key.IsNullOrEmpty())
return;
key = key.ToLowerInvariant();
if (storage.TryGetValue(key, out var actions))
actions.Add(action);
else
storage[key] = new ConcurrentBag<Action> { action };
}
var options = new ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount,
};
Parallel.ForEach(sheet.Where(a => !a.Name.RawData.IsEmpty), options, action =>
{
var startKey = action.AnimationStart?.Value?.Name?.Value?.Key.ToDalamudString().ToString();
var endKey = action.AnimationEnd?.Value?.Key.ToDalamudString().ToString();
var hitKey = action.ActionTimelineHit?.Value?.Key.ToDalamudString().ToString();
AddAction(startKey, action);
AddAction(endKey, action);
AddAction(hitKey, action);
});
return storage.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList<Action>)kvp.Value.ToArray());
}
private void FindEquipment(IDictionary<string, object?> set, GameObjectInfo info)
{
var items = _equipment.Between(info.PrimaryId, info.EquipSlot, info.Variant);
foreach (var item in items)
set[item.Name.ToString()] = item;
}
private void FindWeapon(IDictionary<string, object?> set, GameObjectInfo info)
{
var items = _weapons.Between(info.PrimaryId, info.SecondaryId, info.Variant);
foreach (var item in items)
set[item.Name.ToString()] = item;
}
private void FindModel(IDictionary<string, object?> set, GameObjectInfo info)
{
var type = info.ObjectType.ToModelType();
if (type is 0 or CharacterBase.ModelType.Weapon)
return;
var models = _modelIdentifierToModelChara.Between(type, info.PrimaryId, (byte)info.SecondaryId, info.Variant);
foreach (var model in models.Where(m => m.RowId < ModelCharaToObjects.Count))
{
var objectList = ModelCharaToObjects[(int)model.RowId];
foreach (var (name, kind) in objectList)
set[$"{name} ({kind.ToName()})"] = model;
}
}
private static void AddCounterString(IDictionary<string, object?> set, string data)
{
if (set.TryGetValue(data, out var obj) && obj is int counter)
set[data] = counter + 1;
else
set[data] = 1;
}
private void IdentifyParsed(IDictionary<string, object?> set, GameObjectInfo info)
{
switch (info.FileType)
{
case FileType.Sound:
AddCounterString(set, FileType.Sound.ToString());
return;
case FileType.Animation:
case FileType.Pap:
AddCounterString(set, FileType.Animation.ToString());
return;
case FileType.Shader:
AddCounterString(set, FileType.Shader.ToString());
return;
}
switch (info.ObjectType)
{
case ObjectType.LoadingScreen:
case ObjectType.Map:
case ObjectType.Interface:
case ObjectType.Vfx:
case ObjectType.World:
case ObjectType.Housing:
case ObjectType.Font:
AddCounterString(set, info.ObjectType.ToString());
break;
case ObjectType.DemiHuman:
FindModel(set, info);
break;
case ObjectType.Monster:
FindModel(set, info);
break;
case ObjectType.Icon:
set[$"Icon: {info.IconId}"] = null;
break;
case ObjectType.Accessory:
case ObjectType.Equipment:
FindEquipment(set, info);
break;
case ObjectType.Weapon:
FindWeapon(set, info);
break;
case ObjectType.Character:
var (gender, race) = info.GenderRace.Split();
var raceString = race != ModelRace.Unknown ? race.ToName() + " " : "";
var genderString = gender != Gender.Unknown ? gender.ToName() + " " : "Player ";
switch (info.CustomizationType)
{
case CustomizationType.Skin:
set[$"Customization: {raceString}{genderString}Skin Textures"] = null;
break;
case CustomizationType.DecalFace:
set[$"Customization: Face Decal {info.PrimaryId}"] = null;
break;
case CustomizationType.Iris when race == ModelRace.Unknown:
set[$"Customization: All Eyes (Catchlight)"] = null;
break;
case CustomizationType.DecalEquip:
set[$"Equipment Decal {info.PrimaryId}"] = null;
break;
default:
{
var customizationString = race == ModelRace.Unknown
|| info.BodySlot == BodySlot.Unknown
|| info.CustomizationType == CustomizationType.Unknown
? "Customization: Unknown"
: $"Customization: {race} {gender} {info.BodySlot} ({info.CustomizationType}) {info.PrimaryId}";
set[customizationString] = null;
break;
}
}
break;
}
}
private bool IdentifyVfx(IDictionary<string, object?> set, string path)
{
var key = GamePathParser.VfxToKey(path);
if (key.Length == 0 || !Actions.TryGetValue(key, out var actions) || actions.Count == 0)
return false;
foreach (var action in actions)
set[$"Action: {action.Name}"] = action;
return true;
}
private IReadOnlyList<IReadOnlyList<(string Name, ObjectKind Kind)>> CreateModelObjects(ActorManager.ActorManagerData actors,
DataManager gameData, ClientLanguage language)
{
var modelSheet = gameData.GetExcelSheet<ModelChara>(language)!;
var ret = new List<ConcurrentBag<(string Name, ObjectKind Kind)>>((int)modelSheet.RowCount);
for (var i = -1; i < modelSheet.Last().RowId; ++i)
ret.Add(new ConcurrentBag<(string Name, ObjectKind Kind)>());
void AddChara(int modelChara, ObjectKind kind, uint dataId)
{
if (modelChara == 0 || modelChara >= ret.Count)
return;
if (actors.TryGetName(kind, dataId, out var name))
ret[modelChara].Add((name, kind));
}
var oTask = Task.Run(() =>
{
foreach (var ornament in gameData.GetExcelSheet<Ornament>(language)!)
AddChara(ornament.Model, (ObjectKind)15, ornament.RowId);
});
var mTask = Task.Run(() =>
{
foreach (var mount in gameData.GetExcelSheet<Mount>(language)!)
AddChara((int)mount.ModelChara.Row, ObjectKind.MountType, mount.RowId);
});
var cTask = Task.Run(() =>
{
foreach (var companion in gameData.GetExcelSheet<Companion>(language)!)
AddChara((int)companion.Model.Row, ObjectKind.Companion, companion.RowId);
});
var eTask = Task.Run(() =>
{
foreach (var eNpc in gameData.GetExcelSheet<ENpcBase>(language)!)
AddChara((int)eNpc.ModelChara.Row, ObjectKind.EventNpc, eNpc.RowId);
});
var options = new ParallelOptions()
{
MaxDegreeOfParallelism = Environment.ProcessorCount / 2,
};
Parallel.ForEach(gameData.GetExcelSheet<BNpcBase>(language)!.Where(b => b.RowId < BnpcNames.Count), options, bNpc =>
{
foreach (var name in BnpcNames[(int)bNpc.RowId])
AddChara((int)bNpc.ModelChara.Row, ObjectKind.BattleNpc, name);
});
Task.WaitAll(oTask, mTask, cTask, eTask);
return ret.Select(s => s.Count > 0
? s.ToArray()
: Array.Empty<(string Name, ObjectKind Kind)>()).ToArray();
}
public static unsafe ulong KeyFromCharacterBase(CharacterBase* drawObject)
{
var type = (*(delegate* unmanaged<CharacterBase*, uint>**)drawObject)[Offsets.DrawObjectGetModelTypeVfunc](drawObject);
var unk = (ulong)*((byte*)drawObject + Offsets.DrawObjectModelUnk1) << 8;
return type switch
{
1 => type | unk,
2 => type | unk | ((ulong)*(ushort*)((byte*)drawObject + Offsets.DrawObjectModelUnk3) << 16),
3 => type
| unk
| ((ulong)*(ushort*)((byte*)drawObject + Offsets.DrawObjectModelUnk2) << 16)
| ((ulong)**(ushort**)((byte*)drawObject + Offsets.DrawObjectModelUnk4) << 32)
| ((ulong)**(ushort**)((byte*)drawObject + Offsets.DrawObjectModelUnk3) << 40),
_ => 0u,
};
}
}

View file

@ -1,433 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud;
using Dalamud.Data;
using Dalamud.Logging;
using Dalamud.Plugin;
using Dalamud.Utility;
using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using Race = Penumbra.GameData.Enums.Race;
namespace Penumbra.GameData.Data;
/// <summary>
/// Handle gender- or race-locked gear in the draw model itself.
/// Racial gear gets swapped to the correct current race and gender (it is one set each).
/// Gender-locked gear gets swapped to the equivalent set if it exists (most of them do),
/// with some items getting send to emperor's new clothes and a few funny entries.
/// </summary>
public sealed class RestrictedGear : DataSharer
{
private readonly ExcelSheet<Item> _items;
private readonly ExcelSheet<EquipRaceCategory> _categories;
public readonly IReadOnlySet<uint> RaceGenderSet;
public readonly IReadOnlyDictionary<uint, uint> MaleToFemale;
public readonly IReadOnlyDictionary<uint, uint> FemaleToMale;
public RestrictedGear(DalamudPluginInterface pi, ClientLanguage language, DataManager gameData)
: base(pi, language, 1)
{
_items = gameData.GetExcelSheet<Item>()!;
_categories = gameData.GetExcelSheet<EquipRaceCategory>()!;
(RaceGenderSet, MaleToFemale, FemaleToMale) = TryCatchData("RestrictedGear", CreateRestrictedGear);
}
protected override void DisposeInternal()
=> DisposeTag("RestrictedGear");
/// <summary>
/// Resolve a model given by its model id, variant and slot for your current race and gender.
/// </summary>
/// <param name="armor">The equipment piece.</param>
/// <param name="slot">The equipment slot.</param>
/// <param name="race">The intended race.</param>
/// <param name="gender">The intended gender.</param>
/// <returns>True and the changed-to piece of gear or false and the same piece of gear.</returns>
public (bool Replaced, CharacterArmor Armor) ResolveRestricted(CharacterArmor armor, EquipSlot slot, Race race, Gender gender)
{
var quad = armor.Set.Value | ((uint)armor.Variant << 16);
// Check racial gear, this does not need slots.
if (RaceGenderGroup.Contains(quad))
{
var idx = ((int)race - 1) * 2 + (gender is Gender.Female or Gender.FemaleNpc ? 1 : 0);
var value = RaceGenderGroup[idx];
return (value != quad, new CharacterArmor((ushort)value, (byte)(value >> 16), armor.Stain));
}
// Check gender slots. If current gender is female, check if anything needs to be changed from male to female,
// and vice versa.
// Some items lead to the exact same model- and variant id just gender specified,
// so check for actual difference in the Replaced bool.
var needle = quad | ((uint)slot.ToSlot() << 24);
if (gender is Gender.Female or Gender.FemaleNpc && MaleToFemale.TryGetValue(needle, out var newValue)
|| gender is Gender.Male or Gender.MaleNpc && FemaleToMale.TryGetValue(needle, out newValue))
return (quad != newValue, new CharacterArmor((ushort)newValue, (byte)(newValue >> 16), armor.Stain));
// The gear is not restricted.
return (false, armor);
}
private Tuple<IReadOnlySet<uint>, IReadOnlyDictionary<uint, uint>, IReadOnlyDictionary<uint, uint>> CreateRestrictedGear()
{
var m2f = new Dictionary<uint, uint>();
var f2m = new Dictionary<uint, uint>();
var rg = RaceGenderGroup.Where(c => c is not 0 and not uint.MaxValue).ToHashSet();
AddKnown(m2f, f2m);
UnhandledRestrictedGear(rg, m2f, f2m, false); // Set this to true to create a print of unassigned gear on launch.
return new Tuple<IReadOnlySet<uint>, IReadOnlyDictionary<uint, uint>, IReadOnlyDictionary<uint, uint>>(rg, m2f, f2m);
}
// Add all unknown restricted gear and pair it with emperor's new gear on start up.
// Can also print unhandled items.
private void UnhandledRestrictedGear(IReadOnlySet<uint> rg, Dictionary<uint, uint> m2f, Dictionary<uint, uint> f2m, bool print)
{
if (print)
PluginLog.Information("#### MALE ONLY ######");
void AddEmperor(Item item, bool male, bool female)
{
var slot = ((EquipSlot)item.EquipSlotCategory.Row).ToSlot();
var emperor = slot switch
{
EquipSlot.Head => 10032u,
EquipSlot.Body => 10033u,
EquipSlot.Hands => 10034u,
EquipSlot.Legs => 10035u,
EquipSlot.Feet => 10036u,
EquipSlot.Ears => 09293u,
EquipSlot.Neck => 09292u,
EquipSlot.Wrists => 09294u,
EquipSlot.RFinger => 09295u,
EquipSlot.LFinger => 09295u,
_ => 0u,
};
if (emperor == 0)
return;
if (male)
AddItem(m2f, f2m, item.RowId, emperor, true, false);
if (female)
AddItem(m2f, f2m, emperor, item.RowId, false, true);
}
var unhandled = 0;
foreach (var item in _items.Where(i => i.EquipRestriction == 2))
{
if (m2f.ContainsKey((uint)item.ModelMain | ((uint)((EquipSlot)item.EquipSlotCategory.Row).ToSlot() << 24)))
continue;
++unhandled;
AddEmperor(item, true, false);
if (print)
PluginLog.Information($"{item.RowId:D5} {item.Name.ToDalamudString().TextValue}");
}
if (print)
PluginLog.Information("#### FEMALE ONLY ####");
foreach (var item in _items.Where(i => i.EquipRestriction == 3))
{
if (f2m.ContainsKey((uint)item.ModelMain | ((uint)((EquipSlot)item.EquipSlotCategory.Row).ToSlot() << 24)))
continue;
++unhandled;
AddEmperor(item, false, true);
if (print)
PluginLog.Information($"{item.RowId:D5} {item.Name.ToDalamudString().TextValue}");
}
if (print)
PluginLog.Information("#### OTHER #########");
foreach (var item in _items.Where(i => i.EquipRestriction > 3))
{
if (rg.Contains((uint)item.ModelMain))
continue;
++unhandled;
if (print)
PluginLog.Information(
$"{item.RowId:D5} {item.Name.ToDalamudString().TextValue} RestrictionGroup {_categories.GetRow(item.EquipRestriction)!.RowId:D2}");
}
if (unhandled > 0)
PluginLog.Warning($"There were {unhandled} restricted items not handled and directed to Emperor's New Set.");
}
// Add a item redirection by its item - NOT MODEL - id.
// This uses the items model as well as its slot.
// Creates a <-> redirection by default but can add -> or <- redirections by setting the corresponding bools to false.
// Prints warnings if anything does not make sense.
private void AddItem(Dictionary<uint, uint> m2f, Dictionary<uint, uint> f2m, uint itemIdMale, uint itemIdFemale, bool addMale = true,
bool addFemale = true)
{
if (!addMale && !addFemale)
return;
var mItem = _items.GetRow(itemIdMale);
var fItem = _items.GetRow(itemIdFemale);
if (mItem == null || fItem == null)
{
PluginLog.Warning($"Could not add item {itemIdMale} or {itemIdFemale} to restricted items.");
return;
}
if (mItem.EquipRestriction != 2 && addMale)
{
PluginLog.Warning($"{mItem.Name.ToDalamudString().TextValue} is not restricted anymore.");
return;
}
if (fItem.EquipRestriction != 3 && addFemale)
{
PluginLog.Warning($"{fItem.Name.ToDalamudString().TextValue} is not restricted anymore.");
return;
}
var mSlot = ((EquipSlot)mItem.EquipSlotCategory.Row).ToSlot();
var fSlot = ((EquipSlot)fItem.EquipSlotCategory.Row).ToSlot();
if (!mSlot.IsAccessory() && !mSlot.IsEquipment())
{
PluginLog.Warning($"{mItem.Name.ToDalamudString().TextValue} is not equippable to a known slot.");
return;
}
if (mSlot != fSlot)
{
PluginLog.Warning($"{mItem.Name.ToDalamudString().TextValue} and {fItem.Name.ToDalamudString().TextValue} are not compatible.");
return;
}
var mModelIdSlot = (uint)mItem.ModelMain | ((uint)mSlot << 24);
var fModelIdSlot = (uint)fItem.ModelMain | ((uint)fSlot << 24);
if (addMale)
m2f.TryAdd(mModelIdSlot, fModelIdSlot);
if (addFemale)
f2m.TryAdd(fModelIdSlot, mModelIdSlot);
}
// @formatter:off
// Add all currently existing and known gender restricted items.
private void AddKnown(Dictionary<uint, uint> m2f, Dictionary<uint, uint> f2m)
{
AddItem(m2f, f2m, 02967, 02970); // Lord's Yukata (Blue) <-> Lady's Yukata (Red)
AddItem(m2f, f2m, 02968, 02971); // Lord's Yukata (Green) <-> Lady's Yukata (Blue)
AddItem(m2f, f2m, 02969, 02972); // Lord's Yukata (Grey) <-> Lady's Yukata (Black)
AddItem(m2f, f2m, 02973, 02978); // Red Summer Top <-> Red Summer Halter
AddItem(m2f, f2m, 02974, 02979); // Green Summer Top <-> Green Summer Halter
AddItem(m2f, f2m, 02975, 02980); // Blue Summer Top <-> Blue Summer Halter
AddItem(m2f, f2m, 02976, 02981); // Solar Summer Top <-> Solar Summer Halter
AddItem(m2f, f2m, 02977, 02982); // Lunar Summer Top <-> Lunar Summer Halter
AddItem(m2f, f2m, 02996, 02997); // Hempen Undershirt <-> Hempen Camise
AddItem(m2f, f2m, 03280, 03283); // Lord's Drawers (Black) <-> Lady's Knickers (Black)
AddItem(m2f, f2m, 03281, 03284); // Lord's Drawers (White) <-> Lady's Knickers (White)
AddItem(m2f, f2m, 03282, 03285); // Lord's Drawers (Gold) <-> Lady's Knickers (Gold)
AddItem(m2f, f2m, 03286, 03291); // Red Summer Trunks <-> Red Summer Tanga
AddItem(m2f, f2m, 03287, 03292); // Green Summer Trunks <-> Green Summer Tanga
AddItem(m2f, f2m, 03288, 03293); // Blue Summer Trunks <-> Blue Summer Tanga
AddItem(m2f, f2m, 03289, 03294); // Solar Summer Trunks <-> Solar Summer Tanga
AddItem(m2f, f2m, 03290, 03295); // Lunar Summer Trunks <-> Lunar Summer Tanga
AddItem(m2f, f2m, 03307, 03308); // Hempen Underpants <-> Hempen Pantalettes
AddItem(m2f, f2m, 03748, 03749); // Lord's Clogs <-> Lady's Clogs
AddItem(m2f, f2m, 06045, 06041); // Bohemian's Coat <-> Guardian Corps Coat
AddItem(m2f, f2m, 06046, 06042); // Bohemian's Gloves <-> Guardian Corps Gauntlets
AddItem(m2f, f2m, 06047, 06043); // Bohemian's Trousers <-> Guardian Corps Skirt
AddItem(m2f, f2m, 06048, 06044); // Bohemian's Boots <-> Guardian Corps Boots
AddItem(m2f, f2m, 06094, 06098); // Summer Evening Top <-> Summer Morning Halter
AddItem(m2f, f2m, 06095, 06099); // Summer Evening Trunks <-> Summer Morning Tanga
AddItem(m2f, f2m, 06096, 06100); // Striped Summer Top <-> Striped Summer Halter
AddItem(m2f, f2m, 06097, 06101); // Striped Summer Trunks <-> Striped Summer Tanga
AddItem(m2f, f2m, 06102, 06104); // Black Summer Top <-> Black Summer Halter
AddItem(m2f, f2m, 06103, 06105); // Black Summer Trunks <-> Black Summer Tanga
AddItem(m2f, f2m, 08532, 08535); // Lord's Yukata (Blackflame) <-> Lady's Yukata (Redfly)
AddItem(m2f, f2m, 08533, 08536); // Lord's Yukata (Whiteflame) <-> Lady's Yukata (Bluefly)
AddItem(m2f, f2m, 08534, 08537); // Lord's Yukata (Blueflame) <-> Lady's Yukata (Pinkfly)
AddItem(m2f, f2m, 08542, 08549); // Ti Leaf Lei <-> Coronal Summer Halter
AddItem(m2f, f2m, 08543, 08550); // Red Summer Maro <-> Red Summer Pareo
AddItem(m2f, f2m, 08544, 08551); // South Seas Talisman <-> Sea Breeze Summer Halter
AddItem(m2f, f2m, 08545, 08552); // Blue Summer Maro <-> Sea Breeze Summer Pareo
AddItem(m2f, f2m, 08546, 08553); // Coeurl Talisman <-> Coeurl Beach Halter
AddItem(m2f, f2m, 08547, 08554); // Coeurl Beach Maro <-> Coeurl Beach Pareo
AddItem(m2f, f2m, 08548, 08555); // Coeurl Beach Briefs <-> Coeurl Beach Tanga
AddItem(m2f, f2m, 10316, 10317); // Southern Seas Vest <-> Southern Seas Swimsuit
AddItem(m2f, f2m, 10318, 10319); // Southern Seas Trunks <-> Southern Seas Tanga
AddItem(m2f, f2m, 10320, 10321); // Striped Southern Seas Vest <-> Striped Southern Seas Swimsuit
AddItem(m2f, f2m, 13298, 13567); // Black-feathered Flat Hat <-> Red-feathered Flat Hat
AddItem(m2f, f2m, 13300, 13639); // Lord's Suikan <-> Lady's Suikan
AddItem(m2f, f2m, 13724, 13725); // Little Lord's Clogs <-> Little Lady's Clogs
AddItem(m2f, f2m, 14854, 14857); // Eastern Lord's Togi <-> Eastern Lady's Togi
AddItem(m2f, f2m, 14855, 14858); // Eastern Lord's Trousers <-> Eastern Lady's Loincloth
AddItem(m2f, f2m, 14856, 14859); // Eastern Lord's Crakows <-> Eastern Lady's Crakows
AddItem(m2f, f2m, 15639, 15642); // Far Eastern Patriarch's Hat <-> Far Eastern Matriarch's Sun Hat
AddItem(m2f, f2m, 15640, 15643); // Far Eastern Patriarch's Tunic <-> Far Eastern Matriarch's Dress
AddItem(m2f, f2m, 15641, 15644); // Far Eastern Patriarch's Longboots <-> Far Eastern Matriarch's Boots
AddItem(m2f, f2m, 15922, 15925); // Moonfire Vest <-> Moonfire Halter
AddItem(m2f, f2m, 15923, 15926); // Moonfire Trunks <-> Moonfire Tanga
AddItem(m2f, f2m, 15924, 15927); // Moonfire Caligae <-> Moonfire Sandals
AddItem(m2f, f2m, 16106, 16111); // Makai Mauler's Facemask <-> Makai Manhandler's Facemask
AddItem(m2f, f2m, 16107, 16112); // Makai Mauler's Oilskin <-> Makai Manhandler's Jerkin
AddItem(m2f, f2m, 16108, 16113); // Makai Mauler's Fingerless Gloves <-> Makai Manhandler's Fingerless Gloves
AddItem(m2f, f2m, 16109, 16114); // Makai Mauler's Leggings <-> Makai Manhandler's Quartertights
AddItem(m2f, f2m, 16110, 16115); // Makai Mauler's Boots <-> Makai Manhandler's Longboots
AddItem(m2f, f2m, 16116, 16121); // Makai Marksman's Eyepatch <-> Makai Markswoman's Ribbon
AddItem(m2f, f2m, 16117, 16122); // Makai Marksman's Battlegarb <-> Makai Markswoman's Battledress
AddItem(m2f, f2m, 16118, 16123); // Makai Marksman's Fingerless Gloves <-> Makai Markswoman's Fingerless Gloves
AddItem(m2f, f2m, 16119, 16124); // Makai Marksman's Slops <-> Makai Markswoman's Quartertights
AddItem(m2f, f2m, 16120, 16125); // Makai Marksman's Boots <-> Makai Markswoman's Longboots
AddItem(m2f, f2m, 16126, 16131); // Makai Sun Guide's Circlet <-> Makai Moon Guide's Circlet
AddItem(m2f, f2m, 16127, 16132); // Makai Sun Guide's Oilskin <-> Makai Moon Guide's Gown
AddItem(m2f, f2m, 16128, 16133); // Makai Sun Guide's Fingerless Gloves <-> Makai Moon Guide's Fingerless Gloves
AddItem(m2f, f2m, 16129, 16134); // Makai Sun Guide's Slops <-> Makai Moon Guide's Quartertights
AddItem(m2f, f2m, 16130, 16135); // Makai Sun Guide's Boots <-> Makai Moon Guide's Longboots
AddItem(m2f, f2m, 16136, 16141); // Makai Priest's Coronet <-> Makai Priestess's Headdress
AddItem(m2f, f2m, 16137, 16142); // Makai Priest's Doublet Robe <-> Makai Priestess's Jerkin
AddItem(m2f, f2m, 16138, 16143); // Makai Priest's Fingerless Gloves <-> Makai Priestess's Fingerless Gloves
AddItem(m2f, f2m, 16139, 16144); // Makai Priest's Slops <-> Makai Priestess's Skirt
AddItem(m2f, f2m, 16140, 16145); // Makai Priest's Boots <-> Makai Priestess's Longboots
AddItem(m2f, f2m, 16588, 16592); // Far Eastern Gentleman's Hat <-> Far Eastern Beauty's Hairpin
AddItem(m2f, f2m, 16589, 16593); // Far Eastern Gentleman's Robe <-> Far Eastern Beauty's Robe
AddItem(m2f, f2m, 16590, 16594); // Far Eastern Gentleman's Haidate <-> Far Eastern Beauty's Koshita
AddItem(m2f, f2m, 16591, 16595); // Far Eastern Gentleman's Boots <-> Far Eastern Beauty's Boots
AddItem(m2f, f2m, 17204, 17209); // Common Makai Mauler's Facemask <-> Common Makai Manhandler's Facemask
AddItem(m2f, f2m, 17205, 17210); // Common Makai Mauler's Oilskin <-> Common Makai Manhandler's Jerkin
AddItem(m2f, f2m, 17206, 17211); // Common Makai Mauler's Fingerless Gloves <-> Common Makai Manhandler's Fingerless Glove
AddItem(m2f, f2m, 17207, 17212); // Common Makai Mauler's Leggings <-> Common Makai Manhandler's Quartertights
AddItem(m2f, f2m, 17208, 17213); // Common Makai Mauler's Boots <-> Common Makai Manhandler's Longboots
AddItem(m2f, f2m, 17214, 17219); // Common Makai Marksman's Eyepatch <-> Common Makai Markswoman's Ribbon
AddItem(m2f, f2m, 17215, 17220); // Common Makai Marksman's Battlegarb <-> Common Makai Markswoman's Battledress
AddItem(m2f, f2m, 17216, 17221); // Common Makai Marksman's Fingerless Gloves <-> Common Makai Markswoman's Fingerless Glove
AddItem(m2f, f2m, 17217, 17222); // Common Makai Marksman's Slops <-> Common Makai Markswoman's Quartertights
AddItem(m2f, f2m, 17218, 17223); // Common Makai Marksman's Boots <-> Common Makai Markswoman's Longboots
AddItem(m2f, f2m, 17224, 17229); // Common Makai Sun Guide's Circlet <-> Common Makai Moon Guide's Circlet
AddItem(m2f, f2m, 17225, 17230); // Common Makai Sun Guide's Oilskin <-> Common Makai Moon Guide's Gown
AddItem(m2f, f2m, 17226, 17231); // Common Makai Sun Guide's Fingerless Gloves <-> Common Makai Moon Guide's Fingerless Glove
AddItem(m2f, f2m, 17227, 17232); // Common Makai Sun Guide's Slops <-> Common Makai Moon Guide's Quartertights
AddItem(m2f, f2m, 17228, 17233); // Common Makai Sun Guide's Boots <-> Common Makai Moon Guide's Longboots
AddItem(m2f, f2m, 17234, 17239); // Common Makai Priest's Coronet <-> Common Makai Priestess's Headdress
AddItem(m2f, f2m, 17235, 17240); // Common Makai Priest's Doublet Robe <-> Common Makai Priestess's Jerkin
AddItem(m2f, f2m, 17236, 17241); // Common Makai Priest's Fingerless Gloves <-> Common Makai Priestess's Fingerless Gloves
AddItem(m2f, f2m, 17237, 17242); // Common Makai Priest's Slops <-> Common Makai Priestess's Skirt
AddItem(m2f, f2m, 17238, 17243); // Common Makai Priest's Boots <-> Common Makai Priestess's Longboots
AddItem(m2f, f2m, 20479, 20484); // Star of the Nezha Lord <-> Star of the Nezha Lady
AddItem(m2f, f2m, 20480, 20485); // Nezha Lord's Togi <-> Nezha Lady's Togi
AddItem(m2f, f2m, 20481, 20486); // Nezha Lord's Gloves <-> Nezha Lady's Gloves
AddItem(m2f, f2m, 20482, 20487); // Nezha Lord's Slops <-> Nezha Lady's Slops
AddItem(m2f, f2m, 20483, 20488); // Nezha Lord's Boots <-> Nezha Lady's Kneeboots
AddItem(m2f, f2m, 22367, 22372); // Faerie Tale Prince's Circlet <-> Faerie Tale Princess's Tiara
AddItem(m2f, f2m, 22368, 22373); // Faerie Tale Prince's Vest <-> Faerie Tale Princess's Dress
AddItem(m2f, f2m, 22369, 22374); // Faerie Tale Prince's Gloves <-> Faerie Tale Princess's Gloves
AddItem(m2f, f2m, 22370, 22375); // Faerie Tale Prince's Slops <-> Faerie Tale Princess's Long Skirt
AddItem(m2f, f2m, 22371, 22376); // Faerie Tale Prince's Boots <-> Faerie Tale Princess's Heels
AddItem(m2f, f2m, 24599, 24602); // Far Eastern Schoolboy's Hat <-> Far Eastern Schoolgirl's Hair Ribbon
AddItem(m2f, f2m, 24600, 24603); // Far Eastern Schoolboy's Hakama <-> Far Eastern Schoolgirl's Hakama
AddItem(m2f, f2m, 24601, 24604); // Far Eastern Schoolboy's Zori <-> Far Eastern Schoolgirl's Boots
AddItem(m2f, f2m, 28600, 28605); // Eastern Lord Errant's Hat <-> Eastern Lady Errant's Hat
AddItem(m2f, f2m, 28601, 28606); // Eastern Lord Errant's Jacket <-> Eastern Lady Errant's Coat
AddItem(m2f, f2m, 28602, 28607); // Eastern Lord Errant's Wristbands <-> Eastern Lady Errant's Gloves
AddItem(m2f, f2m, 28603, 28608); // Eastern Lord Errant's Trousers <-> Eastern Lady Errant's Skirt
AddItem(m2f, f2m, 28604, 28609); // Eastern Lord Errant's Shoes <-> Eastern Lady Errant's Boots
AddItem(m2f, f2m, 36336, 36337); // Omega-M Attire <-> Omega-F Attire
AddItem(m2f, f2m, 36338, 36339); // Omega-M Ear Cuffs <-> Omega-F Earrings
AddItem(m2f, f2m, 37442, 37447); // Makai Vanguard's Monocle <-> Makai Vanbreaker's Ribbon
AddItem(m2f, f2m, 37443, 37448); // Makai Vanguard's Battlegarb <-> Makai Vanbreaker's Battledress
AddItem(m2f, f2m, 37444, 37449); // Makai Vanguard's Fingerless Gloves <-> Makai Vanbreaker's Fingerless Gloves
AddItem(m2f, f2m, 37445, 37450); // Makai Vanguard's Leggings <-> Makai Vanbreaker's Quartertights
AddItem(m2f, f2m, 37446, 37451); // Makai Vanguard's Boots <-> Makai Vanbreaker's Longboots
AddItem(m2f, f2m, 37452, 37457); // Makai Harbinger's Facemask <-> Makai Harrower's Facemask
AddItem(m2f, f2m, 37453, 37458); // Makai Harbinger's Battlegarb <-> Makai Harrower's Jerkin
AddItem(m2f, f2m, 37454, 37459); // Makai Harbinger's Fingerless Gloves <-> Makai Harrower's Fingerless Gloves
AddItem(m2f, f2m, 37455, 37460); // Makai Harbinger's Leggings <-> Makai Harrower's Quartertights
AddItem(m2f, f2m, 37456, 37461); // Makai Harbinger's Boots <-> Makai Harrower's Longboots
AddItem(m2f, f2m, 37462, 37467); // Common Makai Vanguard's Monocle <-> Common Makai Vanbreaker's Ribbon
AddItem(m2f, f2m, 37463, 37468); // Common Makai Vanguard's Battlegarb <-> Common Makai Vanbreaker's Battledress
AddItem(m2f, f2m, 37464, 37469); // Common Makai Vanguard's Fingerless Gloves <-> Common Makai Vanbreaker's Fingerless Gloves
AddItem(m2f, f2m, 37465, 37470); // Common Makai Vanguard's Leggings <-> Common Makai Vanbreaker's Quartertights
AddItem(m2f, f2m, 37466, 37471); // Common Makai Vanguard's Boots <-> Common Makai Vanbreaker's Longboots
AddItem(m2f, f2m, 37472, 37477); // Common Makai Harbinger's Facemask <-> Common Makai Harrower's Facemask
AddItem(m2f, f2m, 37473, 37478); // Common Makai Harbinger's Battlegarb <-> Common Makai Harrower's Jerkin
AddItem(m2f, f2m, 37474, 37479); // Common Makai Harbinger's Fingerless Gloves <-> Common Makai Harrower's Fingerless Gloves
AddItem(m2f, f2m, 37475, 37480); // Common Makai Harbinger's Leggings <-> Common Makai Harrower's Quartertights
AddItem(m2f, f2m, 37476, 37481); // Common Makai Harbinger's Boots <-> Common Makai Harrower's Longboots
AddItem(m2f, f2m, 13323, 13322); // Scion Thief's Tunic <-> Scion Conjurer's Dalmatica
AddItem(m2f, f2m, 13693, 10034, true, false); // Scion Thief's Halfgloves -> The Emperor's New Gloves
AddItem(m2f, f2m, 13694, 13691); // Scion Thief's Gaskins <-> Scion Conjurer's Chausses
AddItem(m2f, f2m, 13695, 13692); // Scion Thief's Armored Caligae <-> Scion Conjurer's Pattens
AddItem(m2f, f2m, 13326, 30063); // Scion Thaumaturge's Robe <-> Scion Sorceress's Headdress
AddItem(m2f, f2m, 13696, 30062); // Scion Thaumaturge's Monocle <-> Scion Sorceress's Robe
AddItem(m2f, f2m, 13697, 30064); // Scion Thaumaturge's Gauntlets <-> Scion Sorceress's Shadowtalons
AddItem(m2f, f2m, 13698, 10035, true, false); // Scion Thaumaturge's Gaskins -> The Emperor's New Breeches
AddItem(m2f, f2m, 13699, 30065); // Scion Thaumaturge's Moccasins <-> Scion Sorceress's High Boots
AddItem(m2f, f2m, 13327, 15942); // Scion Chronocler's Cowl <-> Scion Healer's Robe
AddItem(m2f, f2m, 13700, 10034, true, false); // Scion Chronocler's Ringbands -> The Emperor's New Gloves
AddItem(m2f, f2m, 13701, 15943); // Scion Chronocler's Tights <-> Scion Healer's Halftights
AddItem(m2f, f2m, 13702, 15944); // Scion Chronocler's Caligae <-> Scion Healer's Highboots
AddItem(m2f, f2m, 14861, 13324); // Head Engineer's Goggles <-> Scion Striker's Visor
AddItem(m2f, f2m, 14862, 13325); // Head Engineer's Attire <-> Scion Striker's Attire
AddItem(m2f, f2m, 15938, 33751); // Scion Rogue's Jacket <-> Oracle Top
AddItem(m2f, f2m, 15939, 10034, true, false); // Scion Rogue's Armguards -> The Emperor's New Gloves
AddItem(m2f, f2m, 15940, 33752); // Scion Rogue's Gaskins <-> Oracle Leggings
AddItem(m2f, f2m, 15941, 33753); // Scion Rogue's Boots <-> Oracle Pantalettes
AddItem(m2f, f2m, 16042, 16046); // Abes Jacket <-> High Summoner's Dress
AddItem(m2f, f2m, 16043, 16047); // Abes Gloves <-> High Summoner's Armlets
AddItem(m2f, f2m, 16044, 10035, true, false); // Abes Halfslops -> The Emperor's New Breeches
AddItem(m2f, f2m, 16045, 16048); // Abes Boots <-> High Summoner's Boots
AddItem(m2f, f2m, 17473, 28553); // Lord Commander's Coat <-> Majestic Dress
AddItem(m2f, f2m, 17474, 28554); // Lord Commander's Gloves <-> Majestic Wristdresses
AddItem(m2f, f2m, 10036, 28555, false); // Emperor's New Boots <- Majestic Boots
AddItem(m2f, f2m, 21021, 21026); // Werewolf Feet <-> Werewolf Legs
AddItem(m2f, f2m, 22452, 20633); // Cracked Manderville Monocle <-> Blackbosom Hat
AddItem(m2f, f2m, 22453, 20634); // Torn Manderville Coatee <-> Blackbosom Dress
AddItem(m2f, f2m, 22454, 20635); // Singed Manderville Gloves <-> Blackbosom Dress Gloves
AddItem(m2f, f2m, 22455, 10035, true, false); // Stained Manderville Bottoms -> The Emperor's New Breeches
AddItem(m2f, f2m, 22456, 20636); // Scuffed Manderville Gaiters <-> lackbosom Boots
AddItem(m2f, f2m, 23013, 21302); // Doman Liege's Dogi <-> Scion Liberator's Jacket
AddItem(m2f, f2m, 23014, 21303); // Doman Liege's Kote <-> Scion Liberator's Fingerless Gloves
AddItem(m2f, f2m, 23015, 21304); // Doman Liege's Kyakui <-> Scion Liberator's Pantalettes
AddItem(m2f, f2m, 23016, 21305); // Doman Liege's Kyahan <-> Scion Liberator's Sabatons
AddItem(m2f, f2m, 09293, 21306, false); // The Emperor's New Earrings <- Scion Liberator's Earrings
AddItem(m2f, f2m, 24158, 23008, true, false); // Leal Samurai's Kasa -> Eastern Socialite's Hat
AddItem(m2f, f2m, 24159, 23009, true, false); // Leal Samurai's Dogi -> Eastern Socialite's Cheongsam
AddItem(m2f, f2m, 24160, 23010, true, false); // Leal Samurai's Tekko -> Eastern Socialite's Gloves
AddItem(m2f, f2m, 24161, 23011, true, false); // Leal Samurai's Tsutsu-hakama -> Eastern Socialite's Skirt
AddItem(m2f, f2m, 24162, 23012, true, false); // Leal Samurai's Geta -> Eastern Socialite's Boots
AddItem(m2f, f2m, 02966, 13321, false); // Reindeer Suit <- Antecedent's Attire
AddItem(m2f, f2m, 15479, 36843, false); // Swine Body <- Lyse's Leadership Attire
AddItem(m2f, f2m, 21941, 24999, false); // Ala Mhigan Gown <- Gown of Light
AddItem(m2f, f2m, 30757, 25000, false); // Southern Seas Skirt <- Skirt of Light
AddItem(m2f, f2m, 36821, 27933, false); // Archfiend Helm <- Scion Hearer's Hood
AddItem(m2f, f2m, 36822, 27934, false); // Archfiend Armor <- Scion Hearer's Coat
AddItem(m2f, f2m, 36825, 27935, false); // Archfiend Sabatons <- Scion Hearer's Shoes
AddItem(m2f, f2m, 32393, 39302, false); // Edenmete Gown of Casting <- Gaia's Attire
}
// The racial starter sets are available for all 4 slots each,
// but have no associated accessories or hats.
private static readonly uint[] RaceGenderGroup =
{
0x020054,
0x020055,
0x020056,
0x020057,
0x02005C,
0x02005D,
0x020058,
0x020059,
0x02005A,
0x02005B,
0x020101,
0x020102,
0x010255,
uint.MaxValue, // TODO: Female Hrothgar
0x0102E8,
0x010245,
};
// @Formatter:on
}

View file

@ -1,70 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Dalamud;
using Dalamud.Data;
using Dalamud.Plugin;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData.Data;
public sealed class StainData : DataSharer, IReadOnlyDictionary<StainId, Stain>
{
public readonly IReadOnlyDictionary<byte, (string Name, uint Dye, bool Gloss)> Data;
public StainData(DalamudPluginInterface pluginInterface, DataManager dataManager, ClientLanguage language)
: base(pluginInterface, language, 1)
{
Data = TryCatchData("Stains", () => CreateStainData(dataManager));
}
protected override void DisposeInternal()
=> DisposeTag("Stains");
private IReadOnlyDictionary<byte, (string Name, uint Dye, bool Gloss)> CreateStainData(DataManager dataManager)
{
var stainSheet = dataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Stain>(Language)!;
return stainSheet.Where(s => s.Color != 0 && s.Name.RawData.Length > 0)
.ToDictionary(s => (byte)s.RowId, s =>
{
var stain = new Stain(s);
return (stain.Name, stain.RgbaColor, stain.Gloss);
});
}
public IEnumerator<KeyValuePair<StainId, Stain>> GetEnumerator()
=> Data.Select(kvp
=> new KeyValuePair<StainId, Stain>(new StainId(kvp.Key), new Stain(kvp.Value.Name, kvp.Value.Dye, kvp.Key, kvp.Value.Gloss)))
.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
public int Count
=> Data.Count;
public bool ContainsKey(StainId key)
=> Data.ContainsKey(key.Value);
public bool TryGetValue(StainId key, out Stain value)
{
if (!Data.TryGetValue(key.Value, out var data))
{
value = default;
return false;
}
value = new Stain(data.Name, data.Dye, key.Value, data.Gloss);
return true;
}
public Stain this[StainId key]
=> TryGetValue(key, out var data) ? data : throw new ArgumentOutOfRangeException(nameof(key));
public IEnumerable<StainId> Keys
=> Data.Keys.Select(k => new StainId(k));
public IEnumerable<Stain> Values
=> Data.Select(kvp => new Stain(kvp.Value.Name, kvp.Value.Dye, kvp.Key, kvp.Value.Gloss));
}

View file

@ -1,68 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Dalamud;
using Dalamud.Data;
using Dalamud.Plugin;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using PseudoEquipItem = System.ValueTuple<string, uint, ushort, ushort, ushort, byte, byte>;
namespace Penumbra.GameData.Data;
internal sealed class WeaponIdentificationList : KeyList<PseudoEquipItem>
{
private const string Tag = "WeaponIdentification";
private const int Version = 1;
public WeaponIdentificationList(DalamudPluginInterface pi, ClientLanguage language, DataManager gameData)
: base(pi, Tag, language, Version, CreateWeaponList(gameData, language))
{ }
public IEnumerable<EquipItem> Between(SetId modelId)
=> Between(ToKey(modelId, 0, 0), ToKey(modelId, 0xFFFF, 0xFF)).Select(e => (EquipItem)e);
public IEnumerable<EquipItem> Between(SetId modelId, WeaponType type, byte variant = 0)
{
if (type == 0)
return Between(ToKey(modelId, 0, 0), ToKey(modelId, 0xFFFF, 0xFF)).Select(e => (EquipItem)e);
if (variant == 0)
return Between(ToKey(modelId, type, 0), ToKey(modelId, type, 0xFF)).Select(e => (EquipItem)e);
return Between(ToKey(modelId, type, variant), ToKey(modelId, type, variant)).Select(e => (EquipItem)e);
}
public void Dispose(DalamudPluginInterface pi, ClientLanguage language)
=> DataSharer.DisposeTag(pi, Tag, language, Version);
public static ulong ToKey(SetId modelId, WeaponType type, byte variant)
=> ((ulong)modelId << 32) | ((ulong)type << 16) | variant;
public static ulong ToKey(EquipItem i)
=> ToKey(i.ModelId, i.WeaponType, i.Variant);
protected override IEnumerable<ulong> ToKeys(PseudoEquipItem data)
{
yield return ToKey(data);
}
protected override bool ValidKey(ulong key)
=> key != 0;
protected override int ValueKeySelector(PseudoEquipItem data)
=> (int)data.Item2;
private static IEnumerable<PseudoEquipItem> CreateWeaponList(DataManager gameData, ClientLanguage language)
=> gameData.GetExcelSheet<Item>(language)!.SelectMany(ToEquipItems);
private static IEnumerable<PseudoEquipItem> ToEquipItems(Item item)
{
if ((EquipSlot)item.EquipSlotCategory.Row is not (EquipSlot.MainHand or EquipSlot.OffHand or EquipSlot.BothHand))
yield break;
if (item.ModelMain != 0)
yield return (PseudoEquipItem)EquipItem.FromMainhand(item);
if (item.ModelSub != 0)
yield return (PseudoEquipItem)EquipItem.FromOffhand(item);
}
}

View file

@ -1,63 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace Penumbra.GameData.Enums;
public enum BodySlot : byte
{
Unknown,
Hair,
Face,
Tail,
Body,
Zear,
}
public static class BodySlotEnumExtension
{
public static string ToSuffix( this BodySlot value )
=> value switch
{
BodySlot.Zear => "zear",
BodySlot.Face => "face",
BodySlot.Hair => "hair",
BodySlot.Body => "body",
BodySlot.Tail => "tail",
_ => throw new InvalidEnumArgumentException(),
};
public static char ToAbbreviation(this BodySlot value)
=> value switch
{
BodySlot.Hair => 'h',
BodySlot.Face => 'f',
BodySlot.Tail => 't',
BodySlot.Body => 'b',
BodySlot.Zear => 'z',
_ => throw new InvalidEnumArgumentException(),
};
public static CustomizationType ToCustomizationType(this BodySlot value)
=> value switch
{
BodySlot.Hair => CustomizationType.Hair,
BodySlot.Face => CustomizationType.Face,
BodySlot.Tail => CustomizationType.Tail,
BodySlot.Body => CustomizationType.Body,
BodySlot.Zear => CustomizationType.Zear,
_ => throw new ArgumentOutOfRangeException(nameof(value), value, null)
};
}
public static partial class Names
{
public static readonly Dictionary< string, BodySlot > StringToBodySlot = new()
{
{ BodySlot.Zear.ToSuffix(), BodySlot.Zear },
{ BodySlot.Face.ToSuffix(), BodySlot.Face },
{ BodySlot.Hair.ToSuffix(), BodySlot.Hair },
{ BodySlot.Body.ToSuffix(), BodySlot.Body },
{ BodySlot.Tail.ToSuffix(), BodySlot.Tail },
};
}

View file

@ -1,33 +0,0 @@
using System;
using Dalamud.Data;
using Lumina.Excel.GeneratedSheets;
using Penumbra.Api.Enums;
using Action = Lumina.Excel.GeneratedSheets.Action;
namespace Penumbra.GameData.Enums;
public static class ChangedItemExtensions
{
public static (ChangedItemType, uint) ChangedItemToTypeAndId(object? item)
{
return item switch
{
null => (ChangedItemType.None, 0),
Item i => (ChangedItemType.Item, i.RowId),
Action a => (ChangedItemType.Action, a.RowId),
_ => (ChangedItemType.Customization, 0),
};
}
public static object? GetObject(this ChangedItemType type, DataManager manager, uint id)
{
return type switch
{
ChangedItemType.None => null,
ChangedItemType.Item => manager.GetExcelSheet<Item>()?.GetRow(id),
ChangedItemType.Action => manager.GetExcelSheet<Action>()?.GetRow(id),
ChangedItemType.Customization => null,
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null),
};
}
}

View file

@ -1,55 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel;
namespace Penumbra.GameData.Enums
{
public enum CustomizationType : byte
{
Unknown,
Body,
Tail,
Face,
Iris,
Accessory,
Hair,
Zear,
DecalFace,
DecalEquip,
Skin,
Etc,
}
public static class CustomizationTypeEnumExtension
{
public static string ToSuffix( this CustomizationType value )
{
return value switch
{
CustomizationType.Body => "top",
CustomizationType.Face => "fac",
CustomizationType.Iris => "iri",
CustomizationType.Accessory => "acc",
CustomizationType.Hair => "hir",
CustomizationType.Tail => "til",
CustomizationType.Zear => "zer",
CustomizationType.Etc => "etc",
_ => throw new InvalidEnumArgumentException(),
};
}
}
public static partial class Names
{
public static readonly Dictionary< string, CustomizationType > SuffixToCustomizationType = new()
{
{ CustomizationType.Body.ToSuffix(), CustomizationType.Body },
{ CustomizationType.Face.ToSuffix(), CustomizationType.Face },
{ CustomizationType.Iris.ToSuffix(), CustomizationType.Iris },
{ CustomizationType.Accessory.ToSuffix(), CustomizationType.Accessory },
{ CustomizationType.Hair.ToSuffix(), CustomizationType.Hair },
{ CustomizationType.Tail.ToSuffix(), CustomizationType.Tail },
{ CustomizationType.Zear.ToSuffix(), CustomizationType.Zear },
{ CustomizationType.Etc.ToSuffix(), CustomizationType.Etc },
};
}
}

View file

@ -1,224 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Penumbra.GameData.Enums;
public enum EquipSlot : byte
{
Unknown = 0,
MainHand = 1,
OffHand = 2,
Head = 3,
Body = 4,
Hands = 5,
Belt = 6,
Legs = 7,
Feet = 8,
Ears = 9,
Neck = 10,
Wrists = 11,
RFinger = 12,
BothHand = 13,
LFinger = 14, // Not officially existing, means "weapon could be equipped in either hand" for the game.
HeadBody = 15,
BodyHandsLegsFeet = 16,
SoulCrystal = 17,
LegsFeet = 18,
FullBody = 19,
BodyHands = 20,
BodyLegsFeet = 21,
ChestHands = 22,
Nothing = 23,
All = 24, // Not officially existing
}
public static class EquipSlotExtensions
{
public static EquipSlot ToEquipSlot(this uint value)
=> value switch
{
0 => EquipSlot.Head,
1 => EquipSlot.Body,
2 => EquipSlot.Hands,
3 => EquipSlot.Legs,
4 => EquipSlot.Feet,
5 => EquipSlot.Ears,
6 => EquipSlot.Neck,
7 => EquipSlot.Wrists,
8 => EquipSlot.RFinger,
9 => EquipSlot.LFinger,
10 => EquipSlot.MainHand,
11 => EquipSlot.OffHand,
_ => EquipSlot.Unknown,
};
public static uint ToIndex(this EquipSlot slot)
=> slot switch
{
EquipSlot.Head => 0,
EquipSlot.Body => 1,
EquipSlot.Hands => 2,
EquipSlot.Legs => 3,
EquipSlot.Feet => 4,
EquipSlot.Ears => 5,
EquipSlot.Neck => 6,
EquipSlot.Wrists => 7,
EquipSlot.RFinger => 8,
EquipSlot.LFinger => 9,
EquipSlot.MainHand => 10,
EquipSlot.OffHand => 11,
_ => uint.MaxValue,
};
public static string ToSuffix(this EquipSlot value)
{
return value switch
{
EquipSlot.Head => "met",
EquipSlot.Hands => "glv",
EquipSlot.Legs => "dwn",
EquipSlot.Feet => "sho",
EquipSlot.Body => "top",
EquipSlot.Ears => "ear",
EquipSlot.Neck => "nek",
EquipSlot.RFinger => "rir",
EquipSlot.LFinger => "ril",
EquipSlot.Wrists => "wrs",
_ => "unk",
};
}
public static EquipSlot ToSlot(this EquipSlot value)
{
return value switch
{
EquipSlot.MainHand => EquipSlot.MainHand,
EquipSlot.OffHand => EquipSlot.OffHand,
EquipSlot.Head => EquipSlot.Head,
EquipSlot.Body => EquipSlot.Body,
EquipSlot.Hands => EquipSlot.Hands,
EquipSlot.Belt => EquipSlot.Belt,
EquipSlot.Legs => EquipSlot.Legs,
EquipSlot.Feet => EquipSlot.Feet,
EquipSlot.Ears => EquipSlot.Ears,
EquipSlot.Neck => EquipSlot.Neck,
EquipSlot.Wrists => EquipSlot.Wrists,
EquipSlot.RFinger => EquipSlot.RFinger,
EquipSlot.BothHand => EquipSlot.MainHand,
EquipSlot.LFinger => EquipSlot.RFinger,
EquipSlot.HeadBody => EquipSlot.Body,
EquipSlot.BodyHandsLegsFeet => EquipSlot.Body,
EquipSlot.SoulCrystal => EquipSlot.SoulCrystal,
EquipSlot.LegsFeet => EquipSlot.Legs,
EquipSlot.FullBody => EquipSlot.Body,
EquipSlot.BodyHands => EquipSlot.Body,
EquipSlot.BodyLegsFeet => EquipSlot.Body,
EquipSlot.ChestHands => EquipSlot.Body,
_ => EquipSlot.Unknown,
};
}
public static string ToName(this EquipSlot value)
{
return value switch
{
EquipSlot.Head => "Head",
EquipSlot.Hands => "Hands",
EquipSlot.Legs => "Legs",
EquipSlot.Feet => "Feet",
EquipSlot.Body => "Body",
EquipSlot.Ears => "Earrings",
EquipSlot.Neck => "Necklace",
EquipSlot.RFinger => "Right Ring",
EquipSlot.LFinger => "Left Ring",
EquipSlot.Wrists => "Bracelets",
EquipSlot.MainHand => "Primary Weapon",
EquipSlot.OffHand => "Secondary Weapon",
EquipSlot.Belt => "Belt",
EquipSlot.BothHand => "Primary Weapon",
EquipSlot.HeadBody => "Head and Body",
EquipSlot.BodyHandsLegsFeet => "Costume",
EquipSlot.SoulCrystal => "Soul Crystal",
EquipSlot.LegsFeet => "Bottom",
EquipSlot.FullBody => "Costume",
EquipSlot.BodyHands => "Top",
EquipSlot.BodyLegsFeet => "Costume",
EquipSlot.All => "Costume",
_ => "Unknown",
};
}
public static bool IsEquipment(this EquipSlot value)
{
return value switch
{
EquipSlot.Head => true,
EquipSlot.Hands => true,
EquipSlot.Legs => true,
EquipSlot.Feet => true,
EquipSlot.Body => true,
_ => false,
};
}
public static bool IsAccessory(this EquipSlot value)
{
return value switch
{
EquipSlot.Ears => true,
EquipSlot.Neck => true,
EquipSlot.RFinger => true,
EquipSlot.LFinger => true,
EquipSlot.Wrists => true,
_ => false,
};
}
public static bool IsEquipmentPiece(this EquipSlot value)
{
return value switch
{
// Accessories
EquipSlot.RFinger => true,
EquipSlot.Wrists => true,
EquipSlot.Ears => true,
EquipSlot.Neck => true,
// Equipment
EquipSlot.Head => true,
EquipSlot.Body => true,
EquipSlot.Hands => true,
EquipSlot.Legs => true,
EquipSlot.Feet => true,
EquipSlot.BodyHands => true,
EquipSlot.BodyHandsLegsFeet => true,
EquipSlot.BodyLegsFeet => true,
EquipSlot.FullBody => true,
EquipSlot.HeadBody => true,
EquipSlot.LegsFeet => true,
EquipSlot.ChestHands => true,
_ => false,
};
}
public static readonly EquipSlot[] EquipmentSlots = Enum.GetValues<EquipSlot>().Where(e => e.IsEquipment()).ToArray();
public static readonly EquipSlot[] AccessorySlots = Enum.GetValues<EquipSlot>().Where(e => e.IsAccessory()).ToArray();
public static readonly EquipSlot[] EqdpSlots = EquipmentSlots.Concat(AccessorySlots).ToArray();
}
public static partial class Names
{
public static readonly Dictionary<string, EquipSlot> SuffixToEquipSlot = new()
{
{ EquipSlot.Head.ToSuffix(), EquipSlot.Head },
{ EquipSlot.Hands.ToSuffix(), EquipSlot.Hands },
{ EquipSlot.Legs.ToSuffix(), EquipSlot.Legs },
{ EquipSlot.Feet.ToSuffix(), EquipSlot.Feet },
{ EquipSlot.Body.ToSuffix(), EquipSlot.Body },
{ EquipSlot.Ears.ToSuffix(), EquipSlot.Ears },
{ EquipSlot.Neck.ToSuffix(), EquipSlot.Neck },
{ EquipSlot.RFinger.ToSuffix(), EquipSlot.RFinger },
{ EquipSlot.LFinger.ToSuffix(), EquipSlot.LFinger },
{ EquipSlot.Wrists.ToSuffix(), EquipSlot.Wrists },
};
}

View file

@ -1,44 +0,0 @@
using System.Collections.Generic;
namespace Penumbra.GameData.Enums;
public enum FileType : byte
{
Unknown,
Sound,
Imc,
Vfx,
Animation,
Pap,
MetaInfo,
Material,
Texture,
Model,
Shader,
Font,
Environment,
}
public static partial class Names
{
public static readonly Dictionary< string, FileType > ExtensionToFileType = new()
{
{ ".mdl", FileType.Model },
{ ".tex", FileType.Texture },
{ ".mtrl", FileType.Material },
{ ".atex", FileType.Animation },
{ ".avfx", FileType.Vfx },
{ ".scd", FileType.Sound },
{ ".imc", FileType.Imc },
{ ".pap", FileType.Pap },
{ ".eqp", FileType.MetaInfo },
{ ".eqdp", FileType.MetaInfo },
{ ".est", FileType.MetaInfo },
{ ".exd", FileType.MetaInfo },
{ ".exh", FileType.MetaInfo },
{ ".shpk", FileType.Shader },
{ ".shcd", FileType.Shader },
{ ".fdt", FileType.Font },
{ ".envb", FileType.Environment },
};
}

View file

@ -1,420 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Lumina.Excel.GeneratedSheets;
namespace Penumbra.GameData.Enums;
public enum FullEquipType : byte
{
Unknown,
Head,
Body,
Hands,
Legs,
Feet,
Ears,
Neck,
Wrists,
Finger,
Fists, // PGL, MNK
FistsOff,
Sword, // GLA, PLD Main
Axe, // MRD, WAR
Bow, // ARC, BRD
BowOff,
Lance, // LNC, DRG,
Staff, // THM, BLM, CNJ, WHM
Wand, // THM, BLM, CNJ, WHM Main
Book, // ACN, SMN, SCH
Daggers, // ROG, NIN
DaggersOff,
Broadsword, // DRK,
Gun, // MCH,
GunOff,
Orrery, // AST,
OrreryOff,
Katana, // SAM
KatanaOff,
Rapier, // RDM
RapierOff,
Cane, // BLU
Gunblade, // GNB,
Glaives, // DNC,
GlaivesOff,
Scythe, // RPR,
Nouliths, // SGE
Shield, // GLA, PLD, THM, BLM, CNJ, WHM Off
Saw, // CRP
CrossPeinHammer, // BSM
RaisingHammer, // ARM
LapidaryHammer, // GSM
Knife, // LTW
Needle, // WVR
Alembic, // ALC
Frypan, // CUL
Pickaxe, // MIN
Hatchet, // BTN
FishingRod, // FSH
ClawHammer, // CRP Off
File, // BSM Off
Pliers, // ARM Off
GrindingWheel, // GSM Off
Awl, // LTW Off
SpinningWheel, // WVR Off
Mortar, // ALC Off
CulinaryKnife, // CUL Off
Sledgehammer, // MIN Off
GardenScythe, // BTN Off
Gig, // FSH Off
}
public static class FullEquipTypeExtensions
{
internal static FullEquipType ToEquipType(this Item item)
{
var slot = (EquipSlot)item.EquipSlotCategory.Row;
var weapon = (WeaponCategory)item.ItemUICategory.Row;
return slot.ToEquipType(weapon);
}
public static bool IsWeapon(this FullEquipType type)
=> type switch
{
FullEquipType.Fists => true,
FullEquipType.Sword => true,
FullEquipType.Axe => true,
FullEquipType.Bow => true,
FullEquipType.Lance => true,
FullEquipType.Staff => true,
FullEquipType.Wand => true,
FullEquipType.Book => true,
FullEquipType.Daggers => true,
FullEquipType.Broadsword => true,
FullEquipType.Gun => true,
FullEquipType.Orrery => true,
FullEquipType.Katana => true,
FullEquipType.Rapier => true,
FullEquipType.Cane => true,
FullEquipType.Gunblade => true,
FullEquipType.Glaives => true,
FullEquipType.Scythe => true,
FullEquipType.Nouliths => true,
FullEquipType.Shield => true,
_ => false,
};
public static bool IsTool(this FullEquipType type)
=> type switch
{
FullEquipType.Saw => true,
FullEquipType.CrossPeinHammer => true,
FullEquipType.RaisingHammer => true,
FullEquipType.LapidaryHammer => true,
FullEquipType.Knife => true,
FullEquipType.Needle => true,
FullEquipType.Alembic => true,
FullEquipType.Frypan => true,
FullEquipType.Pickaxe => true,
FullEquipType.Hatchet => true,
FullEquipType.FishingRod => true,
_ => false,
};
public static bool IsEquipment(this FullEquipType type)
=> type switch
{
FullEquipType.Head => true,
FullEquipType.Body => true,
FullEquipType.Hands => true,
FullEquipType.Legs => true,
FullEquipType.Feet => true,
_ => false,
};
public static bool IsAccessory(this FullEquipType type)
=> type switch
{
FullEquipType.Ears => true,
FullEquipType.Neck => true,
FullEquipType.Wrists => true,
FullEquipType.Finger => true,
_ => false,
};
public static string ToName(this FullEquipType type)
=> type switch
{
FullEquipType.Head => EquipSlot.Head.ToName(),
FullEquipType.Body => EquipSlot.Body.ToName(),
FullEquipType.Hands => EquipSlot.Hands.ToName(),
FullEquipType.Legs => EquipSlot.Legs.ToName(),
FullEquipType.Feet => EquipSlot.Feet.ToName(),
FullEquipType.Ears => EquipSlot.Ears.ToName(),
FullEquipType.Neck => EquipSlot.Neck.ToName(),
FullEquipType.Wrists => EquipSlot.Wrists.ToName(),
FullEquipType.Finger => "Ring",
FullEquipType.Fists => "Fist Weapon",
FullEquipType.FistsOff => "Fist Weapon (Offhand)",
FullEquipType.Sword => "Sword",
FullEquipType.Axe => "Axe",
FullEquipType.Bow => "Bow",
FullEquipType.BowOff => "Quiver",
FullEquipType.Lance => "Lance",
FullEquipType.Staff => "Staff",
FullEquipType.Wand => "Mace",
FullEquipType.Book => "Book",
FullEquipType.Daggers => "Dagger",
FullEquipType.DaggersOff => "Dagger (Offhand)",
FullEquipType.Broadsword => "Broadsword",
FullEquipType.Gun => "Gun",
FullEquipType.GunOff => "Aetherotransformer",
FullEquipType.Orrery => "Orrery",
FullEquipType.OrreryOff => "Card Holder",
FullEquipType.Katana => "Katana",
FullEquipType.KatanaOff => "Sheathe",
FullEquipType.Rapier => "Rapier",
FullEquipType.RapierOff => "Focus",
FullEquipType.Cane => "Cane",
FullEquipType.Gunblade => "Gunblade",
FullEquipType.Glaives => "Glaive",
FullEquipType.GlaivesOff => "Glaive (Offhand)",
FullEquipType.Scythe => "Scythe",
FullEquipType.Nouliths => "Nouliths",
FullEquipType.Shield => "Shield",
FullEquipType.Saw => "Saw (Carpenter)",
FullEquipType.CrossPeinHammer => "Hammer (Blacksmith)",
FullEquipType.RaisingHammer => "Hammer (Armorsmith)",
FullEquipType.LapidaryHammer => "Hammer (Goldsmith)",
FullEquipType.Knife => "Knife (Leatherworker)",
FullEquipType.Needle => "Needle (Weaver)",
FullEquipType.Alembic => "Alembic (Alchemist)",
FullEquipType.Frypan => "Frypan (Culinarian)",
FullEquipType.Pickaxe => "Pickaxe (Miner)",
FullEquipType.Hatchet => "Hatchet (Botanist)",
FullEquipType.FishingRod => "Fishing Rod",
FullEquipType.ClawHammer => "Clawhammer (Carpenter)",
FullEquipType.File => "File (Blacksmith)",
FullEquipType.Pliers => "Pliers (Armorsmith)",
FullEquipType.GrindingWheel => "Grinding Wheel (Goldsmith)",
FullEquipType.Awl => "Awl (Leatherworker)",
FullEquipType.SpinningWheel => "Spinning Wheel (Weaver)",
FullEquipType.Mortar => "Mortar (Alchemist)",
FullEquipType.CulinaryKnife => "Knife (Culinarian)",
FullEquipType.Sledgehammer => "Sledgehammer (Miner)",
FullEquipType.GardenScythe => "Garden Scythe (Botanist)",
FullEquipType.Gig => "Gig (Fisher)",
_ => "Unknown",
};
public static EquipSlot ToSlot(this FullEquipType type)
=> type switch
{
FullEquipType.Head => EquipSlot.Head,
FullEquipType.Body => EquipSlot.Body,
FullEquipType.Hands => EquipSlot.Hands,
FullEquipType.Legs => EquipSlot.Legs,
FullEquipType.Feet => EquipSlot.Feet,
FullEquipType.Ears => EquipSlot.Ears,
FullEquipType.Neck => EquipSlot.Neck,
FullEquipType.Wrists => EquipSlot.Wrists,
FullEquipType.Finger => EquipSlot.RFinger,
FullEquipType.Fists => EquipSlot.MainHand,
FullEquipType.FistsOff => EquipSlot.OffHand,
FullEquipType.Sword => EquipSlot.MainHand,
FullEquipType.Axe => EquipSlot.MainHand,
FullEquipType.Bow => EquipSlot.MainHand,
FullEquipType.BowOff => EquipSlot.OffHand,
FullEquipType.Lance => EquipSlot.MainHand,
FullEquipType.Staff => EquipSlot.MainHand,
FullEquipType.Wand => EquipSlot.MainHand,
FullEquipType.Book => EquipSlot.MainHand,
FullEquipType.Daggers => EquipSlot.MainHand,
FullEquipType.DaggersOff => EquipSlot.OffHand,
FullEquipType.Broadsword => EquipSlot.MainHand,
FullEquipType.Gun => EquipSlot.MainHand,
FullEquipType.GunOff => EquipSlot.OffHand,
FullEquipType.Orrery => EquipSlot.MainHand,
FullEquipType.OrreryOff => EquipSlot.OffHand,
FullEquipType.Katana => EquipSlot.MainHand,
FullEquipType.KatanaOff => EquipSlot.OffHand,
FullEquipType.Rapier => EquipSlot.MainHand,
FullEquipType.RapierOff => EquipSlot.OffHand,
FullEquipType.Cane => EquipSlot.MainHand,
FullEquipType.Gunblade => EquipSlot.MainHand,
FullEquipType.Glaives => EquipSlot.MainHand,
FullEquipType.GlaivesOff => EquipSlot.OffHand,
FullEquipType.Scythe => EquipSlot.MainHand,
FullEquipType.Nouliths => EquipSlot.MainHand,
FullEquipType.Shield => EquipSlot.OffHand,
FullEquipType.Saw => EquipSlot.MainHand,
FullEquipType.CrossPeinHammer => EquipSlot.MainHand,
FullEquipType.RaisingHammer => EquipSlot.MainHand,
FullEquipType.LapidaryHammer => EquipSlot.MainHand,
FullEquipType.Knife => EquipSlot.MainHand,
FullEquipType.Needle => EquipSlot.MainHand,
FullEquipType.Alembic => EquipSlot.MainHand,
FullEquipType.Frypan => EquipSlot.MainHand,
FullEquipType.Pickaxe => EquipSlot.MainHand,
FullEquipType.Hatchet => EquipSlot.MainHand,
FullEquipType.FishingRod => EquipSlot.MainHand,
FullEquipType.ClawHammer => EquipSlot.OffHand,
FullEquipType.File => EquipSlot.OffHand,
FullEquipType.Pliers => EquipSlot.OffHand,
FullEquipType.GrindingWheel => EquipSlot.OffHand,
FullEquipType.Awl => EquipSlot.OffHand,
FullEquipType.SpinningWheel => EquipSlot.OffHand,
FullEquipType.Mortar => EquipSlot.OffHand,
FullEquipType.CulinaryKnife => EquipSlot.OffHand,
FullEquipType.Sledgehammer => EquipSlot.OffHand,
FullEquipType.GardenScythe => EquipSlot.OffHand,
FullEquipType.Gig => EquipSlot.OffHand,
_ => EquipSlot.Unknown,
};
public static FullEquipType ToEquipType(this EquipSlot slot, WeaponCategory category = WeaponCategory.Unknown, bool mainhand = true)
=> slot switch
{
EquipSlot.Head => FullEquipType.Head,
EquipSlot.Body => FullEquipType.Body,
EquipSlot.Hands => FullEquipType.Hands,
EquipSlot.Legs => FullEquipType.Legs,
EquipSlot.Feet => FullEquipType.Feet,
EquipSlot.Ears => FullEquipType.Ears,
EquipSlot.Neck => FullEquipType.Neck,
EquipSlot.Wrists => FullEquipType.Wrists,
EquipSlot.RFinger => FullEquipType.Finger,
EquipSlot.LFinger => FullEquipType.Finger,
EquipSlot.HeadBody => FullEquipType.Body,
EquipSlot.BodyHandsLegsFeet => FullEquipType.Body,
EquipSlot.LegsFeet => FullEquipType.Legs,
EquipSlot.FullBody => FullEquipType.Body,
EquipSlot.BodyHands => FullEquipType.Body,
EquipSlot.BodyLegsFeet => FullEquipType.Body,
EquipSlot.ChestHands => FullEquipType.Body,
EquipSlot.MainHand => category.ToEquipType(mainhand),
EquipSlot.OffHand => category.ToEquipType(mainhand),
EquipSlot.BothHand => category.ToEquipType(mainhand),
_ => FullEquipType.Unknown,
};
public static FullEquipType ToEquipType(this WeaponCategory category, bool mainhand = true)
=> category switch
{
WeaponCategory.Pugilist when mainhand => FullEquipType.Fists,
WeaponCategory.Pugilist => FullEquipType.FistsOff,
WeaponCategory.Gladiator => FullEquipType.Sword,
WeaponCategory.Marauder => FullEquipType.Axe,
WeaponCategory.Archer when mainhand => FullEquipType.Bow,
WeaponCategory.Archer => FullEquipType.BowOff,
WeaponCategory.Lancer => FullEquipType.Lance,
WeaponCategory.Thaumaturge1 => FullEquipType.Wand,
WeaponCategory.Thaumaturge2 => FullEquipType.Staff,
WeaponCategory.Conjurer1 => FullEquipType.Wand,
WeaponCategory.Conjurer2 => FullEquipType.Staff,
WeaponCategory.Arcanist => FullEquipType.Book,
WeaponCategory.Shield => FullEquipType.Shield,
WeaponCategory.CarpenterMain => FullEquipType.Saw,
WeaponCategory.CarpenterOff => FullEquipType.ClawHammer,
WeaponCategory.BlacksmithMain => FullEquipType.CrossPeinHammer,
WeaponCategory.BlacksmithOff => FullEquipType.File,
WeaponCategory.ArmorerMain => FullEquipType.RaisingHammer,
WeaponCategory.ArmorerOff => FullEquipType.Pliers,
WeaponCategory.GoldsmithMain => FullEquipType.LapidaryHammer,
WeaponCategory.GoldsmithOff => FullEquipType.GrindingWheel,
WeaponCategory.LeatherworkerMain => FullEquipType.Knife,
WeaponCategory.LeatherworkerOff => FullEquipType.Awl,
WeaponCategory.WeaverMain => FullEquipType.Needle,
WeaponCategory.WeaverOff => FullEquipType.SpinningWheel,
WeaponCategory.AlchemistMain => FullEquipType.Alembic,
WeaponCategory.AlchemistOff => FullEquipType.Mortar,
WeaponCategory.CulinarianMain => FullEquipType.Frypan,
WeaponCategory.CulinarianOff => FullEquipType.CulinaryKnife,
WeaponCategory.MinerMain => FullEquipType.Pickaxe,
WeaponCategory.MinerOff => FullEquipType.Sledgehammer,
WeaponCategory.BotanistMain => FullEquipType.Hatchet,
WeaponCategory.BotanistOff => FullEquipType.GardenScythe,
WeaponCategory.FisherMain => FullEquipType.FishingRod,
WeaponCategory.FisherOff => FullEquipType.Gig,
WeaponCategory.Rogue when mainhand => FullEquipType.Daggers,
WeaponCategory.Rogue => FullEquipType.DaggersOff,
WeaponCategory.DarkKnight => FullEquipType.Broadsword,
WeaponCategory.Machinist when mainhand => FullEquipType.Gun,
WeaponCategory.Machinist => FullEquipType.GunOff,
WeaponCategory.Astrologian when mainhand => FullEquipType.Orrery,
WeaponCategory.Astrologian => FullEquipType.OrreryOff,
WeaponCategory.Samurai when mainhand => FullEquipType.Katana,
WeaponCategory.Samurai => FullEquipType.KatanaOff,
WeaponCategory.RedMage when mainhand => FullEquipType.Rapier,
WeaponCategory.RedMage => FullEquipType.RapierOff,
WeaponCategory.Scholar => FullEquipType.Book,
WeaponCategory.BlueMage => FullEquipType.Cane,
WeaponCategory.Gunbreaker => FullEquipType.Gunblade,
WeaponCategory.Dancer when mainhand => FullEquipType.Glaives,
WeaponCategory.Dancer => FullEquipType.GlaivesOff,
WeaponCategory.Reaper => FullEquipType.Scythe,
WeaponCategory.Sage => FullEquipType.Nouliths,
_ => FullEquipType.Unknown,
};
public static FullEquipType Offhand(this FullEquipType type)
=> type switch
{
FullEquipType.Fists => FullEquipType.FistsOff,
FullEquipType.Sword => FullEquipType.Shield,
FullEquipType.Wand => FullEquipType.Shield,
FullEquipType.Daggers => FullEquipType.DaggersOff,
FullEquipType.Gun => FullEquipType.GunOff,
FullEquipType.Orrery => FullEquipType.OrreryOff,
FullEquipType.Rapier => FullEquipType.RapierOff,
FullEquipType.Glaives => FullEquipType.GlaivesOff,
FullEquipType.Bow => FullEquipType.BowOff,
FullEquipType.Katana => FullEquipType.KatanaOff,
FullEquipType.Saw => FullEquipType.ClawHammer,
FullEquipType.CrossPeinHammer => FullEquipType.File,
FullEquipType.RaisingHammer => FullEquipType.Pliers,
FullEquipType.LapidaryHammer => FullEquipType.GrindingWheel,
FullEquipType.Knife => FullEquipType.Awl,
FullEquipType.Needle => FullEquipType.SpinningWheel,
FullEquipType.Alembic => FullEquipType.Mortar,
FullEquipType.Frypan => FullEquipType.CulinaryKnife,
FullEquipType.Pickaxe => FullEquipType.Sledgehammer,
FullEquipType.Hatchet => FullEquipType.GardenScythe,
FullEquipType.FishingRod => FullEquipType.Gig,
_ => FullEquipType.Unknown,
};
internal static string OffhandTypeSuffix(this FullEquipType type)
=> type switch
{
FullEquipType.FistsOff => " (Offhand)",
FullEquipType.DaggersOff => " (Offhand)",
FullEquipType.GunOff => " (Aetherotransformer)",
FullEquipType.OrreryOff => " (Card Holder)",
FullEquipType.RapierOff => " (Focus)",
FullEquipType.GlaivesOff => " (Offhand)",
FullEquipType.BowOff => " (Quiver)",
FullEquipType.KatanaOff => " (Sheathe)",
_ => string.Empty,
};
public static readonly IReadOnlyList<FullEquipType> WeaponTypes
= Enum.GetValues<FullEquipType>().Where(v => v.IsWeapon()).ToArray();
public static readonly IReadOnlyList<FullEquipType> ToolTypes
= Enum.GetValues<FullEquipType>().Where(v => v.IsTool()).ToArray();
public static readonly IReadOnlyList<FullEquipType> EquipmentTypes
= Enum.GetValues<FullEquipType>().Where(v => v.IsEquipment()).ToArray();
public static readonly IReadOnlyList<FullEquipType> AccessoryTypes
= Enum.GetValues<FullEquipType>().Where(v => v.IsAccessory()).ToArray();
public static readonly IReadOnlyList<FullEquipType> OffhandTypes
= Enum.GetValues<FullEquipType>().Where(v => v.OffhandTypeSuffix().Length > 0).ToArray();
}

View file

@ -1,26 +0,0 @@
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
namespace Penumbra.GameData.Enums;
public static class ModelTypeExtensions
{
public static string ToName(this CharacterBase.ModelType type)
=> type switch
{
CharacterBase.ModelType.DemiHuman => "Demihuman",
CharacterBase.ModelType.Monster => "Monster",
CharacterBase.ModelType.Human => "Human",
CharacterBase.ModelType.Weapon => "Weapon",
_ => string.Empty,
};
public static CharacterBase.ModelType ToModelType(this ObjectType type)
=> type switch
{
ObjectType.DemiHuman => CharacterBase.ModelType.DemiHuman,
ObjectType.Monster => CharacterBase.ModelType.Monster,
ObjectType.Character => CharacterBase.ModelType.Human,
ObjectType.Weapon => CharacterBase.ModelType.Weapon,
_ => 0,
};
}

View file

@ -1,53 +0,0 @@
namespace Penumbra.GameData.Enums;
public enum ObjectType : byte
{
Unknown,
Vfx,
DemiHuman,
Accessory,
World,
Housing,
Monster,
Icon,
LoadingScreen,
Map,
Interface,
Equipment,
Character,
Weapon,
Font,
}
public static class ObjectTypeExtensions
{
public static string ToName( this ObjectType type )
=> type switch
{
ObjectType.Vfx => "Visual Effect",
ObjectType.DemiHuman => "Demi Human",
ObjectType.Accessory => "Accessory",
ObjectType.World => "Doodad",
ObjectType.Housing => "Housing Object",
ObjectType.Monster => "Monster",
ObjectType.Icon => "Icon",
ObjectType.LoadingScreen => "Loading Screen",
ObjectType.Map => "Map",
ObjectType.Interface => "UI Element",
ObjectType.Equipment => "Equipment",
ObjectType.Character => "Character",
ObjectType.Weapon => "Weapon",
ObjectType.Font => "Font",
_ => "Unknown",
};
public static readonly ObjectType[] ValidImcTypes =
{
ObjectType.Equipment,
ObjectType.Accessory,
ObjectType.DemiHuman,
ObjectType.Monster,
ObjectType.Weapon,
};
}

View file

@ -1,510 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using static Penumbra.GameData.Enums.GenderRace;
namespace Penumbra.GameData.Enums;
public enum Race : byte
{
Unknown,
Hyur,
Elezen,
Lalafell,
Miqote,
Roegadyn,
AuRa,
Hrothgar,
Viera,
}
public enum Gender : byte
{
Unknown,
Male,
Female,
MaleNpc,
FemaleNpc,
}
public enum ModelRace : byte
{
Unknown,
Midlander,
Highlander,
Elezen,
Lalafell,
Miqote,
Roegadyn,
AuRa,
Hrothgar,
Viera,
}
public enum SubRace : byte
{
Unknown,
Midlander,
Highlander,
Wildwood,
Duskwight,
Plainsfolk,
Dunesfolk,
SeekerOfTheSun,
KeeperOfTheMoon,
Seawolf,
Hellsguard,
Raen,
Xaela,
Helion,
Lost,
Rava,
Veena,
}
// The combined gender-race-npc numerical code as used by the game.
public enum GenderRace : ushort
{
Unknown = 0,
MidlanderMale = 0101,
MidlanderMaleNpc = 0104,
MidlanderFemale = 0201,
MidlanderFemaleNpc = 0204,
HighlanderMale = 0301,
HighlanderMaleNpc = 0304,
HighlanderFemale = 0401,
HighlanderFemaleNpc = 0404,
ElezenMale = 0501,
ElezenMaleNpc = 0504,
ElezenFemale = 0601,
ElezenFemaleNpc = 0604,
MiqoteMale = 0701,
MiqoteMaleNpc = 0704,
MiqoteFemale = 0801,
MiqoteFemaleNpc = 0804,
RoegadynMale = 0901,
RoegadynMaleNpc = 0904,
RoegadynFemale = 1001,
RoegadynFemaleNpc = 1004,
LalafellMale = 1101,
LalafellMaleNpc = 1104,
LalafellFemale = 1201,
LalafellFemaleNpc = 1204,
AuRaMale = 1301,
AuRaMaleNpc = 1304,
AuRaFemale = 1401,
AuRaFemaleNpc = 1404,
HrothgarMale = 1501,
HrothgarMaleNpc = 1504,
HrothgarFemale = 1601,
HrothgarFemaleNpc = 1604,
VieraMale = 1701,
VieraMaleNpc = 1704,
VieraFemale = 1801,
VieraFemaleNpc = 1804,
UnknownMaleNpc = 9104,
UnknownFemaleNpc = 9204,
}
public static class RaceEnumExtensions
{
public static Race ToRace(this ModelRace race)
{
return race switch
{
ModelRace.Unknown => Race.Unknown,
ModelRace.Midlander => Race.Hyur,
ModelRace.Highlander => Race.Hyur,
ModelRace.Elezen => Race.Elezen,
ModelRace.Lalafell => Race.Lalafell,
ModelRace.Miqote => Race.Miqote,
ModelRace.Roegadyn => Race.Roegadyn,
ModelRace.AuRa => Race.AuRa,
ModelRace.Hrothgar => Race.Hrothgar,
ModelRace.Viera => Race.Viera,
_ => throw new ArgumentOutOfRangeException(nameof(race), race, null),
};
}
public static Race ToRace(this SubRace subRace)
{
return subRace switch
{
SubRace.Unknown => Race.Unknown,
SubRace.Midlander => Race.Hyur,
SubRace.Highlander => Race.Hyur,
SubRace.Wildwood => Race.Elezen,
SubRace.Duskwight => Race.Elezen,
SubRace.Plainsfolk => Race.Lalafell,
SubRace.Dunesfolk => Race.Lalafell,
SubRace.SeekerOfTheSun => Race.Miqote,
SubRace.KeeperOfTheMoon => Race.Miqote,
SubRace.Seawolf => Race.Roegadyn,
SubRace.Hellsguard => Race.Roegadyn,
SubRace.Raen => Race.AuRa,
SubRace.Xaela => Race.AuRa,
SubRace.Helion => Race.Hrothgar,
SubRace.Lost => Race.Hrothgar,
SubRace.Rava => Race.Viera,
SubRace.Veena => Race.Viera,
_ => throw new ArgumentOutOfRangeException(nameof(subRace), subRace, null),
};
}
public static string ToName(this ModelRace modelRace)
{
return modelRace switch
{
ModelRace.Midlander => SubRace.Midlander.ToName(),
ModelRace.Highlander => SubRace.Highlander.ToName(),
ModelRace.Elezen => Race.Elezen.ToName(),
ModelRace.Lalafell => Race.Lalafell.ToName(),
ModelRace.Miqote => Race.Miqote.ToName(),
ModelRace.Roegadyn => Race.Roegadyn.ToName(),
ModelRace.AuRa => Race.AuRa.ToName(),
ModelRace.Hrothgar => Race.Hrothgar.ToName(),
ModelRace.Viera => Race.Viera.ToName(),
_ => Race.Unknown.ToName(),
};
}
public static string ToName(this Race race)
{
return race switch
{
Race.Hyur => "Hyur",
Race.Elezen => "Elezen",
Race.Lalafell => "Lalafell",
Race.Miqote => "Miqo'te",
Race.Roegadyn => "Roegadyn",
Race.AuRa => "Au Ra",
Race.Hrothgar => "Hrothgar",
Race.Viera => "Viera",
_ => "Unknown",
};
}
public static string ToName(this Gender gender)
{
return gender switch
{
Gender.Male => "Male",
Gender.Female => "Female",
Gender.MaleNpc => "Male (NPC)",
Gender.FemaleNpc => "Female (NPC)",
_ => "Unknown",
};
}
public static string ToName(this SubRace subRace)
{
return subRace switch
{
SubRace.Midlander => "Midlander",
SubRace.Highlander => "Highlander",
SubRace.Wildwood => "Wildwood",
SubRace.Duskwight => "Duskwight",
SubRace.Plainsfolk => "Plainsfolk",
SubRace.Dunesfolk => "Dunesfolk",
SubRace.SeekerOfTheSun => "Seeker Of The Sun",
SubRace.KeeperOfTheMoon => "Keeper Of The Moon",
SubRace.Seawolf => "Seawolf",
SubRace.Hellsguard => "Hellsguard",
SubRace.Raen => "Raen",
SubRace.Xaela => "Xaela",
SubRace.Helion => "Hellion",
SubRace.Lost => "Lost",
SubRace.Rava => "Rava",
SubRace.Veena => "Veena",
_ => "Unknown",
};
}
public static string ToShortName(this SubRace subRace)
{
return subRace switch
{
SubRace.SeekerOfTheSun => "Sunseeker",
SubRace.KeeperOfTheMoon => "Moonkeeper",
_ => subRace.ToName(),
};
}
public static bool FitsRace(this SubRace subRace, Race race)
=> subRace.ToRace() == race;
public static byte ToByte(this Gender gender, ModelRace modelRace)
=> (byte)((int)gender | ((int)modelRace << 3));
public static byte ToByte(this ModelRace modelRace, Gender gender)
=> gender.ToByte(modelRace);
public static byte ToByte(this GenderRace value)
{
var (gender, race) = value.Split();
return gender.ToByte(race);
}
public static (Gender, ModelRace) Split(this GenderRace value)
{
return value switch
{
Unknown => (Gender.Unknown, ModelRace.Unknown),
MidlanderMale => (Gender.Male, ModelRace.Midlander),
MidlanderMaleNpc => (Gender.MaleNpc, ModelRace.Midlander),
MidlanderFemale => (Gender.Female, ModelRace.Midlander),
MidlanderFemaleNpc => (Gender.FemaleNpc, ModelRace.Midlander),
HighlanderMale => (Gender.Male, ModelRace.Highlander),
HighlanderMaleNpc => (Gender.MaleNpc, ModelRace.Highlander),
HighlanderFemale => (Gender.Female, ModelRace.Highlander),
HighlanderFemaleNpc => (Gender.FemaleNpc, ModelRace.Highlander),
ElezenMale => (Gender.Male, ModelRace.Elezen),
ElezenMaleNpc => (Gender.MaleNpc, ModelRace.Elezen),
ElezenFemale => (Gender.Female, ModelRace.Elezen),
ElezenFemaleNpc => (Gender.FemaleNpc, ModelRace.Elezen),
LalafellMale => (Gender.Male, ModelRace.Lalafell),
LalafellMaleNpc => (Gender.MaleNpc, ModelRace.Lalafell),
LalafellFemale => (Gender.Female, ModelRace.Lalafell),
LalafellFemaleNpc => (Gender.FemaleNpc, ModelRace.Lalafell),
MiqoteMale => (Gender.Male, ModelRace.Miqote),
MiqoteMaleNpc => (Gender.MaleNpc, ModelRace.Miqote),
MiqoteFemale => (Gender.Female, ModelRace.Miqote),
MiqoteFemaleNpc => (Gender.FemaleNpc, ModelRace.Miqote),
RoegadynMale => (Gender.Male, ModelRace.Roegadyn),
RoegadynMaleNpc => (Gender.MaleNpc, ModelRace.Roegadyn),
RoegadynFemale => (Gender.Female, ModelRace.Roegadyn),
RoegadynFemaleNpc => (Gender.FemaleNpc, ModelRace.Roegadyn),
AuRaMale => (Gender.Male, ModelRace.AuRa),
AuRaMaleNpc => (Gender.MaleNpc, ModelRace.AuRa),
AuRaFemale => (Gender.Female, ModelRace.AuRa),
AuRaFemaleNpc => (Gender.FemaleNpc, ModelRace.AuRa),
HrothgarMale => (Gender.Male, ModelRace.Hrothgar),
HrothgarMaleNpc => (Gender.MaleNpc, ModelRace.Hrothgar),
HrothgarFemale => (Gender.Female, ModelRace.Hrothgar),
HrothgarFemaleNpc => (Gender.FemaleNpc, ModelRace.Hrothgar),
VieraMale => (Gender.Male, ModelRace.Viera),
VieraMaleNpc => (Gender.Male, ModelRace.Viera),
VieraFemale => (Gender.Female, ModelRace.Viera),
VieraFemaleNpc => (Gender.FemaleNpc, ModelRace.Viera),
UnknownMaleNpc => (Gender.MaleNpc, ModelRace.Unknown),
UnknownFemaleNpc => (Gender.FemaleNpc, ModelRace.Unknown),
_ => throw new InvalidEnumArgumentException(),
};
}
public static bool IsValid(this GenderRace value)
=> value != Unknown && Enum.IsDefined(typeof(GenderRace), value);
public static string ToRaceCode(this GenderRace value)
{
return value switch
{
MidlanderMale => "0101",
MidlanderMaleNpc => "0104",
MidlanderFemale => "0201",
MidlanderFemaleNpc => "0204",
HighlanderMale => "0301",
HighlanderMaleNpc => "0304",
HighlanderFemale => "0401",
HighlanderFemaleNpc => "0404",
ElezenMale => "0501",
ElezenMaleNpc => "0504",
ElezenFemale => "0601",
ElezenFemaleNpc => "0604",
MiqoteMale => "0701",
MiqoteMaleNpc => "0704",
MiqoteFemale => "0801",
MiqoteFemaleNpc => "0804",
RoegadynMale => "0901",
RoegadynMaleNpc => "0904",
RoegadynFemale => "1001",
RoegadynFemaleNpc => "1004",
LalafellMale => "1101",
LalafellMaleNpc => "1104",
LalafellFemale => "1201",
LalafellFemaleNpc => "1204",
AuRaMale => "1301",
AuRaMaleNpc => "1304",
AuRaFemale => "1401",
AuRaFemaleNpc => "1404",
HrothgarMale => "1501",
HrothgarMaleNpc => "1504",
HrothgarFemale => "1601",
HrothgarFemaleNpc => "1604",
VieraMale => "1701",
VieraMaleNpc => "1704",
VieraFemale => "1801",
VieraFemaleNpc => "1804",
UnknownMaleNpc => "9104",
UnknownFemaleNpc => "9204",
_ => string.Empty,
};
}
public static GenderRace[] Dependencies(this GenderRace raceCode)
=> DependencyList.TryGetValue(raceCode, out var dep) ? dep : Array.Empty<GenderRace>();
public static IEnumerable<GenderRace> OnlyDependencies(this GenderRace raceCode)
=> DependencyList.TryGetValue(raceCode, out var dep) ? dep.Skip(1) : Array.Empty<GenderRace>();
private static readonly Dictionary<GenderRace, GenderRace[]> DependencyList = new()
{
// @formatter:off
[MidlanderMale] = new[]{ MidlanderMale },
[HighlanderMale] = new[]{ HighlanderMale, MidlanderMale },
[ElezenMale] = new[]{ ElezenMale, MidlanderMale },
[MiqoteMale] = new[]{ MiqoteMale, MidlanderMale },
[RoegadynMale] = new[]{ RoegadynMale, MidlanderMale },
[LalafellMale] = new[]{ LalafellMale, MidlanderMale },
[AuRaMale] = new[]{ AuRaMale, MidlanderMale },
[HrothgarMale] = new[]{ HrothgarMale, RoegadynMale, MidlanderMale },
[VieraMale] = new[]{ VieraMale, MidlanderMale },
[MidlanderFemale] = new[]{ MidlanderFemale, MidlanderMale },
[HighlanderFemale] = new[]{ HighlanderFemale, MidlanderFemale, MidlanderMale },
[ElezenFemale] = new[]{ ElezenFemale, MidlanderFemale, MidlanderMale },
[MiqoteFemale] = new[]{ MiqoteFemale, MidlanderFemale, MidlanderMale },
[RoegadynFemale] = new[]{ RoegadynFemale, MidlanderFemale, MidlanderMale },
[LalafellFemale] = new[]{ LalafellFemale, LalafellMale, MidlanderMale },
[AuRaFemale] = new[]{ AuRaFemale, MidlanderFemale, MidlanderMale },
[HrothgarFemale] = new[]{ HrothgarFemale, RoegadynFemale, MidlanderFemale, MidlanderMale },
[VieraFemale] = new[]{ VieraFemale, MidlanderFemale, MidlanderMale },
[MidlanderMaleNpc] = new[]{ MidlanderMaleNpc, MidlanderMale },
[HighlanderMaleNpc] = new[]{ HighlanderMaleNpc, HighlanderMale, MidlanderMaleNpc, MidlanderMale },
[ElezenMaleNpc] = new[]{ ElezenMaleNpc, ElezenMale, MidlanderMaleNpc, MidlanderMale },
[MiqoteMaleNpc] = new[]{ MiqoteMaleNpc, MiqoteMale, MidlanderMaleNpc, MidlanderMale },
[RoegadynMaleNpc] = new[]{ RoegadynMaleNpc, RoegadynMale, MidlanderMaleNpc, MidlanderMale },
[LalafellMaleNpc] = new[]{ LalafellMaleNpc, LalafellMale, MidlanderMaleNpc, MidlanderMale },
[AuRaMaleNpc] = new[]{ AuRaMaleNpc, AuRaMale, MidlanderMaleNpc, MidlanderMale },
[HrothgarMaleNpc] = new[]{ HrothgarMaleNpc, HrothgarMale, RoegadynMaleNpc, RoegadynMale, MidlanderMaleNpc, MidlanderMale },
[VieraMaleNpc] = new[]{ VieraMaleNpc, VieraMale, MidlanderMaleNpc, MidlanderMale },
[MidlanderFemaleNpc] = new[]{ MidlanderFemaleNpc, MidlanderFemale, MidlanderMaleNpc, MidlanderMale },
[HighlanderFemaleNpc] = new[]{ HighlanderFemaleNpc, HighlanderFemale, MidlanderFemaleNpc, MidlanderFemale, MidlanderMaleNpc, MidlanderMale },
[ElezenFemaleNpc] = new[]{ ElezenFemaleNpc, ElezenFemale, MidlanderFemaleNpc, MidlanderFemale, MidlanderMaleNpc, MidlanderMale },
[MiqoteFemaleNpc] = new[]{ MiqoteFemaleNpc, MiqoteFemale, MidlanderFemaleNpc, MidlanderFemale, MidlanderMaleNpc, MidlanderMale },
[RoegadynFemaleNpc] = new[]{ RoegadynFemaleNpc, RoegadynFemale, MidlanderFemaleNpc, MidlanderFemale, MidlanderMaleNpc, MidlanderMale },
[LalafellFemaleNpc] = new[]{ LalafellFemaleNpc, LalafellFemale, LalafellMaleNpc, LalafellMale, MidlanderMaleNpc, MidlanderMale },
[AuRaFemaleNpc] = new[]{ AuRaFemaleNpc, AuRaFemale, MidlanderFemaleNpc, MidlanderFemale, MidlanderMaleNpc, MidlanderMale },
[HrothgarFemaleNpc] = new[]{ HrothgarFemaleNpc, HrothgarFemale, RoegadynFemaleNpc, RoegadynFemale, MidlanderFemaleNpc, MidlanderFemale, MidlanderMaleNpc, MidlanderMale },
[VieraFemaleNpc] = new[]{ VieraFemaleNpc, VieraFemale, MidlanderFemaleNpc, MidlanderFemale, MidlanderMaleNpc, MidlanderMale },
[UnknownMaleNpc] = new[]{ UnknownMaleNpc, MidlanderMaleNpc, MidlanderMale },
[UnknownFemaleNpc] = new[]{ UnknownFemaleNpc, MidlanderFemaleNpc, MidlanderFemale, MidlanderMaleNpc, MidlanderMale },
// @formatter:on
};
}
public static partial class Names
{
public static GenderRace GenderRaceFromCode(string code)
{
return code switch
{
"0101" => MidlanderMale,
"0104" => MidlanderMaleNpc,
"0201" => MidlanderFemale,
"0204" => MidlanderFemaleNpc,
"0301" => HighlanderMale,
"0304" => HighlanderMaleNpc,
"0401" => HighlanderFemale,
"0404" => HighlanderFemaleNpc,
"0501" => ElezenMale,
"0504" => ElezenMaleNpc,
"0601" => ElezenFemale,
"0604" => ElezenFemaleNpc,
"0701" => MiqoteMale,
"0704" => MiqoteMaleNpc,
"0801" => MiqoteFemale,
"0804" => MiqoteFemaleNpc,
"0901" => RoegadynMale,
"0904" => RoegadynMaleNpc,
"1001" => RoegadynFemale,
"1004" => RoegadynFemaleNpc,
"1101" => LalafellMale,
"1104" => LalafellMaleNpc,
"1201" => LalafellFemale,
"1204" => LalafellFemaleNpc,
"1301" => AuRaMale,
"1304" => AuRaMaleNpc,
"1401" => AuRaFemale,
"1404" => AuRaFemaleNpc,
"1501" => HrothgarMale,
"1504" => HrothgarMaleNpc,
"1601" => HrothgarFemale,
"1604" => HrothgarFemaleNpc,
"1701" => VieraMale,
"1704" => VieraMaleNpc,
"1801" => VieraFemale,
"1804" => VieraFemaleNpc,
"9104" => UnknownMaleNpc,
"9204" => UnknownFemaleNpc,
_ => Unknown,
};
}
public static GenderRace GenderRaceFromByte(byte value)
{
var gender = (Gender)(value & 0b111);
var race = (ModelRace)(value >> 3);
return CombinedRace(gender, race);
}
public static GenderRace CombinedRace(Gender gender, ModelRace modelRace)
{
return gender switch
{
Gender.Male => modelRace switch
{
ModelRace.Midlander => MidlanderMale,
ModelRace.Highlander => HighlanderMale,
ModelRace.Elezen => ElezenMale,
ModelRace.Lalafell => LalafellMale,
ModelRace.Miqote => MiqoteMale,
ModelRace.Roegadyn => RoegadynMale,
ModelRace.AuRa => AuRaMale,
ModelRace.Hrothgar => HrothgarMale,
ModelRace.Viera => VieraMale,
_ => Unknown,
},
Gender.MaleNpc => modelRace switch
{
ModelRace.Midlander => MidlanderMaleNpc,
ModelRace.Highlander => HighlanderMaleNpc,
ModelRace.Elezen => ElezenMaleNpc,
ModelRace.Lalafell => LalafellMaleNpc,
ModelRace.Miqote => MiqoteMaleNpc,
ModelRace.Roegadyn => RoegadynMaleNpc,
ModelRace.AuRa => AuRaMaleNpc,
ModelRace.Hrothgar => HrothgarMaleNpc,
ModelRace.Viera => VieraMaleNpc,
_ => Unknown,
},
Gender.Female => modelRace switch
{
ModelRace.Midlander => MidlanderFemale,
ModelRace.Highlander => HighlanderFemale,
ModelRace.Elezen => ElezenFemale,
ModelRace.Lalafell => LalafellFemale,
ModelRace.Miqote => MiqoteFemale,
ModelRace.Roegadyn => RoegadynFemale,
ModelRace.AuRa => AuRaFemale,
ModelRace.Hrothgar => HrothgarFemale,
ModelRace.Viera => VieraFemale,
_ => Unknown,
},
Gender.FemaleNpc => modelRace switch
{
ModelRace.Midlander => MidlanderFemaleNpc,
ModelRace.Highlander => HighlanderFemaleNpc,
ModelRace.Elezen => ElezenFemaleNpc,
ModelRace.Lalafell => LalafellFemaleNpc,
ModelRace.Miqote => MiqoteFemaleNpc,
ModelRace.Roegadyn => RoegadynFemaleNpc,
ModelRace.AuRa => AuRaFemaleNpc,
ModelRace.Hrothgar => HrothgarFemaleNpc,
ModelRace.Viera => VieraFemaleNpc,
_ => Unknown,
},
_ => Unknown,
};
}
}

View file

@ -1,91 +0,0 @@
using System.ComponentModel;
namespace Penumbra.GameData.Enums;
public enum RspAttribute : byte
{
MaleMinSize,
MaleMaxSize,
MaleMinTail,
MaleMaxTail,
FemaleMinSize,
FemaleMaxSize,
FemaleMinTail,
FemaleMaxTail,
BustMinX,
BustMinY,
BustMinZ,
BustMaxX,
BustMaxY,
BustMaxZ,
NumAttributes,
}
public static class RspAttributeExtensions
{
public static Gender ToGender( this RspAttribute attribute )
{
return attribute switch
{
RspAttribute.MaleMinSize => Gender.Male,
RspAttribute.MaleMaxSize => Gender.Male,
RspAttribute.MaleMinTail => Gender.Male,
RspAttribute.MaleMaxTail => Gender.Male,
RspAttribute.FemaleMinSize => Gender.Female,
RspAttribute.FemaleMaxSize => Gender.Female,
RspAttribute.FemaleMinTail => Gender.Female,
RspAttribute.FemaleMaxTail => Gender.Female,
RspAttribute.BustMinX => Gender.Female,
RspAttribute.BustMinY => Gender.Female,
RspAttribute.BustMinZ => Gender.Female,
RspAttribute.BustMaxX => Gender.Female,
RspAttribute.BustMaxY => Gender.Female,
RspAttribute.BustMaxZ => Gender.Female,
_ => Gender.Unknown,
};
}
public static string ToUngenderedString( this RspAttribute attribute )
{
return attribute switch
{
RspAttribute.MaleMinSize => "MinSize",
RspAttribute.MaleMaxSize => "MaxSize",
RspAttribute.MaleMinTail => "MinTail",
RspAttribute.MaleMaxTail => "MaxTail",
RspAttribute.FemaleMinSize => "MinSize",
RspAttribute.FemaleMaxSize => "MaxSize",
RspAttribute.FemaleMinTail => "MinTail",
RspAttribute.FemaleMaxTail => "MaxTail",
RspAttribute.BustMinX => "BustMinX",
RspAttribute.BustMinY => "BustMinY",
RspAttribute.BustMinZ => "BustMinZ",
RspAttribute.BustMaxX => "BustMaxX",
RspAttribute.BustMaxY => "BustMaxY",
RspAttribute.BustMaxZ => "BustMaxZ",
_ => "",
};
}
public static string ToFullString( this RspAttribute attribute )
{
return attribute switch
{
RspAttribute.MaleMinSize => "Male Minimum Size",
RspAttribute.MaleMaxSize => "Male Maximum Size",
RspAttribute.FemaleMinSize => "Female Minimum Size",
RspAttribute.FemaleMaxSize => "Female Maximum Size",
RspAttribute.BustMinX => "Bust Minimum X-Axis",
RspAttribute.BustMaxX => "Bust Maximum X-Axis",
RspAttribute.BustMinY => "Bust Minimum Y-Axis",
RspAttribute.BustMaxY => "Bust Maximum Y-Axis",
RspAttribute.BustMinZ => "Bust Minimum Z-Axis",
RspAttribute.BustMaxZ => "Bust Maximum Z-Axis",
RspAttribute.MaleMinTail => "Male Minimum Tail Length",
RspAttribute.MaleMaxTail => "Male Maximum Tail Length",
RspAttribute.FemaleMinTail => "Female Minimum Tail Length",
RspAttribute.FemaleMaxTail => "Female Maximum Tail Length",
_ => throw new InvalidEnumArgumentException(),
};
}
}

View file

@ -1,51 +0,0 @@
namespace Penumbra.GameData.Enums;
public enum WeaponCategory : byte
{
Unknown = 0,
Pugilist,
Gladiator,
Marauder,
Archer,
Lancer,
Thaumaturge1,
Thaumaturge2,
Conjurer1,
Conjurer2,
Arcanist,
Shield,
CarpenterMain,
CarpenterOff,
BlacksmithMain,
BlacksmithOff,
ArmorerMain,
ArmorerOff,
GoldsmithMain,
GoldsmithOff,
LeatherworkerMain,
LeatherworkerOff,
WeaverMain,
WeaverOff,
AlchemistMain,
AlchemistOff,
CulinarianMain,
CulinarianOff,
MinerMain,
MinerOff,
BotanistMain,
BotanistOff,
FisherMain,
Rogue = 84,
DarkKnight = 87,
Machinist = 88,
Astrologian = 89,
Samurai = 96,
RedMage = 97,
Scholar = 98,
FisherOff = 99,
BlueMage = 105,
Gunbreaker = 106,
Dancer = 107,
Reaper = 108,
Sage = 109,
}

View file

@ -1,283 +0,0 @@
using System;
using System.IO;
using System.Numerics;
using System.Text;
namespace Penumbra.GameData.Files;
public class AvfxFile : IWritable
{
public struct Block
{
public uint Name;
public uint Size;
public byte[] Data;
public Block(BinaryReader r)
{
Name = r.ReadUInt32();
Size = r.ReadUInt32();
Data = r.ReadBytes((int)Size.RoundTo4());
}
public byte ToBool()
=> BitConverter.ToBoolean(Data) ? (byte)1 : (byte)0;
public uint ToUint()
=> BitConverter.ToUInt32(Data);
public float ToFloat()
=> BitConverter.ToSingle(Data);
public new string ToString()
{
var span = Data.AsSpan(0, (int)Size - 1);
return Encoding.UTF8.GetString(span);
}
}
public static readonly Vector3 BadVector = new(float.NaN);
public Vector3 ClipBox = BadVector;
public Vector3 ClipBoxSize = BadVector;
public Vector3 RevisedValuesPos = BadVector;
public Vector3 RevisedValuesRot = BadVector;
public Vector3 RevisedValuesScale = BadVector;
public Vector3 RevisedValuesColor = BadVector;
public uint Version = uint.MaxValue;
public uint DrawLayerType = uint.MaxValue;
public uint DrawOrderType = uint.MaxValue;
public uint DirectionalLightSourceType = uint.MaxValue;
public uint PointLightsType1 = uint.MaxValue;
public uint PointLightsType2 = uint.MaxValue;
public float BiasZmaxScale = float.NaN;
public float BiasZmaxDistance = float.NaN;
public float NearClipBegin = float.NaN;
public float NearClipEnd = float.NaN;
public float FadeInnerX = float.NaN;
public float FadeOuterX = float.NaN;
public float FadeInnerY = float.NaN;
public float FadeOuterY = float.NaN;
public float FadeInnerZ = float.NaN;
public float FadeOuterZ = float.NaN;
public float FarClipBegin = float.NaN;
public float FarClipEnd = float.NaN;
public float SoftParticleFadeRange = float.NaN;
public float SoftKeyOffset = float.NaN;
public float GlobalFogInfluence = float.NaN;
public byte IsDelayFastParticle = byte.MaxValue;
public byte IsFitGround = byte.MaxValue;
public byte IsTransformSkip = byte.MaxValue;
public byte IsAllStopOnHide = byte.MaxValue;
public byte CanBeClippedOut = byte.MaxValue;
public byte ClipBoxEnabled = byte.MaxValue;
public byte IsCameraSpace = byte.MaxValue;
public byte IsFullEnvLight = byte.MaxValue;
public byte IsClipOwnSetting = byte.MaxValue;
public byte FadeEnabledX = byte.MaxValue;
public byte FadeEnabledY = byte.MaxValue;
public byte FadeEnabledZ = byte.MaxValue;
public byte GlobalFogEnabled = byte.MaxValue;
public byte LtsEnabled = byte.MaxValue;
public Block[] Schedulers = Array.Empty<Block>();
public Block[] Timelines = Array.Empty<Block>();
public Block[] Emitters = Array.Empty<Block>();
public Block[] Particles = Array.Empty<Block>();
public Block[] Effectors = Array.Empty<Block>();
public Block[] Binders = Array.Empty<Block>();
public string[] Textures = Array.Empty<string>();
public Block[] Models = Array.Empty<Block>();
public bool Valid
=> true;
public AvfxFile(byte[] data)
{
using var stream = new MemoryStream(data);
using var r = new BinaryReader(stream);
var name = r.ReadUInt32();
var size = r.ReadUInt32();
var schedulerCount = 0;
var timelineCount = 0;
var emitterCount = 0;
var particleCount = 0;
var effectorCount = 0;
var binderCount = 0;
var textureCount = 0;
var modelCount = 0;
while (r.BaseStream.Position < size)
{
var block = new Block(r);
switch (block.Name)
{
// @formatter:off
case AvfxMagic.Version: Version = block.ToUint(); break;
case AvfxMagic.IsDelayFastParticle: IsDelayFastParticle = block.ToBool(); break;
case AvfxMagic.IsFitGround: IsFitGround = block.ToBool(); break;
case AvfxMagic.IsTransformSkip: IsTransformSkip = block.ToBool(); break;
case AvfxMagic.IsAllStopOnHide: IsAllStopOnHide = block.ToBool(); break;
case AvfxMagic.CanBeClippedOut: CanBeClippedOut = block.ToBool(); break;
case AvfxMagic.ClipBoxEnabled: ClipBoxEnabled = block.ToBool(); break;
case AvfxMagic.ClipBoxX: ClipBox.X = block.ToFloat(); break;
case AvfxMagic.ClipBoxY: ClipBox.Y = block.ToFloat(); break;
case AvfxMagic.ClipBoxZ: ClipBox.Z = block.ToFloat(); break;
case AvfxMagic.ClipBoxSizeX: ClipBoxSize.X = block.ToFloat(); break;
case AvfxMagic.ClipBoxSizeY: ClipBoxSize.Y = block.ToFloat(); break;
case AvfxMagic.ClipBoxSizeZ: ClipBoxSize.Z = block.ToFloat(); break;
case AvfxMagic.BiasZmaxScale: BiasZmaxScale = block.ToFloat(); break;
case AvfxMagic.BiasZmaxDistance: BiasZmaxDistance = block.ToFloat(); break;
case AvfxMagic.IsCameraSpace: IsCameraSpace = block.ToBool(); break;
case AvfxMagic.IsFullEnvLight: IsFullEnvLight = block.ToBool(); break;
case AvfxMagic.IsClipOwnSetting: IsClipOwnSetting = block.ToBool(); break;
case AvfxMagic.NearClipBegin: NearClipBegin = block.ToFloat(); break;
case AvfxMagic.NearClipEnd: NearClipEnd = block.ToFloat(); break;
case AvfxMagic.FarClipBegin: FarClipBegin = block.ToFloat(); break;
case AvfxMagic.FarClipEnd: FarClipEnd = block.ToFloat(); break;
case AvfxMagic.SoftParticleFadeRange: SoftParticleFadeRange = block.ToFloat(); break;
case AvfxMagic.SoftKeyOffset: SoftKeyOffset = block.ToFloat(); break;
case AvfxMagic.DrawLayerType: DrawLayerType = block.ToUint(); break;
case AvfxMagic.DrawOrderType: DrawOrderType = block.ToUint(); break;
case AvfxMagic.DirectionalLightSourceType: DirectionalLightSourceType = block.ToUint(); break;
case AvfxMagic.PointLightsType1: PointLightsType1 = block.ToUint(); break;
case AvfxMagic.PointLightsType2: PointLightsType2 = block.ToUint(); break;
case AvfxMagic.RevisedValuesPosX: RevisedValuesPos.X = block.ToFloat(); break;
case AvfxMagic.RevisedValuesPosY: RevisedValuesPos.Y = block.ToFloat(); break;
case AvfxMagic.RevisedValuesPosZ: RevisedValuesPos.Z = block.ToFloat(); break;
case AvfxMagic.RevisedValuesRotX: RevisedValuesRot.X = block.ToFloat(); break;
case AvfxMagic.RevisedValuesRotY: RevisedValuesRot.Y = block.ToFloat(); break;
case AvfxMagic.RevisedValuesRotZ: RevisedValuesRot.Z = block.ToFloat(); break;
case AvfxMagic.RevisedValuesScaleX: RevisedValuesScale.X = block.ToFloat(); break;
case AvfxMagic.RevisedValuesScaleY: RevisedValuesScale.Y = block.ToFloat(); break;
case AvfxMagic.RevisedValuesScaleZ: RevisedValuesScale.Z = block.ToFloat(); break;
case AvfxMagic.RevisedValuesColorR: RevisedValuesColor.X = block.ToFloat(); break;
case AvfxMagic.RevisedValuesColorG: RevisedValuesColor.Y = block.ToFloat(); break;
case AvfxMagic.RevisedValuesColorB: RevisedValuesColor.Z = block.ToFloat(); break;
case AvfxMagic.FadeEnabledX: FadeEnabledX = block.ToBool(); break;
case AvfxMagic.FadeInnerX: FadeInnerX = block.ToFloat(); break;
case AvfxMagic.FadeOuterX: FadeOuterX = block.ToFloat(); break;
case AvfxMagic.FadeEnabledY: FadeEnabledY = block.ToBool(); break;
case AvfxMagic.FadeInnerY: FadeInnerY = block.ToFloat(); break;
case AvfxMagic.FadeOuterY: FadeOuterY = block.ToFloat(); break;
case AvfxMagic.FadeEnabledZ: FadeEnabledZ = block.ToBool(); break;
case AvfxMagic.FadeInnerZ: FadeInnerZ = block.ToFloat(); break;
case AvfxMagic.FadeOuterZ: FadeOuterZ = block.ToFloat(); break;
case AvfxMagic.GlobalFogEnabled: GlobalFogEnabled = block.ToBool(); break;
case AvfxMagic.GlobalFogInfluence: GlobalFogInfluence = block.ToFloat(); break;
case AvfxMagic.LtsEnabled: LtsEnabled = block.ToBool(); break;
case AvfxMagic.NumSchedulers: Schedulers = new Block[block.ToUint()]; break;
case AvfxMagic.NumTimelines: Timelines = new Block[block.ToUint()]; break;
case AvfxMagic.NumEmitters: Emitters = new Block[block.ToUint()]; break;
case AvfxMagic.NumParticles: Particles = new Block[block.ToUint()]; break;
case AvfxMagic.NumEffectors: Effectors = new Block[block.ToUint()]; break;
case AvfxMagic.NumBinders: Binders = new Block[block.ToUint()]; break;
case AvfxMagic.NumTextures: Textures = new string[block.ToUint()]; break;
case AvfxMagic.NumModels: Models = new Block[block.ToUint()]; break;
case AvfxMagic.Scheduler: Schedulers[schedulerCount++] = block; break;
case AvfxMagic.Timeline: Timelines[timelineCount++] = block; break;
case AvfxMagic.Emitter: Emitters[emitterCount++] = block; break;
case AvfxMagic.Particle: Particles[particleCount++] = block; break;
case AvfxMagic.Effector: Effectors[effectorCount++] = block; break;
case AvfxMagic.Binder: Binders[binderCount++] = block; break;
case AvfxMagic.Texture: Textures[textureCount++] = block.ToString(); break;
case AvfxMagic.Model: Models[modelCount++] = block; break;
// @formatter:on
}
}
}
public byte[] Write()
{
using var m = new MemoryStream(512 * 1024);
using var w = new BinaryWriter(m);
w.Write(AvfxMagic.AvfxBase);
var sizePos = w.BaseStream.Position;
w.Write(0u);
w.WriteBlock(AvfxMagic.Version, Version)
.WriteBlock(AvfxMagic.IsDelayFastParticle, IsDelayFastParticle)
.WriteBlock(AvfxMagic.IsFitGround, IsFitGround)
.WriteBlock(AvfxMagic.IsTransformSkip, IsTransformSkip)
.WriteBlock(AvfxMagic.IsAllStopOnHide, IsAllStopOnHide)
.WriteBlock(AvfxMagic.CanBeClippedOut, CanBeClippedOut)
.WriteBlock(AvfxMagic.ClipBoxEnabled, ClipBoxEnabled)
.WriteBlock(AvfxMagic.ClipBoxX, ClipBox.X)
.WriteBlock(AvfxMagic.ClipBoxY, ClipBox.Y)
.WriteBlock(AvfxMagic.ClipBoxZ, ClipBox.Z)
.WriteBlock(AvfxMagic.ClipBoxSizeX, ClipBoxSize.X)
.WriteBlock(AvfxMagic.ClipBoxSizeY, ClipBoxSize.Y)
.WriteBlock(AvfxMagic.ClipBoxSizeZ, ClipBoxSize.Z)
.WriteBlock(AvfxMagic.BiasZmaxScale, BiasZmaxScale)
.WriteBlock(AvfxMagic.BiasZmaxDistance, BiasZmaxDistance)
.WriteBlock(AvfxMagic.IsCameraSpace, IsCameraSpace)
.WriteBlock(AvfxMagic.IsFullEnvLight, IsFullEnvLight)
.WriteBlock(AvfxMagic.IsClipOwnSetting, IsClipOwnSetting)
.WriteBlock(AvfxMagic.NearClipBegin, NearClipBegin)
.WriteBlock(AvfxMagic.NearClipEnd, NearClipEnd)
.WriteBlock(AvfxMagic.FarClipBegin, FarClipBegin)
.WriteBlock(AvfxMagic.FarClipEnd, FarClipEnd)
.WriteBlock(AvfxMagic.SoftParticleFadeRange, SoftParticleFadeRange)
.WriteBlock(AvfxMagic.SoftKeyOffset, SoftKeyOffset)
.WriteBlock(AvfxMagic.DrawLayerType, DrawLayerType)
.WriteBlock(AvfxMagic.DrawOrderType, DrawOrderType)
.WriteBlock(AvfxMagic.DirectionalLightSourceType, DirectionalLightSourceType)
.WriteBlock(AvfxMagic.PointLightsType1, PointLightsType1)
.WriteBlock(AvfxMagic.PointLightsType2, PointLightsType2)
.WriteBlock(AvfxMagic.RevisedValuesPosX, RevisedValuesPos.X)
.WriteBlock(AvfxMagic.RevisedValuesPosY, RevisedValuesPos.Y)
.WriteBlock(AvfxMagic.RevisedValuesPosZ, RevisedValuesPos.Z)
.WriteBlock(AvfxMagic.RevisedValuesRotX, RevisedValuesRot.X)
.WriteBlock(AvfxMagic.RevisedValuesRotY, RevisedValuesRot.Y)
.WriteBlock(AvfxMagic.RevisedValuesRotZ, RevisedValuesRot.Z)
.WriteBlock(AvfxMagic.RevisedValuesScaleX, RevisedValuesScale.X)
.WriteBlock(AvfxMagic.RevisedValuesScaleY, RevisedValuesScale.Y)
.WriteBlock(AvfxMagic.RevisedValuesScaleZ, RevisedValuesScale.Z)
.WriteBlock(AvfxMagic.RevisedValuesColorR, RevisedValuesColor.X)
.WriteBlock(AvfxMagic.RevisedValuesColorG, RevisedValuesColor.Y)
.WriteBlock(AvfxMagic.RevisedValuesColorB, RevisedValuesColor.Z)
.WriteBlock(AvfxMagic.FadeEnabledX, FadeEnabledX)
.WriteBlock(AvfxMagic.FadeInnerX, FadeInnerX)
.WriteBlock(AvfxMagic.FadeOuterX, FadeOuterX)
.WriteBlock(AvfxMagic.FadeEnabledY, FadeEnabledY)
.WriteBlock(AvfxMagic.FadeInnerY, FadeInnerY)
.WriteBlock(AvfxMagic.FadeOuterY, FadeOuterY)
.WriteBlock(AvfxMagic.FadeEnabledZ, FadeEnabledZ)
.WriteBlock(AvfxMagic.FadeInnerZ, FadeInnerZ)
.WriteBlock(AvfxMagic.FadeOuterZ, FadeOuterZ)
.WriteBlock(AvfxMagic.GlobalFogEnabled, GlobalFogEnabled)
.WriteBlock(AvfxMagic.GlobalFogInfluence, GlobalFogInfluence)
.WriteBlock(AvfxMagic.LtsEnabled, LtsEnabled)
.WriteBlock(AvfxMagic.NumSchedulers, (uint)Schedulers.Length)
.WriteBlock(AvfxMagic.NumTimelines, (uint)Timelines.Length)
.WriteBlock(AvfxMagic.NumEmitters, (uint)Emitters.Length)
.WriteBlock(AvfxMagic.NumParticles, (uint)Particles.Length)
.WriteBlock(AvfxMagic.NumEffectors, (uint)Effectors.Length)
.WriteBlock(AvfxMagic.NumBinders, (uint)Binders.Length)
.WriteBlock(AvfxMagic.NumTextures, (uint)Textures.Length)
.WriteBlock(AvfxMagic.NumModels, (uint)Models.Length);
foreach (var block in Schedulers)
w.WriteBlock(block);
foreach (var block in Timelines)
w.WriteBlock(block);
foreach (var block in Emitters)
w.WriteBlock(block);
foreach (var block in Particles)
w.WriteBlock(block);
foreach (var block in Effectors)
w.WriteBlock(block);
foreach (var block in Binders)
w.WriteBlock(block);
foreach (var texture in Textures)
w.WriteTextureBlock(texture);
foreach (var block in Models)
w.WriteBlock(block);
w.Seek((int)sizePos, SeekOrigin.Begin);
w.Write((uint)w.BaseStream.Length - 8u);
return m.ToArray();
}
}

View file

@ -1,149 +0,0 @@
using System.IO;
using System.Numerics;
using System.Text;
// ReSharper disable ShiftExpressionZeroLeftOperand
namespace Penumbra.GameData.Files;
public static class AvfxMagic
{
public const uint AvfxBase = ('A' << 24) | ('V' << 16) | ('F' << 8) | (uint)'X';
public const uint Version = (000 << 24) | ('V' << 16) | ('e' << 8) | (uint)'r';
public const uint IsDelayFastParticle = ('b' << 24) | ('D' << 16) | ('F' << 8) | (uint)'P';
public const uint IsFitGround = (000 << 24) | ('b' << 16) | ('F' << 8) | (uint)'G';
public const uint IsTransformSkip = (000 << 24) | ('b' << 16) | ('T' << 8) | (uint)'S';
public const uint IsAllStopOnHide = ('b' << 24) | ('A' << 16) | ('S' << 8) | (uint)'H';
public const uint CanBeClippedOut = ('b' << 24) | ('C' << 16) | ('B' << 8) | (uint)'C';
public const uint ClipBoxEnabled = ('b' << 24) | ('C' << 16) | ('u' << 8) | (uint)'l';
public const uint ClipBoxX = ('C' << 24) | ('B' << 16) | ('P' << 8) | (uint)'x';
public const uint ClipBoxY = ('C' << 24) | ('B' << 16) | ('P' << 8) | (uint)'y';
public const uint ClipBoxZ = ('C' << 24) | ('B' << 16) | ('P' << 8) | (uint)'z';
public const uint ClipBoxSizeX = ('C' << 24) | ('B' << 16) | ('S' << 8) | (uint)'x';
public const uint ClipBoxSizeY = ('C' << 24) | ('B' << 16) | ('S' << 8) | (uint)'y';
public const uint ClipBoxSizeZ = ('C' << 24) | ('B' << 16) | ('S' << 8) | (uint)'z';
public const uint BiasZmaxScale = ('Z' << 24) | ('B' << 16) | ('M' << 8) | (uint)'s';
public const uint BiasZmaxDistance = ('Z' << 24) | ('B' << 16) | ('M' << 8) | (uint)'d';
public const uint IsCameraSpace = ('b' << 24) | ('C' << 16) | ('m' << 8) | (uint)'S';
public const uint IsFullEnvLight = ('b' << 24) | ('F' << 16) | ('E' << 8) | (uint)'L';
public const uint IsClipOwnSetting = ('b' << 24) | ('O' << 16) | ('S' << 8) | (uint)'t';
public const uint NearClipBegin = (000 << 24) | ('N' << 16) | ('C' << 8) | (uint)'B';
public const uint NearClipEnd = (000 << 24) | ('N' << 16) | ('C' << 8) | (uint)'E';
public const uint FarClipBegin = (000 << 24) | ('F' << 16) | ('C' << 8) | (uint)'B';
public const uint FarClipEnd = (000 << 24) | ('F' << 16) | ('C' << 8) | (uint)'E';
public const uint SoftParticleFadeRange = ('S' << 24) | ('P' << 16) | ('F' << 8) | (uint)'R';
public const uint SoftKeyOffset = (000 << 24) | ('S' << 16) | ('K' << 8) | (uint)'O';
public const uint DrawLayerType = ('D' << 24) | ('w' << 16) | ('L' << 8) | (uint)'y';
public const uint DrawOrderType = ('D' << 24) | ('w' << 16) | ('O' << 8) | (uint)'T';
public const uint DirectionalLightSourceType = ('D' << 24) | ('L' << 16) | ('S' << 8) | (uint)'T';
public const uint PointLightsType1 = ('P' << 24) | ('L' << 16) | ('1' << 8) | (uint)'S';
public const uint PointLightsType2 = ('P' << 24) | ('L' << 16) | ('2' << 8) | (uint)'S';
public const uint RevisedValuesPosX = ('R' << 24) | ('v' << 16) | ('P' << 8) | (uint)'x';
public const uint RevisedValuesPosY = ('R' << 24) | ('v' << 16) | ('P' << 8) | (uint)'y';
public const uint RevisedValuesPosZ = ('R' << 24) | ('v' << 16) | ('P' << 8) | (uint)'z';
public const uint RevisedValuesRotX = ('R' << 24) | ('v' << 16) | ('R' << 8) | (uint)'x';
public const uint RevisedValuesRotY = ('R' << 24) | ('v' << 16) | ('R' << 8) | (uint)'y';
public const uint RevisedValuesRotZ = ('R' << 24) | ('v' << 16) | ('R' << 8) | (uint)'z';
public const uint RevisedValuesScaleX = ('R' << 24) | ('v' << 16) | ('S' << 8) | (uint)'x';
public const uint RevisedValuesScaleY = ('R' << 24) | ('v' << 16) | ('S' << 8) | (uint)'y';
public const uint RevisedValuesScaleZ = ('R' << 24) | ('v' << 16) | ('S' << 8) | (uint)'z';
public const uint RevisedValuesColorR = (000 << 24) | ('R' << 16) | ('v' << 8) | (uint)'R';
public const uint RevisedValuesColorG = (000 << 24) | ('R' << 16) | ('v' << 8) | (uint)'G';
public const uint RevisedValuesColorB = (000 << 24) | ('R' << 16) | ('v' << 8) | (uint)'B';
public const uint FadeEnabledX = ('A' << 24) | ('F' << 16) | ('X' << 8) | (uint)'e';
public const uint FadeInnerX = ('A' << 24) | ('F' << 16) | ('X' << 8) | (uint)'i';
public const uint FadeOuterX = ('A' << 24) | ('F' << 16) | ('X' << 8) | (uint)'o';
public const uint FadeEnabledY = ('A' << 24) | ('F' << 16) | ('Y' << 8) | (uint)'e';
public const uint FadeInnerY = ('A' << 24) | ('F' << 16) | ('Y' << 8) | (uint)'i';
public const uint FadeOuterY = ('A' << 24) | ('F' << 16) | ('Y' << 8) | (uint)'o';
public const uint FadeEnabledZ = ('A' << 24) | ('F' << 16) | ('Z' << 8) | (uint)'e';
public const uint FadeInnerZ = ('A' << 24) | ('F' << 16) | ('Z' << 8) | (uint)'i';
public const uint FadeOuterZ = ('A' << 24) | ('F' << 16) | ('Z' << 8) | (uint)'o';
public const uint GlobalFogEnabled = ('b' << 24) | ('G' << 16) | ('F' << 8) | (uint)'E';
public const uint GlobalFogInfluence = ('G' << 24) | ('F' << 16) | ('I' << 8) | (uint)'M';
public const uint LtsEnabled = ('b' << 24) | ('L' << 16) | ('T' << 8) | (uint)'S';
public const uint NumSchedulers = ('S' << 24) | ('c' << 16) | ('C' << 8) | (uint)'n';
public const uint NumTimelines = ('T' << 24) | ('l' << 16) | ('C' << 8) | (uint)'n';
public const uint NumEmitters = ('E' << 24) | ('m' << 16) | ('C' << 8) | (uint)'n';
public const uint NumParticles = ('P' << 24) | ('r' << 16) | ('C' << 8) | (uint)'n';
public const uint NumEffectors = ('E' << 24) | ('f' << 16) | ('C' << 8) | (uint)'n';
public const uint NumBinders = ('B' << 24) | ('d' << 16) | ('C' << 8) | (uint)'n';
public const uint NumTextures = ('T' << 24) | ('x' << 16) | ('C' << 8) | (uint)'n';
public const uint NumModels = ('M' << 24) | ('d' << 16) | ('C' << 8) | (uint)'n';
public const uint Scheduler = ('S' << 24) | ('c' << 16) | ('h' << 8) | (uint)'d';
public const uint Timeline = ('T' << 24) | ('m' << 16) | ('L' << 8) | (uint)'n';
public const uint Emitter = ('E' << 24) | ('m' << 16) | ('i' << 8) | (uint)'t';
public const uint Particle = ('P' << 24) | ('t' << 16) | ('c' << 8) | (uint)'l';
public const uint Effector = ('E' << 24) | ('f' << 16) | ('c' << 8) | (uint)'t';
public const uint Binder = ('B' << 24) | ('i' << 16) | ('n' << 8) | (uint)'d';
public const uint Texture = (000 << 24) | ('T' << 16) | ('e' << 8) | (uint)'x';
public const uint Model = ('M' << 24) | ('o' << 16) | ('d' << 8) | (uint)'l';
internal static uint RoundTo4(this uint size)
{
var rest = size & 0b11u;
return rest > 0 ? (size & ~0b11u) + 4u : size;
}
internal static BinaryWriter WriteTextureBlock(this BinaryWriter bw, string texture)
{
bw.Write(Texture);
var bytes = Encoding.UTF8.GetBytes(texture);
var size = (uint)bytes.Length + 1u;
bw.Write(size);
bw.Write(bytes);
bw.Write((byte)0);
for (var end = size.RoundTo4(); size < end; ++size)
bw.Write((byte)0);
return bw;
}
internal static BinaryWriter WriteBlock(this BinaryWriter bw, AvfxFile.Block block)
{
bw.Write(block.Name);
bw.Write(block.Size);
bw.Write(block.Data);
return bw;
}
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magic, uint value)
{
if (value != uint.MaxValue)
{
bw.Write(magic);
bw.Write(4u);
bw.Write(value);
}
return bw;
}
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magic, byte value)
{
if (value != byte.MaxValue)
{
bw.Write(magic);
bw.Write(4u);
bw.Write(value == 1 ? 1u : 0u);
}
return bw;
}
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magic, float value)
{
if (!float.IsNaN(value))
{
bw.Write(magic);
bw.Write(4u);
bw.Write(value);
}
return bw;
}
internal static BinaryWriter WriteBlock(this BinaryWriter bw, uint magicX, uint magicY, uint magicZ, Vector3 value)
=> bw.WriteBlock(magicX, value.X)
.WriteBlock(magicY, value.Y)
.WriteBlock(magicZ, value.Z);
}

View file

@ -1,7 +0,0 @@
namespace Penumbra.GameData.Files;
public interface IWritable
{
public bool Valid { get; }
public byte[] Write();
}

View file

@ -1,285 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Lumina.Data.Parsing;
namespace Penumbra.GameData.Files;
public partial class MdlFile
{
private static uint Write(BinaryWriter w, string s, long basePos)
{
var currentPos = w.BaseStream.Position;
w.Write(Encoding.UTF8.GetBytes(s));
w.Write((byte)0);
return (uint)(currentPos - basePos);
}
private List<uint> WriteStrings(BinaryWriter w)
{
var startPos = (int)w.BaseStream.Position;
var basePos = startPos + 8;
var count = (ushort)(Attributes.Length + Bones.Length + Materials.Length + Shapes.Length);
w.Write(count);
w.Seek(basePos, SeekOrigin.Begin);
var ret = Attributes.Concat(Bones)
.Concat(Materials)
.Concat(Shapes.Select(s => s.ShapeName))
.Select(attribute => Write(w, attribute, basePos)).ToList();
var padding = (w.BaseStream.Position & 0b111) > 0 ? (w.BaseStream.Position & ~0b111) + 8 : w.BaseStream.Position;
for (var i = w.BaseStream.Position; i < padding; ++i)
w.Write((byte)0);
var size = (int)w.BaseStream.Position - basePos;
w.Seek(startPos + 4, SeekOrigin.Begin);
w.Write((uint)size);
w.Seek(basePos + size, SeekOrigin.Begin);
return ret;
}
private void WriteModelFileHeader(BinaryWriter w, uint runtimeSize)
{
w.Write(Version);
w.Write(StackSize);
w.Write(runtimeSize);
w.Write((ushort)VertexDeclarations.Length);
w.Write((ushort)Materials.Length);
w.Write(VertexOffset[0] > 0 ? VertexOffset[0] + runtimeSize : 0u);
w.Write(VertexOffset[1] > 0 ? VertexOffset[1] + runtimeSize : 0u);
w.Write(VertexOffset[2] > 0 ? VertexOffset[2] + runtimeSize : 0u);
w.Write(IndexOffset[0] > 0 ? IndexOffset[0] + runtimeSize : 0u);
w.Write(IndexOffset[1] > 0 ? IndexOffset[1] + runtimeSize : 0u);
w.Write(IndexOffset[2] > 0 ? IndexOffset[2] + runtimeSize : 0u);
w.Write(VertexBufferSize[0]);
w.Write(VertexBufferSize[1]);
w.Write(VertexBufferSize[2]);
w.Write(IndexBufferSize[0]);
w.Write(IndexBufferSize[1]);
w.Write(IndexBufferSize[2]);
w.Write(LodCount);
w.Write(EnableIndexBufferStreaming);
w.Write(EnableEdgeGeometry);
w.Write((byte)0); // Padding
}
private void WriteModelHeader(BinaryWriter w)
{
w.Write(Radius);
w.Write((ushort)Meshes.Length);
w.Write((ushort)Attributes.Length);
w.Write((ushort)SubMeshes.Length);
w.Write((ushort)Materials.Length);
w.Write((ushort)Bones.Length);
w.Write((ushort)BoneTables.Length);
w.Write((ushort)Shapes.Length);
w.Write((ushort)ShapeMeshes.Length);
w.Write((ushort)ShapeValues.Length);
w.Write(LodCount);
w.Write((byte)Flags1);
w.Write((ushort)ElementIds.Length);
w.Write((byte)TerrainShadowMeshes.Length);
w.Write((byte)Flags2);
w.Write(ModelClipOutDistance);
w.Write(ShadowClipOutDistance);
w.Write(Unknown4);
w.Write((ushort)TerrainShadowSubMeshes.Length);
w.Write(Unknown5);
w.Write(BgChangeMaterialIndex);
w.Write(BgCrestChangeMaterialIndex);
w.Write(Unknown6);
w.Write(Unknown7);
w.Write(Unknown8);
w.Write(Unknown9);
w.Write((uint)0); // 6 byte padding
w.Write((ushort)0);
}
private static void Write(BinaryWriter w, in MdlStructs.VertexElement vertex)
{
w.Write(vertex.Stream);
w.Write(vertex.Offset);
w.Write(vertex.Type);
w.Write(vertex.Usage);
w.Write(vertex.UsageIndex);
w.Write((ushort)0); // 3 byte padding
w.Write((byte)0);
}
private static void Write(BinaryWriter w, in MdlStructs.VertexDeclarationStruct vertexDecl)
{
foreach (var vertex in vertexDecl.VertexElements)
Write(w, vertex);
Write(w, new MdlStructs.VertexElement() { Stream = 255 });
w.Seek((int)(NumVertices - 1 - vertexDecl.VertexElements.Length) * 8, SeekOrigin.Current);
}
private static void Write(BinaryWriter w, in MdlStructs.ElementIdStruct elementId)
{
w.Write(elementId.ElementId);
w.Write(elementId.ParentBoneName);
w.Write(elementId.Translate[0]);
w.Write(elementId.Translate[1]);
w.Write(elementId.Translate[2]);
w.Write(elementId.Rotate[0]);
w.Write(elementId.Rotate[1]);
w.Write(elementId.Rotate[2]);
}
private static unsafe void Write<T>(BinaryWriter w, in T data) where T : unmanaged
{
fixed (T* ptr = &data)
{
var bytePtr = (byte*)ptr;
var size = sizeof(T);
var span = new ReadOnlySpan<byte>(bytePtr, size);
w.Write(span);
}
}
private static void Write(BinaryWriter w, MdlStructs.MeshStruct mesh)
{
w.Write(mesh.VertexCount);
w.Write((ushort)0); // padding
w.Write(mesh.IndexCount);
w.Write(mesh.MaterialIndex);
w.Write(mesh.SubMeshIndex);
w.Write(mesh.SubMeshCount);
w.Write(mesh.BoneTableIndex);
w.Write(mesh.StartIndex);
w.Write(mesh.VertexBufferOffset[0]);
w.Write(mesh.VertexBufferOffset[1]);
w.Write(mesh.VertexBufferOffset[2]);
w.Write(mesh.VertexBufferStride[0]);
w.Write(mesh.VertexBufferStride[1]);
w.Write(mesh.VertexBufferStride[2]);
w.Write(mesh.VertexStreamCount);
}
private static void Write(BinaryWriter w, MdlStructs.BoneTableStruct bone)
{
foreach (var index in bone.BoneIndex)
w.Write(index);
w.Write(bone.BoneCount);
w.Write((ushort)0); // 3 bytes padding
w.Write((byte)0);
}
private void Write(BinaryWriter w, int shapeIdx, IReadOnlyList<uint> offsets)
{
var shape = Shapes[shapeIdx];
var offset = offsets[Attributes.Length + Bones.Length + Materials.Length + shapeIdx];
w.Write(offset);
w.Write(shape.ShapeMeshStartIndex[0]);
w.Write(shape.ShapeMeshStartIndex[1]);
w.Write(shape.ShapeMeshStartIndex[2]);
w.Write(shape.ShapeMeshCount[0]);
w.Write(shape.ShapeMeshCount[1]);
w.Write(shape.ShapeMeshCount[2]);
}
private static void Write(BinaryWriter w, MdlStructs.BoundingBoxStruct box)
{
w.Write(box.Min[0]);
w.Write(box.Min[1]);
w.Write(box.Min[2]);
w.Write(box.Min[3]);
w.Write(box.Max[0]);
w.Write(box.Max[1]);
w.Write(box.Max[2]);
w.Write(box.Max[3]);
}
public byte[] Write()
{
using var stream = new MemoryStream();
using (var w = new BinaryWriter(stream))
{
// Skip and write this later when we actually know it.
w.Seek((int)FileHeaderSize, SeekOrigin.Begin);
foreach (var vertexDecl in VertexDeclarations)
Write(w, vertexDecl);
var offsets = WriteStrings(w);
WriteModelHeader(w);
foreach (var elementId in ElementIds)
Write(w, elementId);
foreach (var lod in Lods)
Write(w, lod);
if (Flags2.HasFlag(MdlStructs.ModelFlags2.ExtraLodEnabled))
foreach (var extraLod in ExtraLods)
Write(w, extraLod);
foreach (var mesh in Meshes)
Write(w, mesh);
for (var i = 0; i < Attributes.Length; ++i)
w.Write(offsets[i]);
foreach (var terrainShadowMesh in TerrainShadowMeshes)
Write(w, terrainShadowMesh);
foreach (var subMesh in SubMeshes)
Write(w, subMesh);
foreach (var terrainShadowSubMesh in TerrainShadowSubMeshes)
Write(w, terrainShadowSubMesh);
for (var i = 0; i < Materials.Length; ++i)
w.Write(offsets[Attributes.Length + Bones.Length + i]);
for (var i = 0; i < Bones.Length; ++i)
w.Write(offsets[Attributes.Length + i]);
foreach (var boneTable in BoneTables)
Write(w, boneTable);
for (var i = 0; i < Shapes.Length; ++i)
Write(w, i, offsets);
foreach (var shapeMesh in ShapeMeshes)
Write(w, shapeMesh);
foreach (var shapeValue in ShapeValues)
Write(w, shapeValue);
w.Write(SubMeshBoneMap.Length * 2);
foreach (var bone in SubMeshBoneMap)
w.Write(bone);
var pos = w.BaseStream.Position + 1;
var padding = (byte) (pos & 0b111);
if (padding > 0)
padding = (byte) (8 - padding);
w.Write(padding);
for (var i = 0; i < padding; ++i)
w.Write((byte) (0xDEADBEEFF00DCAFEu >> (8 * (7 - i))));
Write(w, BoundingBoxes);
Write(w, ModelBoundingBoxes);
Write(w, WaterBoundingBoxes);
Write(w, VerticalFogBoundingBoxes);
foreach (var box in BoneBoundingBoxes)
Write(w, box);
var totalSize = w.BaseStream.Position;
var runtimeSize = (uint)(totalSize - StackSize - FileHeaderSize);
w.Write(RemainingData);
// Write header data.
w.Seek(0, SeekOrigin.Begin);
WriteModelFileHeader(w, runtimeSize);
}
return stream.ToArray();
}
}

View file

@ -1,249 +0,0 @@
using System;
using System.IO;
using System.Reflection;
using System.Text;
using Lumina.Data;
using Lumina.Data.Parsing;
using Lumina.Extensions;
namespace Penumbra.GameData.Files;
public partial class MdlFile : IWritable
{
public const uint NumVertices = 17;
public const uint FileHeaderSize = 0x44;
// Refers to string, thus not Lumina struct.
public struct Shape
{
public string ShapeName = string.Empty;
public ushort[] ShapeMeshStartIndex;
public ushort[] ShapeMeshCount;
public Shape(MdlStructs.ShapeStruct data, uint[] offsets, string[] strings)
{
var idx = offsets.AsSpan().IndexOf(data.StringOffset);
ShapeName = idx >= 0 ? strings[idx] : string.Empty;
ShapeMeshStartIndex = data.ShapeMeshStartIndex;
ShapeMeshCount = data.ShapeMeshCount;
}
}
// Raw data to write back.
public uint Version;
public float Radius;
public float ModelClipOutDistance;
public float ShadowClipOutDistance;
public byte BgChangeMaterialIndex;
public byte BgCrestChangeMaterialIndex;
public ushort Unknown4;
public byte Unknown5;
public byte Unknown6;
public ushort Unknown7;
public ushort Unknown8;
public ushort Unknown9;
// Offsets are stored relative to RuntimeSize instead of file start.
public uint[] VertexOffset;
public uint[] IndexOffset;
public uint[] VertexBufferSize;
public uint[] IndexBufferSize;
public byte LodCount;
public bool EnableIndexBufferStreaming;
public bool EnableEdgeGeometry;
public MdlStructs.ModelFlags1 Flags1;
public MdlStructs.ModelFlags2 Flags2;
public MdlStructs.BoundingBoxStruct BoundingBoxes;
public MdlStructs.BoundingBoxStruct ModelBoundingBoxes;
public MdlStructs.BoundingBoxStruct WaterBoundingBoxes;
public MdlStructs.BoundingBoxStruct VerticalFogBoundingBoxes;
public MdlStructs.VertexDeclarationStruct[] VertexDeclarations;
public MdlStructs.ElementIdStruct[] ElementIds;
public MdlStructs.MeshStruct[] Meshes;
public MdlStructs.BoneTableStruct[] BoneTables;
public MdlStructs.BoundingBoxStruct[] BoneBoundingBoxes;
public MdlStructs.SubmeshStruct[] SubMeshes;
public MdlStructs.ShapeMeshStruct[] ShapeMeshes;
public MdlStructs.ShapeValueStruct[] ShapeValues;
public MdlStructs.TerrainShadowMeshStruct[] TerrainShadowMeshes;
public MdlStructs.TerrainShadowSubmeshStruct[] TerrainShadowSubMeshes;
public MdlStructs.LodStruct[] Lods;
public MdlStructs.ExtraLodStruct[] ExtraLods;
public ushort[] SubMeshBoneMap;
// Strings are written in order
public string[] Attributes;
public string[] Bones;
public string[] Materials;
public Shape[] Shapes;
// Raw, unparsed data.
public byte[] RemainingData;
public bool Valid { get; }
public MdlFile(byte[] data)
{
using var stream = new MemoryStream(data);
using var r = new LuminaBinaryReader(stream);
var header = LoadModelFileHeader(r);
LodCount = header.LodCount;
VertexBufferSize = header.VertexBufferSize;
IndexBufferSize = header.IndexBufferSize;
VertexOffset = header.VertexOffset;
IndexOffset = header.IndexOffset;
for (var i = 0; i < 3; ++i)
{
if (VertexOffset[i] > 0)
VertexOffset[i] -= header.RuntimeSize;
if (IndexOffset[i] > 0)
IndexOffset[i] -= header.RuntimeSize;
}
VertexDeclarations = new MdlStructs.VertexDeclarationStruct[header.VertexDeclarationCount];
for (var i = 0; i < header.VertexDeclarationCount; ++i)
VertexDeclarations[i] = MdlStructs.VertexDeclarationStruct.Read(r);
var (offsets, strings) = LoadStrings(r);
var modelHeader = LoadModelHeader(r);
ElementIds = new MdlStructs.ElementIdStruct[modelHeader.ElementIdCount];
for (var i = 0; i < modelHeader.ElementIdCount; i++)
ElementIds[i] = MdlStructs.ElementIdStruct.Read(r);
Lods = r.ReadStructuresAsArray<MdlStructs.LodStruct>(3);
ExtraLods = modelHeader.ExtraLodEnabled
? r.ReadStructuresAsArray<MdlStructs.ExtraLodStruct>(3)
: Array.Empty<MdlStructs.ExtraLodStruct>();
Meshes = new MdlStructs.MeshStruct[modelHeader.MeshCount];
for (var i = 0; i < modelHeader.MeshCount; i++)
Meshes[i] = MdlStructs.MeshStruct.Read(r);
Attributes = new string[modelHeader.AttributeCount];
for (var i = 0; i < modelHeader.AttributeCount; ++i)
{
var offset = r.ReadUInt32();
var stringIdx = offsets.AsSpan().IndexOf(offset);
Attributes[i] = stringIdx >= 0 ? strings[stringIdx] : string.Empty;
}
TerrainShadowMeshes = r.ReadStructuresAsArray<MdlStructs.TerrainShadowMeshStruct>(modelHeader.TerrainShadowMeshCount);
SubMeshes = r.ReadStructuresAsArray<MdlStructs.SubmeshStruct>(modelHeader.SubmeshCount);
TerrainShadowSubMeshes = r.ReadStructuresAsArray<MdlStructs.TerrainShadowSubmeshStruct>(modelHeader.TerrainShadowSubmeshCount);
Materials = new string[modelHeader.MaterialCount];
for (var i = 0; i < modelHeader.MaterialCount; ++i)
{
var offset = r.ReadUInt32();
var stringIdx = offsets.AsSpan().IndexOf(offset);
Materials[i] = stringIdx >= 0 ? strings[stringIdx] : string.Empty;
}
Bones = new string[modelHeader.BoneCount];
for (var i = 0; i < modelHeader.BoneCount; ++i)
{
var offset = r.ReadUInt32();
var stringIdx = offsets.AsSpan().IndexOf(offset);
Bones[i] = stringIdx >= 0 ? strings[stringIdx] : string.Empty;
}
BoneTables = new MdlStructs.BoneTableStruct[modelHeader.BoneTableCount];
for (var i = 0; i < modelHeader.BoneTableCount; i++)
BoneTables[i] = MdlStructs.BoneTableStruct.Read(r);
Shapes = new Shape[modelHeader.ShapeCount];
for (var i = 0; i < modelHeader.ShapeCount; i++)
Shapes[i] = new Shape(MdlStructs.ShapeStruct.Read(r), offsets, strings);
ShapeMeshes = r.ReadStructuresAsArray<MdlStructs.ShapeMeshStruct>(modelHeader.ShapeMeshCount);
ShapeValues = r.ReadStructuresAsArray<MdlStructs.ShapeValueStruct>(modelHeader.ShapeValueCount);
var submeshBoneMapSize = r.ReadUInt32();
SubMeshBoneMap = r.ReadStructures<ushort>((int)submeshBoneMapSize / 2).ToArray();
var paddingAmount = r.ReadByte();
r.Seek(r.BaseStream.Position + paddingAmount);
// Dunno what this first one is for?
BoundingBoxes = MdlStructs.BoundingBoxStruct.Read(r);
ModelBoundingBoxes = MdlStructs.BoundingBoxStruct.Read(r);
WaterBoundingBoxes = MdlStructs.BoundingBoxStruct.Read(r);
VerticalFogBoundingBoxes = MdlStructs.BoundingBoxStruct.Read(r);
BoneBoundingBoxes = new MdlStructs.BoundingBoxStruct[modelHeader.BoneCount];
for (var i = 0; i < modelHeader.BoneCount; i++)
BoneBoundingBoxes[i] = MdlStructs.BoundingBoxStruct.Read(r);
var runtimePadding = header.RuntimeSize + FileHeaderSize + header.StackSize - r.BaseStream.Position;
if (runtimePadding > 0)
r.ReadBytes((int)runtimePadding);
RemainingData = r.ReadBytes((int)(r.BaseStream.Length - r.BaseStream.Position));
Valid = true;
}
private MdlStructs.ModelFileHeader LoadModelFileHeader(LuminaBinaryReader r)
{
var header = MdlStructs.ModelFileHeader.Read(r);
Version = header.Version;
EnableIndexBufferStreaming = header.EnableIndexBufferStreaming;
EnableEdgeGeometry = header.EnableEdgeGeometry;
return header;
}
private MdlStructs.ModelHeader LoadModelHeader(BinaryReader r)
{
var modelHeader = r.ReadStructure<MdlStructs.ModelHeader>();
Radius = modelHeader.Radius;
Flags1 = (MdlStructs.ModelFlags1)(modelHeader.GetType()
.GetField("Flags1", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)?.GetValue(modelHeader)
?? 0);
Flags2 = (MdlStructs.ModelFlags2)(modelHeader.GetType()
.GetField("Flags2", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)?.GetValue(modelHeader)
?? 0);
ModelClipOutDistance = modelHeader.ModelClipOutDistance;
ShadowClipOutDistance = modelHeader.ShadowClipOutDistance;
Unknown4 = modelHeader.Unknown4;
Unknown5 = (byte)(modelHeader.GetType()
.GetField("Unknown5", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)?.GetValue(modelHeader)
?? 0);
Unknown6 = modelHeader.Unknown6;
Unknown7 = modelHeader.Unknown7;
Unknown8 = modelHeader.Unknown8;
Unknown9 = modelHeader.Unknown9;
BgChangeMaterialIndex = modelHeader.BGChangeMaterialIndex;
BgCrestChangeMaterialIndex = modelHeader.BGCrestChangeMaterialIndex;
return modelHeader;
}
private static (uint[], string[]) LoadStrings(BinaryReader r)
{
var stringCount = r.ReadUInt16();
r.ReadUInt16();
var stringSize = (int)r.ReadUInt32();
var stringData = r.ReadBytes(stringSize);
var start = 0;
var strings = new string[stringCount];
var offsets = new uint[stringCount];
for (var i = 0; i < stringCount; ++i)
{
var span = stringData.AsSpan(start);
var idx = span.IndexOf((byte)'\0');
strings[i] = Encoding.UTF8.GetString(span[..idx]);
offsets[i] = (uint)start;
start = start + idx + 1;
}
return (offsets, strings);
}
public unsafe uint StackSize
=> (uint)(VertexDeclarations.Length * NumVertices * sizeof(MdlStructs.VertexElement));
}

View file

@ -1,90 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Penumbra.GameData.Files;
public partial class MtrlFile
{
public unsafe struct ColorDyeSet
{
public struct Row
{
private ushort _data;
public ushort Template
{
get => (ushort)(_data >> 5);
set => _data = (ushort)((_data & 0x1F) | (value << 5));
}
public bool Diffuse
{
get => (_data & 0x01) != 0;
set => _data = (ushort)(value ? _data | 0x01 : _data & 0xFFFE);
}
public bool Specular
{
get => (_data & 0x02) != 0;
set => _data = (ushort)(value ? _data | 0x02 : _data & 0xFFFD);
}
public bool Emissive
{
get => (_data & 0x04) != 0;
set => _data = (ushort)(value ? _data | 0x04 : _data & 0xFFFB);
}
public bool Gloss
{
get => (_data & 0x08) != 0;
set => _data = (ushort)(value ? _data | 0x08 : _data & 0xFFF7);
}
public bool SpecularStrength
{
get => (_data & 0x10) != 0;
set => _data = (ushort)(value ? _data | 0x10 : _data & 0xFFEF);
}
}
public struct RowArray : IEnumerable<Row>
{
public const int NumRows = 16;
private fixed ushort _rowData[NumRows];
public ref Row this[int i]
{
get
{
fixed (ushort* ptr = _rowData)
{
return ref ((Row*)ptr)[i];
}
}
}
public IEnumerator<Row> GetEnumerator()
{
for (var i = 0; i < NumRows; ++i)
yield return this[i];
}
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
public ReadOnlySpan<byte> AsBytes()
{
fixed (ushort* ptr = _rowData)
{
return new ReadOnlySpan<byte>(ptr, NumRows * sizeof(ushort));
}
}
}
public RowArray Rows;
public string Name;
public ushort Index;
}
}

View file

@ -1,135 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
namespace Penumbra.GameData.Files;
public partial class MtrlFile
{
public unsafe struct ColorSet
{
public struct Row
{
public const int Size = 32;
private fixed ushort _data[16];
public Vector3 Diffuse
{
get => new(ToFloat(0), ToFloat(1), ToFloat(2));
set
{
_data[0] = FromFloat(value.X);
_data[1] = FromFloat(value.Y);
_data[2] = FromFloat(value.Z);
}
}
public Vector3 Specular
{
get => new(ToFloat(4), ToFloat(5), ToFloat(6));
set
{
_data[4] = FromFloat(value.X);
_data[5] = FromFloat(value.Y);
_data[6] = FromFloat(value.Z);
}
}
public Vector3 Emissive
{
get => new(ToFloat(8), ToFloat(9), ToFloat(10));
set
{
_data[8] = FromFloat(value.X);
_data[9] = FromFloat(value.Y);
_data[10] = FromFloat(value.Z);
}
}
public Vector2 MaterialRepeat
{
get => new(ToFloat(12), ToFloat(15));
set
{
_data[12] = FromFloat(value.X);
_data[15] = FromFloat(value.Y);
}
}
public Vector2 MaterialSkew
{
get => new(ToFloat(13), ToFloat(14));
set
{
_data[13] = FromFloat(value.X);
_data[14] = FromFloat(value.Y);
}
}
public float SpecularStrength
{
get => ToFloat(3);
set => _data[3] = FromFloat(value);
}
public float GlossStrength
{
get => ToFloat(7);
set => _data[7] = FromFloat(value);
}
public ushort TileSet
{
get => (ushort)(ToFloat(11) * 64f);
set => _data[11] = FromFloat(value / 64f);
}
private float ToFloat(int idx)
=> (float)BitConverter.UInt16BitsToHalf(_data[idx]);
private static ushort FromFloat(float x)
=> BitConverter.HalfToUInt16Bits((Half)x);
}
public struct RowArray : IEnumerable<Row>
{
public const int NumRows = 16;
private fixed byte _rowData[NumRows * Row.Size];
public ref Row this[int i]
{
get
{
fixed (byte* ptr = _rowData)
{
return ref ((Row*)ptr)[i];
}
}
}
public IEnumerator<Row> GetEnumerator()
{
for (var i = 0; i < NumRows; ++i)
yield return this[i];
}
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
public ReadOnlySpan<byte> AsBytes()
{
fixed (byte* ptr = _rowData)
{
return new ReadOnlySpan<byte>(ptr, NumRows * Row.Size);
}
}
}
public RowArray Rows;
public string Name;
public ushort Index;
public bool HasRows;
}
}

View file

@ -1,116 +0,0 @@
using System.IO;
using System.Linq;
using System.Text;
namespace Penumbra.GameData.Files;
public partial class MtrlFile
{
public byte[] Write()
{
using var stream = new MemoryStream();
using( var w = new BinaryWriter( stream ) )
{
const int materialHeaderSize = 4 + 2 + 2 + 2 + 2 + 1 + 1 + 1 + 1;
w.BaseStream.Seek( materialHeaderSize, SeekOrigin.Begin );
ushort cumulativeStringOffset = 0;
foreach( var texture in Textures )
{
w.Write( cumulativeStringOffset );
w.Write( texture.Flags );
cumulativeStringOffset += ( ushort )( texture.Path.Length + 1 );
}
foreach( var set in UvSets )
{
w.Write( cumulativeStringOffset );
w.Write( set.Index );
cumulativeStringOffset += ( ushort )( set.Name.Length + 1 );
}
foreach( var set in ColorSets )
{
w.Write( cumulativeStringOffset );
w.Write( set.Index );
cumulativeStringOffset += ( ushort )( set.Name.Length + 1 );
}
foreach( var text in Textures.Select( t => t.Path )
.Concat( UvSets.Select( c => c.Name ) )
.Concat( ColorSets.Select( c => c.Name ) )
.Append( ShaderPackage.Name ) )
{
w.Write( Encoding.UTF8.GetBytes( text ) );
w.Write( ( byte )'\0' );
}
w.Write( AdditionalData );
var dataSetSize = 0;
foreach( var row in ColorSets.Where( c => c.HasRows ).Select( c => c.Rows ) )
{
var span = row.AsBytes();
w.Write( span );
dataSetSize += span.Length;
}
foreach( var row in ColorDyeSets.Select( c => c.Rows ) )
{
var span = row.AsBytes();
w.Write( span );
dataSetSize += span.Length;
}
w.Write( ( ushort )( ShaderPackage.ShaderValues.Length * 4 ) );
w.Write( ( ushort )ShaderPackage.ShaderKeys.Length );
w.Write( ( ushort )ShaderPackage.Constants.Length );
w.Write( ( ushort )ShaderPackage.Samplers.Length );
w.Write( ShaderPackage.Flags );
foreach( var key in ShaderPackage.ShaderKeys )
{
w.Write( key.Category );
w.Write( key.Value );
}
foreach( var constant in ShaderPackage.Constants )
{
w.Write( constant.Id );
w.Write( constant.ByteOffset );
w.Write( constant.ByteSize );
}
foreach( var sampler in ShaderPackage.Samplers )
{
w.Write( sampler.SamplerId );
w.Write( sampler.Flags );
w.Write( sampler.TextureIndex );
w.Write( ( ushort )0 );
w.Write( ( byte )0 );
}
foreach( var value in ShaderPackage.ShaderValues )
{
w.Write( value );
}
WriteHeader( w, ( ushort )w.BaseStream.Position, dataSetSize, cumulativeStringOffset );
}
return stream.ToArray();
}
private void WriteHeader( BinaryWriter w, ushort fileSize, int dataSetSize, ushort shaderPackageNameOffset )
{
w.BaseStream.Seek( 0, SeekOrigin.Begin );
w.Write( Version );
w.Write( fileSize );
w.Write( ( ushort )dataSetSize );
w.Write( ( ushort )( shaderPackageNameOffset + ShaderPackage.Name.Length + 1 ) );
w.Write( shaderPackageNameOffset );
w.Write( ( byte )Textures.Length );
w.Write( ( byte )UvSets.Length );
w.Write( ( byte )ColorSets.Length );
w.Write( ( byte )AdditionalData.Length );
}
}

View file

@ -1,243 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Lumina.Data.Parsing;
using Lumina.Extensions;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData.Files;
public partial class MtrlFile : IWritable
{
public readonly uint Version;
public bool Valid
=> CheckTextures();
public Texture[] Textures;
public UvSet[] UvSets;
public ColorSet[] ColorSets;
public ColorDyeSet[] ColorDyeSets;
public ShaderPackageData ShaderPackage;
public byte[] AdditionalData;
public bool ApplyDyeTemplate(StmFile stm, int colorSetIdx, int rowIdx, StainId stainId)
{
if (colorSetIdx < 0 || colorSetIdx >= ColorDyeSets.Length || rowIdx is < 0 or >= ColorSet.RowArray.NumRows)
return false;
var dyeSet = ColorDyeSets[colorSetIdx].Rows[rowIdx];
if (!stm.TryGetValue(dyeSet.Template, stainId, out var dyes))
return false;
var ret = false;
if (dyeSet.Diffuse && ColorSets[colorSetIdx].Rows[rowIdx].Diffuse != dyes.Diffuse)
{
ColorSets[colorSetIdx].Rows[rowIdx].Diffuse = dyes.Diffuse;
ret = true;
}
if (dyeSet.Specular && ColorSets[colorSetIdx].Rows[rowIdx].Specular != dyes.Specular)
{
ColorSets[colorSetIdx].Rows[rowIdx].Specular = dyes.Specular;
ret = true;
}
if (dyeSet.SpecularStrength && ColorSets[colorSetIdx].Rows[rowIdx].SpecularStrength != dyes.SpecularPower)
{
ColorSets[colorSetIdx].Rows[rowIdx].SpecularStrength = dyes.SpecularPower;
ret = true;
}
if (dyeSet.Emissive && ColorSets[colorSetIdx].Rows[rowIdx].Emissive != dyes.Emissive)
{
ColorSets[colorSetIdx].Rows[rowIdx].Emissive = dyes.Emissive;
ret = true;
}
if (dyeSet.Gloss && ColorSets[colorSetIdx].Rows[rowIdx].GlossStrength != dyes.Gloss)
{
ColorSets[colorSetIdx].Rows[rowIdx].GlossStrength = dyes.Gloss;
ret = true;
}
return ret;
}
public Span<float> GetConstantValues(Constant constant)
{
if ((constant.ByteOffset & 0x3) != 0
|| (constant.ByteSize & 0x3) != 0
|| (constant.ByteOffset + constant.ByteSize) >> 2 > ShaderPackage.ShaderValues.Length)
return null;
return ShaderPackage.ShaderValues.AsSpan().Slice(constant.ByteOffset >> 2, constant.ByteSize >> 2);
}
public List<(Sampler?, ShpkFile.Resource?)> GetSamplersByTexture(ShpkFile? shpk)
{
var samplers = new List<(Sampler?, ShpkFile.Resource?)>();
for (var i = 0; i < Textures.Length; ++i)
{
samplers.Add((null, null));
}
foreach (var sampler in ShaderPackage.Samplers)
{
samplers[sampler.TextureIndex] = (sampler, shpk?.GetSamplerById(sampler.SamplerId));
}
return samplers;
}
public MtrlFile(byte[] data)
{
using var stream = new MemoryStream(data);
using var r = new BinaryReader(stream);
Version = r.ReadUInt32();
r.ReadUInt16(); // file size
var dataSetSize = r.ReadUInt16();
var stringTableSize = r.ReadUInt16();
var shaderPackageNameOffset = r.ReadUInt16();
var textureCount = r.ReadByte();
var uvSetCount = r.ReadByte();
var colorSetCount = r.ReadByte();
var additionalDataSize = r.ReadByte();
Textures = ReadTextureOffsets(r, textureCount, out var textureOffsets);
UvSets = ReadUvSetOffsets(r, uvSetCount, out var uvOffsets);
ColorSets = ReadColorSetOffsets(r, colorSetCount, out var colorOffsets);
var strings = r.ReadBytes(stringTableSize);
for (var i = 0; i < textureCount; ++i)
Textures[i].Path = UseOffset(strings, textureOffsets[i]);
for (var i = 0; i < uvSetCount; ++i)
UvSets[i].Name = UseOffset(strings, uvOffsets[i]);
for (var i = 0; i < colorSetCount; ++i)
ColorSets[i].Name = UseOffset(strings, colorOffsets[i]);
ColorDyeSets = ColorSets.Length * ColorSet.RowArray.NumRows * ColorSet.Row.Size < dataSetSize
? ColorSets.Select(c => new ColorDyeSet
{
Index = c.Index,
Name = c.Name,
}).ToArray()
: Array.Empty<ColorDyeSet>();
ShaderPackage.Name = UseOffset(strings, shaderPackageNameOffset);
AdditionalData = r.ReadBytes(additionalDataSize);
for (var i = 0; i < ColorSets.Length; ++i)
{
if (stream.Position + ColorSet.RowArray.NumRows * ColorSet.Row.Size <= stream.Length)
{
ColorSets[i].Rows = r.ReadStructure<ColorSet.RowArray>();
ColorSets[i].HasRows = true;
}
else
{
ColorSets[i].HasRows = false;
}
}
for (var i = 0; i < ColorDyeSets.Length; ++i)
ColorDyeSets[i].Rows = r.ReadStructure<ColorDyeSet.RowArray>();
var shaderValueListSize = r.ReadUInt16();
var shaderKeyCount = r.ReadUInt16();
var constantCount = r.ReadUInt16();
var samplerCount = r.ReadUInt16();
ShaderPackage.Flags = r.ReadUInt32();
ShaderPackage.ShaderKeys = r.ReadStructuresAsArray<ShaderKey>(shaderKeyCount);
ShaderPackage.Constants = r.ReadStructuresAsArray<Constant>(constantCount);
ShaderPackage.Samplers = r.ReadStructuresAsArray<Sampler>(samplerCount);
ShaderPackage.ShaderValues = r.ReadStructuresAsArray<float>(shaderValueListSize / 4);
}
private static Texture[] ReadTextureOffsets(BinaryReader r, int count, out ushort[] offsets)
{
var ret = new Texture[count];
offsets = new ushort[count];
for (var i = 0; i < count; ++i)
{
offsets[i] = r.ReadUInt16();
ret[i].Flags = r.ReadUInt16();
}
return ret;
}
private static UvSet[] ReadUvSetOffsets(BinaryReader r, int count, out ushort[] offsets)
{
var ret = new UvSet[count];
offsets = new ushort[count];
for (var i = 0; i < count; ++i)
{
offsets[i] = r.ReadUInt16();
ret[i].Index = r.ReadUInt16();
}
return ret;
}
private static ColorSet[] ReadColorSetOffsets(BinaryReader r, int count, out ushort[] offsets)
{
var ret = new ColorSet[count];
offsets = new ushort[count];
for (var i = 0; i < count; ++i)
{
offsets[i] = r.ReadUInt16();
ret[i].Index = r.ReadUInt16();
}
return ret;
}
private static string UseOffset(ReadOnlySpan<byte> strings, ushort offset)
{
strings = strings[offset..];
var end = strings.IndexOf((byte)'\0');
return Encoding.UTF8.GetString(end == -1 ? strings : strings[..end]);
}
private bool CheckTextures()
=> Textures.All(texture => texture.Path.Contains('/'));
public struct UvSet
{
public string Name;
public ushort Index;
}
public struct Texture
{
public string Path;
public ushort Flags;
public bool DX11
=> (Flags & 0x8000) != 0;
}
public struct Constant
{
public uint Id;
public ushort ByteOffset;
public ushort ByteSize;
}
public struct ShaderPackageData
{
public string Name;
public ShaderKey[] ShaderKeys;
public Constant[] Constants;
public Sampler[] Samplers;
public float[] ShaderValues;
public uint Flags;
}
}

View file

@ -1,220 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Lumina.Misc;
using Penumbra.GameData.Data;
namespace Penumbra.GameData.Files;
public partial class ShpkFile
{
public struct Shader
{
public DisassembledShader.ShaderStage Stage;
public DxVersion DirectXVersion;
public Resource[] Constants;
public Resource[] Samplers;
public Resource[] Uavs;
public byte[] AdditionalHeader;
private byte[] _byteData;
private DisassembledShader? _disassembly;
public byte[] Blob
{
get => _byteData;
set
{
if (_byteData == value)
return;
if (Stage != DisassembledShader.ShaderStage.Unspecified)
{
// Reject the blob entirely if we can't disassemble it or if we find inconsistencies.
var disasm = DisassembledShader.Disassemble(value);
if (disasm.Stage != Stage || (disasm.ShaderModel >> 8) + 6 != (uint)DirectXVersion)
throw new ArgumentException(
$"The supplied blob is a DirectX {(disasm.ShaderModel >> 8) + 6} {disasm.Stage} shader ; expected a DirectX {(uint)DirectXVersion} {Stage} shader.",
nameof(value));
if (disasm.ShaderModel >= 0x0500)
{
var samplers = new Dictionary<uint, string>();
var textures = new Dictionary<uint, string>();
foreach (var binding in disasm.ResourceBindings)
{
switch (binding.Type)
{
case DisassembledShader.ResourceType.Texture:
textures[binding.Slot] = NormalizeResourceName(binding.Name);
break;
case DisassembledShader.ResourceType.Sampler:
samplers[binding.Slot] = NormalizeResourceName(binding.Name);
break;
}
}
if (samplers.Count != textures.Count
|| !samplers.All(pair => textures.TryGetValue(pair.Key, out var texName) && pair.Value == texName))
throw new ArgumentException($"The supplied blob has inconsistent sampler and texture allocation.");
}
_byteData = value;
_disassembly = disasm;
}
else
{
_byteData = value;
_disassembly = null;
}
UpdateUsed();
}
}
public DisassembledShader? Disassembly
=> _disassembly;
public Resource? GetConstantById(uint id)
=> Constants.FirstOrNull(res => res.Id == id);
public Resource? GetConstantByName(string name)
=> Constants.FirstOrNull(res => res.Name == name);
public Resource? GetSamplerById(uint id)
=> Samplers.FirstOrNull(s => s.Id == id);
public Resource? GetSamplerByName(string name)
=> Samplers.FirstOrNull(s => s.Name == name);
public Resource? GetUavById(uint id)
=> Uavs.FirstOrNull(u => u.Id == id);
public Resource? GetUavByName(string name)
=> Uavs.FirstOrNull(u => u.Name == name);
public void UpdateResources(ShpkFile file)
{
if (_disassembly == null)
throw new InvalidOperationException();
var constants = new List<Resource>();
var samplers = new List<Resource>();
var uavs = new List<Resource>();
foreach (var binding in _disassembly.ResourceBindings)
{
switch (binding.Type)
{
case DisassembledShader.ResourceType.ConstantBuffer:
var name = NormalizeResourceName(binding.Name);
// We want to preserve IDs as much as possible, and to deterministically generate new ones in a way that's most compliant with the native ones, to maximize compatibility.
var id = GetConstantByName(name)?.Id ?? file.GetConstantByName(name)?.Id ?? Crc32.Get(name, 0xFFFFFFFFu);
constants.Add(new Resource
{
Id = id,
Name = name,
Slot = (ushort)binding.Slot,
Size = (ushort)binding.RegisterCount,
Used = binding.Used,
UsedDynamically = binding.UsedDynamically,
});
break;
case DisassembledShader.ResourceType.Texture:
name = NormalizeResourceName(binding.Name);
id = GetSamplerByName(name)?.Id ?? file.GetSamplerByName(name)?.Id ?? Crc32.Get(name, 0xFFFFFFFFu);
samplers.Add(new Resource
{
Id = id,
Name = name,
Slot = (ushort)binding.Slot,
Size = (ushort)binding.Slot,
Used = binding.Used,
UsedDynamically = binding.UsedDynamically,
});
break;
case DisassembledShader.ResourceType.Uav:
name = NormalizeResourceName(binding.Name);
id = GetUavByName(name)?.Id ?? file.GetUavByName(name)?.Id ?? Crc32.Get(name, 0xFFFFFFFFu);
uavs.Add(new Resource
{
Id = id,
Name = name,
Slot = (ushort)binding.Slot,
Size = (ushort)binding.Slot,
Used = binding.Used,
UsedDynamically = binding.UsedDynamically,
});
break;
}
}
Constants = constants.ToArray();
Samplers = samplers.ToArray();
Uavs = uavs.ToArray();
}
private void UpdateUsed()
{
if (_disassembly != null)
{
var cbUsage = new Dictionary<string, (DisassembledShader.VectorComponents[], DisassembledShader.VectorComponents)>();
var tUsage = new Dictionary<string, (DisassembledShader.VectorComponents[], DisassembledShader.VectorComponents)>();
var uUsage = new Dictionary<string, (DisassembledShader.VectorComponents[], DisassembledShader.VectorComponents)>();
foreach (var binding in _disassembly.ResourceBindings)
{
switch (binding.Type)
{
case DisassembledShader.ResourceType.ConstantBuffer:
cbUsage[NormalizeResourceName(binding.Name)] = (binding.Used, binding.UsedDynamically);
break;
case DisassembledShader.ResourceType.Texture:
tUsage[NormalizeResourceName(binding.Name)] = (binding.Used, binding.UsedDynamically);
break;
case DisassembledShader.ResourceType.Uav:
uUsage[NormalizeResourceName(binding.Name)] = (binding.Used, binding.UsedDynamically);
break;
}
}
static void CopyUsed(Resource[] resources,
Dictionary<string, (DisassembledShader.VectorComponents[], DisassembledShader.VectorComponents)> used)
{
for (var i = 0; i < resources.Length; ++i)
{
if (used.TryGetValue(resources[i].Name, out var usage))
{
resources[i].Used = usage.Item1;
resources[i].UsedDynamically = usage.Item2;
}
else
{
resources[i].Used = null;
resources[i].UsedDynamically = null;
}
}
}
CopyUsed(Constants, cbUsage);
CopyUsed(Samplers, tUsage);
CopyUsed(Uavs, uUsage);
}
else
{
ClearUsed(Constants);
ClearUsed(Samplers);
ClearUsed(Uavs);
}
}
private static string NormalizeResourceName(string resourceName)
{
var dot = resourceName.IndexOf('.');
if (dot >= 0)
return resourceName[..dot];
if (resourceName.Length > 1 && resourceName[^2] is '_' && resourceName[^1] is 'S' or 'T')
return resourceName[..^2];
return resourceName;
}
}
}

View file

@ -1,79 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Penumbra.GameData.Files;
public partial class ShpkFile
{
public class StringPool
{
public MemoryStream Data;
public List<int> StartingOffsets;
public StringPool(ReadOnlySpan<byte> bytes)
{
Data = new MemoryStream();
Data.Write(bytes);
StartingOffsets = new List<int>
{
0,
};
for (var i = 0; i < bytes.Length; ++i)
{
if (bytes[i] == 0)
StartingOffsets.Add(i + 1);
}
if (StartingOffsets[^1] == bytes.Length)
StartingOffsets.RemoveAt(StartingOffsets.Count - 1);
else
Data.WriteByte(0);
}
public string GetString(int offset, int size)
=> Encoding.UTF8.GetString(Data.GetBuffer().AsSpan().Slice(offset, size));
public string GetNullTerminatedString(int offset)
{
var str = Data.GetBuffer().AsSpan()[offset..];
var size = str.IndexOf((byte)0);
if (size >= 0)
str = str[..size];
return Encoding.UTF8.GetString(str);
}
public (int, int) FindOrAddString(string str)
{
var dataSpan = Data.GetBuffer().AsSpan();
var bytes = Encoding.UTF8.GetBytes(str);
foreach (var offset in StartingOffsets)
{
if (offset + bytes.Length > Data.Length)
break;
var strSpan = dataSpan[offset..];
var match = true;
for (var i = 0; i < bytes.Length; ++i)
{
if (strSpan[i] != bytes[i])
{
match = false;
break;
}
}
if (match && strSpan[bytes.Length] == 0)
return (offset, bytes.Length);
}
Data.Seek(0L, SeekOrigin.End);
var newOffset = (int)Data.Position;
StartingOffsets.Add(newOffset);
Data.Write(bytes);
Data.WriteByte(0);
return (newOffset, bytes.Length);
}
}
}

View file

@ -1,165 +0,0 @@
using System;
using System.IO;
namespace Penumbra.GameData.Files;
public partial class ShpkFile
{
public byte[] Write()
{
if (SubViewKeys.Length != 2)
throw new InvalidDataException();
using var stream = new MemoryStream();
using var blobs = new MemoryStream();
var strings = new StringPool(ReadOnlySpan<byte>.Empty);
using (var w = new BinaryWriter(stream))
{
w.Write(ShPkMagic);
w.Write(Version);
w.Write(DirectXVersion switch
{
DxVersion.DirectX9 => Dx9Magic,
DxVersion.DirectX11 => Dx11Magic,
_ => throw new NotImplementedException(),
});
var offsetsPosition = stream.Position;
w.Write(0u); // Placeholder for file size
w.Write(0u); // Placeholder for blobs offset
w.Write(0u); // Placeholder for strings offset
w.Write((uint)VertexShaders.Length);
w.Write((uint)PixelShaders.Length);
w.Write(MaterialParamsSize);
w.Write((uint)MaterialParams.Length);
w.Write((uint)Constants.Length);
w.Write((uint)Samplers.Length);
w.Write((uint)Uavs.Length);
w.Write((uint)SystemKeys.Length);
w.Write((uint)SceneKeys.Length);
w.Write((uint)MaterialKeys.Length);
w.Write((uint)Nodes.Length);
w.Write((uint)Items.Length);
WriteShaderArray(w, VertexShaders, blobs, strings);
WriteShaderArray(w, PixelShaders, blobs, strings);
foreach (var materialParam in MaterialParams)
{
w.Write(materialParam.Id);
w.Write(materialParam.ByteOffset);
w.Write(materialParam.ByteSize);
}
WriteResourceArray(w, Constants, strings);
WriteResourceArray(w, Samplers, strings);
WriteResourceArray(w, Uavs, strings);
foreach (var key in SystemKeys)
{
w.Write(key.Id);
w.Write(key.DefaultValue);
}
foreach (var key in SceneKeys)
{
w.Write(key.Id);
w.Write(key.DefaultValue);
}
foreach (var key in MaterialKeys)
{
w.Write(key.Id);
w.Write(key.DefaultValue);
}
foreach (var key in SubViewKeys)
w.Write(key.DefaultValue);
foreach (var node in Nodes)
{
if (node.PassIndices.Length != 16
|| node.SystemKeys.Length != SystemKeys.Length
|| node.SceneKeys.Length != SceneKeys.Length
|| node.MaterialKeys.Length != MaterialKeys.Length
|| node.SubViewKeys.Length != SubViewKeys.Length)
throw new InvalidDataException();
w.Write(node.Id);
w.Write(node.Passes.Length);
w.Write(node.PassIndices);
foreach (var key in node.SystemKeys)
w.Write(key);
foreach (var key in node.SceneKeys)
w.Write(key);
foreach (var key in node.MaterialKeys)
w.Write(key);
foreach (var key in node.SubViewKeys)
w.Write(key);
foreach (var pass in node.Passes)
{
w.Write(pass.Id);
w.Write(pass.VertexShader);
w.Write(pass.PixelShader);
}
}
foreach (var item in Items)
{
w.Write(item.Id);
w.Write(item.Node);
}
w.Write(AdditionalData);
var blobsOffset = (int)stream.Position;
blobs.WriteTo(stream);
var stringsOffset = (int)stream.Position;
strings.Data.WriteTo(stream);
var fileSize = (int)stream.Position;
stream.Seek(offsetsPosition, SeekOrigin.Begin);
w.Write(fileSize);
w.Write(blobsOffset);
w.Write(stringsOffset);
}
return stream.ToArray();
}
private static void WriteResourceArray(BinaryWriter w, Resource[] array, StringPool strings)
{
foreach (var buf in array)
{
var (strOffset, strSize) = strings.FindOrAddString(buf.Name);
w.Write(buf.Id);
w.Write(strOffset);
w.Write(strSize);
w.Write(buf.Slot);
w.Write(buf.Size);
}
}
private static void WriteShaderArray(BinaryWriter w, Shader[] array, MemoryStream blobs, StringPool strings)
{
foreach (var shader in array)
{
var blobOffset = (int)blobs.Position;
blobs.Write(shader.AdditionalHeader);
blobs.Write(shader.Blob);
var blobSize = (int)blobs.Position - blobOffset;
w.Write(blobOffset);
w.Write(blobSize);
w.Write((ushort)shader.Constants.Length);
w.Write((ushort)shader.Samplers.Length);
w.Write((ushort)shader.Uavs.Length);
w.Write((ushort)0);
WriteResourceArray(w, shader.Constants, strings);
WriteResourceArray(w, shader.Samplers, strings);
WriteResourceArray(w, shader.Uavs, strings);
}
}
}

View file

@ -1,486 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Lumina.Extensions;
using Penumbra.GameData.Data;
namespace Penumbra.GameData.Files;
public partial class ShpkFile : IWritable
{
private const uint ShPkMagic = 0x6B506853u; // bytes of ShPk
private const uint Dx9Magic = 0x00395844u; // bytes of DX9\0
private const uint Dx11Magic = 0x31315844u; // bytes of DX11
public const uint MaterialParamsConstantId = 0x64D12851u;
public uint Version;
public DxVersion DirectXVersion;
public Shader[] VertexShaders;
public Shader[] PixelShaders;
public uint MaterialParamsSize;
public MaterialParam[] MaterialParams;
public Resource[] Constants;
public Resource[] Samplers;
public Resource[] Uavs;
public Key[] SystemKeys;
public Key[] SceneKeys;
public Key[] MaterialKeys;
public Key[] SubViewKeys;
public Node[] Nodes;
public Item[] Items;
public byte[] AdditionalData;
public bool Valid { get; private set; }
private bool _changed;
public MaterialParam? GetMaterialParamById(uint id)
=> MaterialParams.FirstOrNull(m => m.Id == id);
public Resource? GetConstantById(uint id)
=> Constants.FirstOrNull(c => c.Id == id);
public Resource? GetConstantByName(string name)
=> Constants.FirstOrNull(c => c.Name == name);
public Resource? GetSamplerById(uint id)
=> Samplers.FirstOrNull(s => s.Id == id);
public Resource? GetSamplerByName(string name)
=> Samplers.FirstOrNull(s => s.Name == name);
public Resource? GetUavById(uint id)
=> Uavs.FirstOrNull(u => u.Id == id);
public Resource? GetUavByName(string name)
=> Uavs.FirstOrNull(u => u.Name == name);
public Key? GetSystemKeyById(uint id)
=> SystemKeys.FirstOrNull(k => k.Id == id);
public Key? GetSceneKeyById(uint id)
=> SceneKeys.FirstOrNull(k => k.Id == id);
public Key? GetMaterialKeyById(uint id)
=> MaterialKeys.FirstOrNull(k => k.Id == id);
public Node? GetNodeById(uint id)
=> Nodes.FirstOrNull(n => n.Id == id);
public Item? GetItemById(uint id)
=> Items.FirstOrNull(i => i.Id == id);
public ShpkFile(byte[] data, bool disassemble = false)
{
using var stream = new MemoryStream(data);
using var r = new BinaryReader(stream);
if (r.ReadUInt32() != ShPkMagic)
throw new InvalidDataException();
Version = r.ReadUInt32();
DirectXVersion = r.ReadUInt32() switch
{
Dx9Magic => DxVersion.DirectX9,
Dx11Magic => DxVersion.DirectX11,
_ => throw new InvalidDataException(),
};
if (r.ReadUInt32() != data.Length)
throw new InvalidDataException();
var blobsOffset = r.ReadUInt32();
var stringsOffset = r.ReadUInt32();
var vertexShaderCount = r.ReadUInt32();
var pixelShaderCount = r.ReadUInt32();
MaterialParamsSize = r.ReadUInt32();
var materialParamCount = r.ReadUInt32();
var constantCount = r.ReadUInt32();
var samplerCount = r.ReadUInt32();
var uavCount = r.ReadUInt32();
var systemKeyCount = r.ReadUInt32();
var sceneKeyCount = r.ReadUInt32();
var materialKeyCount = r.ReadUInt32();
var nodeCount = r.ReadUInt32();
var itemCount = r.ReadUInt32();
var blobs = new ReadOnlySpan<byte>(data, (int)blobsOffset, (int)(stringsOffset - blobsOffset));
var strings = new StringPool(new ReadOnlySpan<byte>(data, (int)stringsOffset, (int)(data.Length - stringsOffset)));
VertexShaders = ReadShaderArray(r, (int)vertexShaderCount, DisassembledShader.ShaderStage.Vertex, DirectXVersion, disassemble, blobs,
strings);
PixelShaders = ReadShaderArray(r, (int)pixelShaderCount, DisassembledShader.ShaderStage.Pixel, DirectXVersion, disassemble, blobs,
strings);
MaterialParams = r.ReadStructuresAsArray<MaterialParam>((int)materialParamCount);
Constants = ReadResourceArray(r, (int)constantCount, strings);
Samplers = ReadResourceArray(r, (int)samplerCount, strings);
Uavs = ReadResourceArray(r, (int)uavCount, strings);
SystemKeys = ReadKeyArray(r, (int)systemKeyCount);
SceneKeys = ReadKeyArray(r, (int)sceneKeyCount);
MaterialKeys = ReadKeyArray(r, (int)materialKeyCount);
var subViewKey1Default = r.ReadUInt32();
var subViewKey2Default = r.ReadUInt32();
SubViewKeys = new Key[]
{
new()
{
Id = 1,
DefaultValue = subViewKey1Default,
Values = Array.Empty<uint>(),
},
new()
{
Id = 2,
DefaultValue = subViewKey2Default,
Values = Array.Empty<uint>(),
},
};
Nodes = ReadNodeArray(r, (int)nodeCount, SystemKeys.Length, SceneKeys.Length, MaterialKeys.Length, SubViewKeys.Length);
Items = r.ReadStructuresAsArray<Item>((int)itemCount);
AdditionalData = r.ReadBytes((int)(blobsOffset - r.BaseStream.Position)); // This should be empty, but just in case.
if (disassemble)
UpdateUsed();
UpdateKeyValues();
Valid = true;
_changed = false;
}
public void UpdateResources()
{
var constants = new Dictionary<uint, Resource>();
var samplers = new Dictionary<uint, Resource>();
var uavs = new Dictionary<uint, Resource>();
static void CollectResources(Dictionary<uint, Resource> resources, Resource[] shaderResources, Func<uint, Resource?> getExistingById,
DisassembledShader.ResourceType type)
{
foreach (var resource in shaderResources)
{
if (resources.TryGetValue(resource.Id, out var carry) && type != DisassembledShader.ResourceType.ConstantBuffer)
continue;
var existing = getExistingById(resource.Id);
resources[resource.Id] = new Resource
{
Id = resource.Id,
Name = resource.Name,
Slot = existing?.Slot ?? (type == DisassembledShader.ResourceType.ConstantBuffer ? (ushort)65535 : (ushort)2),
Size = type == DisassembledShader.ResourceType.ConstantBuffer ? Math.Max(carry.Size, resource.Size) : existing?.Size ?? 0,
Used = null,
UsedDynamically = null,
};
}
}
foreach (var shader in VertexShaders)
{
CollectResources(constants, shader.Constants, GetConstantById, DisassembledShader.ResourceType.ConstantBuffer);
CollectResources(samplers, shader.Samplers, GetSamplerById, DisassembledShader.ResourceType.Sampler);
CollectResources(uavs, shader.Uavs, GetUavById, DisassembledShader.ResourceType.Uav);
}
foreach (var shader in PixelShaders)
{
CollectResources(constants, shader.Constants, GetConstantById, DisassembledShader.ResourceType.ConstantBuffer);
CollectResources(samplers, shader.Samplers, GetSamplerById, DisassembledShader.ResourceType.Sampler);
CollectResources(uavs, shader.Uavs, GetUavById, DisassembledShader.ResourceType.Uav);
}
Constants = constants.Values.ToArray();
Samplers = samplers.Values.ToArray();
Uavs = uavs.Values.ToArray();
UpdateUsed();
// Ceil required size to a multiple of 16 bytes.
// Offsets can be skipped, MaterialParamsConstantId's size is the count.
MaterialParamsSize = (GetConstantById(MaterialParamsConstantId)?.Size ?? 0u) << 4;
foreach (var param in MaterialParams)
MaterialParamsSize = Math.Max(MaterialParamsSize, (uint)param.ByteOffset + param.ByteSize);
MaterialParamsSize = (MaterialParamsSize + 0xFu) & ~0xFu;
}
private void UpdateUsed()
{
var cUsage = new Dictionary<uint, (DisassembledShader.VectorComponents[], DisassembledShader.VectorComponents)>();
var sUsage = new Dictionary<uint, (DisassembledShader.VectorComponents[], DisassembledShader.VectorComponents)>();
var uUsage = new Dictionary<uint, (DisassembledShader.VectorComponents[], DisassembledShader.VectorComponents)>();
static void CollectUsed(Dictionary<uint, (DisassembledShader.VectorComponents[], DisassembledShader.VectorComponents)> usage,
Resource[] resources)
{
foreach (var resource in resources)
{
if (resource.Used == null)
continue;
usage.TryGetValue(resource.Id, out var carry);
carry.Item1 ??= Array.Empty<DisassembledShader.VectorComponents>();
var combined = new DisassembledShader.VectorComponents[Math.Max(carry.Item1.Length, resource.Used.Length)];
for (var i = 0; i < combined.Length; ++i)
combined[i] = (i < carry.Item1.Length ? carry.Item1[i] : 0) | (i < resource.Used.Length ? resource.Used[i] : 0);
usage[resource.Id] = (combined, carry.Item2 | (resource.UsedDynamically ?? 0));
}
}
static void CopyUsed(Resource[] resources,
Dictionary<uint, (DisassembledShader.VectorComponents[], DisassembledShader.VectorComponents)> used)
{
for (var i = 0; i < resources.Length; ++i)
{
if (used.TryGetValue(resources[i].Id, out var usage))
{
resources[i].Used = usage.Item1;
resources[i].UsedDynamically = usage.Item2;
}
else
{
resources[i].Used = null;
resources[i].UsedDynamically = null;
}
}
}
foreach (var shader in VertexShaders)
{
CollectUsed(cUsage, shader.Constants);
CollectUsed(sUsage, shader.Samplers);
CollectUsed(uUsage, shader.Uavs);
}
foreach (var shader in PixelShaders)
{
CollectUsed(cUsage, shader.Constants);
CollectUsed(sUsage, shader.Samplers);
CollectUsed(uUsage, shader.Uavs);
}
CopyUsed(Constants, cUsage);
CopyUsed(Samplers, sUsage);
CopyUsed(Uavs, uUsage);
}
public void UpdateKeyValues()
{
static HashSet<uint>[] InitializeValueSet(Key[] keys)
=> Array.ConvertAll(keys, key => new HashSet<uint>()
{
key.DefaultValue,
});
static void CollectValues(HashSet<uint>[] valueSets, uint[] values)
{
for (var i = 0; i < valueSets.Length; ++i)
valueSets[i].Add(values[i]);
}
static void CopyValues(Key[] keys, HashSet<uint>[] valueSets)
{
for (var i = 0; i < keys.Length; ++i)
keys[i].Values = valueSets[i].ToArray();
}
var systemKeyValues = InitializeValueSet(SystemKeys);
var sceneKeyValues = InitializeValueSet(SceneKeys);
var materialKeyValues = InitializeValueSet(MaterialKeys);
var subViewKeyValues = InitializeValueSet(SubViewKeys);
foreach (var node in Nodes)
{
CollectValues(systemKeyValues, node.SystemKeys);
CollectValues(sceneKeyValues, node.SceneKeys);
CollectValues(materialKeyValues, node.MaterialKeys);
CollectValues(subViewKeyValues, node.SubViewKeys);
}
CopyValues(SystemKeys, systemKeyValues);
CopyValues(SceneKeys, sceneKeyValues);
CopyValues(MaterialKeys, materialKeyValues);
CopyValues(SubViewKeys, subViewKeyValues);
}
public void SetInvalid()
=> Valid = false;
public void SetChanged()
=> _changed = true;
public bool IsChanged()
{
var changed = _changed;
_changed = false;
return changed;
}
private static void ClearUsed(Resource[] resources)
{
for (var i = 0; i < resources.Length; ++i)
{
resources[i].Used = null;
resources[i].UsedDynamically = null;
}
}
private static Resource[] ReadResourceArray(BinaryReader r, int count, StringPool strings)
{
var ret = new Resource[count];
for (var i = 0; i < count; ++i)
{
var id = r.ReadUInt32();
var strOffset = r.ReadUInt32();
var strSize = r.ReadUInt32();
ret[i] = new Resource
{
Id = id,
Name = strings.GetString((int)strOffset, (int)strSize),
Slot = r.ReadUInt16(),
Size = r.ReadUInt16(),
};
}
return ret;
}
private static Shader[] ReadShaderArray(BinaryReader r, int count, DisassembledShader.ShaderStage stage, DxVersion directX,
bool disassemble, ReadOnlySpan<byte> blobs, StringPool strings)
{
var extraHeaderSize = stage switch
{
DisassembledShader.ShaderStage.Vertex => directX switch
{
DxVersion.DirectX9 => 4,
DxVersion.DirectX11 => 8,
_ => throw new NotImplementedException(),
},
_ => 0,
};
var ret = new Shader[count];
for (var i = 0; i < count; ++i)
{
var blobOffset = r.ReadUInt32();
var blobSize = r.ReadUInt32();
var constantCount = r.ReadUInt16();
var samplerCount = r.ReadUInt16();
var uavCount = r.ReadUInt16();
if (r.ReadUInt16() != 0)
throw new NotImplementedException();
var rawBlob = blobs.Slice((int)blobOffset, (int)blobSize);
ret[i] = new Shader
{
Stage = disassemble ? stage : DisassembledShader.ShaderStage.Unspecified,
DirectXVersion = directX,
Constants = ReadResourceArray(r, constantCount, strings),
Samplers = ReadResourceArray(r, samplerCount, strings),
Uavs = ReadResourceArray(r, uavCount, strings),
AdditionalHeader = rawBlob[..extraHeaderSize].ToArray(),
Blob = rawBlob[extraHeaderSize..].ToArray(),
};
}
return ret;
}
private static Key[] ReadKeyArray(BinaryReader r, int count)
{
var ret = new Key[count];
for (var i = 0; i < count; ++i)
{
ret[i] = new Key
{
Id = r.ReadUInt32(),
DefaultValue = r.ReadUInt32(),
Values = Array.Empty<uint>(),
};
}
return ret;
}
private static Node[] ReadNodeArray(BinaryReader r, int count, int systemKeyCount, int sceneKeyCount, int materialKeyCount,
int subViewKeyCount)
{
var ret = new Node[count];
for (var i = 0; i < count; ++i)
{
var id = r.ReadUInt32();
var passCount = r.ReadUInt32();
ret[i] = new Node
{
Id = id,
PassIndices = r.ReadBytes(16),
SystemKeys = r.ReadStructuresAsArray<uint>(systemKeyCount),
SceneKeys = r.ReadStructuresAsArray<uint>(sceneKeyCount),
MaterialKeys = r.ReadStructuresAsArray<uint>(materialKeyCount),
SubViewKeys = r.ReadStructuresAsArray<uint>(subViewKeyCount),
Passes = r.ReadStructuresAsArray<Pass>((int)passCount),
};
}
return ret;
}
public enum DxVersion : uint
{
DirectX9 = 9,
DirectX11 = 11,
}
public struct Resource
{
public uint Id;
public string Name;
public ushort Slot;
public ushort Size;
public DisassembledShader.VectorComponents[]? Used;
public DisassembledShader.VectorComponents? UsedDynamically;
}
public struct MaterialParam
{
public uint Id;
public ushort ByteOffset;
public ushort ByteSize;
}
public struct Pass
{
public uint Id;
public uint VertexShader;
public uint PixelShader;
}
public struct Key
{
public uint Id;
public uint DefaultValue;
public uint[] Values;
}
public struct Node
{
public uint Id;
public byte[] PassIndices;
public uint[] SystemKeys;
public uint[] SceneKeys;
public uint[] MaterialKeys;
public uint[] SubViewKeys;
public Pass[] Passes;
}
public struct Item
{
public uint Id;
public uint Node;
}
}

View file

@ -1,174 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using Lumina.Extensions;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData.Files;
public partial class StmFile
{
public readonly struct StainingTemplateEntry
{
/// <summary>
/// The number of stains is capped at 128 at the moment
/// </summary>
public const int NumElements = 128;
// ColorSet row information for each stain.
public readonly IReadOnlyList<(Half R, Half G, Half B)> DiffuseEntries;
public readonly IReadOnlyList<(Half R, Half G, Half B)> SpecularEntries;
public readonly IReadOnlyList<(Half R, Half G, Half B)> EmissiveEntries;
public readonly IReadOnlyList<Half> GlossEntries;
public readonly IReadOnlyList<Half> SpecularPowerEntries;
public DyePack this[StainId idx]
=> this[(int)idx.Value];
public DyePack this[int idx]
{
get
{
// The 0th index is skipped.
if (idx is <= 0 or > NumElements)
return default;
--idx;
var (dr, dg, db) = DiffuseEntries[idx];
var (sr, sg, sb) = SpecularEntries[idx];
var (er, eg, eb) = EmissiveEntries[idx];
var g = GlossEntries[idx];
var sp = SpecularPowerEntries[idx];
// Convert to DyePack using floats.
return new DyePack
{
Diffuse = new Vector3((float)dr, (float)dg, (float)db),
Specular = new Vector3((float)sr, (float)sg, (float)sb),
Emissive = new Vector3((float)er, (float)eg, (float)eb),
Gloss = (float)g,
SpecularPower = (float)sp,
};
}
}
private static IReadOnlyList<T> ReadArray<T>(BinaryReader br, int offset, int size, Func<BinaryReader, T> read, int entrySize)
{
br.Seek(offset);
var arraySize = size / entrySize;
// The actual amount of entries informs which type of list we use.
switch (arraySize)
{
case 0: return new RepeatingList<T>(default!, NumElements); // All default
case 1: return new RepeatingList<T>(read(br), NumElements); // All single entry
case NumElements: // 1-to-1 entries
var ret = new T[NumElements];
for (var i = 0; i < NumElements; ++i)
ret[i] = read(br);
return ret;
// Indexed access.
case < NumElements: return new IndexedList<T>(br, arraySize - NumElements / entrySize, NumElements, read);
// Should not happen.
case > NumElements: throw new InvalidDataException($"Stain Template can not have more than {NumElements} elements.");
}
}
// Read functions
private static (Half, Half, Half) ReadTriple(BinaryReader br)
=> (br.ReadHalf(), br.ReadHalf(), br.ReadHalf());
private static Half ReadSingle(BinaryReader br)
=> br.ReadHalf();
// Actually parse an entry.
public unsafe StainingTemplateEntry(BinaryReader br, int offset)
{
br.Seek(offset);
// 5 different lists of values.
Span<ushort> ends = stackalloc ushort[5];
for (var i = 0; i < ends.Length; ++i)
ends[i] = (ushort)(br.ReadUInt16() * 2); // because the ends are in terms of ushort.
offset += ends.Length * 2;
DiffuseEntries = ReadArray(br, offset, ends[0], ReadTriple, 6);
SpecularEntries = ReadArray(br, offset + ends[0], ends[1] - ends[0], ReadTriple, 6);
EmissiveEntries = ReadArray(br, offset + ends[1], ends[2] - ends[1], ReadTriple, 6);
GlossEntries = ReadArray(br, offset + ends[2], ends[3] - ends[2], ReadSingle, 2);
SpecularPowerEntries = ReadArray(br, offset + ends[3], ends[4] - ends[3], ReadSingle, 2);
}
/// <summary>
/// Used if a single value is used for all entries of a list.
/// </summary>
private sealed class RepeatingList<T> : IReadOnlyList<T>
{
private readonly T _value;
public int Count { get; }
public RepeatingList(T value, int size)
{
_value = value;
Count = size;
}
public IEnumerator<T> GetEnumerator()
{
for (var i = 0; i < Count; ++i)
yield return _value;
}
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
public T this[int index]
=> index >= 0 && index < Count ? _value : throw new IndexOutOfRangeException();
}
/// <summary>
/// Used if there is a small set of values for a bigger list, accessed via index information.
/// </summary>
private sealed class IndexedList<T> : IReadOnlyList<T>
{
private readonly T[] _values;
private readonly byte[] _indices;
/// <summary>
/// Reads <paramref name="count"/> values from <paramref name="br"/> via <paramref name="read"/>, then reads <paramref name="indexCount"/> byte indices.
/// </summary>
public IndexedList(BinaryReader br, int count, int indexCount, Func<BinaryReader, T> read)
{
_values = new T[count + 1];
_indices = new byte[indexCount];
_values[0] = default!;
for (var i = 1; i < count + 1; ++i)
_values[i] = read(br);
// Seems to be an unused 0xFF byte marker.
// Necessary for correct offsets.
br.ReadByte();
for (var i = 0; i < indexCount; ++i)
{
_indices[i] = br.ReadByte();
if (_indices[i] > count)
_indices[i] = 0;
}
}
public IEnumerator<T> GetEnumerator()
{
for (var i = 0; i < NumElements; ++i)
yield return _values[_indices[i]];
}
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
public int Count
=> _indices.Length;
public T this[int index]
=> index >= 0 && index < Count ? _values[_indices[index]] : default!;
}
}
}

View file

@ -1,98 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using Dalamud.Data;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData.Files;
public partial class StmFile
{
public const string Path = "chara/base_material/stainingtemplate.stm";
/// <summary>
/// All dye-able color set information for a row.
/// </summary>
public record struct DyePack
{
public Vector3 Diffuse;
public Vector3 Specular;
public Vector3 Emissive;
public float Gloss;
public float SpecularPower;
}
/// <summary>
/// All currently available dyeing templates with their IDs.
/// </summary>
public readonly IReadOnlyDictionary<ushort, StainingTemplateEntry> Entries;
/// <summary>
/// Access a specific dye pack.
/// </summary>
/// <param name="template">The ID of the accessed template.</param>
/// <param name="idx">The ID of the Stain.</param>
/// <returns>The corresponding color set information or a defaulted DyePack of 0-entries.</returns>
public DyePack this[ushort template, int idx]
=> Entries.TryGetValue(template, out var entry) ? entry[idx] : default;
/// <inheritdoc cref="this[ushort, StainId]"/>
public DyePack this[ushort template, StainId idx]
=> this[template, (int)idx.Value];
/// <summary>
/// Try to access a specific dye pack.
/// </summary>
/// <param name="template">The ID of the accessed template.</param>
/// <param name="idx">The ID of the Stain.</param>
/// <param name="dyes">On success, the corresponding color set information, otherwise a defaulted DyePack.</param>
/// <returns>True on success, false otherwise.</returns>
public bool TryGetValue(ushort template, StainId idx, out DyePack dyes)
{
if (idx.Value is > 0 and <= StainingTemplateEntry.NumElements && Entries.TryGetValue(template, out var entry))
{
dyes = entry[idx];
return true;
}
dyes = default;
return false;
}
/// <summary>
/// Create a STM file from the given data array.
/// </summary>
public StmFile(byte[] data)
{
using var stream = new MemoryStream(data);
using var br = new BinaryReader(stream);
br.ReadUInt32();
var numEntries = br.ReadInt32();
var keys = new ushort[numEntries];
var offsets = new ushort[numEntries];
for (var i = 0; i < numEntries; ++i)
keys[i] = br.ReadUInt16();
for (var i = 0; i < numEntries; ++i)
offsets[i] = br.ReadUInt16();
var entries = new Dictionary<ushort, StainingTemplateEntry>(numEntries);
Entries = entries;
for (var i = 0; i < numEntries; ++i)
{
var offset = offsets[i] * 2 + 8 + 4 * numEntries;
entries.Add(keys[i], new StainingTemplateEntry(br, offset));
}
}
/// <summary>
/// Try to read and parse the default STM file given by Lumina.
/// </summary>
public StmFile(DataManager gameData)
: this(gameData.GetFile(Path)?.Data ?? Array.Empty<byte>())
{ }
}

View file

@ -1,73 +0,0 @@
using System;
using System.Collections.Generic;
using Dalamud;
using Dalamud.Data;
using Dalamud.Plugin;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Data;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Penumbra.GameData;
public static class GameData
{
/// <summary>
/// Obtain an object identifier that can link a game path to game objects that use it, using your client language.
/// </summary>
public static IObjectIdentifier GetIdentifier(DalamudPluginInterface pluginInterface, DataManager dataManager)
=> new ObjectIdentification(pluginInterface, dataManager, dataManager.Language);
/// <summary>
/// Obtain an object identifier that can link a game path to game objects that use it using the given language.
/// </summary>
public static IObjectIdentifier GetIdentifier(DalamudPluginInterface pluginInterface, DataManager dataManager, ClientLanguage language)
=> new ObjectIdentification(pluginInterface, dataManager, language);
/// <summary>
/// Obtain a parser for game paths.
/// </summary>
public static IGamePathParser GetGamePathParser()
=> new GamePathParser();
}
public interface IObjectIdentifier : IDisposable
{
/// <summary>
/// An accessible parser for game paths.
/// </summary>
public IGamePathParser GamePathParser { get; }
/// <summary>
/// Add all known game objects using the given game path to the dictionary.
/// </summary>
/// <param name="set">A pre-existing dictionary to which names (and optional linked objects) can be added.</param>
/// <param name="path">The game path to identify.</param>
public void Identify(IDictionary<string, object?> set, string path);
/// <summary>
/// Return named information and possibly linked objects for all known game objects using the given path.
/// </summary>
/// <param name="path">The game path to identify.</param>
public Dictionary<string, object?> Identify(string path);
/// <summary>
/// Identify an equippable item by its model values.
/// </summary>
/// <param name="setId">The primary model ID for the piece of equipment.</param>
/// <param name="weaponType">The secondary model ID for weapons, WeaponType.Zero for equipment and accessories.</param>
/// <param name="variant">The variant ID of the model.</param>
/// <param name="slot">The equipment slot the piece of equipment uses.</param>
public IEnumerable<EquipItem> Identify(SetId setId, WeaponType weaponType, ushort variant, EquipSlot slot);
/// <inheritdoc cref="Identify(SetId, WeaponType, ushort, EquipSlot)"/>
public IEnumerable<EquipItem> Identify(SetId setId, ushort variant, EquipSlot slot)
=> Identify(setId, 0, variant, slot);
}
public interface IGamePathParser
{
public ObjectType PathToObjectType(string path);
public GameObjectInfo GetFileInfo(string path);
public string VfxToKey(string path);
}

View file

@ -1,64 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using Penumbra.String;
namespace Penumbra.GameData.Interop;
internal static class D3DCompiler
{
[Guid("8BA5FB08-5195-40e2-AC58-0D989C3A0102")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface ID3DBlob
{
[PreserveSig]
public unsafe void* GetBufferPointer();
[PreserveSig]
public UIntPtr GetBufferSize();
}
[Flags]
public enum DisassembleFlags : uint
{
EnableColorCode = 1,
EnableDefaultValuePrints = 2,
EnableInstructionNumbering = 4,
EnableInstructionCycle = 8,
DisableDebugInfo = 16,
EnableInstructionOffset = 32,
InstructionOnly = 64,
PrintHexLiterals = 128,
}
public static unsafe ByteString Disassemble(ReadOnlySpan<byte> blob, DisassembleFlags flags = 0, string comments = "")
{
ID3DBlob? disassembly = null;
try
{
fixed (byte* pSrcData = blob)
{
var hr = D3DDisassemble(pSrcData, new UIntPtr((uint)blob.Length), (uint)flags, comments, out disassembly);
Marshal.ThrowExceptionForHR(hr);
}
return disassembly == null
? ByteString.Empty
: new ByteString((byte*)disassembly.GetBufferPointer()).Clone();
}
finally
{
if (disassembly != null)
Marshal.FinalReleaseComObject(disassembly);
}
}
[PreserveSig]
[DllImport("D3DCompiler_47.dll")]
private static extern unsafe int D3DDisassemble(
[In] byte* pSrcData,
[In] UIntPtr srcDataSize,
uint flags,
[MarshalAs(UnmanagedType.LPStr)] string szComments,
out ID3DBlob? ppDisassembly);
}

View file

@ -1,35 +0,0 @@
namespace Penumbra.GameData;
public static class Offsets
{
// ActorManager.Data
public const int AgentCharaCardDataWorldId = 0xC0;
// ObjectIdentification
public const int DrawObjectGetModelTypeVfunc = 50;
private const int DrawObjectModelBase = 0x8E8;
public const int DrawObjectModelUnk1 = DrawObjectModelBase;
public const int DrawObjectModelUnk2 = DrawObjectModelBase + 0x08;
public const int DrawObjectModelUnk3 = DrawObjectModelBase + 0x20;
public const int DrawObjectModelUnk4 = DrawObjectModelBase + 0x28;
// PathResolver.AnimationState
public const int GetGameObjectIdxVfunc = 28;
public const int TimeLinePtr = 0x50;
// PathResolver.Meta
public const int UpdateModelSkip = 0x90c;
public const int GetEqpIndirectSkip1 = 0xA30;
public const int GetEqpIndirectSkip2 = 0xA28;
// FontReloader
public const int ReloadFontsVfunc = 43;
// ObjectReloader
public const int EnableDrawVfunc = 16;
public const int DisableDrawVfunc = 17;
// ResourceHandle
public const int ResourceHandleGetDataVfunc = 23;
public const int ResourceHandleGetLengthVfunc = 17;
}

View file

@ -1,64 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<LangVersion>preview</LangVersion>
<PlatformTarget>x64</PlatformTarget>
<AssemblyTitle>Penumbra.GameData</AssemblyTitle>
<Company>absolute gangstas</Company>
<Product>Penumbra</Product>
<Copyright>Copyright © 2022</Copyright>
<FileVersion>1.0.0.0</FileVersion>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<PropertyGroup>
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3277</MSBuildWarningsAsMessages>
</PropertyGroup>
<PropertyGroup>
<DalamudLibPath>$(AppData)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Penumbra.Api\Penumbra.Api.csproj" />
<ProjectReference Include="..\Penumbra.String\Penumbra.String.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina">
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina.Excel">
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
</Project>

View file

@ -1,90 +0,0 @@
namespace Penumbra.GameData;
public static class Sigs
{
// ResourceLoader.Debug
public const string ResourceManager = "48 8B 05 ?? ?? ?? ?? 33 ED F0";
// ResourceLoader.Replacement
public const string GetResourceSync = "E8 ?? ?? 00 00 48 8D 8F ?? ?? 00 00 48 89 87 ?? ?? 00 00";
public const string GetResourceAsync = "E8 ?? ?? ?? 00 48 8B D8 EB ?? F0 FF 83 ?? ?? 00 00";
public const string ReadFile = "E8 ?? ?? ?? ?? 84 C0 0F 84 ?? 00 00 00 4C 8B C3 BA 05";
public const string ReadSqPack = "E8 ?? ?? ?? ?? EB 05 E8 ?? ?? ?? ?? 84 C0 0F 84 ?? 00 00 00 4C 8B C3";
// ResourceLoader.TexMdl
public const string CheckFileState = "E8 ?? ?? ?? ?? 48 85 c0 74 ?? 45 0f b6 ce 48 89 44 24";
public const string LoadTexFileLocal = "48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 30 49 8B F0 44 88 4C 24 20";
public const string LoadMdlFileLocal = "40 55 53 56 57 41 56 41 57 48 8D 6C 24 D1 48 81 EC 98 00 00 00";
public const string LoadTexFileExtern = "E8 ?? ?? ?? ?? 0F B6 E8 48 8B CB E8";
public const string LoadMdlFileExtern = "E8 ?? ?? ?? ?? EB 02 B0 F1";
// GameEventManager
public const string ResourceHandleDestructor = "48 89 5C 24 ?? 57 48 83 EC ?? 48 8D 05 ?? ?? ?? ?? 48 8B D9 48 89 01 B8";
public const string CopyCharacter = "E8 ?? ?? ?? ?? 0F B6 9F ?? ?? ?? ?? 48 8D 8F";
public const string CharacterDestructor =
"48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC ?? 48 8D 05 ?? ?? ?? ?? 48 8B D9 48 89 01 48 8D 05 ?? ?? ?? ?? 48 89 81 ?? ?? ?? ?? 48 8D 05";
// PathResolver.AnimationState
public const string LoadCharacterSound = "4C 89 4C 24 ?? 55 57 41 56";
public const string LoadTimelineResources = "E8 ?? ?? ?? ?? 83 7F ?? ?? 75 ?? 0F B6 87";
public const string CharacterBaseLoadAnimation = "E8 ?? ?? ?? ?? BA ?? ?? ?? ?? 48 8B CF 44 8B C2 E8 ?? ?? ?? ?? 48 8B 05";
public const string LoadSomePap = "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 56 41 57 48 83 EC ?? 41 8B D9 89 51";
public const string LoadSomeAction = "E8 ?? ?? ?? ?? C6 83 ?? ?? ?? ?? ?? 8B 8E";
public const string LoadCharacterVfx = "E8 ?? ?? ?? ?? 48 8B F8 48 8D 93";
public const string LoadAreaVfx = "48 8B C4 53 55 56 57 41 56 48 81 EC";
public const string ScheduleClipUpdate = "40 53 55 56 57 41 56 48 81 EC ?? ?? ?? ?? 48 8B F9";
// PathResolver.DrawObjectState
public const string CharacterBaseCreate = "E8 ?? ?? ?? ?? 48 85 C0 74 21 C7 40";
public const string CharacterBaseDestructor =
"E8 ?? ?? ?? ?? 40 F6 C7 01 74 3A 40 F6 C7 04 75 27 48 85 DB 74 2F 48 8B 05 ?? ?? ?? ?? 48 8B D3 48 8B 48 30";
public const string EnableDraw = "E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 48 85 C9 74 33 45 33 C0";
public const string WeaponReload = "E8 ?? ?? ?? ?? 33 DB BE";
// PathResolver.Meta
public const string UpdateModel = "48 8B ?? 56 48 83 ?? ?? ?? B9";
public const string GetEqpIndirect = "40 ?? 48 83 ?? ?? ?? 81 ?? ?? ?? ?? ?? 48 8B ?? 74 ?? ?? 83 ?? ?? ?? ?? ?? ?? 74 ?? 4C";
public const string SetupVisor = "48 8B ?? 53 55 57 48 83 ?? ?? 48 8B";
public const string RspSetupCharacter = "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 88 54 24 ?? 57 41 56";
public const string ChangeCustomize = "E8 ?? ?? ?? ?? 41 0F B6 C5 66 41 89 86";
// PathResolver.PathState
public const string HumanVTable = "48 8D 05 ?? ?? ?? ?? 48 89 03 48 B8 ?? ?? ?? ?? ?? ?? ?? ?? 89 8B";
public const string WeaponVTable =
"48 8D 05 ?? ?? ?? ?? 48 89 03 B8 ?? ?? ?? ?? 66 89 83 ?? ?? ?? ?? 48 8B C3 48 89 8B ?? ?? ?? ?? 48 89 8B";
public const string DemiHumanVTable = "48 8D 05 ?? ?? ?? ?? 48 89 03 48 8B C3 89 8B";
public const string MonsterVTable = "48 8D 05 ?? ?? ?? ?? 48 89 03 33 C0 48 89 83 ?? ?? ?? ?? 48 89 83 ?? ?? ?? ?? C7 83";
// PathResolver.Subfiles
public const string LoadMtrlTex = "4C 8B DC 49 89 5B ?? 49 89 73 ?? 55 57 41 55";
public const string LoadMtrlShpk =
"48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 44 0F B7 89";
public const string ApricotResourceLoad = "48 89 74 24 ?? 57 48 83 EC ?? 41 0F B6 F0 48 8B F9";
// CharacterUtility
public const string CharacterUtility = "48 8B 05 ?? ?? ?? ?? 83 B9";
public const string LoadCharacterResources = "E8 ?? ?? ?? ?? 48 8D 8F ?? ?? ?? ?? E8 ?? ?? ?? ?? 33 D2 45 33 C0";
// MetaFileManager
public const string GetFileSpace = "E8 ?? ?? ?? ?? 41 B9 ?? ?? ?? ?? 4C 8B C0";
// ResidentResourceManager
public const string ResidentResourceManager = "0F 44 FE 48 8B 0D ?? ?? ?? ?? 48 85 C9 74 05";
public const string LoadPlayerResources =
"E8 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? BA ?? ?? ?? ?? 41 B8 ?? ?? ?? ?? 48 8B 48 30 48 8B 01 FF 50 10 48 85 C0 74 0A";
public const string UnloadPlayerResources =
"41 55 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 4C 8B E9 48 83 C1 08";
// ActorManager
public const string InspectTitleId = "0F B7 0D ?? ?? ?? ?? C7 85";
public const string InspectWorldId = "0F B7 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B D0";
}

View file

@ -1,59 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace Penumbra.GameData.Structs;
[StructLayout(LayoutKind.Explicit, Pack = 1)]
public struct CharacterArmor : IEquatable<CharacterArmor>
{
public const int Size = 4;
[FieldOffset(0)]
public readonly uint Value;
[FieldOffset(0)]
public SetId Set;
[FieldOffset(2)]
public byte Variant;
[FieldOffset(3)]
public StainId Stain;
public CharacterArmor(SetId set, byte variant, StainId stain)
{
Value = 0;
Set = set;
Variant = variant;
Stain = stain;
}
public readonly CharacterArmor With(StainId stain)
=> new(Set, Variant, stain);
public readonly CharacterWeapon ToWeapon()
=> new(Set, 0, Variant, Stain);
public readonly CharacterWeapon ToWeapon(StainId stain)
=> new(Set, 0, Variant, stain);
public override readonly string ToString()
=> $"{Set},{Variant},{Stain}";
public static readonly CharacterArmor Empty;
public readonly bool Equals(CharacterArmor other)
=> Value == other.Value;
public override readonly bool Equals(object? obj)
=> obj is CharacterArmor other && Equals(other);
public override readonly int GetHashCode()
=> (int)Value;
public static bool operator ==(CharacterArmor left, CharacterArmor right)
=> left.Value == right.Value;
public static bool operator !=(CharacterArmor left, CharacterArmor right)
=> left.Value != right.Value;
}

View file

@ -1,65 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace Penumbra.GameData.Structs;
[StructLayout(LayoutKind.Explicit, Pack = 1, Size = 7)]
public struct CharacterWeapon : IEquatable<CharacterWeapon>
{
[FieldOffset(0)]
public SetId Set;
[FieldOffset(2)]
public WeaponType Type;
[FieldOffset(4)]
public ushort Variant;
[FieldOffset(6)]
public StainId Stain;
public readonly ulong Value
=> (ulong)Set | ((ulong)Type << 16) | ((ulong)Variant << 32) | ((ulong)Stain << 48);
public override readonly string ToString()
=> $"{Set},{Type},{Variant},{Stain}";
public CharacterWeapon(SetId set, WeaponType type, ushort variant, StainId stain)
{
Set = set;
Type = type;
Variant = variant;
Stain = stain;
}
public CharacterWeapon(ulong value)
{
Set = (SetId)value;
Type = (WeaponType)(value >> 16);
Variant = (ushort)(value >> 32);
Stain = (StainId)(value >> 48);
}
public readonly CharacterArmor ToArmor()
=> new(Set, (byte)Variant, Stain);
public readonly CharacterArmor ToArmor(StainId stain)
=> new(Set, (byte)Variant, stain);
public static readonly CharacterWeapon Empty = new(0, 0, 0, 0);
public readonly bool Equals(CharacterWeapon other)
=> Value == other.Value;
public override readonly bool Equals(object? obj)
=> obj is CharacterWeapon other && Equals(other);
public override readonly int GetHashCode()
=> Value.GetHashCode();
public static bool operator ==(CharacterWeapon left, CharacterWeapon right)
=> left.Value == right.Value;
public static bool operator !=(CharacterWeapon left, CharacterWeapon right)
=> left.Value != right.Value;
}

View file

@ -1,100 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using Penumbra.String.Functions;
namespace Penumbra.GameData.Structs;
[StructLayout(LayoutKind.Sequential, Size = Size)]
public unsafe struct CustomizeData : IEquatable< CustomizeData >
{
public const int Size = 26;
public fixed byte Data[Size];
public void Read( void* source )
{
fixed( byte* ptr = Data )
{
MemoryUtility.MemCpyUnchecked( ptr, source, Size );
}
}
public readonly void Write( void* target )
{
fixed( byte* ptr = Data )
{
MemoryUtility.MemCpyUnchecked( target, ptr, Size );
}
}
public readonly CustomizeData Clone()
{
var ret = new CustomizeData();
Write( ret.Data );
return ret;
}
public readonly bool Equals( CustomizeData other )
{
fixed( byte* ptr = Data )
{
return MemoryUtility.MemCmpUnchecked( ptr, other.Data, Size ) == 0;
}
}
public override bool Equals( object? obj )
=> obj is CustomizeData other && Equals( other );
public static bool Equals(CustomizeData* lhs, CustomizeData* rhs)
=> MemoryUtility.MemCmpUnchecked(lhs, rhs, Size) == 0;
/// <remarks>Compare Gender and then only from Height onwards, because all screen actors are set to Height 50,
/// the Race is implicitly included in the subrace (after height),
/// and the body type is irrelevant for players.</remarks>>
public static bool ScreenActorEquals(CustomizeData* lhs, CustomizeData* rhs)
=> lhs->Data[1] == rhs->Data[1] && MemoryUtility.MemCmpUnchecked(lhs->Data + 4, rhs->Data + 4, Size - 4) == 0;
public override int GetHashCode()
{
fixed( byte* ptr = Data )
{
var p = ( int* )ptr;
var u = *( ushort* )( p + 6 );
return HashCode.Combine( *p, p[ 1 ], p[ 2 ], p[ 3 ], p[ 4 ], p[ 5 ], u );
}
}
public readonly string WriteBase64()
{
fixed( byte* ptr = Data )
{
var data = new ReadOnlySpan< byte >( ptr, Size );
return Convert.ToBase64String( data );
}
}
public override string ToString()
{
var sb = new StringBuilder(Size * 3);
for (var i = 0; i < Size - 1; ++i)
{
sb.Append($"{Data[i]:X2} ");
}
sb.Append($"{Data[Size - 1]:X2}");
return sb.ToString();
}
public bool LoadBase64( string base64 )
{
var buffer = stackalloc byte[Size];
var span = new Span< byte >( buffer, Size );
if( !Convert.TryFromBase64String( base64, span, out var written ) || written != Size )
{
return false;
}
Read( buffer );
return true;
}
}

View file

@ -1,120 +0,0 @@
using System;
using System.ComponentModel;
using Penumbra.GameData.Enums;
namespace Penumbra.GameData.Structs;
[Flags]
public enum EqdpEntry : ushort
{
Invalid = 0,
Head1 = 0b0000000001,
Head2 = 0b0000000010,
HeadMask = 0b0000000011,
Body1 = 0b0000000100,
Body2 = 0b0000001000,
BodyMask = 0b0000001100,
Hands1 = 0b0000010000,
Hands2 = 0b0000100000,
HandsMask = 0b0000110000,
Legs1 = 0b0001000000,
Legs2 = 0b0010000000,
LegsMask = 0b0011000000,
Feet1 = 0b0100000000,
Feet2 = 0b1000000000,
FeetMask = 0b1100000000,
Ears1 = 0b0000000001,
Ears2 = 0b0000000010,
EarsMask = 0b0000000011,
Neck1 = 0b0000000100,
Neck2 = 0b0000001000,
NeckMask = 0b0000001100,
Wrists1 = 0b0000010000,
Wrists2 = 0b0000100000,
WristsMask = 0b0000110000,
RingR1 = 0b0001000000,
RingR2 = 0b0010000000,
RingRMask = 0b0011000000,
RingL1 = 0b0100000000,
RingL2 = 0b1000000000,
RingLMask = 0b1100000000,
}
public static class Eqdp
{
public static int Offset( EquipSlot slot )
=> slot switch
{
EquipSlot.Head => 0,
EquipSlot.Body => 2,
EquipSlot.Hands => 4,
EquipSlot.Legs => 6,
EquipSlot.Feet => 8,
EquipSlot.Ears => 0,
EquipSlot.Neck => 2,
EquipSlot.Wrists => 4,
EquipSlot.RFinger => 6,
EquipSlot.LFinger => 8,
_ => throw new InvalidEnumArgumentException(),
};
public static (bool, bool) ToBits( this EqdpEntry entry, EquipSlot slot )
=> slot switch
{
EquipSlot.Head => ( entry.HasFlag( EqdpEntry.Head1 ), entry.HasFlag( EqdpEntry.Head2 ) ),
EquipSlot.Body => ( entry.HasFlag( EqdpEntry.Body1 ), entry.HasFlag( EqdpEntry.Body2 ) ),
EquipSlot.Hands => ( entry.HasFlag( EqdpEntry.Hands1 ), entry.HasFlag( EqdpEntry.Hands2 ) ),
EquipSlot.Legs => ( entry.HasFlag( EqdpEntry.Legs1 ), entry.HasFlag( EqdpEntry.Legs2 ) ),
EquipSlot.Feet => ( entry.HasFlag( EqdpEntry.Feet1 ), entry.HasFlag( EqdpEntry.Feet2 ) ),
EquipSlot.Ears => ( entry.HasFlag( EqdpEntry.Ears1 ), entry.HasFlag( EqdpEntry.Ears2 ) ),
EquipSlot.Neck => ( entry.HasFlag( EqdpEntry.Neck1 ), entry.HasFlag( EqdpEntry.Neck2 ) ),
EquipSlot.Wrists => ( entry.HasFlag( EqdpEntry.Wrists1 ), entry.HasFlag( EqdpEntry.Wrists2 ) ),
EquipSlot.RFinger => ( entry.HasFlag( EqdpEntry.RingR1 ), entry.HasFlag( EqdpEntry.RingR2 ) ),
EquipSlot.LFinger => ( entry.HasFlag( EqdpEntry.RingL1 ), entry.HasFlag( EqdpEntry.RingL2 ) ),
_ => throw new InvalidEnumArgumentException(),
};
public static EqdpEntry FromSlotAndBits( EquipSlot slot, bool bit1, bool bit2 )
{
EqdpEntry ret = 0;
var offset = Offset( slot );
if( bit1 )
{
ret |= ( EqdpEntry )( 1 << offset );
}
if( bit2 )
{
ret |= ( EqdpEntry )( 1 << ( offset + 1 ) );
}
return ret;
}
public static EqdpEntry Mask( EquipSlot slot )
{
return slot switch
{
EquipSlot.Head => EqdpEntry.HeadMask,
EquipSlot.Body => EqdpEntry.BodyMask,
EquipSlot.Hands => EqdpEntry.HandsMask,
EquipSlot.Legs => EqdpEntry.LegsMask,
EquipSlot.Feet => EqdpEntry.FeetMask,
EquipSlot.Ears => EqdpEntry.EarsMask,
EquipSlot.Neck => EqdpEntry.NeckMask,
EquipSlot.Wrists => EqdpEntry.WristsMask,
EquipSlot.RFinger => EqdpEntry.RingRMask,
EquipSlot.LFinger => EqdpEntry.RingLMask,
_ => 0,
};
}
}

View file

@ -1,316 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using Penumbra.GameData.Enums;
namespace Penumbra.GameData.Structs;
[Flags]
public enum EqpEntry : ulong
{
BodyEnabled = 0x00_01ul,
BodyHideWaist = 0x00_02ul,
BodyHideThighs = 0x00_04ul,
BodyHideGlovesS = 0x00_08ul,
_4 = 0x00_10ul,
BodyHideGlovesM = 0x00_20ul,
BodyHideGlovesL = 0x00_40ul,
BodyHideGorget = 0x00_80ul,
BodyShowLeg = 0x01_00ul,
BodyShowHand = 0x02_00ul,
BodyShowHead = 0x04_00ul,
BodyShowNecklace = 0x08_00ul,
BodyShowBracelet = 0x10_00ul,
BodyShowTail = 0x20_00ul,
BodyDisableBreastPhysics = 0x40_00ul,
BodyUsesEvpTable = 0x80_00ul,
BodyMask = 0xFF_FFul,
LegsEnabled = 0x01ul << 16,
LegsHideKneePads = 0x02ul << 16,
LegsHideBootsS = 0x04ul << 16,
LegsHideBootsM = 0x08ul << 16,
_20 = 0x10ul << 16,
LegsShowFoot = 0x20ul << 16,
LegsShowTail = 0x40ul << 16,
_23 = 0x80ul << 16,
LegsMask = 0xFFul << 16,
HandsEnabled = 0x01ul << 24,
HandsHideElbow = 0x02ul << 24,
HandsHideForearm = 0x04ul << 24,
_27 = 0x08ul << 24,
HandShowBracelet = 0x10ul << 24,
HandShowRingL = 0x20ul << 24,
HandShowRingR = 0x40ul << 24,
_31 = 0x80ul << 24,
HandsMask = 0xFFul << 24,
FeetEnabled = 0x01ul << 32,
FeetHideKnee = 0x02ul << 32,
FeetHideCalf = 0x04ul << 32,
FeetHideAnkle = 0x08ul << 32,
_36 = 0x10ul << 32,
_37 = 0x20ul << 32,
_38 = 0x40ul << 32,
_39 = 0x80ul << 32,
FeetMask = 0xFFul << 32,
HeadEnabled = 0x00_00_01ul << 40,
HeadHideScalp = 0x00_00_02ul << 40,
HeadHideHair = 0x00_00_04ul << 40,
HeadShowHairOverride = 0x00_00_08ul << 40,
HeadHideNeck = 0x00_00_10ul << 40,
HeadShowNecklace = 0x00_00_20ul << 40,
_46 = 0x00_00_40ul << 40,
HeadShowEarrings = 0x00_00_80ul << 40,
HeadShowEarringsHuman = 0x00_01_00ul << 40,
HeadShowEarringsAura = 0x00_02_00ul << 40,
HeadShowEarHuman = 0x00_04_00ul << 40,
HeadShowEarMiqote = 0x00_08_00ul << 40,
HeadShowEarAuRa = 0x00_10_00ul << 40,
HeadShowEarViera = 0x00_20_00ul << 40,
_54 = 0x00_40_00ul << 40,
_55 = 0x00_80_00ul << 40,
HeadShowHrothgarHat = 0x01_00_00ul << 40,
HeadShowVieraHat = 0x02_00_00ul << 40,
HeadUsesEvpTable = 0x04_00_00ul << 40,
_59 = 0x08_00_00ul << 40,
_60 = 0x10_00_00ul << 40,
_61 = 0x20_00_00ul << 40,
_62 = 0x40_00_00ul << 40,
_63 = 0x80_00_00ul << 40,
HeadMask = 0xFF_FF_FFul << 40,
}
public static class Eqp
{
// cf. Client::Graphics::Scene::CharacterUtility.GetSlotEqpFlags
public const EqpEntry DefaultEntry = (EqpEntry)0x3fe00070603f00;
public static (int, int) BytesAndOffset(EquipSlot slot)
{
return slot switch
{
EquipSlot.Body => (2, 0),
EquipSlot.Legs => (1, 2),
EquipSlot.Hands => (1, 3),
EquipSlot.Feet => (1, 4),
EquipSlot.Head => (3, 5),
_ => throw new InvalidEnumArgumentException(),
};
}
public static EqpEntry ShiftAndMask(this EqpEntry entry, EquipSlot slot)
{
var (_, offset) = BytesAndOffset(slot);
var mask = Mask(slot);
return (EqpEntry)((ulong)(entry & mask) >> (offset * 8));
}
public static EqpEntry FromSlotAndBytes(EquipSlot slot, byte[] value)
{
EqpEntry ret = 0;
var (bytes, offset) = BytesAndOffset(slot);
if (bytes != value.Length)
throw new ArgumentException();
for (var i = 0; i < bytes; ++i)
ret |= (EqpEntry)((ulong)value[i] << ((offset + i) * 8));
return ret;
}
public static EqpEntry Mask(EquipSlot slot)
{
return slot switch
{
EquipSlot.Body => EqpEntry.BodyMask,
EquipSlot.Head => EqpEntry.HeadMask,
EquipSlot.Legs => EqpEntry.LegsMask,
EquipSlot.Feet => EqpEntry.FeetMask,
EquipSlot.Hands => EqpEntry.HandsMask,
_ => 0,
};
}
public static EquipSlot ToEquipSlot(this EqpEntry entry)
{
return entry switch
{
EqpEntry.BodyEnabled => EquipSlot.Body,
EqpEntry.BodyHideWaist => EquipSlot.Body,
EqpEntry.BodyHideThighs => EquipSlot.Body,
EqpEntry.BodyHideGlovesS => EquipSlot.Body,
EqpEntry._4 => EquipSlot.Body,
EqpEntry.BodyHideGlovesM => EquipSlot.Body,
EqpEntry.BodyHideGlovesL => EquipSlot.Body,
EqpEntry.BodyHideGorget => EquipSlot.Body,
EqpEntry.BodyShowLeg => EquipSlot.Body,
EqpEntry.BodyShowHand => EquipSlot.Body,
EqpEntry.BodyShowHead => EquipSlot.Body,
EqpEntry.BodyShowNecklace => EquipSlot.Body,
EqpEntry.BodyShowBracelet => EquipSlot.Body,
EqpEntry.BodyShowTail => EquipSlot.Body,
EqpEntry.BodyDisableBreastPhysics => EquipSlot.Body,
EqpEntry.BodyUsesEvpTable => EquipSlot.Body,
EqpEntry.LegsEnabled => EquipSlot.Legs,
EqpEntry.LegsHideKneePads => EquipSlot.Legs,
EqpEntry.LegsHideBootsS => EquipSlot.Legs,
EqpEntry.LegsHideBootsM => EquipSlot.Legs,
EqpEntry._20 => EquipSlot.Legs,
EqpEntry.LegsShowFoot => EquipSlot.Legs,
EqpEntry.LegsShowTail => EquipSlot.Legs,
EqpEntry._23 => EquipSlot.Legs,
EqpEntry.HandsEnabled => EquipSlot.Hands,
EqpEntry.HandsHideElbow => EquipSlot.Hands,
EqpEntry.HandsHideForearm => EquipSlot.Hands,
EqpEntry._27 => EquipSlot.Hands,
EqpEntry.HandShowBracelet => EquipSlot.Hands,
EqpEntry.HandShowRingL => EquipSlot.Hands,
EqpEntry.HandShowRingR => EquipSlot.Hands,
EqpEntry._31 => EquipSlot.Hands,
EqpEntry.FeetEnabled => EquipSlot.Feet,
EqpEntry.FeetHideKnee => EquipSlot.Feet,
EqpEntry.FeetHideCalf => EquipSlot.Feet,
EqpEntry.FeetHideAnkle => EquipSlot.Feet,
EqpEntry._36 => EquipSlot.Feet,
EqpEntry._37 => EquipSlot.Feet,
EqpEntry._38 => EquipSlot.Feet,
EqpEntry._39 => EquipSlot.Feet,
EqpEntry.HeadEnabled => EquipSlot.Head,
EqpEntry.HeadHideScalp => EquipSlot.Head,
EqpEntry.HeadHideHair => EquipSlot.Head,
EqpEntry.HeadShowHairOverride => EquipSlot.Head,
EqpEntry.HeadHideNeck => EquipSlot.Head,
EqpEntry.HeadShowNecklace => EquipSlot.Head,
EqpEntry._46 => EquipSlot.Head,
EqpEntry.HeadShowEarrings => EquipSlot.Head,
EqpEntry.HeadShowEarringsHuman => EquipSlot.Head,
EqpEntry.HeadShowEarringsAura => EquipSlot.Head,
EqpEntry.HeadShowEarHuman => EquipSlot.Head,
EqpEntry.HeadShowEarMiqote => EquipSlot.Head,
EqpEntry.HeadShowEarAuRa => EquipSlot.Head,
EqpEntry.HeadShowEarViera => EquipSlot.Head,
EqpEntry._54 => EquipSlot.Head,
EqpEntry._55 => EquipSlot.Head,
EqpEntry.HeadShowHrothgarHat => EquipSlot.Head,
EqpEntry.HeadShowVieraHat => EquipSlot.Head,
EqpEntry.HeadUsesEvpTable => EquipSlot.Head,
// currently unused
EqpEntry._59 => EquipSlot.Unknown,
EqpEntry._60 => EquipSlot.Unknown,
EqpEntry._61 => EquipSlot.Unknown,
EqpEntry._62 => EquipSlot.Unknown,
EqpEntry._63 => EquipSlot.Unknown,
_ => EquipSlot.Unknown,
};
}
public static string ToLocalName(this EqpEntry entry)
{
return entry switch
{
EqpEntry.BodyEnabled => "Enabled",
EqpEntry.BodyHideWaist => "Hide Waist",
EqpEntry.BodyHideThighs => "Hide Thigh Pads",
EqpEntry.BodyHideGlovesS => "Hide Small Gloves",
EqpEntry._4 => "Unknown 4",
EqpEntry.BodyHideGlovesM => "Hide Medium Gloves",
EqpEntry.BodyHideGlovesL => "Hide Large Gloves",
EqpEntry.BodyHideGorget => "Hide Gorget",
EqpEntry.BodyShowLeg => "Show Legs",
EqpEntry.BodyShowHand => "Show Hands",
EqpEntry.BodyShowHead => "Show Head",
EqpEntry.BodyShowNecklace => "Show Necklace",
EqpEntry.BodyShowBracelet => "Show Bracelet",
EqpEntry.BodyShowTail => "Show Tail",
EqpEntry.BodyDisableBreastPhysics => "Disable Breast Physics",
EqpEntry.BodyUsesEvpTable => "Uses EVP Table",
EqpEntry.LegsEnabled => "Enabled",
EqpEntry.LegsHideKneePads => "Hide Knee Pads",
EqpEntry.LegsHideBootsS => "Hide Small Boots",
EqpEntry.LegsHideBootsM => "Hide Medium Boots",
EqpEntry._20 => "Unknown 20",
EqpEntry.LegsShowFoot => "Show Foot",
EqpEntry.LegsShowTail => "Show Tail",
EqpEntry._23 => "Unknown 23",
EqpEntry.HandsEnabled => "Enabled",
EqpEntry.HandsHideElbow => "Hide Elbow",
EqpEntry.HandsHideForearm => "Hide Forearm",
EqpEntry._27 => "Unknown 27",
EqpEntry.HandShowBracelet => "Show Bracelet",
EqpEntry.HandShowRingL => "Show Left Ring",
EqpEntry.HandShowRingR => "Show Right Ring",
EqpEntry._31 => "Unknown 31",
EqpEntry.FeetEnabled => "Enabled",
EqpEntry.FeetHideKnee => "Hide Knees",
EqpEntry.FeetHideCalf => "Hide Calves",
EqpEntry.FeetHideAnkle => "Hide Ankles",
EqpEntry._36 => "Unknown 36",
EqpEntry._37 => "Unknown 37",
EqpEntry._38 => "Unknown 38",
EqpEntry._39 => "Unknown 39",
EqpEntry.HeadEnabled => "Enabled",
EqpEntry.HeadHideScalp => "Hide Scalp",
EqpEntry.HeadHideHair => "Hide Hair",
EqpEntry.HeadShowHairOverride => "Show Hair Override",
EqpEntry.HeadHideNeck => "Hide Neck",
EqpEntry.HeadShowNecklace => "Show Necklace",
EqpEntry._46 => "Unknown 46",
EqpEntry.HeadShowEarrings => "Show Earrings",
EqpEntry.HeadShowEarringsHuman => "Show Earrings (Human)",
EqpEntry.HeadShowEarringsAura => "Show Earrings (Au Ra)",
EqpEntry.HeadShowEarHuman => "Show Ears (Human)",
EqpEntry.HeadShowEarMiqote => "Show Ears (Miqo'te)",
EqpEntry.HeadShowEarAuRa => "Show Ears (Au Ra)",
EqpEntry.HeadShowEarViera => "Show Ears (Viera)",
EqpEntry._54 => "Unknown 54",
EqpEntry._55 => "Unknown 55",
EqpEntry.HeadShowHrothgarHat => "Show on Hrothgar",
EqpEntry.HeadShowVieraHat => "Show on Viera",
EqpEntry.HeadUsesEvpTable => "Uses EVP Table",
EqpEntry._59 => "Unknown 59",
EqpEntry._60 => "Unknown 60",
EqpEntry._61 => "Unknown 61",
EqpEntry._62 => "Unknown 62",
EqpEntry._63 => "Unknown 63",
_ => throw new InvalidEnumArgumentException(),
};
}
private static EqpEntry[] GetEntriesForSlot(EquipSlot slot)
{
return ((EqpEntry[])Enum.GetValues(typeof(EqpEntry)))
.Where(e => e.ToEquipSlot() == slot)
.ToArray();
}
public static readonly EqpEntry[] EqpAttributesBody = GetEntriesForSlot(EquipSlot.Body);
public static readonly EqpEntry[] EqpAttributesLegs = GetEntriesForSlot(EquipSlot.Legs);
public static readonly EqpEntry[] EqpAttributesHands = GetEntriesForSlot(EquipSlot.Hands);
public static readonly EqpEntry[] EqpAttributesFeet = GetEntriesForSlot(EquipSlot.Feet);
public static readonly EqpEntry[] EqpAttributesHead = GetEntriesForSlot(EquipSlot.Head);
public static readonly IReadOnlyDictionary<EquipSlot, EqpEntry[]> EqpAttributes = new Dictionary<EquipSlot, EqpEntry[]>()
{
[EquipSlot.Body] = EqpAttributesBody,
[EquipSlot.Legs] = EqpAttributesLegs,
[EquipSlot.Hands] = EqpAttributesHands,
[EquipSlot.Feet] = EqpAttributesFeet,
[EquipSlot.Head] = EqpAttributesHead,
};
}

View file

@ -1,90 +0,0 @@
using System.Runtime.InteropServices;
using Dalamud.Utility;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using PseudoEquipItem = System.ValueTuple<string, uint, ushort, ushort, ushort, byte, byte>;
namespace Penumbra.GameData.Structs;
[StructLayout(LayoutKind.Sequential)]
public readonly struct EquipItem
{
public readonly string Name;
public readonly uint Id;
public readonly ushort IconId;
public readonly SetId ModelId;
public readonly WeaponType WeaponType;
public readonly byte Variant;
public readonly FullEquipType Type;
public bool Valid
=> Type != FullEquipType.Unknown;
public CharacterArmor Armor()
=> new(ModelId, Variant, 0);
public CharacterArmor Armor(StainId stain)
=> new(ModelId, Variant, stain);
public CharacterWeapon Weapon()
=> new(ModelId, WeaponType, Variant, 0);
public CharacterWeapon Weapon(StainId stain)
=> new(ModelId, WeaponType, Variant, stain);
public EquipItem()
=> Name = string.Empty;
public EquipItem(string name, uint id, ushort iconId, SetId modelId, WeaponType weaponType, byte variant, FullEquipType type)
{
Name = string.Intern(name);
Id = id;
IconId = iconId;
ModelId = modelId;
WeaponType = weaponType;
Variant = variant;
Type = type;
}
public static implicit operator EquipItem(PseudoEquipItem it)
=> new(it.Item1, it.Item2, it.Item3, it.Item4, it.Item5, it.Item6, (FullEquipType)it.Item7);
public static explicit operator PseudoEquipItem(EquipItem it)
=> (it.Name, it.Id, it.IconId, (ushort)it.ModelId, (ushort)it.WeaponType, it.Variant, (byte)it.Type);
public static EquipItem FromArmor(Item item)
{
var type = item.ToEquipType();
var name = item.Name.ToDalamudString().TextValue;
var id = item.RowId;
var icon = item.Icon;
var model = (SetId)item.ModelMain;
var weapon = (WeaponType)0;
var variant = (byte)(item.ModelMain >> 16);
return new EquipItem(name, id, icon, model, weapon, variant, type);
}
public static EquipItem FromMainhand(Item item)
{
var type = item.ToEquipType();
var name = item.Name.ToDalamudString().TextValue;
var id = item.RowId;
var icon = item.Icon;
var model = (SetId)item.ModelMain;
var weapon = (WeaponType)(item.ModelMain >> 16);
var variant = (byte)(item.ModelMain >> 32);
return new EquipItem(name, id, icon, model, weapon, variant, type);
}
public static EquipItem FromOffhand(Item item)
{
var type = item.ToEquipType().Offhand();
var name = item.Name.ToDalamudString().TextValue + type.OffhandTypeSuffix();
var id = item.RowId;
var icon = item.Icon;
var model = (SetId)item.ModelSub;
var weapon = (WeaponType)(item.ModelSub >> 16);
var variant = (byte)(item.ModelSub >> 32);
return new EquipItem(name, id, icon, model, weapon, variant, type);
}
}

View file

@ -1,159 +0,0 @@
using System;
using System.Runtime.InteropServices;
using Dalamud;
using Penumbra.GameData.Enums;
namespace Penumbra.GameData.Structs;
[StructLayout( LayoutKind.Explicit )]
public struct GameObjectInfo : IComparable
{
public static GameObjectInfo Equipment( FileType type, ushort setId, GenderRace gr = GenderRace.Unknown
, EquipSlot slot = EquipSlot.Unknown, byte variant = 0 )
=> new()
{
FileType = type,
ObjectType = slot.IsAccessory() ? ObjectType.Accessory : ObjectType.Equipment,
PrimaryId = setId,
GenderRace = gr,
Variant = variant,
EquipSlot = slot,
};
public static GameObjectInfo Weapon( FileType type, ushort setId, ushort weaponId, byte variant = 0 )
=> new()
{
FileType = type,
ObjectType = ObjectType.Weapon,
PrimaryId = setId,
SecondaryId = weaponId,
Variant = variant,
};
public static GameObjectInfo Customization( FileType type, CustomizationType customizationType, ushort id = 0
, GenderRace gr = GenderRace.Unknown, BodySlot bodySlot = BodySlot.Unknown, byte variant = 0 )
=> new()
{
FileType = type,
ObjectType = ObjectType.Character,
PrimaryId = id,
GenderRace = gr,
BodySlot = bodySlot,
Variant = variant,
CustomizationType = customizationType,
};
public static GameObjectInfo Monster( FileType type, ushort monsterId, ushort bodyId, byte variant = 0 )
=> new()
{
FileType = type,
ObjectType = ObjectType.Monster,
PrimaryId = monsterId,
SecondaryId = bodyId,
Variant = variant,
};
public static GameObjectInfo DemiHuman( FileType type, ushort demiHumanId, ushort bodyId, EquipSlot slot = EquipSlot.Unknown,
byte variant = 0
)
=> new()
{
FileType = type,
ObjectType = ObjectType.DemiHuman,
PrimaryId = demiHumanId,
SecondaryId = bodyId,
Variant = variant,
EquipSlot = slot,
};
public static GameObjectInfo Map( FileType type, byte c1, byte c2, byte c3, byte c4, byte variant, byte suffix = 0 )
=> new()
{
FileType = type,
ObjectType = ObjectType.Map,
MapC1 = c1,
MapC2 = c2,
MapC3 = c3,
MapC4 = c4,
MapSuffix = suffix,
Variant = variant,
};
public static GameObjectInfo Icon( FileType type, uint iconId, bool hq, bool hr, ClientLanguage lang = ClientLanguage.English )
=> new()
{
FileType = type,
ObjectType = ObjectType.Icon,
IconId = iconId,
IconHqHr = ( byte )( hq ? hr ? 3 : 1 : hr ? 2 : 0 ),
Language = lang,
};
[FieldOffset( 0 )]
public readonly ulong Identifier;
[FieldOffset( 0 )]
public FileType FileType;
[FieldOffset( 1 )]
public ObjectType ObjectType;
[FieldOffset( 2 )]
public ushort PrimaryId; // Equipment, Weapon, Customization, Monster, DemiHuman
[FieldOffset( 2 )]
public uint IconId; // Icon
[FieldOffset( 2 )]
public byte MapC1; // Map
[FieldOffset( 3 )]
public byte MapC2; // Map
[FieldOffset( 4 )]
public ushort SecondaryId; // Weapon, Monster, Demihuman
[FieldOffset( 4 )]
public byte MapC3; // Map
[FieldOffset( 4 )]
private byte _genderRaceByte; // Equipment, Customization
public GenderRace GenderRace
{
get => Names.GenderRaceFromByte( _genderRaceByte );
set => _genderRaceByte = value.ToByte();
}
[FieldOffset( 5 )]
public BodySlot BodySlot; // Customization
[FieldOffset( 5 )]
public byte MapC4; // Map
[FieldOffset( 6 )]
public byte Variant; // Equipment, Weapon, Customization, Map, Monster, Demihuman
[FieldOffset( 6 )]
public byte IconHqHr; // Icon
[FieldOffset( 7 )]
public EquipSlot EquipSlot; // Equipment, Demihuman
[FieldOffset( 7 )]
public CustomizationType CustomizationType; // Customization
[FieldOffset( 7 )]
public ClientLanguage Language; // Icon
[FieldOffset( 7 )]
public byte MapSuffix;
public override int GetHashCode()
=> Identifier.GetHashCode();
public int CompareTo( object? r )
=> Identifier.CompareTo( r );
}

View file

@ -1,103 +0,0 @@
using System;
using System.IO;
namespace Penumbra.GameData.Structs;
public struct GmpEntry : IEquatable< GmpEntry >
{
public static readonly GmpEntry Default = new();
public bool Enabled
{
get => ( Value & 1 ) == 1;
set
{
if( value )
{
Value |= 1ul;
}
else
{
Value &= ~1ul;
}
}
}
public bool Animated
{
get => ( Value & 2 ) == 2;
set
{
if( value )
{
Value |= 2ul;
}
else
{
Value &= ~2ul;
}
}
}
public ushort RotationA
{
get => ( ushort )( ( Value >> 2 ) & 0x3FF );
set => Value = ( Value & ~0xFFCul ) | ( ( value & 0x3FFul ) << 2 );
}
public ushort RotationB
{
get => ( ushort )( ( Value >> 12 ) & 0x3FF );
set => Value = ( Value & ~0x3FF000ul ) | ( ( value & 0x3FFul ) << 12 );
}
public ushort RotationC
{
get => ( ushort )( ( Value >> 22 ) & 0x3FF );
set => Value = ( Value & ~0xFFC00000ul ) | ( ( value & 0x3FFul ) << 22 );
}
public byte UnknownA
{
get => ( byte )( ( Value >> 32 ) & 0x0F );
set => Value = ( Value & ~0x0F00000000ul ) | ( ( value & 0x0Ful ) << 32 );
}
public byte UnknownB
{
get => ( byte )( ( Value >> 36 ) & 0x0F );
set => Value = ( Value & ~0xF000000000ul ) | ( ( value & 0x0Ful ) << 36 );
}
public byte UnknownTotal
{
get => ( byte )( ( Value >> 32 ) & 0xFF );
set => Value = ( Value & ~0xFF00000000ul ) | ( ( value & 0xFFul ) << 32 );
}
public ulong Value { get; set; }
public static GmpEntry FromTexToolsMeta( byte[] data )
{
GmpEntry ret = new();
using var reader = new BinaryReader( new MemoryStream( data ) );
ret.Value = reader.ReadUInt32();
ret.UnknownTotal = data[ 4 ];
return ret;
}
public static implicit operator ulong( GmpEntry entry )
=> entry.Value;
public static explicit operator GmpEntry( ulong entry )
=> new() { Value = entry };
public bool Equals( GmpEntry other )
=> Value == other.Value;
public override bool Equals( object? obj )
=> obj is GmpEntry other && Equals( other );
public override int GetHashCode()
=> Value.GetHashCode();
}

View file

@ -1,50 +0,0 @@
using System;
using Newtonsoft.Json;
namespace Penumbra.GameData.Structs;
public readonly struct ImcEntry : IEquatable<ImcEntry>
{
public byte MaterialId { get; init; }
public byte DecalId { get; init; }
public readonly ushort AttributeAndSound;
public byte VfxId { get; init; }
public byte MaterialAnimationId { get; init; }
public ushort AttributeMask
{
get => (ushort)(AttributeAndSound & 0x3FF);
init => AttributeAndSound = (ushort)((AttributeAndSound & ~0x3FF) | (value & 0x3FF));
}
public byte SoundId
{
get => (byte)(AttributeAndSound >> 10);
init => AttributeAndSound = (ushort)(AttributeMask | (value << 10));
}
public bool Equals(ImcEntry other)
=> MaterialId == other.MaterialId
&& DecalId == other.DecalId
&& AttributeAndSound == other.AttributeAndSound
&& VfxId == other.VfxId
&& MaterialAnimationId == other.MaterialAnimationId;
public override bool Equals(object? obj)
=> obj is ImcEntry other && Equals(other);
public override int GetHashCode()
=> HashCode.Combine(MaterialId, DecalId, AttributeAndSound, VfxId, MaterialAnimationId);
[JsonConstructor]
public ImcEntry(byte materialId, byte decalId, ushort attributeMask, byte soundId, byte vfxId, byte materialAnimationId)
{
MaterialId = materialId;
DecalId = decalId;
AttributeAndSound = 0;
VfxId = vfxId;
MaterialAnimationId = materialAnimationId;
AttributeMask = attributeMask;
SoundId = soundId;
}
}

View file

@ -1,57 +0,0 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using Penumbra.GameData.Enums;
namespace Penumbra.GameData.Structs;
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
public readonly struct RspEntry
{
public const int ByteSize = ( int )RspAttribute.NumAttributes * 4;
private readonly float[] Attributes;
public RspEntry( RspEntry copy )
=> Attributes = ( float[] )copy.Attributes.Clone();
public RspEntry( byte[] bytes, int offset )
{
if( offset < 0 || offset + ByteSize > bytes.Length )
{
throw new ArgumentOutOfRangeException();
}
Attributes = new float[( int )RspAttribute.NumAttributes];
using MemoryStream s = new(bytes) { Position = offset };
using BinaryReader br = new(s);
for( var i = 0; i < ( int )RspAttribute.NumAttributes; ++i )
{
Attributes[ i ] = br.ReadSingle();
}
}
private static int ToIndex( RspAttribute attribute )
=> attribute < RspAttribute.NumAttributes && attribute >= 0
? ( int )attribute
: throw new InvalidEnumArgumentException();
public float this[ RspAttribute attribute ]
{
get => Attributes[ ToIndex( attribute ) ];
set => Attributes[ ToIndex( attribute ) ] = value;
}
public byte[] ToBytes()
{
using var s = new MemoryStream( ByteSize );
using var bw = new BinaryWriter( s );
foreach( var attribute in Attributes )
{
bw.Write( attribute );
}
return s.ToArray();
}
}

View file

@ -1,29 +0,0 @@
using System;
namespace Penumbra.GameData.Structs;
public readonly struct SetId : IComparable< SetId >, IEquatable<SetId>, IEquatable<ushort>
{
public readonly ushort Value;
public SetId( ushort value )
=> Value = value;
public static implicit operator SetId( ushort id )
=> new(id);
public static explicit operator ushort( SetId id )
=> id.Value;
public bool Equals(SetId other)
=> Value == other.Value;
public bool Equals(ushort other)
=> Value == other;
public override string ToString()
=> Value.ToString();
public int CompareTo( SetId other )
=> Value.CompareTo( other.Value );
}

View file

@ -1,52 +0,0 @@
using Dalamud.Utility;
namespace Penumbra.GameData.Structs;
// A wrapper for the clothing dyes the game provides with their RGBA color value, game ID, unmodified color value and name.
public readonly struct Stain
{
// An empty stain with transparent color.
public static readonly Stain None = new("None");
public readonly string Name;
public readonly uint RgbaColor;
public readonly byte RowIndex;
public readonly bool Gloss;
public byte R
=> (byte)(RgbaColor & 0xFF);
public byte G
=> (byte)((RgbaColor >> 8) & 0xFF);
public byte B
=> (byte)((RgbaColor >> 16) & 0xFF);
public byte Intensity
=> (byte)((1 + R + G + B) / 3);
// R and B need to be shuffled and Alpha set to max.
private static uint SeColorToRgba(uint color)
=> ((color & 0xFF) << 16) | ((color >> 16) & 0xFF) | (color & 0xFF00) | 0xFF000000;
public Stain(Lumina.Excel.GeneratedSheets.Stain stain)
: this(stain.Name.ToDalamudString().ToString(), SeColorToRgba(stain.Color), (byte)stain.RowId, stain.Unknown5)
{ }
internal Stain(string name, uint dye, byte index, bool gloss)
{
Name = name;
RowIndex = index;
Gloss = gloss;
RgbaColor = dye;
}
// Only used by None.
private Stain(string name)
{
Name = name;
RowIndex = 0;
RgbaColor = 0;
Gloss = false;
}
}

View file

@ -1,36 +0,0 @@
using System;
using System.Numerics;
namespace Penumbra.GameData.Structs;
public readonly struct StainId : IEquatable< StainId >, IEqualityOperators<StainId, StainId, bool>
{
public readonly byte Value;
public StainId( byte value )
=> Value = value;
public static implicit operator StainId( byte id )
=> new(id);
public static explicit operator byte( StainId id )
=> id.Value;
public override string ToString()
=> Value.ToString();
public bool Equals( StainId other )
=> Value == other.Value;
public override bool Equals( object? obj )
=> obj is StainId other && Equals( other );
public override int GetHashCode()
=> Value.GetHashCode();
public static bool operator ==(StainId left, StainId right)
=> left.Value == right.Value;
public static bool operator !=(StainId left, StainId right)
=> left.Value != right.Value;
}

View file

@ -1,35 +0,0 @@
using System;
namespace Penumbra.GameData.Structs;
public readonly struct WeaponType : IEquatable< WeaponType >
{
public readonly ushort Value;
public WeaponType( ushort value )
=> Value = value;
public static implicit operator WeaponType( ushort id )
=> new(id);
public static explicit operator ushort( WeaponType id )
=> id.Value;
public override string ToString()
=> Value.ToString();
public bool Equals( WeaponType other )
=> Value == other.Value;
public override bool Equals( object? obj )
=> obj is WeaponType other && Equals( other );
public override int GetHashCode()
=> Value.GetHashCode();
public static bool operator ==( WeaponType lhs, WeaponType rhs )
=> lhs.Value == rhs.Value;
public static bool operator !=( WeaponType lhs, WeaponType rhs )
=> lhs.Value != rhs.Value;
}

View file

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
namespace Penumbra.GameData;
public static class UtilityFunctions
{
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
public static T? FirstOrNull<T>(this IEnumerable<T> values, Func<T, bool> predicate) where T : struct
=> values.Cast<T?>().FirstOrDefault(v => predicate(v!.Value));
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
public static T[] AddItem<T>(this T[] array, T element, int count = 1)
{
var length = array.Length;
var newArray = new T[array.Length + count];
Array.Copy(array, newArray, length);
for (var i = length; i < newArray.Length; ++i)
newArray[i] = element;
return newArray;
}
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
public static T[] RemoveItems<T>(this T[] array, int offset, int count = 1)
{
var newArray = new T[array.Length - count];
Array.Copy(array, newArray, offset);
Array.Copy(array, offset + count, newArray, offset, newArray.Length - offset);
return newArray;
}
}

@ -1 +1 @@
Subproject commit 5d9f36c5b57685b07354460e225e65759ef9996e
Subproject commit 9bd016fbef5fb2de467dd42165267fdd93cd9592

View file

@ -8,7 +8,11 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F89C9EAE-25C8-43BE-8108-5921E5A93502}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
base_repo.json = base_repo.json
.github\workflows\build.yml = .github\workflows\build.yml
Penumbra\Penumbra.json = Penumbra\Penumbra.json
.github\workflows\release.yml = .github\workflows\release.yml
repo.json = repo.json
.github\workflows\test_release.yml = .github\workflows\test_release.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.GameData", "Penumbra.GameData\Penumbra.GameData.csproj", "{EE551E87-FDB3-4612-B500-DC870C07C605}"
@ -19,36 +23,76 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.Api", "Penumbra.Ap
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.String", "Penumbra.String\Penumbra.String.csproj", "{5549BAFD-6357-4B1A-800C-75AC36E5B76D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.CrashHandler", "Penumbra.CrashHandler\Penumbra.CrashHandler.csproj", "{EE834491-A98F-4395-BE0D-6861AE5AD953}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Schemas", "Schemas", "{BFEA7504-1210-4F79-A7FE-BF03B6567E33}"
ProjectSection(SolutionItems) = preProject
schemas\default_mod.json = schemas\default_mod.json
schemas\group.json = schemas\group.json
schemas\local_mod_data-v3.json = schemas\local_mod_data-v3.json
schemas\mod_meta-v3.json = schemas\mod_meta-v3.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "structs", "structs", "{B03F276A-0572-4F62-AF86-EF62F6B80463}"
ProjectSection(SolutionItems) = preProject
schemas\structs\container.json = schemas\structs\container.json
schemas\structs\group_combining.json = schemas\structs\group_combining.json
schemas\structs\group_imc.json = schemas\structs\group_imc.json
schemas\structs\group_multi.json = schemas\structs\group_multi.json
schemas\structs\group_single.json = schemas\structs\group_single.json
schemas\structs\manipulation.json = schemas\structs\manipulation.json
schemas\structs\meta_atch.json = schemas\structs\meta_atch.json
schemas\structs\meta_atr.json = schemas\structs\meta_atr.json
schemas\structs\meta_enums.json = schemas\structs\meta_enums.json
schemas\structs\meta_eqdp.json = schemas\structs\meta_eqdp.json
schemas\structs\meta_eqp.json = schemas\structs\meta_eqp.json
schemas\structs\meta_est.json = schemas\structs\meta_est.json
schemas\structs\meta_geqp.json = schemas\structs\meta_geqp.json
schemas\structs\meta_gmp.json = schemas\structs\meta_gmp.json
schemas\structs\meta_imc.json = schemas\structs\meta_imc.json
schemas\structs\meta_rsp.json = schemas\structs\meta_rsp.json
schemas\structs\meta_shp.json = schemas\structs\meta_shp.json
schemas\structs\option.json = schemas\structs\option.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|Any CPU.Build.0 = Release|Any CPU
{EE551E87-FDB3-4612-B500-DC870C07C605}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE551E87-FDB3-4612-B500-DC870C07C605}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE551E87-FDB3-4612-B500-DC870C07C605}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE551E87-FDB3-4612-B500-DC870C07C605}.Release|Any CPU.Build.0 = Release|Any CPU
{87750518-1A20-40B4-9FC1-22F906EFB290}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87750518-1A20-40B4-9FC1-22F906EFB290}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87750518-1A20-40B4-9FC1-22F906EFB290}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87750518-1A20-40B4-9FC1-22F906EFB290}.Release|Any CPU.Build.0 = Release|Any CPU
{1FE4D8DF-B56A-464F-B39E-CDC0ED4167D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1FE4D8DF-B56A-464F-B39E-CDC0ED4167D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1FE4D8DF-B56A-464F-B39E-CDC0ED4167D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1FE4D8DF-B56A-464F-B39E-CDC0ED4167D4}.Release|Any CPU.Build.0 = Release|Any CPU
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Release|Any CPU.Build.0 = Release|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.ActiveCfg = Debug|x64
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.Build.0 = Debug|x64
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.ActiveCfg = Release|x64
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.Build.0 = Release|x64
{EE551E87-FDB3-4612-B500-DC870C07C605}.Debug|x64.ActiveCfg = Debug|x64
{EE551E87-FDB3-4612-B500-DC870C07C605}.Debug|x64.Build.0 = Debug|x64
{EE551E87-FDB3-4612-B500-DC870C07C605}.Release|x64.ActiveCfg = Release|x64
{EE551E87-FDB3-4612-B500-DC870C07C605}.Release|x64.Build.0 = Release|x64
{87750518-1A20-40B4-9FC1-22F906EFB290}.Debug|x64.ActiveCfg = Debug|x64
{87750518-1A20-40B4-9FC1-22F906EFB290}.Debug|x64.Build.0 = Debug|x64
{87750518-1A20-40B4-9FC1-22F906EFB290}.Release|x64.ActiveCfg = Release|x64
{87750518-1A20-40B4-9FC1-22F906EFB290}.Release|x64.Build.0 = Release|x64
{1FE4D8DF-B56A-464F-B39E-CDC0ED4167D4}.Debug|x64.ActiveCfg = Debug|x64
{1FE4D8DF-B56A-464F-B39E-CDC0ED4167D4}.Debug|x64.Build.0 = Debug|x64
{1FE4D8DF-B56A-464F-B39E-CDC0ED4167D4}.Release|x64.ActiveCfg = Release|x64
{1FE4D8DF-B56A-464F-B39E-CDC0ED4167D4}.Release|x64.Build.0 = Release|x64
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Debug|x64.ActiveCfg = Debug|x64
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Debug|x64.Build.0 = Debug|x64
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Release|x64.ActiveCfg = Release|x64
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Release|x64.Build.0 = Release|x64
{EE834491-A98F-4395-BE0D-6861AE5AD953}.Debug|x64.ActiveCfg = Debug|x64
{EE834491-A98F-4395-BE0D-6861AE5AD953}.Debug|x64.Build.0 = Debug|x64
{EE834491-A98F-4395-BE0D-6861AE5AD953}.Release|x64.ActiveCfg = Release|x64
{EE834491-A98F-4395-BE0D-6861AE5AD953}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BFEA7504-1210-4F79-A7FE-BF03B6567E33} = {F89C9EAE-25C8-43BE-8108-5921E5A93502}
{B03F276A-0572-4F62-AF86-EF62F6B80463} = {BFEA7504-1210-4F79-A7FE-BF03B6567E33}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF}
EndGlobalSection

View file

@ -0,0 +1,78 @@
using OtterGui.Log;
using OtterGui.Services;
using Penumbra.Api.Enums;
using Penumbra.Collections;
using Penumbra.Collections.Manager;
using Penumbra.GameData.Actors;
using Penumbra.GameData.Interop;
using Penumbra.Interop.PathResolving;
namespace Penumbra.Api.Api;
public class ApiHelpers(
CollectionManager collectionManager,
ObjectManager objects,
CollectionResolver collectionResolver,
ActorManager actors) : IApiService
{
/// <summary> Return the associated identifier for an object given by its index. </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
internal ActorIdentifier AssociatedIdentifier(int gameObjectIdx)
{
if (gameObjectIdx < 0 || gameObjectIdx >= objects.TotalCount)
return ActorIdentifier.Invalid;
var ptr = objects[gameObjectIdx];
return actors.FromObject(ptr, out _, false, true, true);
}
/// <summary>
/// Return the collection associated to a current game object. If it does not exist, return the default collection.
/// If the index is invalid, returns false and the default collection.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
internal unsafe bool AssociatedCollection(int gameObjectIdx, out ModCollection collection)
{
collection = collectionManager.Active.Default;
if (gameObjectIdx < 0 || gameObjectIdx >= objects.TotalCount)
return false;
var ptr = objects[gameObjectIdx];
var data = collectionResolver.IdentifyCollection(ptr.AsObject, false);
if (data.Valid)
collection = data.ModCollection;
return true;
}
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
internal static PenumbraApiEc Return(PenumbraApiEc ec, LazyString args, [CallerMemberName] string name = "Unknown")
{
if (ec is PenumbraApiEc.Success or PenumbraApiEc.NothingChanged)
Penumbra.Log.Verbose($"[{name}] Called with {args}, returned {ec}.");
else
Penumbra.Log.Debug($"[{name}] Called with {args}, returned {ec}.");
return ec;
}
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
internal static LazyString Args(params object[] arguments)
{
if (arguments.Length == 0)
return new LazyString(() => "no arguments");
return new LazyString(() =>
{
var sb = new StringBuilder();
for (var i = 0; i < arguments.Length / 2; ++i)
{
sb.Append(arguments[2 * i]);
sb.Append(" = ");
sb.Append(arguments[2 * i + 1]);
sb.Append(", ");
}
return sb.ToString(0, sb.Length - 2);
});
}
}

View file

@ -0,0 +1,177 @@
using OtterGui.Services;
using Penumbra.Api.Enums;
using Penumbra.Collections;
using Penumbra.Collections.Manager;
using Penumbra.Mods;
namespace Penumbra.Api.Api;
public class CollectionApi(CollectionManager collections, ApiHelpers helpers) : IPenumbraApiCollection, IApiService
{
public Dictionary<Guid, string> GetCollections()
=> collections.Storage.ToDictionary(c => c.Identity.Id, c => c.Identity.Name);
public List<(Guid Id, string Name)> GetCollectionsByIdentifier(string identifier)
{
if (identifier.Length == 0)
return [];
var list = new List<(Guid Id, string Name)>(4);
if (Guid.TryParse(identifier, out var guid) && collections.Storage.ById(guid, out var collection) && collection != ModCollection.Empty)
list.Add((collection.Identity.Id, collection.Identity.Name));
else if (identifier.Length >= 8)
list.AddRange(collections.Storage.Where(c => c.Identity.Identifier.StartsWith(identifier, StringComparison.OrdinalIgnoreCase))
.Select(c => (c.Identity.Id, c.Identity.Name)));
list.AddRange(collections.Storage
.Where(c => string.Equals(c.Identity.Name, identifier, StringComparison.OrdinalIgnoreCase)
&& !list.Contains((c.Identity.Id, c.Identity.Name)))
.Select(c => (c.Identity.Id, c.Identity.Name)));
return list;
}
public Func<string, (string ModDirectory, string ModName)[]> CheckCurrentChangedItemFunc()
{
var weakRef = new WeakReference<CollectionManager>(collections);
return s =>
{
if (!weakRef.TryGetTarget(out var c))
throw new ObjectDisposedException("The underlying collection storage of this IPC container was disposed.");
if (!c.Active.Current.ChangedItems.TryGetValue(s, out var d))
return [];
return d.Item1.Select(m => (m is Mod mod ? mod.Identifier : string.Empty, m.Name.Text)).ToArray();
};
}
public Dictionary<string, object?> GetChangedItemsForCollection(Guid collectionId)
{
try
{
if (!collections.Storage.ById(collectionId, out var collection))
collection = ModCollection.Empty;
if (collection.HasCache)
return collection.ChangedItems.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Item2?.ToInternalObject());
Penumbra.Log.Warning($"Collection {collectionId} does not exist or is not loaded.");
return [];
}
catch (Exception e)
{
Penumbra.Log.Error($"Could not obtain Changed Items for {collectionId}:\n{e}");
throw;
}
}
public (Guid Id, string Name)? GetCollection(ApiCollectionType type)
{
if (!Enum.IsDefined(type))
return null;
var collection = collections.Active.ByType((CollectionType)type);
return collection == null ? null : (collection.Identity.Id, collection.Identity.Name);
}
internal (Guid Id, string Name)? GetCollection(byte type)
=> GetCollection((ApiCollectionType)type);
public (bool ObjectValid, bool IndividualSet, (Guid Id, string Name) EffectiveCollection) GetCollectionForObject(int gameObjectIdx)
{
var id = helpers.AssociatedIdentifier(gameObjectIdx);
if (!id.IsValid)
return (false, false, (collections.Active.Default.Identity.Id, collections.Active.Default.Identity.Name));
if (collections.Active.Individuals.TryGetValue(id, out var collection))
return (true, true, (collection.Identity.Id, collection.Identity.Name));
helpers.AssociatedCollection(gameObjectIdx, out collection);
return (true, false, (collection.Identity.Id, collection.Identity.Name));
}
public Guid[] GetCollectionByName(string name)
=> collections.Storage.Where(c => string.Equals(name, c.Identity.Name, StringComparison.OrdinalIgnoreCase)).Select(c => c.Identity.Id)
.ToArray();
public (PenumbraApiEc, (Guid Id, string Name)? OldCollection) SetCollection(ApiCollectionType type, Guid? collectionId,
bool allowCreateNew, bool allowDelete)
{
if (!Enum.IsDefined(type))
return (PenumbraApiEc.InvalidArgument, null);
var oldCollection = collections.Active.ByType((CollectionType)type);
var old = oldCollection != null ? (oldCollection.Identity.Id, oldCollection.Identity.Name) : new ValueTuple<Guid, string>?();
if (collectionId == null)
{
if (old == null)
return (PenumbraApiEc.NothingChanged, old);
if (!allowDelete || type is ApiCollectionType.Current or ApiCollectionType.Default or ApiCollectionType.Interface)
return (PenumbraApiEc.AssignmentDeletionDisallowed, old);
collections.Active.RemoveSpecialCollection((CollectionType)type);
return (PenumbraApiEc.Success, old);
}
if (!collections.Storage.ById(collectionId.Value, out var collection))
return (PenumbraApiEc.CollectionMissing, old);
if (old == null)
{
if (!allowCreateNew)
return (PenumbraApiEc.AssignmentCreationDisallowed, old);
collections.Active.CreateSpecialCollection((CollectionType)type);
}
else if (old.Value.Item1 == collection.Identity.Id)
{
return (PenumbraApiEc.NothingChanged, old);
}
collections.Active.SetCollection(collection, (CollectionType)type);
return (PenumbraApiEc.Success, old);
}
public (PenumbraApiEc, (Guid Id, string Name)? OldCollection) SetCollectionForObject(int gameObjectIdx, Guid? collectionId,
bool allowCreateNew, bool allowDelete)
{
var id = helpers.AssociatedIdentifier(gameObjectIdx);
if (!id.IsValid)
return (PenumbraApiEc.InvalidIdentifier, (collections.Active.Default.Identity.Id, collections.Active.Default.Identity.Name));
var oldCollection = collections.Active.Individuals.TryGetValue(id, out var c) ? c : null;
var old = oldCollection != null ? (oldCollection.Identity.Id, oldCollection.Identity.Name) : new ValueTuple<Guid, string>?();
if (collectionId == null)
{
if (old == null)
return (PenumbraApiEc.NothingChanged, old);
if (!allowDelete)
return (PenumbraApiEc.AssignmentDeletionDisallowed, old);
var idx = collections.Active.Individuals.Index(id);
collections.Active.RemoveIndividualCollection(idx);
return (PenumbraApiEc.Success, old);
}
if (!collections.Storage.ById(collectionId.Value, out var collection))
return (PenumbraApiEc.CollectionMissing, old);
if (old == null)
{
if (!allowCreateNew)
return (PenumbraApiEc.AssignmentCreationDisallowed, old);
var ids = collections.Active.Individuals.GetGroup(id);
collections.Active.CreateIndividualCollection(ids);
}
else if (old.Value.Item1 == collection.Identity.Id)
{
return (PenumbraApiEc.NothingChanged, old);
}
collections.Active.SetCollection(collection, CollectionType.Individual, collections.Active.Individuals.Index(id));
return (PenumbraApiEc.Success, old);
}
}

View file

@ -0,0 +1,54 @@
using OtterGui.Services;
using Penumbra.Import.Textures;
using TextureType = Penumbra.Api.Enums.TextureType;
namespace Penumbra.Api.Api;
public class EditingApi(TextureManager textureManager) : IPenumbraApiEditing, IApiService
{
public Task ConvertTextureFile(string inputFile, string outputFile, TextureType textureType, bool mipMaps)
=> textureType switch
{
TextureType.Png => textureManager.SavePng(inputFile, outputFile),
TextureType.Targa => textureManager.SaveTga(inputFile, outputFile),
TextureType.AsIsTex => textureManager.SaveAs(CombinedTexture.TextureSaveType.AsIs, mipMaps, true, inputFile, outputFile),
TextureType.AsIsDds => textureManager.SaveAs(CombinedTexture.TextureSaveType.AsIs, mipMaps, false, inputFile, outputFile),
TextureType.RgbaTex => textureManager.SaveAs(CombinedTexture.TextureSaveType.Bitmap, mipMaps, true, inputFile, outputFile),
TextureType.RgbaDds => textureManager.SaveAs(CombinedTexture.TextureSaveType.Bitmap, mipMaps, false, inputFile, outputFile),
TextureType.Bc3Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC3, mipMaps, true, inputFile, outputFile),
TextureType.Bc3Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC3, mipMaps, false, inputFile, outputFile),
TextureType.Bc7Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC7, mipMaps, true, inputFile, outputFile),
TextureType.Bc7Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC7, mipMaps, false, inputFile, outputFile),
TextureType.Bc1Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC1, mipMaps, true, inputFile, outputFile),
TextureType.Bc1Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC1, mipMaps, false, inputFile, outputFile),
TextureType.Bc4Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC4, mipMaps, true, inputFile, outputFile),
TextureType.Bc4Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC4, mipMaps, false, inputFile, outputFile),
TextureType.Bc5Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC5, mipMaps, true, inputFile, outputFile),
TextureType.Bc5Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC5, mipMaps, false, inputFile, outputFile),
_ => Task.FromException(new Exception($"Invalid input value {textureType}.")),
};
// @formatter:off
public Task ConvertTextureData(byte[] rgbaData, int width, string outputFile, TextureType textureType, bool mipMaps)
=> textureType switch
{
TextureType.Png => textureManager.SavePng(new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Targa => textureManager.SaveTga(new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.AsIsTex => textureManager.SaveAs(CombinedTexture.TextureSaveType.AsIs, mipMaps, true, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.AsIsDds => textureManager.SaveAs(CombinedTexture.TextureSaveType.AsIs, mipMaps, false, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.RgbaTex => textureManager.SaveAs(CombinedTexture.TextureSaveType.Bitmap, mipMaps, true, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.RgbaDds => textureManager.SaveAs(CombinedTexture.TextureSaveType.Bitmap, mipMaps, false, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc3Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC3, mipMaps, true, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc3Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC3, mipMaps, false, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc7Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC7, mipMaps, true, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc7Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC7, mipMaps, false, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc1Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC1, mipMaps, true, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc1Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC1, mipMaps, false, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc4Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC4, mipMaps, true, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc4Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC4, mipMaps, false, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc5Tex => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC5, mipMaps, true, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
TextureType.Bc5Dds => textureManager.SaveAs(CombinedTexture.TextureSaveType.BC5, mipMaps, false, new BaseImage(), outputFile, rgbaData, width, rgbaData.Length / 4 / width),
_ => Task.FromException(new Exception($"Invalid input value {textureType}.")),
};
// @formatter:on
}

View file

@ -0,0 +1,123 @@
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using OtterGui.Services;
using Penumbra.Api.Enums;
using Penumbra.Collections;
using Penumbra.Interop.Hooks.ResourceLoading;
using Penumbra.Interop.PathResolving;
using Penumbra.Interop.Structs;
using Penumbra.Services;
using Penumbra.String.Classes;
namespace Penumbra.Api.Api;
public class GameStateApi : IPenumbraApiGameState, IApiService, IDisposable
{
private readonly CommunicatorService _communicator;
private readonly CollectionResolver _collectionResolver;
private readonly DrawObjectState _drawObjectState;
private readonly CutsceneService _cutsceneService;
private readonly ResourceLoader _resourceLoader;
public unsafe GameStateApi(CommunicatorService communicator, CollectionResolver collectionResolver, CutsceneService cutsceneService,
ResourceLoader resourceLoader, DrawObjectState drawObjectState)
{
_communicator = communicator;
_collectionResolver = collectionResolver;
_cutsceneService = cutsceneService;
_resourceLoader = resourceLoader;
_drawObjectState = drawObjectState;
_resourceLoader.ResourceLoaded += OnResourceLoaded;
_resourceLoader.PapRequested += OnPapRequested;
_communicator.CreatedCharacterBase.Subscribe(OnCreatedCharacterBase, Communication.CreatedCharacterBase.Priority.Api);
}
public unsafe void Dispose()
{
_resourceLoader.ResourceLoaded -= OnResourceLoaded;
_resourceLoader.PapRequested -= OnPapRequested;
_communicator.CreatedCharacterBase.Unsubscribe(OnCreatedCharacterBase);
}
public event CreatedCharacterBaseDelegate? CreatedCharacterBase;
public event GameObjectResourceResolvedDelegate? GameObjectResourceResolved;
public event CreatingCharacterBaseDelegate? CreatingCharacterBase
{
add
{
if (value == null)
return;
_communicator.CreatingCharacterBase.Subscribe(new Action<nint, Guid, nint, nint, nint>(value),
Communication.CreatingCharacterBase.Priority.Api);
}
remove
{
if (value == null)
return;
_communicator.CreatingCharacterBase.Unsubscribe(new Action<nint, Guid, nint, nint, nint>(value));
}
}
public unsafe (nint GameObject, (Guid Id, string Name) Collection) GetDrawObjectInfo(nint drawObject)
{
var data = _collectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
return (data.AssociatedGameObject, (Id: data.ModCollection.Identity.Id, Name: data.ModCollection.Identity.Name));
}
public int GetCutsceneParentIndex(int actorIdx)
=> _cutsceneService.GetParentIndex(actorIdx);
public Func<int, int> GetCutsceneParentIndexFunc()
{
var weakRef = new WeakReference<CutsceneService>(_cutsceneService);
return idx =>
{
if (!weakRef.TryGetTarget(out var c))
throw new ObjectDisposedException("The underlying cutscene state storage of this IPC container was disposed.");
return c.GetParentIndex(idx);
};
}
public Func<nint, nint> GetGameObjectFromDrawObjectFunc()
{
var weakRef = new WeakReference<DrawObjectState>(_drawObjectState);
return model =>
{
if (!weakRef.TryGetTarget(out var c))
throw new ObjectDisposedException("The underlying draw object state storage of this IPC container was disposed.");
return c.TryGetValue(model, out var data) ? data.Item1.Address : nint.Zero;
};
}
public PenumbraApiEc SetCutsceneParentIndex(int copyIdx, int newParentIdx)
=> _cutsceneService.SetParentIndex(copyIdx, newParentIdx)
? PenumbraApiEc.Success
: PenumbraApiEc.InvalidArgument;
private unsafe void OnResourceLoaded(ResourceHandle* handle, Utf8GamePath originalPath, FullPath? manipulatedPath, ResolveData resolveData)
{
if (resolveData.AssociatedGameObject != nint.Zero && GameObjectResourceResolved != null)
{
var original = originalPath.ToString();
GameObjectResourceResolved.Invoke(resolveData.AssociatedGameObject, original,
manipulatedPath?.ToString() ?? original);
}
}
private void OnPapRequested(Utf8GamePath originalPath, FullPath? manipulatedPath, ResolveData resolveData)
{
if (resolveData.AssociatedGameObject != nint.Zero && GameObjectResourceResolved != null)
{
var original = originalPath.ToString();
GameObjectResourceResolved.Invoke(resolveData.AssociatedGameObject, original,
manipulatedPath?.ToString() ?? original);
}
}
private void OnCreatedCharacterBase(nint gameObject, ModCollection collection, nint drawObject)
=> CreatedCharacterBase?.Invoke(gameObject, collection.Identity.Id, drawObject);
}

View file

@ -0,0 +1,7 @@
namespace Penumbra.Api.Api;
public static class IdentityChecker
{
public static bool Check(string identity)
=> true;
}

544
Penumbra/Api/Api/MetaApi.cs Normal file
View file

@ -0,0 +1,544 @@
using Dalamud.Plugin.Services;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OtterGui;
using OtterGui.Services;
using Penumbra.Collections;
using Penumbra.Collections.Cache;
using Penumbra.GameData.Files.AtchStructs;
using Penumbra.GameData.Files.Utility;
using Penumbra.GameData.Structs;
using Penumbra.Interop.PathResolving;
using Penumbra.Meta.Manipulations;
namespace Penumbra.Api.Api;
public class MetaApi(IFramework framework, CollectionResolver collectionResolver, ApiHelpers helpers)
: IPenumbraApiMeta, IApiService
{
public string GetPlayerMetaManipulations()
{
var collection = collectionResolver.PlayerCollection();
return CompressMetaManipulations(collection);
}
public string GetMetaManipulations(int gameObjectIdx)
{
helpers.AssociatedCollection(gameObjectIdx, out var collection);
return CompressMetaManipulations(collection);
}
public Task<string> GetPlayerMetaManipulationsAsync()
{
return Task.Run(async () =>
{
var playerCollection = await framework.RunOnFrameworkThread(collectionResolver.PlayerCollection).ConfigureAwait(false);
return CompressMetaManipulations(playerCollection);
});
}
public Task<string> GetMetaManipulationsAsync(int gameObjectIdx)
{
return Task.Run(async () =>
{
var playerCollection = await framework.RunOnFrameworkThread(() =>
{
helpers.AssociatedCollection(gameObjectIdx, out var collection);
return collection;
}).ConfigureAwait(false);
return CompressMetaManipulations(playerCollection);
});
}
internal static string CompressMetaManipulations(ModCollection collection)
=> CompressMetaManipulationsV1(collection);
private static string CompressMetaManipulationsV0(ModCollection collection)
{
var array = new JArray();
if (collection.MetaCache is { } cache)
{
MetaDictionary.SerializeTo(array, cache.GlobalEqp.Select(kvp => kvp.Key));
MetaDictionary.SerializeTo(array, cache.Imc.Select(kvp => new KeyValuePair<ImcIdentifier, ImcEntry>(kvp.Key, kvp.Value.Entry)));
MetaDictionary.SerializeTo(array, cache.Eqp.Select(kvp => new KeyValuePair<EqpIdentifier, EqpEntry>(kvp.Key, kvp.Value.Entry)));
MetaDictionary.SerializeTo(array, cache.Eqdp.Select(kvp => new KeyValuePair<EqdpIdentifier, EqdpEntry>(kvp.Key, kvp.Value.Entry)));
MetaDictionary.SerializeTo(array, cache.Est.Select(kvp => new KeyValuePair<EstIdentifier, EstEntry>(kvp.Key, kvp.Value.Entry)));
MetaDictionary.SerializeTo(array, cache.Rsp.Select(kvp => new KeyValuePair<RspIdentifier, RspEntry>(kvp.Key, kvp.Value.Entry)));
MetaDictionary.SerializeTo(array, cache.Gmp.Select(kvp => new KeyValuePair<GmpIdentifier, GmpEntry>(kvp.Key, kvp.Value.Entry)));
MetaDictionary.SerializeTo(array, cache.Atch.Select(kvp => new KeyValuePair<AtchIdentifier, AtchEntry>(kvp.Key, kvp.Value.Entry)));
MetaDictionary.SerializeTo(array, cache.Shp.Select(kvp => new KeyValuePair<ShpIdentifier, ShpEntry>(kvp.Key, kvp.Value.Entry)));
MetaDictionary.SerializeTo(array, cache.Atr.Select(kvp => new KeyValuePair<AtrIdentifier, AtrEntry>(kvp.Key, kvp.Value.Entry)));
}
return Functions.ToCompressedBase64(array, 0);
}
private static unsafe string CompressMetaManipulationsV1(ModCollection? collection)
{
using var ms = new MemoryStream();
ms.Capacity = 1024;
using (var zipStream = new GZipStream(ms, CompressionMode.Compress, true))
{
zipStream.Write((byte)1);
zipStream.Write("META0001"u8);
if (collection?.MetaCache is not { } cache)
{
zipStream.Write(0);
zipStream.Write(0);
zipStream.Write(0);
zipStream.Write(0);
zipStream.Write(0);
zipStream.Write(0);
zipStream.Write(0);
}
else
{
WriteCache(zipStream, cache.Imc);
WriteCache(zipStream, cache.Eqp);
WriteCache(zipStream, cache.Eqdp);
WriteCache(zipStream, cache.Est);
WriteCache(zipStream, cache.Rsp);
WriteCache(zipStream, cache.Gmp);
cache.GlobalEqp.EnterReadLock();
try
{
zipStream.Write(cache.GlobalEqp.Count);
foreach (var (globalEqp, _) in cache.GlobalEqp)
zipStream.Write(new ReadOnlySpan<byte>(&globalEqp, sizeof(GlobalEqpManipulation)));
}
finally
{
cache.GlobalEqp.ExitReadLock();
}
WriteCache(zipStream, cache.Atch);
WriteCache(zipStream, cache.Shp);
WriteCache(zipStream, cache.Atr);
}
}
ms.Flush();
ms.Position = 0;
var data = ms.GetBuffer().AsSpan(0, (int)ms.Length);
return Convert.ToBase64String(data);
void WriteCache<TKey, TValue>(Stream stream, MetaCacheBase<TKey, TValue> metaCache)
where TKey : unmanaged, IMetaIdentifier
where TValue : unmanaged
{
metaCache.EnterReadLock();
try
{
stream.Write(metaCache.Count);
foreach (var (identifier, (_, value)) in metaCache)
{
stream.Write(identifier);
stream.Write(value);
}
}
finally
{
metaCache.ExitReadLock();
}
}
}
public const uint ImcKey = ((uint)'I' << 24) | ((uint)'M' << 16) | ((uint)'C' << 8);
public const uint EqpKey = ((uint)'E' << 24) | ((uint)'Q' << 16) | ((uint)'P' << 8);
public const uint EqdpKey = ((uint)'E' << 24) | ((uint)'Q' << 16) | ((uint)'D' << 8) | 'P';
public const uint EstKey = ((uint)'E' << 24) | ((uint)'S' << 16) | ((uint)'T' << 8);
public const uint RspKey = ((uint)'R' << 24) | ((uint)'S' << 16) | ((uint)'P' << 8);
public const uint GmpKey = ((uint)'G' << 24) | ((uint)'M' << 16) | ((uint)'P' << 8);
public const uint GeqpKey = ((uint)'G' << 24) | ((uint)'E' << 16) | ((uint)'Q' << 8) | 'P';
public const uint AtchKey = ((uint)'A' << 24) | ((uint)'T' << 16) | ((uint)'C' << 8) | 'H';
public const uint ShpKey = ((uint)'S' << 24) | ((uint)'H' << 16) | ((uint)'P' << 8);
public const uint AtrKey = ((uint)'A' << 24) | ((uint)'T' << 16) | ((uint)'R' << 8);
private static unsafe string CompressMetaManipulationsV2(ModCollection? collection)
{
using var ms = new MemoryStream();
ms.Capacity = 1024;
using (var zipStream = new GZipStream(ms, CompressionMode.Compress, true))
{
zipStream.Write((byte)2);
zipStream.Write("META0002"u8);
if (collection?.MetaCache is { } cache)
{
WriteCache(zipStream, cache.Imc, ImcKey);
WriteCache(zipStream, cache.Eqp, EqpKey);
WriteCache(zipStream, cache.Eqdp, EqdpKey);
WriteCache(zipStream, cache.Est, EstKey);
WriteCache(zipStream, cache.Rsp, RspKey);
WriteCache(zipStream, cache.Gmp, GmpKey);
cache.GlobalEqp.EnterReadLock();
try
{
if (cache.GlobalEqp.Count > 0)
{
zipStream.Write(GeqpKey);
zipStream.Write(cache.GlobalEqp.Count);
foreach (var (globalEqp, _) in cache.GlobalEqp)
zipStream.Write(new ReadOnlySpan<byte>(&globalEqp, sizeof(GlobalEqpManipulation)));
}
}
finally
{
cache.GlobalEqp.ExitReadLock();
}
WriteCache(zipStream, cache.Atch, AtchKey);
WriteCache(zipStream, cache.Shp, ShpKey);
WriteCache(zipStream, cache.Atr, AtrKey);
}
}
ms.Flush();
ms.Position = 0;
var data = ms.GetBuffer().AsSpan(0, (int)ms.Length);
return Convert.ToBase64String(data);
void WriteCache<TKey, TValue>(Stream stream, MetaCacheBase<TKey, TValue> metaCache, uint label)
where TKey : unmanaged, IMetaIdentifier
where TValue : unmanaged
{
metaCache.EnterReadLock();
try
{
if (metaCache.Count <= 0)
return;
stream.Write(label);
stream.Write(metaCache.Count);
foreach (var (identifier, (_, value)) in metaCache)
{
stream.Write(identifier);
stream.Write(value);
}
}
finally
{
metaCache.ExitReadLock();
}
}
}
/// <summary>
/// Convert manipulations from a transmitted base64 string to actual manipulations.
/// The empty string is treated as an empty set.
/// Only returns true if all conversions are successful and distinct.
/// </summary>
internal static bool ConvertManips(string manipString, [NotNullWhen(true)] out MetaDictionary? manips, out byte version)
{
if (manipString.Length == 0)
{
manips = new MetaDictionary();
version = byte.MaxValue;
return true;
}
try
{
var bytes = Convert.FromBase64String(manipString);
using var compressedStream = new MemoryStream(bytes);
using var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress);
using var resultStream = new MemoryStream();
zipStream.CopyTo(resultStream);
resultStream.Flush();
resultStream.Position = 0;
var data = resultStream.GetBuffer().AsSpan(0, (int)resultStream.Length);
version = data[0];
data = data[1..];
switch (version)
{
case 0: return ConvertManipsV0(data, out manips);
case 1: return ConvertManipsV1(data, out manips);
case 2: return ConvertManipsV2(data, out manips);
default:
Penumbra.Log.Debug($"Invalid version for manipulations: {version}.");
manips = null;
return false;
}
}
catch (Exception ex)
{
Penumbra.Log.Debug($"Error decompressing manipulations:\n{ex}");
manips = null;
version = byte.MaxValue;
return false;
}
}
private static bool ConvertManipsV2(ReadOnlySpan<byte> data, [NotNullWhen(true)] out MetaDictionary? manips)
{
if (!data.StartsWith("META0002"u8))
{
Penumbra.Log.Debug("Invalid manipulations of version 2, does not start with valid prefix.");
manips = null;
return false;
}
manips = new MetaDictionary();
var r = new SpanBinaryReader(data[8..]);
while (r.Remaining > 4)
{
var prefix = r.ReadUInt32();
var count = r.Remaining > 4 ? r.ReadInt32() : 0;
if (count is 0)
continue;
switch (prefix)
{
case ImcKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<ImcIdentifier>();
var value = r.Read<ImcEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
break;
case EqpKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<EqpIdentifier>();
var value = r.Read<EqpEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
break;
case EqdpKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<EqdpIdentifier>();
var value = r.Read<EqdpEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
break;
case EstKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<EstIdentifier>();
var value = r.Read<EstEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
break;
case RspKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<RspIdentifier>();
var value = r.Read<RspEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
break;
case GmpKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<GmpIdentifier>();
var value = r.Read<GmpEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
break;
case GeqpKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<GlobalEqpManipulation>();
if (!identifier.Validate() || !manips.TryAdd(identifier))
return false;
}
break;
case AtchKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<AtchIdentifier>();
var value = r.Read<AtchEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
break;
case ShpKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<ShpIdentifier>();
var value = r.Read<ShpEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
break;
case AtrKey:
for (var i = 0; i < count; ++i)
{
var identifier = r.Read<AtrIdentifier>();
var value = r.Read<AtrEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
break;
}
}
return true;
}
private static bool ConvertManipsV1(ReadOnlySpan<byte> data, [NotNullWhen(true)] out MetaDictionary? manips)
{
if (!data.StartsWith("META0001"u8))
{
Penumbra.Log.Debug($"Invalid manipulations of version 1, does not start with valid prefix.");
manips = null;
return false;
}
manips = new MetaDictionary();
var r = new SpanBinaryReader(data[8..]);
var imcCount = r.ReadInt32();
for (var i = 0; i < imcCount; ++i)
{
var identifier = r.Read<ImcIdentifier>();
var value = r.Read<ImcEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
var eqpCount = r.ReadInt32();
for (var i = 0; i < eqpCount; ++i)
{
var identifier = r.Read<EqpIdentifier>();
var value = r.Read<EqpEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
var eqdpCount = r.ReadInt32();
for (var i = 0; i < eqdpCount; ++i)
{
var identifier = r.Read<EqdpIdentifier>();
var value = r.Read<EqdpEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
var estCount = r.ReadInt32();
for (var i = 0; i < estCount; ++i)
{
var identifier = r.Read<EstIdentifier>();
var value = r.Read<EstEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
var rspCount = r.ReadInt32();
for (var i = 0; i < rspCount; ++i)
{
var identifier = r.Read<RspIdentifier>();
var value = r.Read<RspEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
var gmpCount = r.ReadInt32();
for (var i = 0; i < gmpCount; ++i)
{
var identifier = r.Read<GmpIdentifier>();
var value = r.Read<GmpEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
var globalEqpCount = r.ReadInt32();
for (var i = 0; i < globalEqpCount; ++i)
{
var manip = r.Read<GlobalEqpManipulation>();
if (!manip.Validate() || !manips.TryAdd(manip))
return false;
}
// Atch was added after there were already some V1 around, so check for size here.
if (r.Position < r.Count)
{
var atchCount = r.ReadInt32();
for (var i = 0; i < atchCount; ++i)
{
var identifier = r.Read<AtchIdentifier>();
var value = r.Read<AtchEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
// Shp and Atr was added later
if (r.Position < r.Count)
{
var shpCount = r.ReadInt32();
for (var i = 0; i < shpCount; ++i)
{
var identifier = r.Read<ShpIdentifier>();
var value = r.Read<ShpEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
var atrCount = r.ReadInt32();
for (var i = 0; i < atrCount; ++i)
{
var identifier = r.Read<AtrIdentifier>();
var value = r.Read<AtrEntry>();
if (!identifier.Validate() || !manips.TryAdd(identifier, value))
return false;
}
}
}
return true;
}
private static bool ConvertManipsV0(ReadOnlySpan<byte> data, [NotNullWhen(true)] out MetaDictionary? manips)
{
var json = Encoding.UTF8.GetString(data);
manips = JsonConvert.DeserializeObject<MetaDictionary>(json);
return manips != null;
}
internal void TestMetaManipulations()
{
var collection = collectionResolver.PlayerCollection();
var dict = new MetaDictionary(collection.MetaCache);
var count = dict.Count;
var watch = Stopwatch.StartNew();
var v0 = CompressMetaManipulationsV0(collection);
var v0Time = watch.ElapsedMilliseconds;
watch.Restart();
var v1 = CompressMetaManipulationsV1(collection);
var v1Time = watch.ElapsedMilliseconds;
watch.Restart();
var v1Success = ConvertManips(v1, out var v1Roundtrip, out _);
var v1RoundtripTime = watch.ElapsedMilliseconds;
watch.Restart();
var v0Success = ConvertManips(v0, out var v0Roundtrip, out _);
var v0RoundtripTime = watch.ElapsedMilliseconds;
Penumbra.Log.Information($"Version | Count | Time | Length | Success | ReCount | ReTime | Equal");
Penumbra.Log.Information(
$"0 | {count} | {v0Time} | {v0.Length} | {v0Success} | {v0Roundtrip?.Count} | {v0RoundtripTime} | {v0Roundtrip?.Equals(dict)}");
Penumbra.Log.Information(
$"1 | {count} | {v1Time} | {v1.Length} | {v1Success} | {v1Roundtrip?.Count} | {v1RoundtripTime} | {v0Roundtrip?.Equals(dict)}");
}
}

View file

@ -0,0 +1,362 @@
using OtterGui.Extensions;
using OtterGui.Services;
using Penumbra.Api.Enums;
using Penumbra.Api.Helpers;
using Penumbra.Collections;
using Penumbra.Collections.Manager;
using Penumbra.Communication;
using Penumbra.Interop.PathResolving;
using Penumbra.Mods;
using Penumbra.Mods.Editor;
using Penumbra.Mods.Groups;
using Penumbra.Mods.Manager;
using Penumbra.Mods.Manager.OptionEditor;
using Penumbra.Mods.Settings;
using Penumbra.Mods.SubMods;
using Penumbra.Services;
namespace Penumbra.Api.Api;
public class ModSettingsApi : IPenumbraApiModSettings, IApiService, IDisposable
{
private readonly CollectionResolver _collectionResolver;
private readonly ModManager _modManager;
private readonly CollectionManager _collectionManager;
private readonly CollectionEditor _collectionEditor;
private readonly CommunicatorService _communicator;
public ModSettingsApi(CollectionResolver collectionResolver,
ModManager modManager,
CollectionManager collectionManager,
CollectionEditor collectionEditor,
CommunicatorService communicator)
{
_collectionResolver = collectionResolver;
_modManager = modManager;
_collectionManager = collectionManager;
_collectionEditor = collectionEditor;
_communicator = communicator;
_communicator.ModPathChanged.Subscribe(OnModPathChange, ModPathChanged.Priority.ApiModSettings);
_communicator.ModSettingChanged.Subscribe(OnModSettingChange, Communication.ModSettingChanged.Priority.Api);
_communicator.ModOptionChanged.Subscribe(OnModOptionEdited, ModOptionChanged.Priority.Api);
_communicator.ModFileChanged.Subscribe(OnModFileChanged, ModFileChanged.Priority.Api);
}
public void Dispose()
{
_communicator.ModPathChanged.Unsubscribe(OnModPathChange);
_communicator.ModSettingChanged.Unsubscribe(OnModSettingChange);
_communicator.ModOptionChanged.Unsubscribe(OnModOptionEdited);
_communicator.ModFileChanged.Unsubscribe(OnModFileChanged);
}
public event ModSettingChangedDelegate? ModSettingChanged;
public AvailableModSettings? GetAvailableModSettings(string modDirectory, string modName)
{
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return null;
var dict = new Dictionary<string, (string[], int)>(mod.Groups.Count);
foreach (var g in mod.Groups)
dict.Add(g.Name, (g.Options.Select(o => o.Name).ToArray(), (int)g.Type));
return new AvailableModSettings(dict);
}
public (PenumbraApiEc, (bool, int, Dictionary<string, List<string>>, bool)?) GetCurrentModSettings(Guid collectionId, string modDirectory,
string modName, bool ignoreInheritance)
{
var ret = GetCurrentModSettingsWithTemp(collectionId, modDirectory, modName, ignoreInheritance, true, 0);
if (ret.Item2 is null)
return (ret.Item1, null);
return (ret.Item1, (ret.Item2.Value.Item1, ret.Item2.Value.Item2, ret.Item2.Value.Item3, ret.Item2.Value.Item4));
}
public PenumbraApiEc GetSettingsInAllCollections(string modDirectory, string modName,
out Dictionary<Guid, (bool, int, Dictionary<string, List<string>>, bool, bool)> settings,
bool ignoreTemporaryCollections = false)
{
settings = [];
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return PenumbraApiEc.ModMissing;
var collections = ignoreTemporaryCollections
? _collectionManager.Storage.Where(c => c != ModCollection.Empty)
: _collectionManager.Storage.Where(c => c != ModCollection.Empty).Concat(_collectionManager.Temp.Values);
settings = [];
foreach (var collection in collections)
{
if (GetCurrentSettings(collection, mod, false, false, 0) is { } s)
settings.Add(collection.Identity.Id, s);
}
return PenumbraApiEc.Success;
}
public (PenumbraApiEc, (bool, int, Dictionary<string, List<string>>, bool, bool)?) GetCurrentModSettingsWithTemp(Guid collectionId,
string modDirectory, string modName, bool ignoreInheritance, bool ignoreTemporary, int key)
{
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return (PenumbraApiEc.ModMissing, null);
if (!_collectionManager.Storage.ById(collectionId, out var collection))
return (PenumbraApiEc.CollectionMissing, null);
if (collection.Identity.Id == Guid.Empty)
return (PenumbraApiEc.Success, null);
if (GetCurrentSettings(collection, mod, ignoreInheritance, ignoreTemporary, key) is { } settings)
return (PenumbraApiEc.Success, settings);
return (PenumbraApiEc.Success, null);
}
public (PenumbraApiEc, Dictionary<string, (bool, int, Dictionary<string, List<string>>, bool, bool)>?) GetAllModSettings(Guid collectionId,
bool ignoreInheritance, bool ignoreTemporary, int key)
{
if (!_collectionManager.Storage.ById(collectionId, out var collection))
return (PenumbraApiEc.CollectionMissing, null);
if (collection.Identity.Id == Guid.Empty)
return (PenumbraApiEc.Success, []);
var ret = new Dictionary<string, (bool, int, Dictionary<string, List<string>>, bool, bool)>(_modManager.Count);
foreach (var mod in _modManager)
{
if (GetCurrentSettings(collection, mod, ignoreInheritance, ignoreTemporary, key) is { } settings)
ret[mod.Identifier] = settings;
}
return (PenumbraApiEc.Success, ret);
}
public PenumbraApiEc TryInheritMod(Guid collectionId, string modDirectory, string modName, bool inherit)
{
var args = ApiHelpers.Args("CollectionId", collectionId, "ModDirectory", modDirectory, "ModName", modName, "Inherit",
inherit.ToString());
if (collectionId == Guid.Empty)
return ApiHelpers.Return(PenumbraApiEc.InvalidArgument, args);
if (!_collectionManager.Storage.ById(collectionId, out var collection))
return ApiHelpers.Return(PenumbraApiEc.CollectionMissing, args);
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return ApiHelpers.Return(PenumbraApiEc.ModMissing, args);
var ret = _collectionEditor.SetModInheritance(collection, mod, inherit)
? PenumbraApiEc.Success
: PenumbraApiEc.NothingChanged;
return ApiHelpers.Return(ret, args);
}
public PenumbraApiEc TrySetMod(Guid collectionId, string modDirectory, string modName, bool enabled)
{
var args = ApiHelpers.Args("CollectionId", collectionId, "ModDirectory", modDirectory, "ModName", modName, "Enabled", enabled);
if (!_collectionManager.Storage.ById(collectionId, out var collection))
return ApiHelpers.Return(PenumbraApiEc.CollectionMissing, args);
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return ApiHelpers.Return(PenumbraApiEc.ModMissing, args);
var ret = _collectionEditor.SetModState(collection, mod, enabled)
? PenumbraApiEc.Success
: PenumbraApiEc.NothingChanged;
return ApiHelpers.Return(ret, args);
}
public PenumbraApiEc TrySetModPriority(Guid collectionId, string modDirectory, string modName, int priority)
{
var args = ApiHelpers.Args("CollectionId", collectionId, "ModDirectory", modDirectory, "ModName", modName, "Priority", priority);
if (!_collectionManager.Storage.ById(collectionId, out var collection))
return ApiHelpers.Return(PenumbraApiEc.CollectionMissing, args);
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return ApiHelpers.Return(PenumbraApiEc.ModMissing, args);
var ret = _collectionEditor.SetModPriority(collection, mod, new ModPriority(priority))
? PenumbraApiEc.Success
: PenumbraApiEc.NothingChanged;
return ApiHelpers.Return(ret, args);
}
public PenumbraApiEc TrySetModSetting(Guid collectionId, string modDirectory, string modName, string optionGroupName, string optionName)
{
var args = ApiHelpers.Args("CollectionId", collectionId, "ModDirectory", modDirectory, "ModName", modName, "OptionGroupName",
optionGroupName, "OptionName", optionName);
if (!_collectionManager.Storage.ById(collectionId, out var collection))
return ApiHelpers.Return(PenumbraApiEc.CollectionMissing, args);
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return ApiHelpers.Return(PenumbraApiEc.ModMissing, args);
var groupIdx = mod.Groups.IndexOf(g => g.Name == optionGroupName);
if (groupIdx < 0)
return ApiHelpers.Return(PenumbraApiEc.OptionGroupMissing, args);
var optionIdx = mod.Groups[groupIdx].Options.IndexOf(o => o.Name == optionName);
if (optionIdx < 0)
return ApiHelpers.Return(PenumbraApiEc.OptionMissing, args);
var setting = mod.Groups[groupIdx].Behaviour switch
{
GroupDrawBehaviour.MultiSelection => Setting.Multi(optionIdx),
GroupDrawBehaviour.SingleSelection => Setting.Single(optionIdx),
_ => Setting.Zero,
};
var ret = _collectionEditor.SetModSetting(collection, mod, groupIdx, setting)
? PenumbraApiEc.Success
: PenumbraApiEc.NothingChanged;
return ApiHelpers.Return(ret, args);
}
public PenumbraApiEc TrySetModSettings(Guid collectionId, string modDirectory, string modName, string optionGroupName,
IReadOnlyList<string> optionNames)
{
var args = ApiHelpers.Args("CollectionId", collectionId, "ModDirectory", modDirectory, "ModName", modName, "OptionGroupName",
optionGroupName, "#optionNames", optionNames.Count);
if (!_collectionManager.Storage.ById(collectionId, out var collection))
return ApiHelpers.Return(PenumbraApiEc.CollectionMissing, args);
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return ApiHelpers.Return(PenumbraApiEc.ModMissing, args);
var settingSuccess = ConvertModSetting(mod, optionGroupName, optionNames, out var groupIdx, out var setting);
if (settingSuccess is not PenumbraApiEc.Success)
return ApiHelpers.Return(settingSuccess, args);
var ret = _collectionEditor.SetModSetting(collection, mod, groupIdx, setting)
? PenumbraApiEc.Success
: PenumbraApiEc.NothingChanged;
return ApiHelpers.Return(ret, args);
}
public PenumbraApiEc CopyModSettings(Guid? collectionId, string modDirectoryFrom, string modDirectoryTo)
{
var args = ApiHelpers.Args("CollectionId", collectionId.HasValue ? collectionId.Value.ToString() : "NULL",
"From", modDirectoryFrom, "To", modDirectoryTo);
var sourceMod = _modManager.FirstOrDefault(m => string.Equals(m.ModPath.Name, modDirectoryFrom, StringComparison.OrdinalIgnoreCase));
var targetMod = _modManager.FirstOrDefault(m => string.Equals(m.ModPath.Name, modDirectoryTo, StringComparison.OrdinalIgnoreCase));
if (collectionId == null)
foreach (var collection in _collectionManager.Storage)
_collectionEditor.CopyModSettings(collection, sourceMod, modDirectoryFrom, targetMod, modDirectoryTo);
else if (_collectionManager.Storage.ById(collectionId.Value, out var collection))
_collectionEditor.CopyModSettings(collection, sourceMod, modDirectoryFrom, targetMod, modDirectoryTo);
else
return ApiHelpers.Return(PenumbraApiEc.CollectionMissing, args);
return ApiHelpers.Return(PenumbraApiEc.Success, args);
}
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
private (bool, int, Dictionary<string, List<string>>, bool, bool)? GetCurrentSettings(ModCollection collection, Mod mod,
bool ignoreInheritance, bool ignoreTemporary, int key)
{
var settings = collection.Settings.Settings[mod.Index];
if (!ignoreTemporary && settings.TempSettings is { } tempSettings && (tempSettings.Lock <= 0 || tempSettings.Lock == key))
{
if (!tempSettings.ForceInherit)
return (tempSettings.Enabled, tempSettings.Priority.Value, tempSettings.ConvertToShareable(mod).Settings,
false, true);
if (!ignoreInheritance && collection.GetActualSettings(mod.Index).Settings is { } actualSettingsTemp)
return (actualSettingsTemp.Enabled, actualSettingsTemp.Priority.Value,
actualSettingsTemp.ConvertToShareable(mod).Settings, true, true);
}
if (settings.Settings is { } ownSettings)
return (ownSettings.Enabled, ownSettings.Priority.Value, ownSettings.ConvertToShareable(mod).Settings, false,
false);
if (!ignoreInheritance && collection.GetInheritedSettings(mod.Index).Settings is { } actualSettings)
return (actualSettings.Enabled, actualSettings.Priority.Value,
actualSettings.ConvertToShareable(mod).Settings, true, false);
return null;
}
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
private void TriggerSettingEdited(Mod mod)
{
var collection = _collectionResolver.PlayerCollection();
var (settings, parent) = collection.GetActualSettings(mod.Index);
if (settings is { Enabled: true })
ModSettingChanged?.Invoke(ModSettingChange.Edited, collection.Identity.Id, mod.Identifier, parent != collection);
}
private void OnModPathChange(ModPathChangeType type, Mod mod, DirectoryInfo? _1, DirectoryInfo? _2)
{
if (type == ModPathChangeType.Reloaded)
TriggerSettingEdited(mod);
}
private void OnModSettingChange(ModCollection collection, ModSettingChange type, Mod? mod, Setting _1, int _2, bool inherited)
=> ModSettingChanged?.Invoke(type, collection.Identity.Id, mod?.ModPath.Name ?? string.Empty, inherited);
private void OnModOptionEdited(ModOptionChangeType type, Mod mod, IModGroup? group, IModOption? option, IModDataContainer? container,
int moveIndex)
{
switch (type)
{
case ModOptionChangeType.GroupDeleted:
case ModOptionChangeType.GroupMoved:
case ModOptionChangeType.GroupTypeChanged:
case ModOptionChangeType.PriorityChanged:
case ModOptionChangeType.OptionDeleted:
case ModOptionChangeType.OptionMoved:
case ModOptionChangeType.OptionFilesChanged:
case ModOptionChangeType.OptionFilesAdded:
case ModOptionChangeType.OptionSwapsChanged:
case ModOptionChangeType.OptionMetaChanged:
TriggerSettingEdited(mod);
break;
}
}
private void OnModFileChanged(Mod mod, FileRegistry file)
{
if (file.CurrentUsage == 0)
return;
TriggerSettingEdited(mod);
}
public static PenumbraApiEc ConvertModSetting(Mod mod, string groupName, IReadOnlyList<string> optionNames, out int groupIndex,
out Setting setting)
{
groupIndex = mod.Groups.IndexOf(g => g.Name.Equals(groupName, StringComparison.OrdinalIgnoreCase));
setting = Setting.Zero;
if (groupIndex < 0)
return PenumbraApiEc.OptionGroupMissing;
switch (mod.Groups[groupIndex])
{
case { Behaviour: GroupDrawBehaviour.SingleSelection } single:
{
var optionIdx = optionNames.Count == 0 ? -1 : single.Options.IndexOf(o => o.Name == optionNames[^1]);
if (optionIdx < 0)
return PenumbraApiEc.OptionMissing;
setting = Setting.Single(optionIdx);
break;
}
case { Behaviour: GroupDrawBehaviour.MultiSelection } multi:
{
foreach (var name in optionNames)
{
var optionIdx = multi.Options.IndexOf(o => o.Name == name);
if (optionIdx < 0)
return PenumbraApiEc.OptionMissing;
setting |= Setting.Multi(optionIdx);
}
break;
}
}
return PenumbraApiEc.Success;
}
}

165
Penumbra/Api/Api/ModsApi.cs Normal file
View file

@ -0,0 +1,165 @@
using Newtonsoft.Json.Linq;
using OtterGui.Compression;
using OtterGui.Services;
using Penumbra.Api.Enums;
using Penumbra.Communication;
using Penumbra.Mods;
using Penumbra.Mods.Manager;
using Penumbra.Services;
namespace Penumbra.Api.Api;
public class ModsApi : IPenumbraApiMods, IApiService, IDisposable
{
private readonly CommunicatorService _communicator;
private readonly ModManager _modManager;
private readonly ModImportManager _modImportManager;
private readonly Configuration _config;
private readonly ModFileSystem _modFileSystem;
private readonly MigrationManager _migrationManager;
public ModsApi(ModManager modManager, ModImportManager modImportManager, Configuration config, ModFileSystem modFileSystem,
CommunicatorService communicator, MigrationManager migrationManager)
{
_modManager = modManager;
_modImportManager = modImportManager;
_config = config;
_modFileSystem = modFileSystem;
_communicator = communicator;
_migrationManager = migrationManager;
_communicator.ModPathChanged.Subscribe(OnModPathChanged, ModPathChanged.Priority.ApiMods);
}
private void OnModPathChanged(ModPathChangeType type, Mod mod, DirectoryInfo? oldDirectory, DirectoryInfo? newDirectory)
{
switch (type)
{
case ModPathChangeType.Deleted when oldDirectory != null: ModDeleted?.Invoke(oldDirectory.Name); break;
case ModPathChangeType.Added when newDirectory != null: ModAdded?.Invoke(newDirectory.Name); break;
case ModPathChangeType.Moved when newDirectory != null && oldDirectory != null:
ModMoved?.Invoke(oldDirectory.Name, newDirectory.Name);
break;
}
}
public void Dispose()
{
_communicator.ModPathChanged.Unsubscribe(OnModPathChanged);
}
public Dictionary<string, string> GetModList()
=> _modManager.ToDictionary(m => m.ModPath.Name, m => m.Name.Text);
public PenumbraApiEc InstallMod(string modFilePackagePath)
{
if (!File.Exists(modFilePackagePath))
return ApiHelpers.Return(PenumbraApiEc.FileMissing, ApiHelpers.Args("ModFilePackagePath", modFilePackagePath));
_modImportManager.AddUnpack(modFilePackagePath);
return ApiHelpers.Return(PenumbraApiEc.Success, ApiHelpers.Args("ModFilePackagePath", modFilePackagePath));
}
public PenumbraApiEc ReloadMod(string modDirectory, string modName)
{
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return ApiHelpers.Return(PenumbraApiEc.ModMissing, ApiHelpers.Args("ModDirectory", modDirectory, "ModName", modName));
_modManager.ReloadMod(mod);
return ApiHelpers.Return(PenumbraApiEc.Success, ApiHelpers.Args("ModDirectory", modDirectory, "ModName", modName));
}
public PenumbraApiEc AddMod(string modDirectory)
{
var args = ApiHelpers.Args("ModDirectory", modDirectory);
var dir = new DirectoryInfo(Path.Join(_modManager.BasePath.FullName, Path.GetFileName(modDirectory)));
if (!dir.Exists)
return ApiHelpers.Return(PenumbraApiEc.FileMissing, args);
if (dir.Parent == null
|| Path.TrimEndingDirectorySeparator(Path.GetFullPath(_modManager.BasePath.FullName))
!= Path.TrimEndingDirectorySeparator(Path.GetFullPath(dir.Parent.FullName)))
return ApiHelpers.Return(PenumbraApiEc.InvalidArgument, args);
_modManager.AddMod(dir, true);
if (_config.MigrateImportedModelsToV6)
{
_migrationManager.MigrateMdlDirectory(dir.FullName, false);
_migrationManager.Await();
}
if (_config.UseFileSystemCompression)
new FileCompactor(Penumbra.Log).StartMassCompact(dir.EnumerateFiles("*.*", SearchOption.AllDirectories),
CompressionAlgorithm.Xpress8K, false);
return ApiHelpers.Return(PenumbraApiEc.Success, args);
}
public PenumbraApiEc DeleteMod(string modDirectory, string modName)
{
if (!_modManager.TryGetMod(modDirectory, modName, out var mod))
return ApiHelpers.Return(PenumbraApiEc.NothingChanged, ApiHelpers.Args("ModDirectory", modDirectory, "ModName", modName));
_modManager.DeleteMod(mod);
return ApiHelpers.Return(PenumbraApiEc.Success, ApiHelpers.Args("ModDirectory", modDirectory, "ModName", modName));
}
public event Action<string>? ModDeleted;
public event Action<string>? ModAdded;
public event Action<string, string>? ModMoved;
public event Action<JObject, ushort, string>? CreatingPcp
{
add => _communicator.PcpCreation.Subscribe(value!, PcpCreation.Priority.ModsApi);
remove => _communicator.PcpCreation.Unsubscribe(value!);
}
public event Action<JObject, string, Guid>? ParsingPcp
{
add => _communicator.PcpParsing.Subscribe(value!, PcpParsing.Priority.ModsApi);
remove => _communicator.PcpParsing.Unsubscribe(value!);
}
public (PenumbraApiEc, string, bool, bool) GetModPath(string modDirectory, string modName)
{
if (!_modManager.TryGetMod(modDirectory, modName, out var mod)
|| !_modFileSystem.TryGetValue(mod, out var leaf))
return (PenumbraApiEc.ModMissing, string.Empty, false, false);
var fullPath = leaf.FullName();
var isDefault = ModFileSystem.ModHasDefaultPath(mod, fullPath);
var isNameDefault = isDefault || ModFileSystem.ModHasDefaultPath(mod, leaf.Name);
return (PenumbraApiEc.Success, fullPath, !isDefault, !isNameDefault);
}
public PenumbraApiEc SetModPath(string modDirectory, string modName, string newPath)
{
if (newPath.Length == 0)
return PenumbraApiEc.InvalidArgument;
if (!_modManager.TryGetMod(modDirectory, modName, out var mod)
|| !_modFileSystem.TryGetValue(mod, out var leaf))
return PenumbraApiEc.ModMissing;
try
{
_modFileSystem.RenameAndMove(leaf, newPath);
return PenumbraApiEc.Success;
}
catch
{
return PenumbraApiEc.PathRenameFailed;
}
}
public Dictionary<string, object?> GetChangedItems(string modDirectory, string modName)
=> _modManager.TryGetMod(modDirectory, modName, out var mod)
? mod.ChangedItems.ToDictionary(kvp => kvp.Key, kvp => kvp.Value?.ToInternalObject())
: [];
public IReadOnlyDictionary<string, IReadOnlyDictionary<string, object?>> GetChangedItemAdapterDictionary()
=> new ModChangedItemAdapter(new WeakReference<ModStorage>(_modManager));
public IReadOnlyList<(string ModDirectory, IReadOnlyDictionary<string, object?> ChangedItems)> GetChangedItemAdapterList()
=> new ModChangedItemAdapter(new WeakReference<ModStorage>(_modManager));
}

View file

@ -0,0 +1,43 @@
using OtterGui.Services;
namespace Penumbra.Api.Api;
public class PenumbraApi(
CollectionApi collection,
EditingApi editing,
GameStateApi gameState,
MetaApi meta,
ModsApi mods,
ModSettingsApi modSettings,
PluginStateApi pluginState,
RedrawApi redraw,
ResolveApi resolve,
ResourceTreeApi resourceTree,
TemporaryApi temporary,
UiApi ui) : IDisposable, IApiService, IPenumbraApi
{
public const int BreakingVersion = 5;
public const int FeatureVersion = 13;
public void Dispose()
{
Valid = false;
}
public (int Breaking, int Feature) ApiVersion
=> (BreakingVersion, FeatureVersion);
public bool Valid { get; private set; } = true;
public IPenumbraApiCollection Collection { get; } = collection;
public IPenumbraApiEditing Editing { get; } = editing;
public IPenumbraApiGameState GameState { get; } = gameState;
public IPenumbraApiMeta Meta { get; } = meta;
public IPenumbraApiMods Mods { get; } = mods;
public IPenumbraApiModSettings ModSettings { get; } = modSettings;
public IPenumbraApiPluginState PluginState { get; } = pluginState;
public IPenumbraApiRedraw Redraw { get; } = redraw;
public IPenumbraApiResolve Resolve { get; } = resolve;
public IPenumbraApiResourceTree ResourceTree { get; } = resourceTree;
public IPenumbraApiTemporary Temporary { get; } = temporary;
public IPenumbraApiUi Ui { get; } = ui;
}

View file

@ -0,0 +1,38 @@
using System.Collections.Frozen;
using Newtonsoft.Json;
using OtterGui.Services;
using Penumbra.Communication;
using Penumbra.Mods;
using Penumbra.Services;
namespace Penumbra.Api.Api;
public class PluginStateApi(Configuration config, CommunicatorService communicator) : IPenumbraApiPluginState, IApiService
{
public string GetModDirectory()
=> config.ModDirectory;
public string GetConfiguration()
=> JsonConvert.SerializeObject(config, Formatting.Indented);
public event Action<string, bool>? ModDirectoryChanged
{
add => communicator.ModDirectoryChanged.Subscribe(value!, Communication.ModDirectoryChanged.Priority.Api);
remove => communicator.ModDirectoryChanged.Unsubscribe(value!);
}
public bool GetEnabledState()
=> config.EnableMods;
public event Action<bool>? EnabledChange
{
add => communicator.EnabledChanged.Subscribe(value!, EnabledChanged.Priority.Api);
remove => communicator.EnabledChanged.Unsubscribe(value!);
}
public FrozenSet<string> SupportedFeatures
=> FeatureChecker.SupportedFeatures.ToFrozenSet();
public string[] CheckSupportedFeatures(IEnumerable<string> requiredFeatures)
=> requiredFeatures.Where(f => !FeatureChecker.Supported(f)).ToArray();
}

View file

@ -0,0 +1,57 @@
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Plugin.Services;
using OtterGui.Services;
using Penumbra.Api.Enums;
using Penumbra.Collections;
using Penumbra.Collections.Manager;
using Penumbra.GameData.Interop;
using Penumbra.Interop.Services;
namespace Penumbra.Api.Api;
public class RedrawApi(RedrawService redrawService, IFramework framework, CollectionManager collections, ObjectManager objects, ApiHelpers helpers) : IPenumbraApiRedraw, IApiService
{
public void RedrawObject(int gameObjectIndex, RedrawType setting)
{
framework.RunOnFrameworkThread(() => redrawService.RedrawObject(gameObjectIndex, setting));
}
public void RedrawObject(string name, RedrawType setting)
{
framework.RunOnFrameworkThread(() => redrawService.RedrawObject(name, setting));
}
public void RedrawObject(IGameObject? gameObject, RedrawType setting)
{
framework.RunOnFrameworkThread(() => redrawService.RedrawObject(gameObject, setting));
}
public void RedrawAll(RedrawType setting)
{
framework.RunOnFrameworkThread(() => redrawService.RedrawAll(setting));
}
public void RedrawCollectionMembers(Guid collectionId, RedrawType setting)
{
if (!collections.Storage.ById(collectionId, out var collection))
collection = ModCollection.Empty;
framework.RunOnFrameworkThread(() =>
{
foreach (var actor in objects.Objects)
{
helpers.AssociatedCollection(actor.ObjectIndex, out var modCollection);
if (collection == modCollection)
{
redrawService.RedrawObject(actor.ObjectIndex, setting);
}
}
});
}
public event GameObjectRedrawnDelegate? GameObjectRedrawn
{
add => redrawService.GameObjectRedrawn += value;
remove => redrawService.GameObjectRedrawn -= value;
}
}

View file

@ -0,0 +1,135 @@
using Dalamud.Plugin.Services;
using OtterGui.Services;
using Penumbra.Api.Enums;
using Penumbra.Collections;
using Penumbra.Collections.Manager;
using Penumbra.Interop.PathResolving;
using Penumbra.Mods.Manager;
using Penumbra.String.Classes;
namespace Penumbra.Api.Api;
public class ResolveApi(
ModManager modManager,
CollectionManager collectionManager,
Configuration config,
CollectionResolver collectionResolver,
ApiHelpers helpers,
IFramework framework) : IPenumbraApiResolve, IApiService
{
public string ResolveDefaultPath(string gamePath)
=> ResolvePath(gamePath, modManager, collectionManager.Active.Default);
public string ResolveInterfacePath(string gamePath)
=> ResolvePath(gamePath, modManager, collectionManager.Active.Interface);
public string ResolveGameObjectPath(string gamePath, int gameObjectIdx)
{
helpers.AssociatedCollection(gameObjectIdx, out var collection);
return ResolvePath(gamePath, modManager, collection);
}
public string ResolvePlayerPath(string gamePath)
=> ResolvePath(gamePath, modManager, collectionResolver.PlayerCollection());
public string[] ReverseResolveGameObjectPath(string moddedPath, int gameObjectIdx)
{
if (!config.EnableMods)
return [moddedPath];
helpers.AssociatedCollection(gameObjectIdx, out var collection);
var ret = collection.ReverseResolvePath(new FullPath(moddedPath));
return ret.Select(r => r.ToString()).ToArray();
}
public PenumbraApiEc ResolvePath(Guid collectionId, string gamePath, out string resolvedPath)
{
resolvedPath = gamePath;
if (!collectionManager.Storage.ById(collectionId, out var collection))
return PenumbraApiEc.CollectionMissing;
if (!collection.HasCache)
return PenumbraApiEc.CollectionInactive;
resolvedPath = ResolvePath(gamePath, modManager, collection);
return PenumbraApiEc.Success;
}
public string[] ReverseResolvePlayerPath(string moddedPath)
{
if (!config.EnableMods)
return [moddedPath];
var ret = collectionResolver.PlayerCollection().ReverseResolvePath(new FullPath(moddedPath));
return ret.Select(r => r.ToString()).ToArray();
}
public (string[], string[][]) ResolvePlayerPaths(string[] forward, string[] reverse)
{
if (!config.EnableMods)
return (forward, reverse.Select(p => new[]
{
p,
}).ToArray());
var playerCollection = collectionResolver.PlayerCollection();
var resolved = forward.Select(p => ResolvePath(p, modManager, playerCollection)).ToArray();
var reverseResolved = playerCollection.ReverseResolvePaths(reverse);
return (resolved, reverseResolved.Select(a => a.Select(p => p.ToString()).ToArray()).ToArray());
}
public PenumbraApiEc ResolvePaths(Guid collectionId, string[] forward, string[] reverse, out string[] resolvedForward,
out string[][] resolvedReverse)
{
resolvedForward = forward;
resolvedReverse = [];
if (!config.EnableMods)
return PenumbraApiEc.Success;
if (!collectionManager.Storage.ById(collectionId, out var collection))
return PenumbraApiEc.CollectionMissing;
if (!collection.HasCache)
return PenumbraApiEc.CollectionInactive;
resolvedForward = forward.Select(p => ResolvePath(p, modManager, collection)).ToArray();
var reverseResolved = collection.ReverseResolvePaths(reverse);
resolvedReverse = reverseResolved.Select(a => a.Select(p => p.ToString()).ToArray()).ToArray();
return PenumbraApiEc.Success;
}
public async Task<(string[], string[][])> ResolvePlayerPathsAsync(string[] forward, string[] reverse)
{
if (!config.EnableMods)
return (forward, reverse.Select(p => new[]
{
p,
}).ToArray());
return await Task.Run(async () =>
{
var playerCollection = await framework.RunOnFrameworkThread(collectionResolver.PlayerCollection).ConfigureAwait(false);
var forwardTask = Task.Run(() =>
{
var forwardRet = new string[forward.Length];
Parallel.For(0, forward.Length, idx => forwardRet[idx] = ResolvePath(forward[idx], modManager, playerCollection));
return forwardRet;
}).ConfigureAwait(false);
var reverseTask = Task.Run(() => playerCollection.ReverseResolvePaths(reverse)).ConfigureAwait(false);
var reverseResolved = (await reverseTask).Select(a => a.Select(p => p.ToString()).ToArray()).ToArray();
return (await forwardTask, reverseResolved);
}).ConfigureAwait(false);
}
/// <summary> Resolve a path given by string for a specific collection. </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
private string ResolvePath(string path, ModManager _, ModCollection collection)
{
if (!config.EnableMods)
return path;
var gamePath = Utf8GamePath.FromString(path, out var p) ? p : Utf8GamePath.Empty;
var ret = collection.ResolvePath(gamePath);
return ret?.ToString() ?? path;
}
}

View file

@ -0,0 +1,63 @@
using Dalamud.Game.ClientState.Objects.Types;
using Newtonsoft.Json.Linq;
using OtterGui.Services;
using Penumbra.Api.Enums;
using Penumbra.Api.Helpers;
using Penumbra.GameData.Interop;
using Penumbra.Interop.ResourceTree;
namespace Penumbra.Api.Api;
public class ResourceTreeApi(ResourceTreeFactory resourceTreeFactory, ObjectManager objects) : IPenumbraApiResourceTree, IApiService
{
public Dictionary<string, HashSet<string>>?[] GetGameObjectResourcePaths(params ushort[] gameObjects)
{
var characters = gameObjects.Select(index => objects.GetDalamudObject((int)index)).OfType<ICharacter>();
var resourceTrees = resourceTreeFactory.FromCharacters(characters, 0);
var pathDictionaries = ResourceTreeApiHelper.GetResourcePathDictionaries(resourceTrees);
return Array.ConvertAll(gameObjects, obj => pathDictionaries.GetValueOrDefault(obj));
}
public Dictionary<ushort, Dictionary<string, HashSet<string>>> GetPlayerResourcePaths()
{
var resourceTrees = resourceTreeFactory.FromObjectTable(ResourceTreeFactory.Flags.LocalPlayerRelatedOnly);
return ResourceTreeApiHelper.GetResourcePathDictionaries(resourceTrees);
}
public GameResourceDict?[] GetGameObjectResourcesOfType(ResourceType type, bool withUiData,
params ushort[] gameObjects)
{
var characters = gameObjects.Select(index => objects.GetDalamudObject((int)index)).OfType<ICharacter>();
var resourceTrees = resourceTreeFactory.FromCharacters(characters, withUiData ? ResourceTreeFactory.Flags.WithUiData : 0);
var resDictionaries = ResourceTreeApiHelper.GetResourcesOfType(resourceTrees, type);
return Array.ConvertAll(gameObjects, obj => resDictionaries.GetValueOrDefault(obj));
}
public Dictionary<ushort, GameResourceDict> GetPlayerResourcesOfType(ResourceType type,
bool withUiData)
{
var resourceTrees = resourceTreeFactory.FromObjectTable(ResourceTreeFactory.Flags.LocalPlayerRelatedOnly
| (withUiData ? ResourceTreeFactory.Flags.WithUiData : 0));
return ResourceTreeApiHelper.GetResourcesOfType(resourceTrees, type);
}
public JObject?[] GetGameObjectResourceTrees(bool withUiData, params ushort[] gameObjects)
{
var characters = gameObjects.Select(index => objects.GetDalamudObject((int)index)).OfType<ICharacter>();
var resourceTrees = resourceTreeFactory.FromCharacters(characters, withUiData ? ResourceTreeFactory.Flags.WithUiData : 0);
var resDictionary = ResourceTreeApiHelper.EncapsulateResourceTrees(resourceTrees);
return Array.ConvertAll(gameObjects, obj => resDictionary.GetValueOrDefault(obj));
}
public Dictionary<ushort, JObject> GetPlayerResourceTrees(bool withUiData)
{
var resourceTrees = resourceTreeFactory.FromObjectTable(ResourceTreeFactory.Flags.LocalPlayerRelatedOnly
| (withUiData ? ResourceTreeFactory.Flags.WithUiData : 0));
var resDictionary = ResourceTreeApiHelper.EncapsulateResourceTrees(resourceTrees);
return resDictionary;
}
}

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