The main wabbajack app compiles

This commit is contained in:
Timothy Baldridge 2020-03-28 14:04:22 -06:00
parent b605879d6a
commit c01ed4375c
18 changed files with 142 additions and 128 deletions

View File

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -362,6 +363,16 @@ namespace Wabbajack.Common
{ {
return string.Compare(_path, other._path, StringComparison.Ordinal); return string.Compare(_path, other._path, StringComparison.Ordinal);
} }
public string ReadAllText()
{
return File.ReadAllText(_path);
}
public FileStream OpenShared()
{
return File.Open(_path, FileMode.Open, FileAccess.Read);
}
} }
public struct RelativePath : IPath, IEquatable<RelativePath>, IComparable<RelativePath> public struct RelativePath : IPath, IEquatable<RelativePath>, IComparable<RelativePath>

View File

@ -937,15 +937,15 @@ namespace Wabbajack.Common
return ErrorResponse.Success; return ErrorResponse.Success;
} }
public static IErrorResponse IsDirectoryPathValid(string path) public static IErrorResponse IsDirectoryPathValid(AbsolutePath path)
{ {
if (string.IsNullOrWhiteSpace(path)) if (path == default)
{ {
return ErrorResponse.Fail("Path is empty"); return ErrorResponse.Fail("Path is empty");
} }
try try
{ {
var fi = new System.IO.DirectoryInfo(path); var fi = new System.IO.DirectoryInfo((string)path);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {

View File

@ -83,6 +83,16 @@ namespace Wabbajack.Lib.ModListRegistry
return metadata.OrderBy(m => (m.ValidationSummary?.HasFailures ?? false ? 1 : 0, m.Title)).ToList(); return metadata.OrderBy(m => (m.ValidationSummary?.HasFailures ?? false ? 1 : 0, m.Title)).ToList();
} }
public bool NeedsDownload(AbsolutePath modlistPath)
{
if (!modlistPath.Exists) return true;
if (DownloadMetadata?.Hash == null)
{
return true;
}
return DownloadMetadata.Hash != modlistPath.FileHashCached(true);
}
} }
public class DownloadMetadata public class DownloadMetadata

View File

@ -28,23 +28,22 @@ namespace Wabbajack
public static bool TryLoadTypicalSettings(out MainSettings settings) public static bool TryLoadTypicalSettings(out MainSettings settings)
{ {
if (!File.Exists(Consts.SettingsFile)) if (!Consts.SettingsFile.Exists)
{ {
settings = default; settings = default;
return false; return false;
} }
// Version check // Version check
settings = JsonConvert.DeserializeObject<MainSettings>(File.ReadAllText(Consts.SettingsFile)); settings = JsonConvert.DeserializeObject<MainSettings>(Consts.SettingsFile.ReadAllText());
if (settings.Version == Consts.SettingsVersion) if (settings.Version == Consts.SettingsVersion)
return true; return true;
var backup = Consts.SettingsFile + "-backup.json"; var backup = (AbsolutePath)(Consts.SettingsFile + "-backup.json");
if(File.Exists(backup)) backup.Delete();
File.Delete(backup);
File.Copy(Consts.SettingsFile, backup); Consts.SettingsFile.CopyTo(backup);
File.Delete(Consts.SettingsFile); Consts.SettingsFile.Delete();
settings = default; settings = default;
return false; return false;
@ -59,27 +58,27 @@ namespace Wabbajack
//settings._saveSignal.OnCompleted(); //settings._saveSignal.OnCompleted();
//await settings._saveSignal; //await settings._saveSignal;
File.WriteAllText(Consts.SettingsFile, JsonConvert.SerializeObject(settings, Formatting.Indented)); Consts.SettingsFile.WriteAllText(JsonConvert.SerializeObject(settings, Formatting.Indented));
} }
} }
public class InstallerSettings public class InstallerSettings
{ {
public string LastInstalledListLocation { get; set; } public AbsolutePath LastInstalledListLocation { get; set; }
public Dictionary<string, Mo2ModlistInstallationSettings> Mo2ModlistSettings { get; } = new Dictionary<string, Mo2ModlistInstallationSettings>(); public Dictionary<AbsolutePath, Mo2ModlistInstallationSettings> Mo2ModlistSettings { get; } = new Dictionary<AbsolutePath, Mo2ModlistInstallationSettings>();
} }
public class Mo2ModlistInstallationSettings public class Mo2ModlistInstallationSettings
{ {
public string InstallationLocation { get; set; } public AbsolutePath InstallationLocation { get; set; }
public string DownloadLocation { get; set; } public AbsolutePath DownloadLocation { get; set; }
public bool AutomaticallyOverrideExistingInstall { get; set; } public bool AutomaticallyOverrideExistingInstall { get; set; }
} }
public class CompilerSettings public class CompilerSettings
{ {
public ModManager LastCompiledModManager { get; set; } public ModManager LastCompiledModManager { get; set; }
public string OutputLocation { get; set; } public AbsolutePath OutputLocation { get; set; }
public MO2CompilationSettings MO2Compilation { get; } = new MO2CompilationSettings(); public MO2CompilationSettings MO2Compilation { get; } = new MO2CompilationSettings();
public VortexCompilationSettings VortexCompilation { get; } = new VortexCompilationSettings(); public VortexCompilationSettings VortexCompilation { get; } = new VortexCompilationSettings();
} }
@ -118,14 +117,14 @@ namespace Wabbajack
public string Website { get; set; } public string Website { get; set; }
public bool ReadmeIsWebsite { get; set; } public bool ReadmeIsWebsite { get; set; }
public string Readme { get; set; } public string Readme { get; set; }
public string SplashScreen { get; set; } public AbsolutePath SplashScreen { get; set; }
} }
public class MO2CompilationSettings public class MO2CompilationSettings
{ {
public string DownloadLocation { get; set; } public AbsolutePath DownloadLocation { get; set; }
public string LastCompiledProfileLocation { get; set; } public AbsolutePath LastCompiledProfileLocation { get; set; }
public Dictionary<string, CompilationModlistSettings> ModlistSettings { get; } = new Dictionary<string, CompilationModlistSettings>(); public Dictionary<AbsolutePath, CompilationModlistSettings> ModlistSettings { get; } = new Dictionary<AbsolutePath, CompilationModlistSettings>();
} }
public class VortexCompilationSettings public class VortexCompilationSettings

