mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 06:13:45 +01:00
Remove CMP file.
This commit is contained in:
parent
ebef4ff650
commit
9ecc4ab46d
15 changed files with 244 additions and 83 deletions
|
|
@ -145,9 +145,6 @@ public class MetaCache(MetaFileManager manager, ModCollection collection)
|
|||
public MetaList.MetaReverter? TemporarilySetEqdpFile(GenderRace genderRace, bool accessory)
|
||||
=> Eqdp.TemporarilySetFile(genderRace, accessory);
|
||||
|
||||
public MetaList.MetaReverter TemporarilySetCmpFile()
|
||||
=> Rsp.TemporarilySetFile();
|
||||
|
||||
/// <summary> Try to obtain a manipulated IMC file. </summary>
|
||||
public bool GetImcFile(Utf8GamePath path, [NotNullWhen(true)] out Meta.Files.ImcFile? file)
|
||||
=> Imc.GetFile(path, out file);
|
||||
|
|
|
|||
|
|
@ -1,78 +1,26 @@
|
|||
using Penumbra.Interop.Services;
|
||||
using Penumbra.Interop.Structs;
|
||||
using Penumbra.Meta;
|
||||
using Penumbra.Meta.Files;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
|
||||
namespace Penumbra.Collections.Cache;
|
||||
|
||||
public sealed class RspCache(MetaFileManager manager, ModCollection collection) : MetaCacheBase<RspIdentifier, RspEntry>(manager, collection)
|
||||
{
|
||||
private CmpFile? _cmpFile;
|
||||
|
||||
public override void SetFiles()
|
||||
=> Manager.SetFile(_cmpFile, MetaIndex.HumanCmp);
|
||||
{ }
|
||||
|
||||
protected override void IncorporateChangesInternal()
|
||||
{
|
||||
if (GetFile() is not { } file)
|
||||
return;
|
||||
|
||||
foreach (var (identifier, (_, entry)) in this)
|
||||
Apply(file, identifier, entry);
|
||||
|
||||
Penumbra.Log.Verbose($"{Collection.AnonymizedName}: Loaded {Count} delayed RSP manipulations.");
|
||||
}
|
||||
|
||||
public MetaList.MetaReverter TemporarilySetFile()
|
||||
=> Manager.TemporarilySetFile(_cmpFile, MetaIndex.HumanCmp);
|
||||
{ }
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (_cmpFile == null)
|
||||
return;
|
||||
|
||||
_cmpFile.Reset(Keys.Select(identifier => (identifier.SubRace, identifier.Attribute)));
|
||||
Clear();
|
||||
}
|
||||
=> Clear();
|
||||
|
||||
protected override void ApplyModInternal(RspIdentifier identifier, RspEntry entry)
|
||||
{
|
||||
if (GetFile() is { } file)
|
||||
Apply(file, identifier, entry);
|
||||
}
|
||||
{ }
|
||||
|
||||
protected override void RevertModInternal(RspIdentifier identifier)
|
||||
{
|
||||
if (GetFile() is { } file)
|
||||
Apply(file, identifier, CmpFile.GetDefault(Manager, identifier.SubRace, identifier.Attribute));
|
||||
}
|
||||
{ }
|
||||
|
||||
public static bool Apply(CmpFile file, RspIdentifier identifier, RspEntry entry)
|
||||
{
|
||||
var value = file[identifier.SubRace, identifier.Attribute];
|
||||
if (value == entry)
|
||||
return false;
|
||||
|
||||
file[identifier.SubRace, identifier.Attribute] = entry;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool _)
|
||||
{
|
||||
_cmpFile?.Dispose();
|
||||
_cmpFile = null;
|
||||
Clear();
|
||||
}
|
||||
|
||||
private CmpFile? GetFile()
|
||||
{
|
||||
if (_cmpFile != null)
|
||||
return _cmpFile;
|
||||
|
||||
if (!Manager.CharacterUtility.Ready)
|
||||
return null;
|
||||
|
||||
return _cmpFile = new CmpFile(Manager);
|
||||
}
|
||||
=> Clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,8 +99,4 @@ public partial class ModCollection
|
|||
var idx = CharacterUtilityData.EqdpIdx(genderRace, accessory);
|
||||
return idx >= 0 ? utility.TemporarilyResetResource(idx) : null;
|
||||
}
|
||||
|
||||
public MetaList.MetaReverter TemporarilySetCmpFile(CharacterUtility utility)
|
||||
=> _cache?.Meta.TemporarilySetCmpFile()
|
||||
?? utility.TemporarilyResetResource(MetaIndex.HumanCmp);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue