mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using Penumbra.Mods.Manager;
|
|
using Penumbra.Mods.SubMods;
|
|
using Penumbra.String.Classes;
|
|
using Penumbra.Util;
|
|
|
|
public class ModSwapEditor(ModManager modManager)
|
|
{
|
|
private readonly Dictionary<Utf8GamePath, FullPath> _swaps = [];
|
|
|
|
public IReadOnlyDictionary<Utf8GamePath, FullPath> Swaps
|
|
=> _swaps;
|
|
|
|
public void Revert(IModDataContainer option)
|
|
{
|
|
_swaps.SetTo(option.FileSwaps);
|
|
Changes = false;
|
|
}
|
|
|
|
public void Apply(IModDataContainer container)
|
|
{
|
|
if (!Changes)
|
|
return;
|
|
|
|
modManager.OptionEditor.SetFileSwaps(container, _swaps);
|
|
Changes = false;
|
|
}
|
|
|
|
public bool Changes { get; private set; }
|
|
|
|
public void Remove(Utf8GamePath path)
|
|
=> Changes |= _swaps.Remove(path);
|
|
|
|
public void Add(Utf8GamePath path, FullPath file)
|
|
=> Changes |= _swaps.TryAdd(path, file);
|
|
|
|
public void Change(Utf8GamePath path, Utf8GamePath newPath)
|
|
{
|
|
if (_swaps.Remove(path, out var file))
|
|
Add(newPath, file);
|
|
}
|
|
|
|
public void Change(Utf8GamePath path, FullPath file)
|
|
{
|
|
_swaps[path] = file;
|
|
Changes = true;
|
|
}
|
|
}
|