From f98428323160f73550d3327d35d705308d38b2ed Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 8 Jul 2022 10:47:11 +0200 Subject: [PATCH] Increment the collection change counter when character utility is ready. --- Penumbra/Collections/ModCollection.Cache.cs | 17 ++++++++++++++--- Penumbra/Meta/Manager/MetaManager.cs | 6 ++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Penumbra/Collections/ModCollection.Cache.cs b/Penumbra/Collections/ModCollection.Cache.cs index 34ef8924..fa9669b6 100644 --- a/Penumbra/Collections/ModCollection.Cache.cs +++ b/Penumbra/Collections/ModCollection.Cache.cs @@ -51,15 +51,18 @@ public partial class ModCollection public Cache( ModCollection collection ) { _collection = collection; - MetaManipulations = new MetaManager( collection ); + MetaManipulations = new MetaManager( _collection ); _collection.ModSettingChanged += OnModSettingChange; _collection.InheritanceChanged += OnInheritanceChange; + if( !Penumbra.CharacterUtility.Ready ) + Penumbra.CharacterUtility.LoadingFinished += IncrementCounter; } public void Dispose() { - _collection.ModSettingChanged -= OnModSettingChange; - _collection.InheritanceChanged -= OnInheritanceChange; + _collection.ModSettingChanged -= OnModSettingChange; + _collection.InheritanceChanged -= OnInheritanceChange; + Penumbra.CharacterUtility.LoadingFinished -= IncrementCounter; } // Resolve a given game path according to this collection. @@ -443,6 +446,14 @@ public partial class ModCollection private void AddMetaFiles() => MetaManipulations.SetImcFiles(); + // Increment the counter to ensure new files are loaded after applying meta changes. + private void IncrementCounter() + { + ++ChangeCounter; + Penumbra.CharacterUtility.LoadingFinished -= IncrementCounter; + } + + // Identify and record all manipulated objects for this entire collection. private void SetChangedItems() { diff --git a/Penumbra/Meta/Manager/MetaManager.cs b/Penumbra/Meta/Manager/MetaManager.cs index 1d664039..4eb46e82 100644 --- a/Penumbra/Meta/Manager/MetaManager.cs +++ b/Penumbra/Meta/Manager/MetaManager.cs @@ -24,7 +24,6 @@ public partial class MetaManager : IDisposable, IEnumerable< KeyValuePair< MetaM public IReadOnlyCollection< MetaManipulation > Manipulations => _manipulations.Keys; - public IEnumerator< KeyValuePair< MetaManipulation, IMod > > GetEnumerator() => _manipulations.GetEnumerator(); @@ -35,7 +34,10 @@ public partial class MetaManager : IDisposable, IEnumerable< KeyValuePair< MetaM { _collection = collection; SetupImcDelegate(); - Penumbra.CharacterUtility.LoadingFinished += ApplyStoredManipulations; + if( !Penumbra.CharacterUtility.Ready ) + { + Penumbra.CharacterUtility.LoadingFinished += ApplyStoredManipulations; + } } public void SetFiles()