Skip to content

Commit

Permalink
Resource Tree: Make skp child of sklb
Browse files Browse the repository at this point in the history
  • Loading branch information
Exter-N committed Sep 2, 2023
1 parent 30c622c commit a17a1e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
11 changes: 10 additions & 1 deletion Penumbra/Interop/ResourceTree/ResolveContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,17 @@ static ushort GetTextureIndex(ushort texFlags)

var node = CreateNodeFromResourceHandle(ResourceType.Sklb, (nint)sklb, (ResourceHandle*)sklb->SkeletonResourceHandle, false, WithUIData);
if (node != null)
{
var skpNode = CreateParameterNodeFromPartialSkeleton(sklb);
if (skpNode != null)
node.Children.Add(skpNode);
Nodes.Add((nint)sklb->SkeletonResourceHandle, node);
}

return node;
}

public unsafe ResourceNode? CreateParameterNodeFromPartialSkeleton(FFXIVClientStructs.FFXIV.Client.Graphics.Render.PartialSkeleton* sklb)
private unsafe ResourceNode? CreateParameterNodeFromPartialSkeleton(FFXIVClientStructs.FFXIV.Client.Graphics.Render.PartialSkeleton* sklb)
{
if (sklb->SkeletonParameterResourceHandle == null)
return null;
Expand All @@ -298,7 +303,11 @@ static ushort GetTextureIndex(ushort texFlags)

var node = CreateNodeFromResourceHandle(ResourceType.Skp, (nint)sklb, (ResourceHandle*)sklb->SkeletonParameterResourceHandle, true, WithUIData);
if (node != null)
{
if (WithUIData)
node = node.WithUIData("Skeleton Parameters", node.Icon);
Nodes.Add((nint)sklb->SkeletonParameterResourceHandle, node);
}

return node;
}
Expand Down
4 changes: 0 additions & 4 deletions Penumbra/Interop/ResourceTree/ResourceTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ private unsafe void AddSkeleton(List<ResourceNode> nodes, ResolveContext context
var sklbNode = context.CreateNodeFromPartialSkeleton(&skeleton->PartialSkeletons[i]);
if (sklbNode != null)
nodes.Add(context.WithUIData ? sklbNode.WithUIData($"{prefix}Skeleton #{i}", sklbNode.Icon) : sklbNode);

var skpNode = context.CreateParameterNodeFromPartialSkeleton(&skeleton->PartialSkeletons[i]);
if (skpNode != null)
nodes.Add(context.WithUIData ? skpNode.WithUIData($"{prefix}Skeleton #{i} Parameters", skpNode.Icon) : skpNode);
}
}
}
10 changes: 7 additions & 3 deletions Penumbra/UI/AdvancedWindow/ResourceTreeViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
using OtterGui;
using Penumbra.Interop.ResourceTree;
using Penumbra.UI.Classes;

using System.Linq;

namespace Penumbra.UI.AdvancedWindow;

public class ResourceTreeViewer
Expand Down Expand Up @@ -125,7 +126,10 @@ private void DrawNodes(IEnumerable<ResourceNode> resourceNodes, int level, nint
var unfolded = _unfolded.Contains(nodePathHash);
using (var indent = ImRaii.PushIndent(level))
{
if (resourceNode.Children.Count > 0)
var unfoldable = debugMode
? resourceNode.Children.Count > 0
: resourceNode.Children.Any(child => !child.Internal);
if (unfoldable)
{
using var font = ImRaii.PushFont(UiBuilder.IconFont);
var icon = (unfolded ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight).ToIconString();
Expand All @@ -142,7 +146,7 @@ private void DrawNodes(IEnumerable<ResourceNode> resourceNodes, int level, nint
_changedItemDrawer.DrawCategoryIcon(resourceNode.Icon);
ImGui.SameLine(0f, ImGui.GetStyle().ItemInnerSpacing.X);
ImGui.TableHeader(resourceNode.Name);
if (ImGui.IsItemClicked() && resourceNode.Children.Count > 0)
if (ImGui.IsItemClicked() && unfoldable)
{
if (unfolded)
_unfolded.Remove(nodePathHash);
Expand Down

0 comments on commit a17a1e9

Please sign in to comment.