From 8a53313c33d0a42edfbbdf09a141525f7db14794 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 18 Nov 2024 20:14:06 +0100 Subject: [PATCH] Add .atch file debugging. --- Penumbra.GameData | 2 +- Penumbra/UI/Tabs/Debug/AtchDrawer.cs | 56 ++++++++++++++++++++++++++++ Penumbra/UI/Tabs/Debug/DebugTab.cs | 29 +++++++++++++- 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 Penumbra/UI/Tabs/Debug/AtchDrawer.cs diff --git a/Penumbra.GameData b/Penumbra.GameData index 79d8d782..1c82c086 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 79d8d782b3b454a41f7f87f398806ec4d08d485f +Subproject commit 1c82c086704e2f1b3608644a9b1d70628fbe0ca9 diff --git a/Penumbra/UI/Tabs/Debug/AtchDrawer.cs b/Penumbra/UI/Tabs/Debug/AtchDrawer.cs new file mode 100644 index 00000000..f6f6c50e --- /dev/null +++ b/Penumbra/UI/Tabs/Debug/AtchDrawer.cs @@ -0,0 +1,56 @@ +using ImGuiNET; +using OtterGui; +using OtterGui.Text; +using Penumbra.GameData.Files; + +namespace Penumbra.UI.Tabs.Debug; + +public static class AtchDrawer +{ + public static void Draw(AtchFile file) + { + using (ImUtf8.Group()) + { + ImUtf8.Text("Entries: "u8); + ImUtf8.Text("States: "u8); + } + + ImGui.SameLine(); + using (ImUtf8.Group()) + { + ImUtf8.Text($"{file.Entries.Count}"); + if (file.Entries.Count == 0) + { + ImUtf8.Text("0"u8); + return; + } + + ImUtf8.Text($"{file.Entries[0].States.Count}"); + } + + foreach (var (entry, index) in file.Entries.WithIndex()) + { + using var id = ImUtf8.PushId(index); + using var tree = ImUtf8.TreeNode(entry.Name.Span); + if (tree) + { + ImUtf8.TreeNode(entry.Accessory ? "Accessory"u8 : "Weapon"u8, ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose(); + foreach (var (state, i) in entry.States.WithIndex()) + { + id.Push(i); + using var t = ImUtf8.TreeNode(state.Bone.Span); + if (t) + { + ImUtf8.TreeNode($"Scale: {state.Scale}", ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose(); + ImUtf8.TreeNode($"Offset: {state.Offset.X} | {state.Offset.Y} | {state.Offset.Z}", + ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose(); + ImUtf8.TreeNode($"Rotation: {state.Rotation.X} | {state.Rotation.Y} | {state.Rotation.Z}", + ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose(); + } + + id.Pop(); + } + } + } + } +} diff --git a/Penumbra/UI/Tabs/Debug/DebugTab.cs b/Penumbra/UI/Tabs/Debug/DebugTab.cs index 9184ffe8..cdaaadaa 100644 --- a/Penumbra/UI/Tabs/Debug/DebugTab.cs +++ b/Penumbra/UI/Tabs/Debug/DebugTab.cs @@ -98,6 +98,7 @@ public class DebugTab : Window, ITab, IUiService private readonly Diagnostics _diagnostics; private readonly ObjectManager _objects; private readonly IClientState _clientState; + private readonly IDataManager _dataManager; private readonly IpcTester _ipcTester; private readonly CrashHandlerPanel _crashHandlerPanel; private readonly TexHeaderDrawer _texHeaderDrawer; @@ -105,7 +106,7 @@ public class DebugTab : Window, ITab, IUiService private readonly TexMdlScdService _texMdlScdService; public DebugTab(PerformanceTracker performance, Configuration config, CollectionManager collectionManager, ObjectManager objects, - IClientState clientState, + IClientState clientState, IDataManager dataManager, ValidityChecker validityChecker, ModManager modManager, HttpApi httpApi, ActorManager actors, StainService stains, CharacterUtility characterUtility, ResidentResourceManager residentResources, ResourceManagerService resourceManager, CollectionResolver collectionResolver, @@ -154,6 +155,7 @@ public class DebugTab : Window, ITab, IUiService _texMdlScdService = texMdlScdService; _objects = objects; _clientState = clientState; + _dataManager = dataManager; } public ReadOnlySpan Label @@ -665,11 +667,36 @@ public class DebugTab : Window, ITab, IUiService DrawEmotes(); DrawStainTemplates(); + DrawAtch(); } private string _emoteSearchFile = string.Empty; private string _emoteSearchName = string.Empty; + + private AtchFile? _atchFile; + + private void DrawAtch() + { + try + { + _atchFile ??= new AtchFile(_dataManager.GetFile("chara/xls/attachOffset/c0101.atch")!.Data); + } + catch + { + // ignored + } + + if (_atchFile == null) + return; + + using var mainTree = ImUtf8.TreeNode("Atch File C0101"u8); + if (!mainTree) + return; + + AtchDrawer.Draw(_atchFile); + } + private void DrawEmotes() { using var mainTree = TreeNode("Emotes");