Increment the collection change counter when character utility is ready.

This commit is contained in:
Ottermandias 2022-07-08 10:47:11 +02:00
parent 9115cbaac1
commit f984283231
2 changed files with 18 additions and 5 deletions

View file

@ -51,15 +51,18 @@ public partial class ModCollection
public Cache( ModCollection collection ) public Cache( ModCollection collection )
{ {
_collection = collection; _collection = collection;
MetaManipulations = new MetaManager( collection ); MetaManipulations = new MetaManager( _collection );
_collection.ModSettingChanged += OnModSettingChange; _collection.ModSettingChanged += OnModSettingChange;
_collection.InheritanceChanged += OnInheritanceChange; _collection.InheritanceChanged += OnInheritanceChange;
if( !Penumbra.CharacterUtility.Ready )
Penumbra.CharacterUtility.LoadingFinished += IncrementCounter;
} }
public void Dispose() public void Dispose()
{ {
_collection.ModSettingChanged -= OnModSettingChange; _collection.ModSettingChanged -= OnModSettingChange;
_collection.InheritanceChanged -= OnInheritanceChange; _collection.InheritanceChanged -= OnInheritanceChange;
Penumbra.CharacterUtility.LoadingFinished -= IncrementCounter;
} }
// Resolve a given game path according to this collection. // Resolve a given game path according to this collection.
@ -443,6 +446,14 @@ public partial class ModCollection
private void AddMetaFiles() private void AddMetaFiles()
=> MetaManipulations.SetImcFiles(); => 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. // Identify and record all manipulated objects for this entire collection.
private void SetChangedItems() private void SetChangedItems()
{ {

View file

@ -24,7 +24,6 @@ public partial class MetaManager : IDisposable, IEnumerable< KeyValuePair< MetaM
public IReadOnlyCollection< MetaManipulation > Manipulations public IReadOnlyCollection< MetaManipulation > Manipulations
=> _manipulations.Keys; => _manipulations.Keys;
public IEnumerator< KeyValuePair< MetaManipulation, IMod > > GetEnumerator() public IEnumerator< KeyValuePair< MetaManipulation, IMod > > GetEnumerator()
=> _manipulations.GetEnumerator(); => _manipulations.GetEnumerator();
@ -35,7 +34,10 @@ public partial class MetaManager : IDisposable, IEnumerable< KeyValuePair< MetaM
{ {
_collection = collection; _collection = collection;
SetupImcDelegate(); SetupImcDelegate();
Penumbra.CharacterUtility.LoadingFinished += ApplyStoredManipulations; if( !Penumbra.CharacterUtility.Ready )
{
Penumbra.CharacterUtility.LoadingFinished += ApplyStoredManipulations;
}
} }
public void SetFiles() public void SetFiles()