Skip to content

Commit a36f9cc

Browse files
committed
Improve ResourceTree display with new function
1 parent dba85f5 commit a36f9cc

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

Penumbra/Interop/ResourceTree/ResourceNode.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class ResourceNode : ICloneable
1515
public readonly nint ResourceHandle;
1616
public Utf8GamePath[] PossibleGamePaths;
1717
public FullPath FullPath;
18+
public string? ModName;
19+
public string? ModRelativePath;
1820
public CiByteString AdditionalData;
1921
public readonly ulong Length;
2022
public readonly List<ResourceNode> Children;
@@ -57,6 +59,8 @@ private ResourceNode(ResourceNode other)
5759
ResourceHandle = other.ResourceHandle;
5860
PossibleGamePaths = other.PossibleGamePaths;
5961
FullPath = other.FullPath;
62+
ModName = other.ModName;
63+
ModRelativePath = other.ModRelativePath;
6064
AdditionalData = other.AdditionalData;
6165
Length = other.Length;
6266
Children = other.Children;

Penumbra/Interop/ResourceTree/ResourceTreeFactory.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Penumbra.GameData.Interop;
1010
using Penumbra.Interop.PathResolving;
1111
using Penumbra.Meta;
12+
using Penumbra.Mods.Manager;
1213
using Penumbra.String.Classes;
1314

1415
namespace Penumbra.Interop.ResourceTree;
@@ -21,7 +22,8 @@ public class ResourceTreeFactory(
2122
ObjectIdentification objectIdentifier,
2223
Configuration config,
2324
ActorManager actors,
24-
PathState pathState) : IService
25+
PathState pathState,
26+
ModManager modManager) : IService
2527
{
2628
private TreeBuildCache CreateTreeBuildCache()
2729
=> new(objects, gameData, actors);
@@ -93,7 +95,10 @@ public IEnumerable<ICharacter> GetLocalPlayerRelatedCharacters()
9395
// This is currently unneeded as we can resolve all paths by querying the draw object:
9496
// ResolveGamePaths(tree, collectionResolveData.ModCollection);
9597
if (globalContext.WithUiData)
98+
{
9699
ResolveUiData(tree);
100+
ResolveModData(tree);
101+
}
97102
FilterFullPaths(tree, (flags & Flags.RedactExternalPaths) != 0 ? config.ModDirectory : null);
98103
Cleanup(tree);
99104

@@ -123,6 +128,18 @@ private static void ResolveUiData(ResourceTree tree)
123128
});
124129
}
125130

131+
private void ResolveModData(ResourceTree tree)
132+
{
133+
foreach (var node in tree.FlatNodes)
134+
{
135+
if (node.FullPath.IsRooted && modManager.TryIdentifyPath(node.FullPath.FullName, out var mod, out var relativePath))
136+
{
137+
node.ModName = mod.Name;
138+
node.ModRelativePath = relativePath;
139+
}
140+
}
141+
}
142+
126143
private static void FilterFullPaths(ResourceTree tree, string? onlyWithinPath)
127144
{
128145
foreach (var node in tree.FlatNodes)

Penumbra/UI/AdvancedWindow/ResourceTreeViewer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ string GetAdditionalDataSuffix(CiByteString data)
316316
ImGui.TableNextColumn();
317317
if (resourceNode.FullPath.FullName.Length > 0)
318318
{
319-
ImGui.Selectable(resourceNode.FullPath.ToPath(), false, 0, new Vector2(ImGui.GetContentRegionAvail().X, cellHeight));
319+
var uiFullPathStr = resourceNode.ModName != null && resourceNode.ModRelativePath != null
320+
? $"[{resourceNode.ModName}] {resourceNode.ModRelativePath}"
321+
: resourceNode.FullPath.ToPath();
322+
ImGui.Selectable(uiFullPathStr, false, 0, new Vector2(ImGui.GetContentRegionAvail().X, cellHeight));
320323
if (ImGui.IsItemClicked())
321324
ImGui.SetClipboardText(resourceNode.FullPath.ToPath());
322325
ImGuiUtil.HoverTooltip(

0 commit comments

Comments
 (0)