diff --git a/Penumbra.Api b/Penumbra.Api index a8e2fe02..2f76f42e 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit a8e2fe0219b8fd1f787171f11e33571317e531c1 +Subproject commit 2f76f42e54141258d89300aa78d42fb3f1878092 diff --git a/Penumbra/Api/Api/ApiHelpers.cs b/Penumbra/Api/Api/ApiHelpers.cs index 32a3956f..92a30bce 100644 --- a/Penumbra/Api/Api/ApiHelpers.cs +++ b/Penumbra/Api/Api/ApiHelpers.cs @@ -48,8 +48,10 @@ public class ApiHelpers( [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] internal static PenumbraApiEc Return(PenumbraApiEc ec, LazyString args, [CallerMemberName] string name = "Unknown") { - Penumbra.Log.Debug( - $"[{name}] Called with {args}, returned {ec}."); + if (ec is PenumbraApiEc.Success or PenumbraApiEc.NothingChanged) + Penumbra.Log.Verbose($"[{name}] Called with {args}, returned {ec}."); + else + Penumbra.Log.Debug($"[{name}] Called with {args}, returned {ec}."); return ec; } diff --git a/Penumbra/Api/Api/CollectionApi.cs b/Penumbra/Api/Api/CollectionApi.cs index de704460..e99850a6 100644 --- a/Penumbra/Api/Api/CollectionApi.cs +++ b/Penumbra/Api/Api/CollectionApi.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using OtterGui.Services; using Penumbra.Api.Enums; using Penumbra.Collections; @@ -10,6 +11,24 @@ public class CollectionApi(CollectionManager collections, ApiHelpers helpers) : public Dictionary GetCollections() => collections.Storage.ToDictionary(c => c.Id, c => c.Name); + public List<(Guid Id, string Name)> GetCollectionsByIdentifier(string identifier) + { + if (identifier.Length == 0) + return []; + + var list = new List<(Guid Id, string Name)>(4); + if (Guid.TryParse(identifier, out var guid) && collections.Storage.ById(guid, out var collection) && collection != ModCollection.Empty) + list.Add((collection.Id, collection.Name)); + else if (identifier.Length >= 8) + list.AddRange(collections.Storage.Where(c => c.Identifier.StartsWith(identifier, StringComparison.OrdinalIgnoreCase)) + .Select(c => (c.Id, c.Name))); + + list.AddRange(collections.Storage + .Where(c => string.Equals(c.Name, identifier, StringComparison.OrdinalIgnoreCase) && !list.Contains((c.Id, c.Name))) + .Select(c => (c.Id, c.Name))); + return list; + } + public Dictionary GetChangedItemsForCollection(Guid collectionId) { try diff --git a/Penumbra/Api/IpcProviders.cs b/Penumbra/Api/IpcProviders.cs index 293af588..cc98ef0d 100644 --- a/Penumbra/Api/IpcProviders.cs +++ b/Penumbra/Api/IpcProviders.cs @@ -19,6 +19,7 @@ public sealed class IpcProviders : IDisposable, IApiService _providers = [ IpcSubscribers.GetCollections.Provider(pi, api.Collection), + IpcSubscribers.GetCollectionsByIdentifier.Provider(pi, api.Collection), IpcSubscribers.GetChangedItemsForCollection.Provider(pi, api.Collection), IpcSubscribers.GetCollection.Provider(pi, api.Collection), IpcSubscribers.GetCollectionForObject.Provider(pi, api.Collection), diff --git a/Penumbra/Api/IpcTester/CollectionsIpcTester.cs b/Penumbra/Api/IpcTester/CollectionsIpcTester.cs index 12314f0c..2679bc69 100644 --- a/Penumbra/Api/IpcTester/CollectionsIpcTester.cs +++ b/Penumbra/Api/IpcTester/CollectionsIpcTester.cs @@ -35,7 +35,7 @@ public class CollectionsIpcTester(DalamudPluginInterface pi) : IUiService ImGuiUtil.GenericEnumCombo("Collection Type", 200, _type, out _type, t => ((CollectionType)t).ToName()); ImGui.InputInt("Object Index##Collections", ref _objectIdx, 0, 0); - ImGuiUtil.GuidInput("Collection Id##Collections", "Collection GUID...", string.Empty, ref _collectionId, ref _collectionIdString); + ImGuiUtil.GuidInput("Collection Id##Collections", "Collection Identifier...", string.Empty, ref _collectionId, ref _collectionIdString); ImGui.Checkbox("Allow Assignment Creation", ref _allowCreation); ImGui.SameLine(); ImGui.Checkbox("Allow Assignment Deletion", ref _allowDeletion); @@ -48,6 +48,25 @@ public class CollectionsIpcTester(DalamudPluginInterface pi) : IUiService if (_oldCollection != null) ImGui.TextUnformatted(!_oldCollection.HasValue ? "Created" : _oldCollection.ToString()); + IpcTester.DrawIntro(GetCollectionsByIdentifier.Label, "Collection Identifier"); + var collectionList = new GetCollectionsByIdentifier(pi).Invoke(_collectionIdString); + if (collectionList.Count == 0) + { + DrawCollection(null); + } + else + { + DrawCollection(collectionList[0]); + foreach (var pair in collectionList.Skip(1)) + { + ImGui.TableNextRow(); + ImGui.TableNextColumn(); + ImGui.TableNextColumn(); + ImGui.TableNextColumn(); + DrawCollection(pair); + } + } + IpcTester.DrawIntro(GetCollection.Label, "Current Collection"); DrawCollection(new GetCollection(pi).Invoke(ApiCollectionType.Current));