mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-23 08:17:59 +01:00
Remove cached data from mod and use ModCaches where required.
This commit is contained in:
parent
2ffbd7beba
commit
e79b110429
14 changed files with 44 additions and 155 deletions
|
|
@ -10,8 +10,6 @@ public interface IMod
|
|||
public int Index { get; }
|
||||
public int Priority { get; }
|
||||
|
||||
public int TotalManipulations { get; }
|
||||
|
||||
public ISubMod Default { get; }
|
||||
public IReadOnlyList< IModGroup > Groups { get; }
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ namespace Penumbra.Mods;
|
|||
public class ModNormalizer
|
||||
{
|
||||
private readonly ModManager _modManager;
|
||||
private readonly ModCacheManager _modCacheManager;
|
||||
private readonly List<List<Dictionary<Utf8GamePath, FullPath>>> _redirections = new();
|
||||
|
||||
public Mod Mod { get; private set; } = null!;
|
||||
|
|
@ -24,8 +25,11 @@ public class ModNormalizer
|
|||
public bool Running
|
||||
=> Step < TotalSteps;
|
||||
|
||||
public ModNormalizer(ModManager modManager)
|
||||
=> _modManager = modManager;
|
||||
public ModNormalizer(ModManager modManager, ModCacheManager modCacheManager)
|
||||
{
|
||||
_modManager = modManager;
|
||||
_modCacheManager = modCacheManager;
|
||||
}
|
||||
|
||||
public void Normalize(Mod mod)
|
||||
{
|
||||
|
|
@ -36,7 +40,7 @@ public class ModNormalizer
|
|||
_normalizationDirName = Path.Combine(Mod.ModPath.FullName, "TmpNormalization");
|
||||
_oldDirName = Path.Combine(Mod.ModPath.FullName, "TmpNormalizationOld");
|
||||
Step = 0;
|
||||
TotalSteps = mod.TotalFileCount + 5;
|
||||
TotalSteps = _modCacheManager[mod].TotalFileCount + 5;
|
||||
|
||||
Task.Run(NormalizeSync);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ public class ModOptionEditor
|
|||
|
||||
mod._groups[groupIdx] = group.Convert(type);
|
||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx));
|
||||
mod.HasOptions = mod.Groups.Any(o => o.IsOption);
|
||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupTypeChanged, mod, groupIdx, -1, -1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,8 +76,6 @@ public partial class Mod
|
|||
IncorporateAllMetaChanges(true);
|
||||
}
|
||||
|
||||
ComputeChangedItems();
|
||||
SetCounts();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Penumbra.GameData.Data;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
|
||||
public sealed partial class Mod
|
||||
{
|
||||
public SortedList< string, object? > ChangedItems { get; } = new();
|
||||
public string LowerChangedItemsString { get; private set; } = string.Empty;
|
||||
|
||||
internal void ComputeChangedItems()
|
||||
{
|
||||
ChangedItems.Clear();
|
||||
foreach( var gamePath in AllRedirects )
|
||||
{
|
||||
Penumbra.Identifier.Identify( ChangedItems, gamePath.ToString() );
|
||||
}
|
||||
|
||||
foreach( var manip in AllManipulations )
|
||||
{
|
||||
ComputeChangedItems( ChangedItems, manip );
|
||||
}
|
||||
|
||||
LowerChangedItemsString = string.Join( "\0", ChangedItems.Keys.Select( k => k.ToLowerInvariant() ) );
|
||||
}
|
||||
|
||||
public static void ComputeChangedItems( SortedList< string, object? > changedItems, MetaManipulation manip )
|
||||
{
|
||||
switch( manip.ManipulationType )
|
||||
{
|
||||
case MetaManipulation.Type.Imc:
|
||||
switch( manip.Imc.ObjectType )
|
||||
{
|
||||
case ObjectType.Equipment:
|
||||
case ObjectType.Accessory:
|
||||
Penumbra.Identifier.Identify( changedItems,
|
||||
GamePaths.Equipment.Mtrl.Path( manip.Imc.PrimaryId, GenderRace.MidlanderMale, manip.Imc.EquipSlot, manip.Imc.Variant, "a" ) );
|
||||
break;
|
||||
case ObjectType.Weapon:
|
||||
Penumbra.Identifier.Identify( changedItems, GamePaths.Weapon.Mtrl.Path( manip.Imc.PrimaryId, manip.Imc.SecondaryId, manip.Imc.Variant, "a" ) );
|
||||
break;
|
||||
case ObjectType.DemiHuman:
|
||||
Penumbra.Identifier.Identify( changedItems,
|
||||
GamePaths.DemiHuman.Mtrl.Path( manip.Imc.PrimaryId, manip.Imc.SecondaryId, manip.Imc.EquipSlot, manip.Imc.Variant, "a" ) );
|
||||
break;
|
||||
case ObjectType.Monster:
|
||||
Penumbra.Identifier.Identify( changedItems, GamePaths.Monster.Mtrl.Path( manip.Imc.PrimaryId, manip.Imc.SecondaryId, manip.Imc.Variant, "a" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case MetaManipulation.Type.Eqdp:
|
||||
Penumbra.Identifier.Identify( changedItems,
|
||||
GamePaths.Equipment.Mdl.Path( manip.Eqdp.SetId, Names.CombinedRace( manip.Eqdp.Gender, manip.Eqdp.Race ), manip.Eqdp.Slot ) );
|
||||
break;
|
||||
case MetaManipulation.Type.Eqp:
|
||||
Penumbra.Identifier.Identify( changedItems, GamePaths.Equipment.Mdl.Path( manip.Eqp.SetId, GenderRace.MidlanderMale, manip.Eqp.Slot ) );
|
||||
break;
|
||||
case MetaManipulation.Type.Est:
|
||||
switch( manip.Est.Slot )
|
||||
{
|
||||
case EstManipulation.EstType.Hair:
|
||||
changedItems.TryAdd( $"Customization: {manip.Est.Race} {manip.Est.Gender} Hair (Hair) {manip.Est.SetId}", null );
|
||||
break;
|
||||
case EstManipulation.EstType.Face:
|
||||
changedItems.TryAdd( $"Customization: {manip.Est.Race} {manip.Est.Gender} Face (Face) {manip.Est.SetId}", null );
|
||||
break;
|
||||
case EstManipulation.EstType.Body:
|
||||
Penumbra.Identifier.Identify( changedItems,
|
||||
GamePaths.Equipment.Mdl.Path( manip.Est.SetId, Names.CombinedRace( manip.Est.Gender, manip.Est.Race ), EquipSlot.Body ) );
|
||||
break;
|
||||
case EstManipulation.EstType.Head:
|
||||
Penumbra.Identifier.Identify( changedItems,
|
||||
GamePaths.Equipment.Mdl.Path( manip.Est.SetId, Names.CombinedRace( manip.Est.Gender, manip.Est.Race ), EquipSlot.Head ) );
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case MetaManipulation.Type.Gmp:
|
||||
Penumbra.Identifier.Identify( changedItems, GamePaths.Equipment.Mdl.Path( manip.Gmp.SetId, GenderRace.MidlanderMale, EquipSlot.Head ) );
|
||||
break;
|
||||
case MetaManipulation.Type.Rsp:
|
||||
changedItems.TryAdd( $"{manip.Rsp.SubRace.ToName()} {manip.Rsp.Attribute.ToFullString()}", null );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,29 +20,6 @@ public partial class Mod
|
|||
internal readonly SubMod _default;
|
||||
internal readonly List<IModGroup> _groups = new();
|
||||
|
||||
public int TotalFileCount { get; internal set; }
|
||||
public int TotalSwapCount { get; internal set; }
|
||||
public int TotalManipulations { get; internal set; }
|
||||
public bool HasOptions { get; internal set; }
|
||||
|
||||
internal bool SetCounts()
|
||||
{
|
||||
TotalFileCount = 0;
|
||||
TotalSwapCount = 0;
|
||||
TotalManipulations = 0;
|
||||
foreach (var s in AllSubMods)
|
||||
{
|
||||
TotalFileCount += s.Files.Count;
|
||||
TotalSwapCount += s.FileSwaps.Count;
|
||||
TotalManipulations += s.Manipulations.Count;
|
||||
}
|
||||
|
||||
HasOptions = _groups.Any(o
|
||||
=> o is MultiModGroup m && m.PrioritizedOptions.Count > 0
|
||||
|| o is SingleModGroup s && s.OptionData.Count > 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<ISubMod> AllSubMods
|
||||
=> _groups.SelectMany(o => o).Prepend(_default);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ public sealed partial class Mod
|
|||
|
||||
public IReadOnlyList<string> LocalTags { get; private set; } = Array.Empty<string>();
|
||||
|
||||
public string AllTagsLower { get; private set; } = string.Empty;
|
||||
public string Note { get; internal set; } = string.Empty;
|
||||
public bool Favorite { get; internal set; } = false;
|
||||
|
||||
|
|
@ -46,9 +45,6 @@ public sealed partial class Mod
|
|||
}
|
||||
}
|
||||
|
||||
if (type != 0)
|
||||
AllTagsLower = string.Join('\0', ModTags.Concat(LocalTags).Select(s => s.ToLowerInvariant()));
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class ModCacheManager : IDisposable, IReadOnlyList<ModCache>
|
|||
}
|
||||
|
||||
public IEnumerator<ModCache> GetEnumerator()
|
||||
=> _cache.GetEnumerator();
|
||||
=> _cache.Take(Count).GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
=> GetEnumerator();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue