Make saving files and recalculating effective files threaded/once per frame.

This commit is contained in:
Ottermandias 2022-05-12 17:33:54 +02:00
parent b8210e094b
commit 67de0ccf45
14 changed files with 147 additions and 42 deletions

View file

@ -57,7 +57,15 @@ public interface IModGroup : IEnumerable< ISubMod >
}
}
public static void SaveModGroup( IModGroup group, DirectoryInfo basePath, int groupIdx )
public static void SaveDelayed( IModGroup group, DirectoryInfo basePath, int groupIdx )
{
Penumbra.Framework.RegisterDelayed( $"{nameof( SaveModGroup )}_{basePath.Name}_{group.Name}", () => SaveModGroup( group, basePath, groupIdx ) );
}
public static void Save( IModGroup group, DirectoryInfo basePath, int groupIdx )
=> SaveModGroup( group, basePath, groupIdx );
private static void SaveModGroup( IModGroup group, DirectoryInfo basePath, int groupIdx )
{
var file = group.FileName( basePath, groupIdx );
using var s = File.Exists( file ) ? File.Open( file, FileMode.Truncate ) : File.Open( file, FileMode.CreateNew );