Fix issue with reverted IMC edits and change counter on disabling mods.

This commit is contained in:
Ottermandias 2023-05-12 00:54:47 +02:00
parent 3f03712e24
commit 0aa74692a8
4 changed files with 14 additions and 9 deletions

View file

@ -151,6 +151,10 @@ public class CollectionCache : IDisposable
{ {
var conflicts = Conflicts(mod); var conflicts = Conflicts(mod);
var (paths, manipulations) = ModData.RemoveMod(mod); var (paths, manipulations) = ModData.RemoveMod(mod);
if (addMetaChanges)
++_collection.ChangeCounter;
foreach (var path in paths) foreach (var path in paths)
{ {
if (ResolvedFiles.Remove(path, out var mp) && mp.Mod != mod) if (ResolvedFiles.Remove(path, out var mp) && mp.Mod != mod)
@ -183,10 +187,7 @@ public class CollectionCache : IDisposable
} }
if (addMetaChanges) if (addMetaChanges)
{
++_collection.ChangeCounter;
_manager.MetaFileManager.ApplyDefaultFiles(_collection); _manager.MetaFileManager.ApplyDefaultFiles(_collection);
}
} }

View file

@ -27,7 +27,10 @@ public class CollectionCacheManager : IDisposable
internal readonly MetaFileManager MetaFileManager; internal readonly MetaFileManager MetaFileManager;
public int Count { get; private set; } private int _count;
public int Count
=> _count;
public IEnumerable<ModCollection> Active public IEnumerable<ModCollection> Active
=> _storage.Where(c => c.HasCache); => _storage.Where(c => c.HasCache);
@ -78,7 +81,8 @@ public class CollectionCacheManager : IDisposable
return false; return false;
collection._cache = new CollectionCache(this, collection); collection._cache = new CollectionCache(this, collection);
++Count; if (collection.Index > 0)
Interlocked.Increment(ref _count);
Penumbra.Log.Verbose($"Created new cache for collection {collection.AnonymizedName}."); Penumbra.Log.Verbose($"Created new cache for collection {collection.AnonymizedName}.");
return true; return true;
} }
@ -295,7 +299,8 @@ public class CollectionCacheManager : IDisposable
collection._cache!.Dispose(); collection._cache!.Dispose();
collection._cache = null; collection._cache = null;
--Count; if (collection.Index > 0)
Interlocked.Decrement(ref _count);
Penumbra.Log.Verbose($"Cleared cache of collection {collection.AnonymizedName}."); Penumbra.Log.Verbose($"Cleared cache of collection {collection.AnonymizedName}.");
} }

View file

@ -7,7 +7,6 @@ using Penumbra.Api.Enums;
using Penumbra.Mods; using Penumbra.Mods;
using Penumbra.Mods.Manager; using Penumbra.Mods.Manager;
using Penumbra.Services; using Penumbra.Services;
using Penumbra.Util;
namespace Penumbra.Collections.Manager; namespace Penumbra.Collections.Manager;

View file

@ -154,7 +154,7 @@ public class DebugTab : Window, ITab
if (collection.HasCache) if (collection.HasCache)
{ {
using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.FolderExpanded.Value()); using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.FolderExpanded.Value());
using var node = TreeNode(collection.AnonymizedName); using var node = TreeNode($"{collection.AnonymizedName} (Change Counter {collection.ChangeCounter})");
if (!node) if (!node)
continue; continue;
@ -177,7 +177,7 @@ public class DebugTab : Window, ITab
else else
{ {
using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.UndefinedMod.Value()); using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.UndefinedMod.Value());
TreeNode(collection.AnonymizedName, ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose(); TreeNode($"{collection.AnonymizedName} (Change Counter {collection.ChangeCounter})", ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose();
} }
} }
} }