View File

@ -8,6 +8,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Windows.Input; using System.Windows.Input;
using Wabbajack.Common;
using Wabbajack.Lib; using Wabbajack.Lib;
namespace Wabbajack namespace Wabbajack
@ -35,7 +36,7 @@ namespace Wabbajack
public ICommand SetTargetPathCommand { get; set; } public ICommand SetTargetPathCommand { get; set; }
[Reactive] [Reactive]
public string TargetPath { get; set; } public AbsolutePath TargetPath { get; set; }
[Reactive] [Reactive]
public string PromptTitle { get; set; } public string PromptTitle { get; set; }
@ -81,7 +82,7 @@ namespace Wabbajack
// Dont want to debounce the initial value, because we know it's null // Dont want to debounce the initial value, because we know it's null
.Skip(1) .Skip(1)
.Debounce(TimeSpan.FromMilliseconds(200), RxApp.MainThreadScheduler) .Debounce(TimeSpan.FromMilliseconds(200), RxApp.MainThreadScheduler)
.StartWith(default(string)), .StartWith(default(AbsolutePath)),
resultSelector: (existsOption, type, path) => (ExistsOption: existsOption, Type: type, Path: path)) resultSelector: (existsOption, type, path) => (ExistsOption: existsOption, Type: type, Path: path))
.StartWith((ExistsOption: ExistCheckOption, Type: PathType, Path: TargetPath)) .StartWith((ExistsOption: ExistCheckOption, Type: PathType, Path: TargetPath))
.Replay(1) .Replay(1)
@ -97,7 +98,7 @@ namespace Wabbajack
case CheckOptions.Off: case CheckOptions.Off:
return false; return false;
case CheckOptions.IfPathNotEmpty: case CheckOptions.IfPathNotEmpty:
return !string.IsNullOrWhiteSpace(t.Path); return t.Path != null;
case CheckOptions.On: case CheckOptions.On:
return true; return true;
default: default:
@ -125,7 +126,7 @@ namespace Wabbajack
switch (t.ExistsOption) switch (t.ExistsOption)
{ {
case CheckOptions.IfPathNotEmpty: case CheckOptions.IfPathNotEmpty:
if (string.IsNullOrWhiteSpace(t.Path)) return false; if (t.Path == default) return false;
break; break;
case CheckOptions.On: case CheckOptions.On:
break; break;
@ -136,11 +137,11 @@ namespace Wabbajack
switch (t.Type) switch (t.Type)
{ {
case PathTypeOptions.Either: case PathTypeOptions.Either:
return File.Exists(t.Path) || Directory.Exists(t.Path); return t.Path.Exists;
case PathTypeOptions.File: case PathTypeOptions.File:
return File.Exists(t.Path); return t.Path.IsFile;
case PathTypeOptions.Folder: case PathTypeOptions.Folder:
return Directory.Exists(t.Path); return t.Path.IsDirectory;
case PathTypeOptions.Off: case PathTypeOptions.Off:
default: default:
return false; return false;
@ -171,7 +172,7 @@ namespace Wabbajack
case CheckOptions.Off: case CheckOptions.Off:
return true; return true;
case CheckOptions.IfPathNotEmpty: case CheckOptions.IfPathNotEmpty:
if (string.IsNullOrWhiteSpace(target)) return true; if (target == default) return true;
break; break;
case CheckOptions.On: case CheckOptions.On:
break; break;
@ -181,10 +182,7 @@ namespace Wabbajack
try try
{ {
var extension = Path.GetExtension(target); if (!query.Any(filter => filter.Extensions.Any(ext => new Extension(ext) == target.Extension))) return false;
if (extension == null || !extension.StartsWith(".")) return false;
extension = extension.Substring(1);
if (!query.Any(filter => filter.Extensions.Any(ext => string.Equals(ext, extension)))) return false;
} }
catch (ArgumentException) catch (ArgumentException)
{ {
@ -250,23 +248,16 @@ namespace Wabbajack
return ReactiveCommand.Create( return ReactiveCommand.Create(
execute: () => execute: () =>
{ {
string dirPath; AbsolutePath dirPath;
if (File.Exists(TargetPath)) dirPath = TargetPath.Exists ? TargetPath.Parent : TargetPath;
{
dirPath = Path.GetDirectoryName(TargetPath);
}
else
{
dirPath = TargetPath;
}
var dlg = new CommonOpenFileDialog var dlg = new CommonOpenFileDialog
{ {
Title = PromptTitle, Title = PromptTitle,
IsFolderPicker = PathType == PathTypeOptions.Folder, IsFolderPicker = PathType == PathTypeOptions.Folder,
InitialDirectory = dirPath, InitialDirectory = (string)dirPath,
AddToMostRecentlyUsedList = false, AddToMostRecentlyUsedList = false,
AllowNonFileSystemItems = false, AllowNonFileSystemItems = false,
DefaultDirectory = dirPath, DefaultDirectory = (string)dirPath,
EnsureFileExists = true, EnsureFileExists = true,
EnsurePathExists = true, EnsurePathExists = true,
EnsureReadOnly = false, EnsureReadOnly = false,
@ -279,7 +270,7 @@ namespace Wabbajack
dlg.Filters.Add(filter); dlg.Filters.Add(filter);
} }
if (dlg.ShowDialog() != CommonFileDialogResult.Ok) return; if (dlg.ShowDialog() != CommonFileDialogResult.Ok) return;
TargetPath = dlg.FileName; TargetPath = (AbsolutePath)dlg.FileName;
}, canExecute: canExecute); }, canExecute: canExecute);
} }
} }

View File

@ -30,16 +30,16 @@ namespace Wabbajack
return img; return img;
} }
public static bool TryGetBitmapImageFromFile(string path, out BitmapImage bitmapImage) public static bool TryGetBitmapImageFromFile(AbsolutePath path, out BitmapImage bitmapImage)
{ {
try try
{ {
if (!File.Exists(path)) if (!path.Exists)
{ {
bitmapImage = default; bitmapImage = default;
return false; return false;
} }
bitmapImage = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute)); bitmapImage = new BitmapImage(new Uri((string)path, UriKind.RelativeOrAbsolute));
return true; return true;
} }
catch (Exception) catch (Exception)
@ -49,14 +49,14 @@ namespace Wabbajack
} }
} }
public static string OpenFileDialog(string filter, string initialDirectory = null) public static AbsolutePath OpenFileDialog(string filter, string initialDirectory = null)
{ {
OpenFileDialog ofd = new OpenFileDialog(); OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = filter; ofd.Filter = filter;
ofd.InitialDirectory = initialDirectory; ofd.InitialDirectory = initialDirectory;
if (ofd.ShowDialog() == DialogResult.OK) if (ofd.ShowDialog() == DialogResult.OK)
return ofd.FileName; return (AbsolutePath)ofd.FileName;
return null; return default;
} }
public static IDisposable BindCpuStatus(IObservable<CPUStatus> status, ObservableCollectionExtended<CPUDisplayVM> list) public static IDisposable BindCpuStatus(IObservable<CPUStatus> status, ObservableCollectionExtended<CPUDisplayVM> list)

