Skip to content

Commit

Permalink
Some debug vis improvements, disable .atch file modding for the momen…
Browse files Browse the repository at this point in the history
…t until modular .atch file modding is implemented.
  • Loading branch information
Ottermandias committed Nov 20, 2024
1 parent 11d0cfd commit 3beef61
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Penumbra/Interop/PathResolving/PathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public PathResolver(PerformanceTracker performance, Configuration config, Collec
if (resourceType is ResourceType.Lvb or ResourceType.Lgb or ResourceType.Sgb)
return (null, ResolveData.Invalid);

// Prevent .atch loading to prevent crashes on outdated .atch files. TODO: handle atch modding differently.
if (resourceType is ResourceType.Atch)
return (null, ResolveData.Invalid);

return category switch
{
// Only Interface collection.
Expand Down
2 changes: 1 addition & 1 deletion Penumbra/UI/Tabs/Debug/AtchDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void Draw(AtchFile file)
foreach (var (entry, index) in file.Entries.WithIndex())
{
using var id = ImUtf8.PushId(index);
using var tree = ImUtf8.TreeNode(entry.Name.Span);
using var tree = ImUtf8.TreeNode($"{index:D3}: {entry.Name.Span}");
if (tree)
{
ImUtf8.TreeNode(entry.Accessory ? "Accessory"u8 : "Weapon"u8, ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose();
Expand Down
47 changes: 34 additions & 13 deletions Penumbra/UI/Tabs/Debug/DebugTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
using Penumbra.Interop.Hooks.PostProcessing;
using Penumbra.Interop.Hooks.ResourceLoading;
using Penumbra.GameData.Files.StainMapStructs;
using Penumbra.String.Classes;
using Penumbra.UI.AdvancedWindow.Materials;

namespace Penumbra.UI.Tabs.Debug;
Expand Down Expand Up @@ -196,7 +197,7 @@ public void DrawContent()
}


private void DrawCollectionCaches()
private unsafe void DrawCollectionCaches()
{
if (!ImGui.CollapsingHeader(
$"Collections ({_collectionManager.Caches.Count}/{_collectionManager.Storage.Count - 1} Caches)###Collections"))
Expand All @@ -207,25 +208,35 @@ private void DrawCollectionCaches()
if (collection.HasCache)
{
using var color = PushColor(ImGuiCol.Text, ColorId.FolderExpanded.Value());
using var node = TreeNode($"{collection.AnonymizedName} (Change Counter {collection.ChangeCounter})");
using var node = TreeNode($"{collection.Name} (Change Counter {collection.ChangeCounter})###{collection.Name}");
if (!node)
continue;

color.Pop();
foreach (var (mod, paths, manips) in collection._cache!.ModData.Data.OrderBy(t => t.Item1.Name))
using (var resourceNode = ImUtf8.TreeNode("Custom Resources"u8))
{
using var id = mod is TemporaryMod t ? PushId(t.Priority.Value) : PushId(((Mod)mod).ModPath.Name);
using var node2 = TreeNode(mod.Name.Text);
if (!node2)
continue;
if (resourceNode)
foreach (var (path, resource) in collection._cache!.CustomResources)
ImUtf8.TreeNode($"{path} -> 0x{(ulong)resource.ResourceHandle:X}",
ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose();
}

foreach (var path in paths)
using var modNode = ImUtf8.TreeNode("Enabled Mods"u8);
if (modNode)
foreach (var (mod, paths, manips) in collection._cache!.ModData.Data.OrderBy(t => t.Item1.Name))
{
using var id = mod is TemporaryMod t ? PushId(t.Priority.Value) : PushId(((Mod)mod).ModPath.Name);
using var node2 = TreeNode(mod.Name.Text);
if (!node2)
continue;

TreeNode(path.ToString(), ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose();
foreach (var path in paths)

foreach (var manip in manips)
TreeNode(manip.ToString(), ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose();
}
TreeNode(path.ToString(), ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose();

foreach (var manip in manips)
TreeNode(manip.ToString(), ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose();
}
}
else
{
Expand Down Expand Up @@ -1051,17 +1062,27 @@ private unsafe void DrawGlobalVariableInfo()
DrawDebugResidentResources();
}

private string _crcInput = string.Empty;
private FullPath _crcPath = FullPath.Empty;

private unsafe void DrawCrcCache()
{
var header = ImUtf8.CollapsingHeader("CRC Cache"u8);
if (!header)
return;

if (ImUtf8.InputText("##crcInput"u8, ref _crcInput, "Input path for CRC..."u8))
_crcPath = new FullPath(_crcInput);

using var font = ImRaii.PushFont(UiBuilder.MonoFont);
ImUtf8.Text($" CRC32: {_crcPath.InternalName.CiCrc32:X8}");
ImUtf8.Text($"CI CRC32: {_crcPath.InternalName.Crc32:X8}");
ImUtf8.Text($" CRC64: {_crcPath.Crc64:X16}");

using var table = ImUtf8.Table("table"u8, 2);
if (!table)
return;

using var font = ImRaii.PushFont(UiBuilder.MonoFont);
ImUtf8.TableSetupColumn("Hash"u8, ImGuiTableColumnFlags.WidthFixed, 18 * UiBuilder.MonoFont.GetCharAdvance('0'));
ImUtf8.TableSetupColumn("Type"u8, ImGuiTableColumnFlags.WidthFixed, 5 * UiBuilder.MonoFont.GetCharAdvance('0'));
ImGui.TableHeadersRow();
Expand Down

0 comments on commit 3beef61

Please sign in to comment.