From 374178db3b48f397cdc3958b56e3aa43af646039 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 23 Nov 2019 18:53:04 -0600 Subject: [PATCH] Output location systems implemented --- Wabbajack/Settings.cs | 1 + .../View Models/Compilers/MO2CompilerVM.cs | 34 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Wabbajack/Settings.cs b/Wabbajack/Settings.cs index 1fe2fce1..522500ce 100644 --- a/Wabbajack/Settings.cs +++ b/Wabbajack/Settings.cs @@ -59,6 +59,7 @@ namespace Wabbajack public class CompilerSettings { public ModManager LastCompiledModManager { get; set; } + public string OutputLocation { get; set; } public MO2CompilationSettings MO2Compilation { get; } = new MO2CompilationSettings(); public VortexCompilationSettings VortexCompilation { get; } = new VortexCompilationSettings(); } diff --git a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs index 36d18ed4..56f34136 100644 --- a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs +++ b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs @@ -1,4 +1,5 @@ -using ReactiveUI; +using Microsoft.WindowsAPICodePack.Dialogs; +using ReactiveUI; using ReactiveUI.Fody.Helpers; using System; using System.IO; @@ -12,6 +13,8 @@ namespace Wabbajack { public class MO2CompilerVM : ViewModel, ISubCompilerVM { + public CompilerVM Parent { get; } + private readonly MO2CompilationSettings _settings; private readonly ObservableAsPropertyHelper _mo2Folder; @@ -24,6 +27,8 @@ namespace Wabbajack public FilePickerVM ModlistLocation { get; } + public FilePickerVM OutputLocation { get; } + public IReactiveCommand BeginCommand { get; } [Reactive] @@ -37,17 +42,24 @@ namespace Wabbajack public MO2CompilerVM(CompilerVM parent) { + Parent = parent; ModlistLocation = new FilePickerVM() { ExistCheckOption = FilePickerVM.ExistCheckOptions.On, PathType = FilePickerVM.PathTypeOptions.File, - PromptTitle = "Select Modlist" + PromptTitle = "Select modlist" }; DownloadLocation = new FilePickerVM() { ExistCheckOption = FilePickerVM.ExistCheckOptions.On, PathType = FilePickerVM.PathTypeOptions.Folder, - PromptTitle = "Select Download Location", + PromptTitle = "Select download location", + }; + OutputLocation = new FilePickerVM() + { + ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty, + PathType = FilePickerVM.PathTypeOptions.Folder, + PromptTitle = "Select the folder to place the resulting modlist.wabbajack file", }; _mo2Folder = this.WhenAny(x => x.ModlistLocation.TargetPath) @@ -92,16 +104,26 @@ namespace Wabbajack canExecute: Observable.CombineLatest( this.WhenAny(x => x.ModlistLocation.InError), this.WhenAny(x => x.DownloadLocation.InError), - resultSelector: (ml, down) => !ml && !down) + this.WhenAny(x => x.OutputLocation.InError), + resultSelector: (ml, down, output) => !ml && !down && !output) .ObserveOnGuiThread(), execute: async () => { try { + string outputFile; + if (string.IsNullOrWhiteSpace(OutputLocation.TargetPath)) + { + outputFile = MOProfile + ExtensionManager.Extension; + } + else + { + outputFile = Path.Combine(OutputLocation.TargetPath, MOProfile + ExtensionManager.Extension); + } ActiveCompilation = new MO2Compiler( mo2Folder: Mo2Folder, mo2Profile: MOProfile, - outputFile: MOProfile + ExtensionManager.Extension) + outputFile: outputFile) { ModListName = ModlistSettings.ModListName, ModListAuthor = ModlistSettings.AuthorText, @@ -143,6 +165,7 @@ namespace Wabbajack { DownloadLocation.TargetPath = _settings.DownloadLocation; } + OutputLocation.TargetPath = parent.MWVM.Settings.Compiler.OutputLocation; parent.MWVM.Settings.SaveSignal .Subscribe(_ => Unload()) .DisposeWith(CompositeDisposable); @@ -195,6 +218,7 @@ namespace Wabbajack { _settings.DownloadLocation = DownloadLocation.TargetPath; _settings.LastCompiledProfileLocation = ModlistLocation.TargetPath; + Parent.MWVM.Settings.Compiler.OutputLocation = OutputLocation.TargetPath; ModlistSettings?.Save(); } }