Cleanup ACompiler

This commit is contained in:
Timothy Baldridge 2020-10-18 07:18:16 -06:00
parent 2bc3553dcf
commit c5c444b707

View File

@ -19,57 +19,23 @@ namespace Wabbajack.Lib
{
public abstract class ACompiler : ABatchProcessor
{
/// <summary>
/// Set to true to include game files during compilation, only ever disabled
/// in testing (to speed up tests)
/// </summary>
public bool UseGamePaths { get; set; } = true;
protected readonly Subject<(string, float)> _progressUpdates = new Subject<(string, float)>();
public CompilerSettings Settings { get; set; }
public List<IndexedArchive> IndexedArchives = new List<IndexedArchive>();
public Dictionary<Hash, IEnumerable<VirtualFile>> IndexedFiles =
new Dictionary<Hash, IEnumerable<VirtualFile>>();
public ModList ModList = new ModList();
public AbsolutePath ModListImage;
public bool ModlistIsNSFW;
public string? ModListName, ModListAuthor, ModListDescription, ModListWebsite, ModlistReadme;
public Version? ModlistVersion;
public AbsolutePath ModListImage;
public bool ModlistIsNSFW;
protected Version? WabbajackVersion;
public AbsolutePath VFSCacheName =>
Consts.LocalAppDataPath.Combine(
$"vfs_compile_cache-2-{Path.Combine((string)SourcePath ?? "Unknown", "ModOrganizer.exe").StringSha256Hex()}.bin");
//protected string VFSCacheName => Path.Combine(Consts.LocalAppDataPath, $"vfs_compile_cache.bin");
/// <summary>
/// A stream of tuples of ("Update Title", 0.25) which represent the name of the current task
/// and the current progress.
/// </summary>
public IObservable<(string, float)> ProgressUpdates => _progressUpdates;
protected readonly Subject<(string, float)> _progressUpdates = new Subject<(string, float)>();
public abstract AbsolutePath GamePath { get; }
public Dictionary<Game, HashSet<Hash>> GameHashes { get; set; } = new Dictionary<Game, HashSet<Hash>>();
public Dictionary<Hash, Game[]> GamesWithHashes { get; set; } = new Dictionary<Hash, Game[]>();
public AbsolutePath SourcePath { get;}
public AbsolutePath DownloadsPath { get;}
public GameMetaData CompilingGame { get; set; }
public AbsolutePath ModListOutputFolder { get; }
public AbsolutePath ModListOutputFile { get; }
public bool IgnoreMissingFiles { get; set; }
public List<Archive> SelectedArchives { get; protected set; } = new List<Archive>();
public List<Directive> InstallDirectives { get; protected set; } = new List<Directive>();
public List<RawSourceFile> AllFiles { get; protected set; } = new List<RawSourceFile>();
public ModList ModList = new ModList();
public List<IndexedArchive> IndexedArchives = new List<IndexedArchive>();
public Dictionary<AbsolutePath, IndexedArchive> ArchivesByFullPath { get; set; } = new Dictionary<AbsolutePath, IndexedArchive>();
public Dictionary<Hash, IEnumerable<VirtualFile>> IndexedFiles = new Dictionary<Hash, IEnumerable<VirtualFile>>();
public ACompiler(int steps, string modlistName, AbsolutePath sourcePath, AbsolutePath downloadsPath, AbsolutePath outputModListName)
public ACompiler(int steps, string modlistName, AbsolutePath sourcePath, AbsolutePath downloadsPath,
AbsolutePath outputModListName)
: base(steps)
{
SourcePath = sourcePath;
@ -83,6 +49,46 @@ namespace Wabbajack.Lib
CompilingGame = new GameMetaData();
}
/// <summary>
/// Set to true to include game files during compilation, only ever disabled
/// in testing (to speed up tests)
/// </summary>
public bool UseGamePaths { get; set; } = true;
public CompilerSettings Settings { get; set; }
public AbsolutePath VFSCacheName =>
Consts.LocalAppDataPath.Combine(
$"vfs_compile_cache-2-{Path.Combine((string)SourcePath ?? "Unknown", "ModOrganizer.exe").StringSha256Hex()}.bin");
//protected string VFSCacheName => Path.Combine(Consts.LocalAppDataPath, $"vfs_compile_cache.bin");
/// <summary>
/// A stream of tuples of ("Update Title", 0.25) which represent the name of the current task
/// and the current progress.
/// </summary>
public IObservable<(string, float)> ProgressUpdates => _progressUpdates;
public abstract AbsolutePath GamePath { get; }
public Dictionary<Game, HashSet<Hash>> GameHashes { get; set; } = new Dictionary<Game, HashSet<Hash>>();
public Dictionary<Hash, Game[]> GamesWithHashes { get; set; } = new Dictionary<Hash, Game[]>();
public AbsolutePath SourcePath { get; }
public AbsolutePath DownloadsPath { get; }
public GameMetaData CompilingGame { get; set; }
public AbsolutePath ModListOutputFolder { get; }
public AbsolutePath ModListOutputFile { get; }
public bool IgnoreMissingFiles { get; set; }
public List<Archive> SelectedArchives { get; protected set; } = new List<Archive>();
public List<Directive> InstallDirectives { get; protected set; } = new List<Directive>();
public List<RawSourceFile> AllFiles { get; protected set; } = new List<RawSourceFile>();
public Dictionary<AbsolutePath, IndexedArchive> ArchivesByFullPath { get; set; } =
new Dictionary<AbsolutePath, IndexedArchive>();
public static void Info(string msg)
{
Utils.Log(msg);
@ -186,7 +192,7 @@ namespace Wabbajack.Lib
{
var meta = f.State.GetMetaIniString();
var ini = meta.LoadIniString();
var state = (GameFileSourceDownloader.State) f.State;
var state = (GameFileSourceDownloader.State)f.State;
return new IndexedArchive(
VFS.Index.ByRootPath[ag.MetaData().GameLocation().Combine(state.GameFile)])
{
@ -286,7 +292,7 @@ namespace Wabbajack.Lib
});
}
public async Task ExportModList()
protected async Task ExportModList()
{
Utils.Log($"Exporting ModList to {ModListOutputFile}");
@ -547,6 +553,7 @@ namespace Wabbajack.Lib
{
Utils.LogStraightToFile($" {file.To} - {file.Reason}");
}
if (count == max && noMatches.Count > max)
{
Utils.Log($" ...");
@ -572,7 +579,6 @@ namespace Wabbajack.Lib
file.SourceDataID = id;
file.SourceDataFile = null;
}
});
}
@ -591,6 +597,7 @@ namespace Wabbajack.Lib
return true;
}
}
return false;
}
}