From 5bb291a3102d423386308eb6ec4bc7cd42118edd Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sun, 1 Dec 2019 14:22:33 -0600 Subject: [PATCH] AInstaller ctor parameters made more picky for required input --- Wabbajack.Lib/AInstaller.cs | 18 +++++++++++++----- Wabbajack.Lib/MO2Installer.cs | 20 +++++++++++--------- Wabbajack.Lib/VortexInstaller.cs | 15 ++++++++++----- Wabbajack.Test/ACompilerTest.cs | 7 +++++-- Wabbajack.Test/AVortexCompilerTest.cs | 7 +++++-- Wabbajack.Test/EndToEndTests.cs | 7 +++++-- Wabbajack/View Models/InstallerVM.cs | 9 +++++---- 7 files changed, 54 insertions(+), 29 deletions(-) diff --git a/Wabbajack.Lib/AInstaller.cs b/Wabbajack.Lib/AInstaller.cs index 12488410..b122c472 100644 --- a/Wabbajack.Lib/AInstaller.cs +++ b/Wabbajack.Lib/AInstaller.cs @@ -18,15 +18,23 @@ namespace Wabbajack.Lib { public bool IgnoreMissingFiles { get; internal set; } = false; - public string OutputFolder { get; set; } - public string DownloadFolder { get; set; } + public string OutputFolder { get; private set; } + public string DownloadFolder { get; private set; } - public ModManager ModManager; + public abstract ModManager ModManager { get; } - public string ModListArchive { get; internal set; } - public ModList ModList { get; internal set; } + public string ModListArchive { get; private set; } + public ModList ModList { get; private set; } public Dictionary HashedArchives { get; set; } + public AInstaller(string archive, ModList modList, string outputFolder, string downloadFolder) + { + ModList = modList; + ModListArchive = archive; + OutputFolder = outputFolder; + DownloadFolder = downloadFolder; + } + public void Info(string msg) { Utils.Log(msg); diff --git a/Wabbajack.Lib/MO2Installer.cs b/Wabbajack.Lib/MO2Installer.cs index f953671b..ad4a71a1 100644 --- a/Wabbajack.Lib/MO2Installer.cs +++ b/Wabbajack.Lib/MO2Installer.cs @@ -16,18 +16,20 @@ namespace Wabbajack.Lib public class MO2Installer : AInstaller { public bool WarnOnOverwrite { get; set; } = true; - - public MO2Installer(string archive, ModList modList, string outputFolder) - { - ModManager = ModManager.MO2; - ModListArchive = archive; - OutputFolder = outputFolder; - DownloadFolder = Path.Combine(OutputFolder, "downloads"); - ModList = modList; - } + + public override ModManager ModManager => ModManager.MO2; public string GameFolder { get; set; } + public MO2Installer(string archive, ModList modList, string outputFolder, string downloadFolder) + : base( + archive: archive, + modList: modList, + outputFolder: outputFolder, + downloadFolder: downloadFolder) + { + } + protected override bool _Begin() { ConfigureProcessor(17, RecommendQueueSize()); diff --git a/Wabbajack.Lib/VortexInstaller.cs b/Wabbajack.Lib/VortexInstaller.cs index 645ab8aa..f37f162d 100644 --- a/Wabbajack.Lib/VortexInstaller.cs +++ b/Wabbajack.Lib/VortexInstaller.cs @@ -10,14 +10,19 @@ namespace Wabbajack.Lib { public GameMetaData GameInfo { get; internal set; } - public VortexInstaller(string archive, ModList modList) - { - ModManager = ModManager.Vortex; - ModListArchive = archive; - ModList = modList; + public override ModManager ModManager => ModManager.Vortex; + public VortexInstaller(string archive, ModList modList, string outputFolder, string downloadFolder) + : base( + archive: archive, + modList: modList, + outputFolder: outputFolder, + downloadFolder: downloadFolder) + { + #if DEBUG // TODO: only for testing IgnoreMissingFiles = true; + #endif GameInfo = GameRegistry.Games[ModList.GameType]; } diff --git a/Wabbajack.Test/ACompilerTest.cs b/Wabbajack.Test/ACompilerTest.cs index d48e5340..a92035f5 100644 --- a/Wabbajack.Test/ACompilerTest.cs +++ b/Wabbajack.Test/ACompilerTest.cs @@ -49,9 +49,12 @@ namespace Wabbajack.Test protected void Install(MO2Compiler compiler) { var modlist = AInstaller.LoadFromFile(compiler.ModListOutputFile); - var installer = new MO2Installer(compiler.ModListOutputFile, modlist, utils.InstallFolder); + var installer = new MO2Installer( + archive: compiler.ModListOutputFile, + modList: modlist, + outputFolder: utils.InstallFolder, + downloadFolder: utils.DownloadsFolder); installer.WarnOnOverwrite = false; - installer.DownloadFolder = utils.DownloadsFolder; installer.GameFolder = utils.GameFolder; installer.Begin().Wait(); } diff --git a/Wabbajack.Test/AVortexCompilerTest.cs b/Wabbajack.Test/AVortexCompilerTest.cs index 54da7222..af577970 100644 --- a/Wabbajack.Test/AVortexCompilerTest.cs +++ b/Wabbajack.Test/AVortexCompilerTest.cs @@ -62,9 +62,12 @@ namespace Wabbajack.Test protected void Install(VortexCompiler vortexCompiler) { var modList = AInstaller.LoadFromFile(vortexCompiler.ModListOutputFile); - var installer = new MO2Installer(vortexCompiler.ModListOutputFile, modList, utils.InstallFolder) + var installer = new MO2Installer( + archive: vortexCompiler.ModListOutputFile, + modList: modList, + outputFolder: utils.InstallFolder, + downloadFolder: utils.DownloadsFolder) { - DownloadFolder = utils.DownloadsFolder, GameFolder = utils.GameFolder, }; installer.Begin().Wait(); diff --git a/Wabbajack.Test/EndToEndTests.cs b/Wabbajack.Test/EndToEndTests.cs index 38a2d876..16d7b0e9 100644 --- a/Wabbajack.Test/EndToEndTests.cs +++ b/Wabbajack.Test/EndToEndTests.cs @@ -147,8 +147,11 @@ namespace Wabbajack.Test private void Install(MO2Compiler compiler) { var modlist = AInstaller.LoadFromFile(compiler.ModListOutputFile); - var installer = new MO2Installer(compiler.ModListOutputFile, modlist, utils.InstallFolder); - installer.DownloadFolder = utils.DownloadsFolder; + var installer = new MO2Installer( + archive: compiler.ModListOutputFile, + modList: modlist, + outputFolder: utils.InstallFolder, + downloadFolder: utils.DownloadsFolder); installer.GameFolder = utils.GameFolder; installer.Begin().Wait(); } diff --git a/Wabbajack/View Models/InstallerVM.cs b/Wabbajack/View Models/InstallerVM.cs index 14d6a099..77cd6ec0 100644 --- a/Wabbajack/View Models/InstallerVM.cs +++ b/Wabbajack/View Models/InstallerVM.cs @@ -328,10 +328,11 @@ namespace Wabbajack try { - installer = new MO2Installer(ModListPath.TargetPath, ModList.SourceModList, Location.TargetPath) - { - DownloadFolder = DownloadLocation.TargetPath - }; + installer = new MO2Installer( + archive: ModListPath.TargetPath, + modList: ModList.SourceModList, + outputFolder: Location.TargetPath, + downloadFolder: DownloadLocation.TargetPath); } catch (Exception ex) {