diff --git a/Penumbra/Api/IpcTester.cs b/Penumbra/Api/IpcTester.cs index fb8719f4..86719160 100644 --- a/Penumbra/Api/IpcTester.cs +++ b/Penumbra/Api/IpcTester.cs @@ -1408,10 +1408,9 @@ public class IpcTester : IDisposable private readonly DalamudPluginInterface _pi; private readonly IObjectTable _objects; - private string _gameObjectIndices = "0"; - private bool _mergeSameCollection = false; - private ResourceType _type = ResourceType.Mtrl; - private bool _withUIData = false; + private string _gameObjectIndices = "0"; + private ResourceType _type = ResourceType.Mtrl; + private bool _withUIData = false; private (string, IReadOnlyDictionary?)[]? _lastGameObjectResourcePaths; private (string, IReadOnlyDictionary?)[]? _lastPlayerResourcePaths; @@ -1431,7 +1430,6 @@ public class IpcTester : IDisposable return; ImGui.InputText("GameObject indices", ref _gameObjectIndices, 511); - ImGui.Checkbox("Merge entries that use the same collection", ref _mergeSameCollection); ImGuiUtil.GenericEnumCombo("Resource type", ImGui.CalcItemWidth(), _type, out _type, Enum.GetValues()); ImGui.Checkbox("Also get names and icons", ref _withUIData); @@ -1443,7 +1441,7 @@ public class IpcTester : IDisposable if (ImGui.Button("Get##GameObjectResourcePaths")) { var gameObjects = GetSelectedGameObjects(); - var resourcePaths = Ipc.GetGameObjectResourcePaths.Subscriber(_pi).Invoke(gameObjects, _mergeSameCollection); + var resourcePaths = Ipc.GetGameObjectResourcePaths.Subscriber(_pi).Invoke(gameObjects); _lastGameObjectResourcePaths = gameObjects .Select(GameObjectToString) @@ -1456,7 +1454,7 @@ public class IpcTester : IDisposable DrawIntro(Ipc.GetPlayerResourcePaths.Label, "Get local player resource paths"); if (ImGui.Button("Get##PlayerResourcePaths")) { - _lastPlayerResourcePaths = Ipc.GetPlayerResourcePaths.Subscriber(_pi).Invoke(_mergeSameCollection) + _lastPlayerResourcePaths = Ipc.GetPlayerResourcePaths.Subscriber(_pi).Invoke() .Select(pair => (GameObjectToString(pair.Key), (IReadOnlyDictionary?)pair.Value)) .ToArray(); diff --git a/Penumbra/Api/PenumbraApi.cs b/Penumbra/Api/PenumbraApi.cs index 1c56b9df..0572d868 100644 --- a/Penumbra/Api/PenumbraApi.cs +++ b/Penumbra/Api/PenumbraApi.cs @@ -1016,19 +1016,19 @@ public class PenumbraApi : IDisposable, IPenumbraApi }; // @formatter:on - public IReadOnlyDictionary?[] GetGameObjectResourcePaths(ushort[] gameObjects, bool mergeSameCollection) + public IReadOnlyDictionary?[] GetGameObjectResourcePaths(ushort[] gameObjects) { var characters = gameObjects.Select(index => _dalamud.Objects[index]).OfType(); var resourceTrees = _resourceTreeFactory.FromCharacters(characters, false, false); - var pathDictionaries = ResourceTreeApiHelper.GetResourcePathDictionaries(resourceTrees, mergeSameCollection); + var pathDictionaries = ResourceTreeApiHelper.GetResourcePathDictionaries(resourceTrees); return Array.ConvertAll(gameObjects, obj => pathDictionaries.TryGetValue(obj, out var pathDict) ? pathDict : null); } - public IReadOnlyDictionary> GetPlayerResourcePaths(bool mergeSameCollection) + public IReadOnlyDictionary> GetPlayerResourcePaths() { var resourceTrees = _resourceTreeFactory.FromObjectTable(true, false, false); - var pathDictionaries = ResourceTreeApiHelper.GetResourcePathDictionaries(resourceTrees, mergeSameCollection); + var pathDictionaries = ResourceTreeApiHelper.GetResourcePathDictionaries(resourceTrees); return pathDictionaries.AsReadOnly(); } diff --git a/Penumbra/Api/PenumbraIpcProviders.cs b/Penumbra/Api/PenumbraIpcProviders.cs index c05a7c47..aca57aac 100644 --- a/Penumbra/Api/PenumbraIpcProviders.cs +++ b/Penumbra/Api/PenumbraIpcProviders.cs @@ -119,8 +119,8 @@ public class PenumbraIpcProviders : IDisposable internal readonly FuncProvider RemoveTemporaryMod; // Resource Tree - internal readonly FuncProvider?[]> GetGameObjectResourcePaths; - internal readonly FuncProvider>> GetPlayerResourcePaths; + internal readonly FuncProvider?[]> GetGameObjectResourcePaths; + internal readonly FuncProvider>> GetPlayerResourcePaths; internal readonly FuncProvider?[]> GetGameObjectResourcesOfType; internal readonly FuncProvider>> GetPlayerResourcesOfType; diff --git a/Penumbra/Interop/ResourceTree/ResourceTreeApiHelper.cs b/Penumbra/Interop/ResourceTree/ResourceTreeApiHelper.cs index e7d9abc2..6c1e4d1e 100644 --- a/Penumbra/Interop/ResourceTree/ResourceTreeApiHelper.cs +++ b/Penumbra/Interop/ResourceTree/ResourceTreeApiHelper.cs @@ -6,37 +6,7 @@ namespace Penumbra.Interop.ResourceTree; internal static class ResourceTreeApiHelper { - public static Dictionary> GetResourcePathDictionaries(IEnumerable<(Character, ResourceTree)> resourceTrees, - bool mergeSameCollection) - => mergeSameCollection ? GetResourcePathDictionariesMerged(resourceTrees) : GetResourcePathDictionariesUnmerged(resourceTrees); - - private static Dictionary> GetResourcePathDictionariesMerged(IEnumerable<(Character, ResourceTree)> resourceTrees) - { - var collections = new Dictionary(4); - var pathDictionaries = new Dictionary>>(4); - - foreach (var (gameObject, resourceTree) in resourceTrees) - { - if (collections.ContainsKey(gameObject.ObjectIndex)) - continue; - - collections.Add(gameObject.ObjectIndex, resourceTree.CollectionName); - if (!pathDictionaries.TryGetValue(resourceTree.CollectionName, out var pathDictionary)) - { - pathDictionary = new(); - pathDictionaries.Add(resourceTree.CollectionName, pathDictionary); - } - - CollectResourcePaths(pathDictionary, resourceTree); - } - - var pathRODictionaries = pathDictionaries.ToDictionary(pair => pair.Key, - pair => (IReadOnlyDictionary)pair.Value.ToDictionary(pair => pair.Key, pair => pair.Value.ToArray()).AsReadOnly()); - - return collections.ToDictionary(pair => pair.Key, pair => pathRODictionaries[pair.Value]); - } - - private static Dictionary> GetResourcePathDictionariesUnmerged(IEnumerable<(Character, ResourceTree)> resourceTrees) + public static Dictionary> GetResourcePathDictionaries(IEnumerable<(Character, ResourceTree)> resourceTrees) { var pathDictionaries = new Dictionary>>(4);