View File

@ -102,8 +102,10 @@ namespace Wabbajack
{ {
case ModManager.MO2: case ModManager.MO2:
return new MO2CompilerVM(this); return new MO2CompilerVM(this);
/*
case ModManager.Vortex: case ModManager.Vortex:
return new VortexCompilerVM(this); return new VortexCompilerVM(this);
*/
default: default:
return null; return null;
} }
@ -128,12 +130,8 @@ namespace Wabbajack
.ObserveOnGuiThread() .ObserveOnGuiThread()
.Select(path => .Select(path =>
{ {
if (string.IsNullOrWhiteSpace(path)) return UIUtils.BitmapImageFromResource("Resources/Wabba_Mouth_No_Text.png"); if (path == default) return UIUtils.BitmapImageFromResource("Resources/Wabba_Mouth_No_Text.png");
if (UIUtils.TryGetBitmapImageFromFile(path, out var image)) return UIUtils.TryGetBitmapImageFromFile(path, out var image) ? image : null;
{
return image;
}
return null;
}) })
.ToGuiProperty(this, nameof(Image)); .ToGuiProperty(this, nameof(Image));
@ -233,14 +231,14 @@ namespace Wabbajack
{ {
if (Completed?.Failed ?? false) if (Completed?.Failed ?? false)
{ {
Process.Start("explorer.exe", Utils.LogFolder); Process.Start("explorer.exe", (string)Utils.LogFolder);
} }
else else
{ {
Process.Start("explorer.exe", Process.Start("explorer.exe",
string.IsNullOrWhiteSpace(OutputLocation.TargetPath) (string)(OutputLocation.TargetPath == default
? Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) ? AbsolutePath.EntryPoint
: OutputLocation.TargetPath); : OutputLocation.TargetPath));
} }
}); });

