mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Add ipc GetPlayerResourceTrees, change ipc resource node to be nested
This commit is contained in:
parent
73af509885
commit
0f03e0484c
4 changed files with 16 additions and 9 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3f3af19d11ec4d7a83ee6c17810eb55ec4237675
|
Subproject commit 1fa1839aef7ddd4a90f53e9642403f950579c2eb
|
||||||
|
|
@ -1084,6 +1084,14 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
return Array.ConvertAll(gameObjects, obj => resDictionary.TryGetValue(obj, out var nodes) ? nodes : null);
|
return Array.ConvertAll(gameObjects, obj => resDictionary.TryGetValue(obj, out var nodes) ? nodes : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IReadOnlyDictionary<ushort, IEnumerable<Ipc.ResourceNode>> GetPlayerResourceTrees(bool withUIData)
|
||||||
|
{
|
||||||
|
var resourceTrees = _resourceTreeFactory.FromObjectTable(ResourceTreeFactory.Flags.LocalPlayerRelatedOnly
|
||||||
|
| (withUIData ? ResourceTreeFactory.Flags.WithUiData : 0));
|
||||||
|
var resDictionary = ResourceTreeApiHelper.EncapsulateResourceTrees(resourceTrees);
|
||||||
|
|
||||||
|
return resDictionary.AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: cleanup when incrementing API
|
// TODO: cleanup when incrementing API
|
||||||
public string GetMetaManipulations(string characterName)
|
public string GetMetaManipulations(string characterName)
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,7 @@ public class PenumbraIpcProviders : IDisposable
|
||||||
GetPlayerResourcesOfType;
|
GetPlayerResourcesOfType;
|
||||||
|
|
||||||
internal readonly FuncProvider<bool, ushort[], IEnumerable<Ipc.ResourceNode>?[]> GetGameObjectResourceTrees;
|
internal readonly FuncProvider<bool, ushort[], IEnumerable<Ipc.ResourceNode>?[]> GetGameObjectResourceTrees;
|
||||||
|
internal readonly FuncProvider<bool, IReadOnlyDictionary<ushort, IEnumerable<Ipc.ResourceNode>>> GetPlayerResourceTrees;
|
||||||
|
|
||||||
public PenumbraIpcProviders(DalamudServices dalamud, IPenumbraApi api, ModManager modManager, CollectionManager collections,
|
public PenumbraIpcProviders(DalamudServices dalamud, IPenumbraApi api, ModManager modManager, CollectionManager collections,
|
||||||
TempModManager tempMods, TempCollectionManager tempCollections, SaveService saveService, Configuration config)
|
TempModManager tempMods, TempCollectionManager tempCollections, SaveService saveService, Configuration config)
|
||||||
|
|
@ -257,6 +258,7 @@ public class PenumbraIpcProviders : IDisposable
|
||||||
GetGameObjectResourcesOfType = Ipc.GetGameObjectResourcesOfType.Provider(pi, Api.GetGameObjectResourcesOfType);
|
GetGameObjectResourcesOfType = Ipc.GetGameObjectResourcesOfType.Provider(pi, Api.GetGameObjectResourcesOfType);
|
||||||
GetPlayerResourcesOfType = Ipc.GetPlayerResourcesOfType.Provider(pi, Api.GetPlayerResourcesOfType);
|
GetPlayerResourcesOfType = Ipc.GetPlayerResourcesOfType.Provider(pi, Api.GetPlayerResourcesOfType);
|
||||||
GetGameObjectResourceTrees = Ipc.GetGameObjectResourceTrees.Provider(pi, Api.GetGameObjectResourceTrees);
|
GetGameObjectResourceTrees = Ipc.GetGameObjectResourceTrees.Provider(pi, Api.GetGameObjectResourceTrees);
|
||||||
|
GetPlayerResourceTrees = Ipc.GetPlayerResourceTrees.Provider(pi, Api.GetPlayerResourceTrees);
|
||||||
|
|
||||||
Tester = new IpcTester(config, dalamud, this, modManager, collections, tempMods, tempCollections, saveService);
|
Tester = new IpcTester(config, dalamud, this, modManager, collections, tempMods, tempCollections, saveService);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,9 @@ internal static class ResourceTreeApiHelper
|
||||||
|
|
||||||
public static Dictionary<ushort, IEnumerable<Ipc.ResourceNode>> EncapsulateResourceTrees(IEnumerable<(Character, ResourceTree)> resourceTrees)
|
public static Dictionary<ushort, IEnumerable<Ipc.ResourceNode>> EncapsulateResourceTrees(IEnumerable<(Character, ResourceTree)> resourceTrees)
|
||||||
{
|
{
|
||||||
static Ipc.ResourceNode GetIpcNode(ResourceNode[] tree, ResourceNode node) =>
|
static Ipc.ResourceNode GetIpcNode(ResourceNode node) =>
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
ChildrenIndices = node.Children.Select(c => Array.IndexOf(tree, c)).ToArray(),
|
|
||||||
Type = node.Type,
|
Type = node.Type,
|
||||||
Icon = ChangedItemDrawer.ToApiIcon(node.Icon),
|
Icon = ChangedItemDrawer.ToApiIcon(node.Icon),
|
||||||
Name = node.Name,
|
Name = node.Name,
|
||||||
|
|
@ -87,13 +86,11 @@ internal static class ResourceTreeApiHelper
|
||||||
ActualPath = node.FullPath.ToString(),
|
ActualPath = node.FullPath.ToString(),
|
||||||
ObjectAddress = node.ObjectAddress,
|
ObjectAddress = node.ObjectAddress,
|
||||||
ResourceHandle = node.ResourceHandle,
|
ResourceHandle = node.ResourceHandle,
|
||||||
|
Children = node.Children.Select(GetIpcNode).ToArray(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static IEnumerable<Ipc.ResourceNode> GetIpcNodes(ResourceTree tree)
|
static IEnumerable<Ipc.ResourceNode> GetIpcNodes(ResourceTree tree) =>
|
||||||
{
|
tree.Nodes.Select(GetIpcNode).ToArray();
|
||||||
var nodes = tree.FlatNodes.ToArray();
|
|
||||||
return nodes.Select(n => GetIpcNode(nodes, n)).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
var resDictionary = new Dictionary<ushort, IEnumerable<Ipc.ResourceNode>>(4);
|
var resDictionary = new Dictionary<ushort, IEnumerable<Ipc.ResourceNode>>(4);
|
||||||
foreach (var (gameObject, resourceTree) in resourceTrees)
|
foreach (var (gameObject, resourceTree) in resourceTrees)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue