Target Modlist exposure on Install Config View

This commit is contained in:
Justin Swanson 2019-11-24 02:44:41 -06:00
parent 5533b14cda
commit d1fec7feec
8 changed files with 42 additions and 34 deletions

View File

@ -58,6 +58,7 @@ namespace Wabbajack.Lib
public static ModList LoadFromFile(string path) public static ModList LoadFromFile(string path)
{ {
if (!File.Exists(path)) return null;
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read)) using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
{ {

View File

@ -31,8 +31,7 @@ namespace Wabbajack
private readonly ObservableAsPropertyHelper<ModListVM> _modList; private readonly ObservableAsPropertyHelper<ModListVM> _modList;
public ModListVM ModList => _modList.Value; public ModListVM ModList => _modList.Value;
[Reactive] public FilePickerVM ModListPath { get; }
public string ModListPath { get; set; }
[Reactive] [Reactive]
public bool UIReady { get; set; } public bool UIReady { get; set; }
@ -120,9 +119,15 @@ namespace Wabbajack
}; };
DownloadLocation.AdditionalError = this.WhenAny(x => x.DownloadLocation.TargetPath) DownloadLocation.AdditionalError = this.WhenAny(x => x.DownloadLocation.TargetPath)
.Select(x => Utils.IsDirectoryPathValid(x)); .Select(x => Utils.IsDirectoryPathValid(x));
ModListPath = new FilePickerVM()
{
ExistCheckOption = FilePickerVM.ExistCheckOptions.On,
PathType = FilePickerVM.PathTypeOptions.File,
PromptTitle = "Select a modlist to install"
};
// Load settings // Load settings
_CurrentSettings = this.WhenAny(x => x.ModListPath) _CurrentSettings = this.WhenAny(x => x.ModListPath.TargetPath)
.Select(path => path == null ? null : MWVM.Settings.Installer.ModlistSettings.TryCreate(path)) .Select(path => path == null ? null : MWVM.Settings.Installer.ModlistSettings.TryCreate(path))
.ToProperty(this, nameof(CurrentSettings)); .ToProperty(this, nameof(CurrentSettings));
this.WhenAny(x => x.CurrentSettings) this.WhenAny(x => x.CurrentSettings)
@ -139,7 +144,7 @@ namespace Wabbajack
.Subscribe(_ => SaveSettings(CurrentSettings)) .Subscribe(_ => SaveSettings(CurrentSettings))
.DisposeWith(CompositeDisposable); .DisposeWith(CompositeDisposable);
_modList = this.WhenAny(x => x.ModListPath) _modList = this.WhenAny(x => x.ModListPath.TargetPath)
.ObserveOn(RxApp.TaskpoolScheduler) .ObserveOn(RxApp.TaskpoolScheduler)
.Select(modListPath => .Select(modListPath =>
{ {
@ -285,7 +290,7 @@ namespace Wabbajack
private void OpenReadmeWindow() private void OpenReadmeWindow()
{ {
if (string.IsNullOrEmpty(ModList.Readme)) return; if (string.IsNullOrEmpty(ModList.Readme)) return;
using (var fs = new FileStream(ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var fs = new FileStream(ModListPath.TargetPath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read)) using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
{ {
@ -315,7 +320,7 @@ namespace Wabbajack
try try
{ {
installer = new MO2Installer(ModListPath, ModList.SourceModList, Location.TargetPath) installer = new MO2Installer(ModListPath.TargetPath, ModList.SourceModList, Location.TargetPath)
{ {
DownloadFolder = DownloadLocation.TargetPath DownloadFolder = DownloadLocation.TargetPath
}; };
@ -357,6 +362,7 @@ namespace Wabbajack
private void SaveSettings(ModlistInstallationSettings settings) private void SaveSettings(ModlistInstallationSettings settings)
{ {
MWVM.Settings.Installer.LastInstalledListLocation = ModListPath.TargetPath;
if (settings == null) return; if (settings == null) return;
settings.InstallationLocation = Location.TargetPath; settings.InstallationLocation = Location.TargetPath;
settings.DownloadLocation = DownloadLocation.TargetPath; settings.DownloadLocation = DownloadLocation.TargetPath;

View File

@ -1,16 +0,0 @@
using Wabbajack.Lib;
using Wabbajack.Lib.ModListRegistry;
namespace Wabbajack.UI
{
public class ModListDefinition : ViewModel
{
private readonly ModlistMetadata _meta;
public ModListDefinition(ModlistMetadata meta)
{
_meta = meta;
}
}
}

View File

@ -29,10 +29,13 @@ namespace Wabbajack
InstallCommand = ReactiveCommand.Create( InstallCommand = ReactiveCommand.Create(
execute: () => execute: () =>
{ {
OpenInstaller( var path = mainVM.Settings.Installer.LastInstalledListLocation;
UIUtils.OpenFileDialog( if (string.IsNullOrWhiteSpace(path)
$"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}", || !File.Exists(path))
initialDirectory: mainVM.Settings.Installer.LastInstalledListLocation)); {
path = UIUtils.OpenFileDialog($"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}");
}
OpenInstaller(path);
}); });
CompileCommand = ReactiveCommand.Create( CompileCommand = ReactiveCommand.Create(
@ -57,7 +60,7 @@ namespace Wabbajack
var installer = _mainVM.Installer.Value; var installer = _mainVM.Installer.Value;
_mainVM.Settings.Installer.LastInstalledListLocation = path; _mainVM.Settings.Installer.LastInstalledListLocation = path;
_mainVM.ActivePane = installer; _mainVM.ActivePane = installer;
installer.ModListPath = path; installer.ModListPath.TargetPath = path;
} }
private string Download() private string Download()

View File

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Wabbajack.UI" xmlns:local="clr-namespace:Wabbajack"
Style="{StaticResource {x:Type Window}}" Icon="../Resources/Icons/wabbajack.ico" WindowStyle="ToolWindow" Style="{StaticResource {x:Type Window}}" Icon="../Resources/Icons/wabbajack.ico" WindowStyle="ToolWindow"
mc:Ignorable="d" mc:Ignorable="d"
Title="Downloading Modlist" Height="200" Width="800"> Title="Downloading Modlist" Height="200" Width="800">

View File

@ -286,6 +286,7 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="40" /> <RowDefinition Height="40" />
<RowDefinition Height="40" /> <RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock <TextBlock
@ -294,14 +295,14 @@
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="14" FontSize="14"
Text="Installation Location" Text="Target Modlist"
TextAlignment="Center" /> TextAlignment="Center" />
<local:FilePicker <local:FilePicker
Grid.Row="1" Grid.Row="1"
Grid.Column="2" Grid.Column="2"
Height="30" Height="30"
VerticalAlignment="Center" VerticalAlignment="Center"
DataContext="{Binding Location}" DataContext="{Binding ModListPath}"
FontSize="14" /> FontSize="14" />
<TextBlock <TextBlock
Grid.Row="2" Grid.Row="2"
@ -309,18 +310,33 @@
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="14" FontSize="14"
Text="Download Location" Text="Installation Location"
TextAlignment="Center" /> TextAlignment="Center" />
<local:FilePicker <local:FilePicker
Grid.Row="2" Grid.Row="2"
Grid.Column="2" Grid.Column="2"
Height="30" Height="30"
VerticalAlignment="Center" VerticalAlignment="Center"
DataContext="{Binding Location}"
FontSize="14" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="14"
Text="Download Location"
TextAlignment="Center" />
<local:FilePicker
Grid.Row="3"
Grid.Column="2"
Height="30"
VerticalAlignment="Center"
DataContext="{Binding DownloadLocation}" DataContext="{Binding DownloadLocation}"
FontSize="14" /> FontSize="14" />
<local:BeginButton <local:BeginButton
Grid.Row="1" Grid.Row="1"
Grid.RowSpan="2" Grid.RowSpan="3"
Grid.Column="4" Grid.Column="4"
Margin="0,0,25,0" Margin="0,0,25,0"
HorizontalAlignment="Right" HorizontalAlignment="Right"

View File

@ -51,7 +51,6 @@
<RowDefinition Height="15" /> <RowDefinition Height="15" />
<RowDefinition Height="150" /> <RowDefinition Height="150" />
<RowDefinition Height="20" /> <RowDefinition Height="20" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Image <Image
Grid.Row="0" Grid.Row="0"

View File

@ -215,7 +215,6 @@
<DependentUpon>DownloadWindow.xaml</DependentUpon> <DependentUpon>DownloadWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="View Models\ModeSelectionVM.cs" /> <Compile Include="View Models\ModeSelectionVM.cs" />
<Compile Include="View Models\ModListDefinition.cs" />
<Compile Include="Views\Common\FilePicker.xaml.cs"> <Compile Include="Views\Common\FilePicker.xaml.cs">
<DependentUpon>FilePicker.xaml</DependentUpon> <DependentUpon>FilePicker.xaml</DependentUpon>
</Compile> </Compile>