View File

@ -18,8 +18,8 @@ namespace Wabbajack
private readonly MO2CompilationSettings _settings; private readonly MO2CompilationSettings _settings;
private readonly ObservableAsPropertyHelper<string> _mo2Folder; private readonly ObservableAsPropertyHelper<AbsolutePath> _mo2Folder;
public string Mo2Folder => _mo2Folder.Value; public AbsolutePath Mo2Folder => _mo2Folder.Value;
private readonly ObservableAsPropertyHelper<string> _moProfile; private readonly ObservableAsPropertyHelper<string> _moProfile;
public string MOProfile => _moProfile.Value; public string MOProfile => _moProfile.Value;
@ -60,12 +60,12 @@ namespace Wabbajack
{ {
try try
{ {
var profileFolder = Path.GetDirectoryName(loc); var profileFolder = loc.Parent;
return Path.GetDirectoryName(Path.GetDirectoryName(profileFolder)); return profileFolder.Parent.Parent;
} }
catch (Exception) catch (Exception)
{ {
return null; return default;
} }
}) })
.ToGuiProperty(this, nameof(Mo2Folder)); .ToGuiProperty(this, nameof(Mo2Folder));
@ -74,8 +74,7 @@ namespace Wabbajack
{ {
try try
{ {
var profileFolder = Path.GetDirectoryName(loc); return (string)loc.Parent.FileName;
return Path.GetFileName(profileFolder);
} }
catch (Exception) catch (Exception)
{ {
@ -86,9 +85,9 @@ namespace Wabbajack
// Wire missing Mo2Folder to signal error state for ModList Location // Wire missing Mo2Folder to signal error state for ModList Location
ModListLocation.AdditionalError = this.WhenAny(x => x.Mo2Folder) ModListLocation.AdditionalError = this.WhenAny(x => x.Mo2Folder)
.Select<string, IErrorResponse>(moFolder => .Select<AbsolutePath, IErrorResponse>(moFolder =>
{ {
if (Directory.Exists(moFolder)) return ErrorResponse.Success; if (moFolder.IsDirectory) return ErrorResponse.Success;
return ErrorResponse.Fail($"MO2 folder could not be located from the given ModList location.{Environment.NewLine}Make sure your ModList is inside a valid MO2 distribution."); return ErrorResponse.Fail($"MO2 folder could not be located from the given ModList location.{Environment.NewLine}Make sure your ModList is inside a valid MO2 distribution.");
}); });
@ -132,7 +131,7 @@ namespace Wabbajack
// Load settings // Load settings
_settings = parent.MWVM.Settings.Compiler.MO2Compilation; _settings = parent.MWVM.Settings.Compiler.MO2Compilation;
ModListLocation.TargetPath = _settings.LastCompiledProfileLocation; ModListLocation.TargetPath = _settings.LastCompiledProfileLocation;
if (!string.IsNullOrWhiteSpace(_settings.DownloadLocation)) if (_settings.DownloadLocation != default)
{ {
DownloadLocation.TargetPath = _settings.DownloadLocation; DownloadLocation.TargetPath = _settings.DownloadLocation;
} }
@ -143,7 +142,7 @@ namespace Wabbajack
// If Mo2 folder changes and download location is empty, set it for convenience // If Mo2 folder changes and download location is empty, set it for convenience
this.WhenAny(x => x.Mo2Folder) this.WhenAny(x => x.Mo2Folder)
.DelayInitial(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler) .DelayInitial(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler)
.Where(x => Directory.Exists(x)) .Where(x => x.IsDirectory)
.FlowSwitch( .FlowSwitch(
(this).WhenAny(x => x.DownloadLocation.Exists) (this).WhenAny(x => x.DownloadLocation.Exists)
.Invert()) .Invert())
@ -165,14 +164,14 @@ namespace Wabbajack
public async Task<GetResponse<ModList>> Compile() public async Task<GetResponse<ModList>> Compile()
{ {
string outputFile; AbsolutePath outputFile;
if (string.IsNullOrWhiteSpace(Parent.OutputLocation.TargetPath)) if (Parent.OutputLocation.TargetPath == default)
{ {
outputFile = MOProfile + Consts.ModListExtension; outputFile = (MOProfile + Consts.ModListExtension).RelativeTo(AbsolutePath.EntryPoint);
} }
else else
{ {
outputFile = Path.Combine(Parent.OutputLocation.TargetPath, MOProfile + Consts.ModListExtension); outputFile = Parent.OutputLocation.TargetPath.Combine(MOProfile + Consts.ModListExtension);
} }
try try
@ -187,7 +186,7 @@ namespace Wabbajack
ModListDescription = ModlistSettings.Description, ModListDescription = ModlistSettings.Description,
ModListImage = ModlistSettings.ImagePath.TargetPath, ModListImage = ModlistSettings.ImagePath.TargetPath,
ModListWebsite = ModlistSettings.Website, ModListWebsite = ModlistSettings.Website,
ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath, //ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath,
ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite, ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite,
MO2DownloadsFolder = DownloadLocation.TargetPath, MO2DownloadsFolder = DownloadLocation.TargetPath,
}) })

View File

@ -80,11 +80,13 @@ namespace Wabbajack
ReadmeIsWebsite = _settings.ReadmeIsWebsite; ReadmeIsWebsite = _settings.ReadmeIsWebsite;
if (ReadmeIsWebsite) if (ReadmeIsWebsite)
{ {
ReadmeWebsite = _settings.Readme; // TODO README
// ReadmeWebsite = _settings.Readme;
} }
else else
{ {
ReadmeFilePath.TargetPath = _settings.Readme; // TODO README
//ReadmeFilePath.TargetPath = _settings.Readme;
} }
ImagePath.TargetPath = _settings.SplashScreen; ImagePath.TargetPath = _settings.SplashScreen;
Website = _settings.Website; Website = _settings.Website;
@ -102,7 +104,8 @@ namespace Wabbajack
} }
else else
{ {
_settings.Readme = ReadmeFilePath.TargetPath; // TODO README
//_settings.Readme = ReadmeFilePath.TargetPath;
} }
_settings.SplashScreen = ImagePath.TargetPath; _settings.SplashScreen = ImagePath.TargetPath;
_settings.Website = Website; _settings.Website = Website;

View File

@ -31,7 +31,7 @@ namespace Wabbajack
private readonly ObservableAsPropertyHelper<bool> _Exists; private readonly ObservableAsPropertyHelper<bool> _Exists;
public bool Exists => _Exists.Value; public bool Exists => _Exists.Value;
public string Location { get; } public AbsolutePath Location { get; }
[Reactive] [Reactive]
public Percent ProgressPercent { get; private set; } public Percent ProgressPercent { get; private set; }
@ -52,7 +52,7 @@ namespace Wabbajack
{ {
_parent = parent; _parent = parent;
Metadata = metadata; Metadata = metadata;
Location = Path.Combine(Consts.ModListDownloadFolder, Metadata.Links.MachineURL + Consts.ModListExtension); Location = Consts.ModListDownloadFolder.RelativeTo(AbsolutePath.EntryPoint).Combine(Metadata.Links.MachineURL + Consts.ModListExtension);
IsBroken = metadata.ValidationSummary.HasFailures; IsBroken = metadata.ValidationSummary.HasFailures;
OpenWebsiteCommand = ReactiveCommand.Create(() => Utils.OpenWebsite(new Uri($"https://www.wabbajack.org/modlist/{Metadata.Links.MachineURL}"))); OpenWebsiteCommand = ReactiveCommand.Create(() => Utils.OpenWebsite(new Uri($"https://www.wabbajack.org/modlist/{Metadata.Links.MachineURL}")));
ExecuteCommand = ReactiveCommand.CreateFromObservable<Unit, Unit>( ExecuteCommand = ReactiveCommand.CreateFromObservable<Unit, Unit>(
@ -83,7 +83,7 @@ namespace Wabbajack
return false; return false;
} }
// Return an updated check on exists // Return an updated check on exists
return File.Exists(Location); return Location.Exists;
} }
return exists; return exists;
}) })
@ -92,7 +92,7 @@ namespace Wabbajack
.ObserveOnGuiThread() .ObserveOnGuiThread()
.Select(_ => .Select(_ =>
{ {
_parent.MWVM.OpenInstaller(Path.GetFullPath(Location)); _parent.MWVM.OpenInstaller(Location);
// Wait for modlist member to be filled, then open its readme // Wait for modlist member to be filled, then open its readme
return _parent.MWVM.Installer.Value.WhenAny(x => x.ModList) return _parent.MWVM.Installer.Value.WhenAny(x => x.ModList)

View File

@ -128,8 +128,8 @@ namespace Wabbajack
{ {
case ModManager.MO2: case ModManager.MO2:
return new MO2InstallerVM(this); return new MO2InstallerVM(this);
case ModManager.Vortex: /*case ModManager.Vortex:
return new VortexInstallerVM(this); return new VortexInstallerVM(this);*/
default: default:
return null; return null;
} }
@ -162,7 +162,7 @@ namespace Wabbajack
resultSelector: (path, active) => (path, active)) resultSelector: (path, active) => (path, active))
.Select(x => .Select(x =>
{ {
if (!x.active) return default(string); if (!x.active) return default;
return x.path; return x.path;
}) })
// Throttle slightly so changes happen more atomically // Throttle slightly so changes happen more atomically
@ -175,8 +175,8 @@ namespace Wabbajack
// Convert from active path to modlist VM // Convert from active path to modlist VM
.Select(modListPath => .Select(modListPath =>
{ {
if (modListPath == null) return default(ModListVM); if (modListPath == default) return default;
if (!File.Exists(modListPath)) return default(ModListVM); if (!modListPath.Exists) return default;
return new ModListVM(modListPath); return new ModListVM(modListPath);
}) })
.DisposeOld() .DisposeOld()

View File

@ -79,9 +79,9 @@ namespace Wabbajack
.Skip(1) // Don't do it initially .Skip(1) // Don't do it initially
.Subscribe(installPath => .Subscribe(installPath =>
{ {
if (string.IsNullOrWhiteSpace(DownloadLocation.TargetPath)) if (DownloadLocation.TargetPath == default)
{ {
DownloadLocation.TargetPath = Path.Combine(installPath, "downloads"); DownloadLocation.TargetPath = installPath.Combine("downloads");
} }
}) })
.DisposeWith(CompositeDisposable); .DisposeWith(CompositeDisposable);
@ -142,7 +142,7 @@ namespace Wabbajack
public void AfterInstallNavigation() public void AfterInstallNavigation()
{ {
Process.Start("explorer.exe", Location.TargetPath); Process.Start("explorer.exe", (string)Location.TargetPath);
} }
public async Task<bool> Install() public async Task<bool> Install()

View File

@ -154,7 +154,7 @@ namespace Wabbajack
Process.Start(process); Process.Start(process);
} }
private static bool IsStartingFromModlist(out string modlistPath) private static bool IsStartingFromModlist(out AbsolutePath modlistPath)
{ {
if (CLIArguments.InstallPath == null) if (CLIArguments.InstallPath == null)
{ {
@ -162,14 +162,14 @@ namespace Wabbajack
return false; return false;
} }
modlistPath = CLIArguments.InstallPath; modlistPath = (AbsolutePath)CLIArguments.InstallPath;
return true; return true;
} }
public void OpenInstaller(string path) public void OpenInstaller(AbsolutePath path)
{ {
if (path == null) return; if (path == default) return;
var installer = Installer.Value; var installer = Installer.Value;
Settings.Installer.LastInstalledListLocation = path; Settings.Installer.LastInstalledListLocation = path;
NavigateTo(installer); NavigateTo(installer);

View File

@ -15,7 +15,7 @@ namespace Wabbajack
{ {
public ModList SourceModList { get; private set; } public ModList SourceModList { get; private set; }
public Exception Error { get; } public Exception Error { get; }
public string ModListPath { get; } public AbsolutePath ModListPath { get; }
public string Name => SourceModList?.Name; public string Name => SourceModList?.Name;
public string Readme => SourceModList?.Readme; public string Readme => SourceModList?.Readme;
public string Author => SourceModList?.Author; public string Author => SourceModList?.Author;
@ -28,7 +28,7 @@ namespace Wabbajack
// and the cached image will automatically be released when the last interested party is gone. // and the cached image will automatically be released when the last interested party is gone.
public IObservable<BitmapImage> ImageObservable { get; } public IObservable<BitmapImage> ImageObservable { get; }
public ModListVM(string modListPath) public ModListVM(AbsolutePath modListPath)
{ {
ModListPath = modListPath; ModListPath = modListPath;
try try
@ -48,18 +48,16 @@ namespace Wabbajack
{ {
try try
{ {
using (var fs = new FileStream(ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read)) using var fs = ModListPath.OpenShared();
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read)) using var ar = new ZipArchive(fs, ZipArchiveMode.Read);
var ms = new MemoryStream();
var entry = ar.GetEntry("modlist-image.png");
if (entry == null) return default(MemoryStream);
using (var e = entry.Open())
{ {
var ms = new MemoryStream(); e.CopyTo(ms);
var entry = ar.GetEntry("modlist-image.png");
if (entry == null) return default(MemoryStream);
using (var e = entry.Open())
{
e.CopyTo(ms);
}
return ms;
} }
return ms;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -100,26 +98,24 @@ namespace Wabbajack
} }
else else
{ {
using (var fs = new FileStream(ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read)) using var fs = ModListPath.OpenShared();
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();
var entry = ar.GetEntry(Readme);
if (entry == null)
{ {
var entry = ar.GetEntry(Readme); Utils.Log($"Tried to open a non-existent readme: {Readme}");
if (entry == null) return;
{ }
Utils.Log($"Tried to open a non-existent readme: {Readme}"); using (var e = entry.Open())
return; {
} e.CopyTo(ms);
using (var e = entry.Open()) }
{ ms.Seek(0, SeekOrigin.Begin);
e.CopyTo(ms); using (var reader = new StreamReader(ms))
} {
ms.Seek(0, SeekOrigin.Begin); var viewer = new TextViewer(reader.ReadToEnd(), Name);
using (var reader = new StreamReader(ms)) viewer.Show();
{
var viewer = new TextViewer(reader.ReadToEnd(), Name);
viewer.Show();
}
} }
} }
} }

View File

@ -27,8 +27,7 @@ namespace Wabbajack
execute: () => execute: () =>
{ {
var path = mainVM.Settings.Installer.LastInstalledListLocation; var path = mainVM.Settings.Installer.LastInstalledListLocation;
if (string.IsNullOrWhiteSpace(path) if (path == default || !path.Exists)
|| !File.Exists(path))
{ {
path = UIUtils.OpenFileDialog($"*{Consts.ModListExtension}|*{Consts.ModListExtension}"); path = UIUtils.OpenFileDialog($"*{Consts.ModListExtension}|*{Consts.ModListExtension}");
} }

View File

@ -272,9 +272,11 @@
<DataTemplate DataType="{x:Type local:MO2CompilerVM}"> <DataTemplate DataType="{x:Type local:MO2CompilerVM}">
<local:MO2CompilerConfigView /> <local:MO2CompilerConfigView />
</DataTemplate> </DataTemplate>
<!--
<DataTemplate DataType="{x:Type local:VortexCompilerVM}"> <DataTemplate DataType="{x:Type local:VortexCompilerVM}">
<local:VortexCompilerConfigView /> <local:VortexCompilerConfigView />
</DataTemplate> </DataTemplate>
-->
</ContentPresenter.Resources> </ContentPresenter.Resources>
</ContentPresenter> </ContentPresenter>
<local:BeginButton <local:BeginButton

View File

@ -358,9 +358,11 @@
<DataTemplate DataType="{x:Type local:MO2InstallerVM}"> <DataTemplate DataType="{x:Type local:MO2InstallerVM}">
<local:MO2InstallerConfigView /> <local:MO2InstallerConfigView />
</DataTemplate> </DataTemplate>
<!--
<DataTemplate DataType="{x:Type local:VortexInstallerVM}"> <DataTemplate DataType="{x:Type local:VortexInstallerVM}">
<local:VortexInstallerConfigView /> <local:VortexInstallerConfigView />
</DataTemplate> </DataTemplate>
-->
</ContentPresenter.Resources> </ContentPresenter.Resources>
<ContentPresenter.Style> <ContentPresenter.Style>
<Style TargetType="ContentPresenter"> <Style TargetType="ContentPresenter">

View File

@ -50,6 +50,10 @@
<None Remove="Resources\Wabba_Mouth.png" /> <None Remove="Resources\Wabba_Mouth.png" />
<None Remove="Resources\Wabba_Mouth_No_Text.png" /> <None Remove="Resources\Wabba_Mouth_No_Text.png" />
<None Remove="Resources\Wabba_Mouth_Small.png" /> <None Remove="Resources\Wabba_Mouth_Small.png" />
<Compile Remove="View Models\Compilers\VortexCompilerVM.cs" />
<None Include="View Models\Compilers\VortexCompilerVM.cs" />
<Compile Remove="View Models\Installers\VortexInstallerVM.cs" />
<None Include="View Models\Installers\VortexInstallerVM.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>