This commit is contained in:
Ottermandias 2022-04-06 11:34:12 +02:00
parent 33db156544
commit 8db54ef4f4
17 changed files with 546 additions and 212 deletions

View file

@ -3,7 +3,7 @@ using System.IO;
using Dalamud.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Penumbra.Util;
using OtterGui;
namespace Penumbra.Mods;

View file

@ -0,0 +1,39 @@
using System.IO;
using OtterGui.Filesystem;
namespace Penumbra.Mods;
public sealed class ModFileSystemA : FileSystem< Mod >
{
public void Save()
=> SaveToFile( new FileInfo( Mod.Manager.SortOrderFile ), SaveMod, true );
public static ModFileSystemA Load()
{
var x = new ModFileSystemA();
if( x.Load( new FileInfo( Mod.Manager.SortOrderFile ), Penumbra.ModManager.Mods, ModToIdentifier, ModToName ) )
{
x.Save();
}
x.Changed += ( _1, _2, _3, _4 ) => x.Save();
return x;
}
private static string ModToIdentifier( Mod mod )
=> mod.BasePath.Name;
private static string ModToName( Mod mod )
=> mod.Meta.Name.Text;
private static (string, bool) SaveMod( Mod mod, string fullPath )
{
if( fullPath == ModToName( mod ) )
{
return ( string.Empty, false );
}
return ( ModToIdentifier( mod ), true );
}
}

View file

@ -5,6 +5,7 @@ using System.Linq;
using Dalamud.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OtterGui;
using Penumbra.GameData.ByteString;
using Penumbra.Util;