wabbajack/Wabbajack.Lib/VortexInstaller.cs

71 lines
2.2 KiB
C#
Raw Normal View History

2019-11-17 14:06:28 +00:00
using System.Linq;
2019-11-09 20:40:25 +00:00
using Wabbajack.Common;
2019-11-15 13:06:34 +00:00
using Wabbajack.VirtualFileSystem;
2019-11-09 21:45:10 +00:00
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using File = Alphaleonis.Win32.Filesystem.File;
using Path = Alphaleonis.Win32.Filesystem.Path;
2019-11-09 20:40:25 +00:00
namespace Wabbajack.Lib
{
public class VortexInstaller : AInstaller
2019-11-09 20:40:25 +00:00
{
2019-11-09 21:45:10 +00:00
public GameMetaData GameInfo { get; internal set; }
2019-11-09 20:40:25 +00:00
public VortexInstaller(string archive, ModList modList)
{
ModManager = ModManager.Vortex;
2019-11-09 20:40:25 +00:00
ModListArchive = archive;
ModList = modList;
2019-11-09 21:45:10 +00:00
// TODO: only for testing
IgnoreMissingFiles = true;
GameInfo = GameRegistry.Games[ModList.GameType];
2019-11-09 20:40:25 +00:00
}
protected override bool _Begin()
2019-11-09 21:45:10 +00:00
{
ConfigureProcessor(10);
2019-11-09 21:45:10 +00:00
Directory.CreateDirectory(DownloadFolder);
HashArchives();
DownloadArchives();
HashArchives();
var missing = ModList.Archives.Where(a => !HashedArchives.ContainsKey(a.Hash)).ToList();
if (missing.Count > 0)
{
foreach (var a in missing)
Info($"Unable to download {a.Name}");
if (IgnoreMissingFiles)
Info("Missing some archives, but continuing anyways at the request of the user");
else
Error("Cannot continue, was unable to download one or more archives");
}
PrimeVFS();
BuildFolderStructure();
InstallArchives();
InstallIncludedFiles();
//InstallIncludedDownloadMetas();
2019-11-09 21:45:10 +00:00
Info("Installation complete! You may exit the program.");
return true;
2019-11-09 21:45:10 +00:00
}
private void InstallIncludedFiles()
{
Info("Writing inline files");
ModList.Directives.OfType<InlineFile>()
2019-11-17 04:16:42 +00:00
.PMap(Queue,directive =>
2019-11-09 21:45:10 +00:00
{
Status($"Writing included file {directive.To}");
var outPath = Path.Combine(OutputFolder, directive.To);
2019-11-09 21:45:10 +00:00
if(File.Exists(outPath)) File.Delete(outPath);
File.WriteAllBytes(outPath, LoadBytesFromPath(directive.SourceDataID));
});
}
2019-11-09 20:40:25 +00:00
}
}