mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 06:13:45 +01:00
Fix some caching issues.
This commit is contained in:
parent
94a0864556
commit
9c0406ec9d
7 changed files with 54 additions and 24 deletions
|
|
@ -168,10 +168,10 @@ public class ModCacheManager : IDisposable
|
|||
=> mod.TotalFileCount = mod.AllSubMods.Sum(s => s.Files.Count);
|
||||
|
||||
private static void UpdateSwapCount(Mod mod)
|
||||
=> mod.TotalFileCount = mod.AllSubMods.Sum(s => s.FileSwaps.Count);
|
||||
=> mod.TotalSwapCount = mod.AllSubMods.Sum(s => s.FileSwaps.Count);
|
||||
|
||||
private static void UpdateMetaCount(Mod mod)
|
||||
=> mod.TotalFileCount = mod.AllSubMods.Sum(s => s.Manipulations.Count);
|
||||
=> mod.TotalManipulations = mod.AllSubMods.Sum(s => s.Manipulations.Count);
|
||||
|
||||
private static void UpdateHasOptions(Mod mod)
|
||||
=> mod.HasOptions = mod.Groups.Any(o => o.IsOption);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public enum ModPathChangeType
|
|||
StartingReload,
|
||||
}
|
||||
|
||||
public sealed class ModManager : ModStorage
|
||||
public sealed class ModManager : ModStorage, IDisposable
|
||||
{
|
||||
private readonly Configuration _config;
|
||||
private readonly CommunicatorService _communicator;
|
||||
|
|
@ -49,7 +49,8 @@ public sealed class ModManager : ModStorage
|
|||
DataEditor = dataEditor;
|
||||
OptionEditor = optionEditor;
|
||||
Creator = creator;
|
||||
SetBaseDirectory(config.ModDirectory, true);
|
||||
SetBaseDirectory(config.ModDirectory, true);
|
||||
_communicator.ModPathChanged.Subscribe(OnModPathChange);
|
||||
DiscoverMods();
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ public sealed class ModManager : ModStorage
|
|||
public void DiscoverMods()
|
||||
{
|
||||
_communicator.ModDiscoveryStarted.Invoke();
|
||||
NewMods.Clear();
|
||||
ClearNewMods();
|
||||
Mods.Clear();
|
||||
BasePath.Refresh();
|
||||
|
||||
|
|
@ -243,11 +244,11 @@ public sealed class ModManager : ModStorage
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case ModPathChangeType.Added:
|
||||
NewMods.Add(mod);
|
||||
case ModPathChangeType.Added:
|
||||
SetNew(mod);
|
||||
break;
|
||||
case ModPathChangeType.Deleted:
|
||||
NewMods.Remove(mod);
|
||||
SetKnown(mod);
|
||||
break;
|
||||
case ModPathChangeType.Moved:
|
||||
if (oldDirectory != null && newDirectory != null)
|
||||
|
|
@ -258,7 +259,7 @@ public sealed class ModManager : ModStorage
|
|||
}
|
||||
|
||||
public void Dispose()
|
||||
{ }
|
||||
=> _communicator.ModPathChanged.Unsubscribe(OnModPathChange);
|
||||
|
||||
/// <summary>
|
||||
/// Set the mod base directory.
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ public class ModOptionEditor
|
|||
return;
|
||||
|
||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
||||
subMod.ManipulationData = manipulations;
|
||||
subMod.ManipulationData.SetTo(manipulations);
|
||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx));
|
||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionMetaChanged, mod, groupIdx, optionIdx, -1);
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ public class ModOptionEditor
|
|||
return;
|
||||
|
||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
||||
subMod.FileData = replacements;
|
||||
subMod.FileData.SetTo(replacements);
|
||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx));
|
||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionFilesChanged, mod, groupIdx, optionIdx, -1);
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ public class ModOptionEditor
|
|||
return;
|
||||
|
||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
||||
subMod.FileSwapData = swaps;
|
||||
subMod.FileSwapData.SetTo(swaps);
|
||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx));
|
||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionSwapsChanged, mod, groupIdx, optionIdx, -1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,14 +53,17 @@ public class ModStorage : IReadOnlyList<Mod>
|
|||
/// Mods are removed when they are deleted or when they are toggled in any collection.
|
||||
/// Also gets cleared on mod rediscovery.
|
||||
/// </summary>
|
||||
protected readonly HashSet<Mod> NewMods = new();
|
||||
private readonly HashSet<Mod> _newMods = new();
|
||||
|
||||
public bool IsNew(Mod mod)
|
||||
=> NewMods.Contains(mod);
|
||||
=> _newMods.Contains(mod);
|
||||
|
||||
public void SetNew(Mod mod)
|
||||
=> NewMods.Add(mod);
|
||||
=> _newMods.Add(mod);
|
||||
|
||||
public void SetKnown(Mod mod)
|
||||
=> NewMods.Remove(mod);
|
||||
=> _newMods.Remove(mod);
|
||||
|
||||
public void ClearNewMods()
|
||||
=> _newMods.Clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue