diff --git a/Penumbra/Collections/Cache/CollectionCacheManager.cs b/Penumbra/Collections/Cache/CollectionCacheManager.cs index a14facb4..c1d42258 100644 --- a/Penumbra/Collections/Cache/CollectionCacheManager.cs +++ b/Penumbra/Collections/Cache/CollectionCacheManager.cs @@ -51,6 +51,7 @@ public class CollectionCacheManager : IDisposable _communicator.ModSettingChanged.Subscribe(OnModSettingChange); _communicator.CollectionInheritanceChanged.Subscribe(OnCollectionInheritanceChange); CreateNecessaryCaches(); + _active.Individuals.Loaded += CreateNecessaryCaches; if (!MetaFileManager.CharacterUtility.Ready) MetaFileManager.CharacterUtility.LoadingFinished += IncrementCounters; diff --git a/Penumbra/Collections/Manager/ActiveCollections.cs b/Penumbra/Collections/Manager/ActiveCollections.cs index 99d3c651..19aa27cd 100644 --- a/Penumbra/Collections/Manager/ActiveCollections.cs +++ b/Penumbra/Collections/Manager/ActiveCollections.cs @@ -47,6 +47,7 @@ public class ActiveCollections : ISavable, IDisposable _communicator.CollectionChange.Subscribe(OnCollectionChange, -100); LoadCollections(); UpdateCurrentCollectionInUse(); + Individuals.Loaded += UpdateCurrentCollectionInUse; } public void Dispose() @@ -275,7 +276,7 @@ public class ActiveCollections : ISavable, IDisposable jObj.WriteTo(j); } - public void UpdateCurrentCollectionInUse() + private void UpdateCurrentCollectionInUse() => CurrentCollectionInUse = SpecialCollections .OfType() .Prepend(Interface) diff --git a/Penumbra/Collections/Manager/IndividualCollections.Files.cs b/Penumbra/Collections/Manager/IndividualCollections.Files.cs index 54b845f7..6fe12a9d 100644 --- a/Penumbra/Collections/Manager/IndividualCollections.Files.cs +++ b/Penumbra/Collections/Manager/IndividualCollections.Files.cs @@ -34,7 +34,7 @@ public partial class IndividualCollections { if (ReadJObjectInternal(obj, storage)) saver.ImmediateSave(parent); - parent.UpdateCurrentCollectionInUse(); + Loaded?.Invoke(); _actorService.FinishedCreation -= Func; } _actorService.FinishedCreation += Func; diff --git a/Penumbra/Collections/Manager/IndividualCollections.cs b/Penumbra/Collections/Manager/IndividualCollections.cs index f333ed81..dfecec67 100644 --- a/Penumbra/Collections/Manager/IndividualCollections.cs +++ b/Penumbra/Collections/Manager/IndividualCollections.cs @@ -17,6 +17,8 @@ public sealed partial class IndividualCollections private readonly List<(string DisplayName, IReadOnlyList Identifiers, ModCollection Collection)> _assignments = new(); private readonly Dictionary _individuals = new(); + public event Action? Loaded; + public IReadOnlyList<(string DisplayName, IReadOnlyList Identifiers, ModCollection Collection)> Assignments => _assignments; @@ -95,7 +97,7 @@ public sealed partial class IndividualCollections case IdentifierType.Owned: if (!ByteString.FromString(name, out var ownerName)) return AddResult.Invalid; - + identifiers = dataIds.Select(id => manager.CreateOwned(ownerName, homeWorld, kind, id)).ToArray(); break; case IdentifierType.Npc: @@ -242,8 +244,9 @@ public sealed partial class IndividualCollections IdentifierType.Retainer => $"{identifier.PlayerName} (Retainer)", IdentifierType.Owned => $"{identifier.PlayerName} ({_actorService.AwaitedService.Data.ToWorldName(identifier.HomeWorld)})'s {_actorService.AwaitedService.Data.ToName(identifier.Kind, identifier.DataId)}", - IdentifierType.Npc => $"{_actorService.AwaitedService.Data.ToName(identifier.Kind, identifier.DataId)} ({identifier.Kind.ToName()})", - _ => string.Empty, + IdentifierType.Npc => + $"{_actorService.AwaitedService.Data.ToName(identifier.Kind, identifier.DataId)} ({identifier.Kind.ToName()})", + _ => string.Empty, }; } }