Add .atch file debugging.

This commit is contained in:
Ottermandias 2024-11-18 20:14:06 +01:00
parent 41718d8f8f
commit 8a53313c33
3 changed files with 85 additions and 2 deletions

@ -1 +1 @@
Subproject commit 79d8d782b3b454a41f7f87f398806ec4d08d485f
Subproject commit 1c82c086704e2f1b3608644a9b1d70628fbe0ca9

View file

@ -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();
}
}
}
}
}

View file

@ -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<byte> 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");