mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 20:54:16 +01:00
Improve ResourceTree display with new function
This commit is contained in:
parent
dba85f5da3
commit
a36f9ccec7
3 changed files with 26 additions and 2 deletions
|
|
@ -15,6 +15,8 @@ public class ResourceNode : ICloneable
|
|||
public readonly nint ResourceHandle;
|
||||
public Utf8GamePath[] PossibleGamePaths;
|
||||
public FullPath FullPath;
|
||||
public string? ModName;
|
||||
public string? ModRelativePath;
|
||||
public CiByteString AdditionalData;
|
||||
public readonly ulong Length;
|
||||
public readonly List<ResourceNode> Children;
|
||||
|
|
@ -57,6 +59,8 @@ public class ResourceNode : ICloneable
|
|||
ResourceHandle = other.ResourceHandle;
|
||||
PossibleGamePaths = other.PossibleGamePaths;
|
||||
FullPath = other.FullPath;
|
||||
ModName = other.ModName;
|
||||
ModRelativePath = other.ModRelativePath;
|
||||
AdditionalData = other.AdditionalData;
|
||||
Length = other.Length;
|
||||
Children = other.Children;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using Penumbra.GameData.Enums;
|
|||
using Penumbra.GameData.Interop;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
using Penumbra.Meta;
|
||||
using Penumbra.Mods.Manager;
|
||||
using Penumbra.String.Classes;
|
||||
|
||||
namespace Penumbra.Interop.ResourceTree;
|
||||
|
|
@ -21,7 +22,8 @@ public class ResourceTreeFactory(
|
|||
ObjectIdentification objectIdentifier,
|
||||
Configuration config,
|
||||
ActorManager actors,
|
||||
PathState pathState) : IService
|
||||
PathState pathState,
|
||||
ModManager modManager) : IService
|
||||
{
|
||||
private TreeBuildCache CreateTreeBuildCache()
|
||||
=> new(objects, gameData, actors);
|
||||
|
|
@ -93,7 +95,10 @@ public class ResourceTreeFactory(
|
|||
// This is currently unneeded as we can resolve all paths by querying the draw object:
|
||||
// ResolveGamePaths(tree, collectionResolveData.ModCollection);
|
||||
if (globalContext.WithUiData)
|
||||
{
|
||||
ResolveUiData(tree);
|
||||
ResolveModData(tree);
|
||||
}
|
||||
FilterFullPaths(tree, (flags & Flags.RedactExternalPaths) != 0 ? config.ModDirectory : null);
|
||||
Cleanup(tree);
|
||||
|
||||
|
|
@ -123,6 +128,18 @@ public class ResourceTreeFactory(
|
|||
});
|
||||
}
|
||||
|
||||
private void ResolveModData(ResourceTree tree)
|
||||
{
|
||||
foreach (var node in tree.FlatNodes)
|
||||
{
|
||||
if (node.FullPath.IsRooted && modManager.TryIdentifyPath(node.FullPath.FullName, out var mod, out var relativePath))
|
||||
{
|
||||
node.ModName = mod.Name;
|
||||
node.ModRelativePath = relativePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void FilterFullPaths(ResourceTree tree, string? onlyWithinPath)
|
||||
{
|
||||
foreach (var node in tree.FlatNodes)
|
||||
|
|
|
|||
|
|
@ -316,7 +316,10 @@ public class ResourceTreeViewer
|
|||
ImGui.TableNextColumn();
|
||||
if (resourceNode.FullPath.FullName.Length > 0)
|
||||
{
|
||||
ImGui.Selectable(resourceNode.FullPath.ToPath(), false, 0, new Vector2(ImGui.GetContentRegionAvail().X, cellHeight));
|
||||
var uiFullPathStr = resourceNode.ModName != null && resourceNode.ModRelativePath != null
|
||||
? $"[{resourceNode.ModName}] {resourceNode.ModRelativePath}"
|
||||
: resourceNode.FullPath.ToPath();
|
||||
ImGui.Selectable(uiFullPathStr, false, 0, new Vector2(ImGui.GetContentRegionAvail().X, cellHeight));
|
||||
if (ImGui.IsItemClicked())
|
||||
ImGui.SetClipboardText(resourceNode.FullPath.ToPath());
|
||||
ImGuiUtil.HoverTooltip(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue