Output location systems implemented

This commit is contained in:
Justin Swanson 2019-11-23 18:53:04 -06:00
parent 4e0f061e05
commit 374178db3b
2 changed files with 30 additions and 5 deletions

View File

@ -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();
}

View File

@ -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<string> _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();
}
}