mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 12:44:19 +01:00
Resource Tree: Deduplicate nodes, add skp
This commit is contained in:
parent
ccc0b51a99
commit
db521dd21c
4 changed files with 114 additions and 34 deletions
|
|
@ -18,7 +18,7 @@ public class ResourceTreeViewer
|
|||
private readonly int _actionCapacity;
|
||||
private readonly Action _onRefresh;
|
||||
private readonly Action<ResourceNode, Vector2> _drawActions;
|
||||
private readonly HashSet<ResourceNode> _unfolded;
|
||||
private readonly HashSet<nint> _unfolded;
|
||||
|
||||
private Task<ResourceTree[]>? _task;
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ public class ResourceTreeViewer
|
|||
_actionCapacity = actionCapacity;
|
||||
_onRefresh = onRefresh;
|
||||
_drawActions = drawActions;
|
||||
_unfolded = new HashSet<ResourceNode>();
|
||||
_unfolded = new HashSet<nint>();
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
|
|
@ -82,7 +82,7 @@ public class ResourceTreeViewer
|
|||
(_actionCapacity - 1) * 3 * ImGuiHelpers.GlobalScale + _actionCapacity * ImGui.GetFrameHeight());
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
DrawNodes(tree.Nodes, 0);
|
||||
DrawNodes(tree.Nodes, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ public class ResourceTreeViewer
|
|||
}
|
||||
});
|
||||
|
||||
private void DrawNodes(IEnumerable<ResourceNode> resourceNodes, int level)
|
||||
private void DrawNodes(IEnumerable<ResourceNode> resourceNodes, int level, nint pathHash)
|
||||
{
|
||||
var debugMode = _config.DebugMode;
|
||||
var frameHeight = ImGui.GetFrameHeight();
|
||||
|
|
@ -109,26 +109,36 @@ public class ResourceTreeViewer
|
|||
foreach (var (resourceNode, index) in resourceNodes.WithIndex())
|
||||
{
|
||||
if (resourceNode.Internal && !debugMode)
|
||||
continue;
|
||||
continue;
|
||||
|
||||
var textColor = ImGui.GetColorU32(ImGuiCol.Text);
|
||||
var textColorInternal = (textColor & 0x00FFFFFFu) | ((textColor & 0xFE000000u) >> 1); // Half opacity
|
||||
|
||||
using var mutedColor = ImRaii.PushColor(ImGuiCol.Text, textColorInternal, resourceNode.Internal);
|
||||
|
||||
var nodePathHash = unchecked(pathHash + resourceNode.ResourceHandle);
|
||||
|
||||
using var id = ImRaii.PushId(index);
|
||||
ImGui.TableNextColumn();
|
||||
var unfolded = _unfolded.Contains(resourceNode);
|
||||
var unfolded = _unfolded.Contains(nodePathHash);
|
||||
using (var indent = ImRaii.PushIndent(level))
|
||||
{
|
||||
ImGui.TableHeader((resourceNode.Children.Count > 0 ? unfolded ? "[-] " : "[+] " : string.Empty) + resourceNode.Name);
|
||||
if (ImGui.IsItemClicked() && resourceNode.Children.Count > 0)
|
||||
{
|
||||
if (unfolded)
|
||||
_unfolded.Remove(resourceNode);
|
||||
_unfolded.Remove(nodePathHash);
|
||||
else
|
||||
_unfolded.Add(resourceNode);
|
||||
_unfolded.Add(nodePathHash);
|
||||
unfolded = !unfolded;
|
||||
}
|
||||
|
||||
if (debugMode)
|
||||
if (debugMode)
|
||||
{
|
||||
using var _ = ImRaii.PushFont(UiBuilder.MonoFont);
|
||||
ImGuiUtil.HoverTooltip(
|
||||
$"Resource Type: {resourceNode.Type}\nObject Address: 0x{resourceNode.ObjectAddress:X16}\nResource Handle: 0x{resourceNode.ResourceHandle:X16}\nLength: 0x{resourceNode.Length:X}");
|
||||
$"Resource Type: {resourceNode.Type}\nObject Address: 0x{resourceNode.ObjectAddress:X16}\nResource Handle: 0x{resourceNode.ResourceHandle:X16}\nLength: 0x{resourceNode.Length:X16}");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
|
|
@ -171,7 +181,7 @@ public class ResourceTreeViewer
|
|||
}
|
||||
|
||||
if (unfolded)
|
||||
DrawNodes(resourceNode.Children, level + 1);
|
||||
DrawNodes(resourceNode.Children, level + 1, unchecked(nodePathHash * 31));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue