mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
commit
5ba0514a0e
@ -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<string, string> 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);
|
||||
|
@ -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());
|
||||
|
@ -383,7 +383,7 @@ namespace Wabbajack.Lib
|
||||
new IgnoreDisabledVortexMods(this),
|
||||
new IncludeVortexDeployment(this),
|
||||
new IgnoreVortex(this),
|
||||
new IgnoreRegex(this, "^*__vortex_staging_folder$"),
|
||||
new IgnoreRegex(this, $"^*{StagingMarkerName}$"),
|
||||
|
||||
Game == Game.DarkestDungeon ? new IncludeRegex(this, "project\\.xml$") : null,
|
||||
|
||||
@ -443,6 +443,11 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
return IsValidBaseStagingFolder(Path.GetDirectoryName(path));
|
||||
}
|
||||
|
||||
public static bool IsActiveVortexGame(Game g)
|
||||
{
|
||||
return GameRegistry.Games[g].SupportedModManager == ModManager.Vortex && !GameRegistry.Games[g].Disabled;
|
||||
}
|
||||
}
|
||||
|
||||
public class VortexDeployment
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -47,10 +47,10 @@ namespace Wabbajack
|
||||
public class InstallerSettings
|
||||
{
|
||||
public string LastInstalledListLocation { get; set; }
|
||||
public Dictionary<string, ModlistInstallationSettings> ModlistSettings { get; } = new Dictionary<string, ModlistInstallationSettings>();
|
||||
public Dictionary<string, Mo2ModlistInstallationSettings> Mo2ModlistSettings { get; } = new Dictionary<string, Mo2ModlistInstallationSettings>();
|
||||
}
|
||||
|
||||
public class ModlistInstallationSettings
|
||||
public class Mo2ModlistInstallationSettings
|
||||
{
|
||||
public string InstallationLocation { get; set; }
|
||||
public string DownloadLocation { get; set; }
|
||||
|
@ -28,9 +28,6 @@ namespace Wabbajack
|
||||
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _currentModlistSettings;
|
||||
public ModlistSettingsEditorVM CurrentModlistSettings => _currentModlistSettings.Value;
|
||||
|
||||
private readonly ObservableAsPropertyHelper<StatusUpdateTracker> _currentStatusTracker;
|
||||
public StatusUpdateTracker CurrentStatusTracker => _currentStatusTracker.Value;
|
||||
|
||||
private readonly ObservableAsPropertyHelper<bool> _compiling;
|
||||
public bool Compiling => _compiling.Value;
|
||||
|
||||
@ -86,10 +83,6 @@ namespace Wabbajack
|
||||
_currentModlistSettings = this.WhenAny(x => x.Compiler.ModlistSettings)
|
||||
.ToProperty(this, nameof(CurrentModlistSettings));
|
||||
|
||||
// Let sub VM determine what progress we're seeing
|
||||
_currentStatusTracker = this.WhenAny(x => x.Compiler.StatusTracker)
|
||||
.ToProperty(this, nameof(CurrentStatusTracker));
|
||||
|
||||
_image = this.WhenAny(x => x.CurrentModlistSettings.ImagePath.TargetPath)
|
||||
// Throttle so that it only loads image after any sets of swaps have completed
|
||||
.Throttle(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
|
||||
|
@ -10,7 +10,6 @@ namespace Wabbajack
|
||||
ACompiler ActiveCompilation { get; }
|
||||
|
||||
ModlistSettingsEditorVM ModlistSettings { get; }
|
||||
StatusUpdateTracker StatusTracker { get;}
|
||||
void Unload();
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace Wabbajack
|
||||
|
||||
private static readonly ObservableCollectionExtended<GameVM> _gameOptions = new ObservableCollectionExtended<GameVM>(
|
||||
EnumExt.GetValues<Game>()
|
||||
.Where(g => GameRegistry.Games[g].SupportedModManager == ModManager.Vortex && !GameRegistry.Games[g].Disabled)
|
||||
.Where(g => VortexCompiler.IsActiveVortexGame(g))
|
||||
.Select(g => new GameVM(g))
|
||||
.OrderBy(g => g.DisplayName));
|
||||
|
||||
|
18
Wabbajack/View Models/Installers/ISubInstallerVM.cs
Normal file
18
Wabbajack/View Models/Installers/ISubInstallerVM.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public interface ISubInstallerVM
|
||||
{
|
||||
IReactiveCommand BeginCommand { get; }
|
||||
AInstaller ActiveInstallation { get; }
|
||||
void Unload();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
using Syroot.Windows.IO;
|
||||
using Syroot.Windows.IO;
|
||||
using System;
|
||||
using ReactiveUI;
|
||||
using System.Diagnostics;
|
||||
@ -17,6 +17,7 @@ using ReactiveUI.Fody.Helpers;
|
||||
using System.Windows.Media;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -33,15 +34,12 @@ namespace Wabbajack
|
||||
|
||||
public FilePickerVM ModListPath { get; }
|
||||
|
||||
[Reactive]
|
||||
public bool UIReady { get; set; }
|
||||
private readonly ObservableAsPropertyHelper<ISubInstallerVM> _installer;
|
||||
public ISubInstallerVM Installer => _installer.Value;
|
||||
|
||||
private readonly ObservableAsPropertyHelper<string> _htmlReport;
|
||||
public string HTMLReport => _htmlReport.Value;
|
||||
|
||||
[Reactive]
|
||||
public AInstaller ActiveInstallation { get; private set; }
|
||||
|
||||
private readonly ObservableAsPropertyHelper<bool> _installing;
|
||||
public bool Installing => _installing.Value;
|
||||
|
||||
@ -51,10 +49,6 @@ namespace Wabbajack
|
||||
[Reactive]
|
||||
public bool InstallingMode { get; set; }
|
||||
|
||||
public FilePickerVM Location { get; }
|
||||
|
||||
public FilePickerVM DownloadLocation { get; }
|
||||
|
||||
private readonly ObservableAsPropertyHelper<ImageSource> _image;
|
||||
public ImageSource Image => _image.Value;
|
||||
|
||||
@ -79,11 +73,10 @@ namespace Wabbajack
|
||||
public ObservableCollectionExtended<CPUStatus> StatusList { get; } = new ObservableCollectionExtended<CPUStatus>();
|
||||
public ObservableCollectionExtended<string> Log => MWVM.Log;
|
||||
|
||||
private readonly ObservableAsPropertyHelper<ModlistInstallationSettings> _CurrentSettings;
|
||||
public ModlistInstallationSettings CurrentSettings => _CurrentSettings.Value;
|
||||
private readonly ObservableAsPropertyHelper<ModManager?> _TargetManager;
|
||||
public ModManager? TargetManager => _TargetManager.Value;
|
||||
|
||||
// Command properties
|
||||
public IReactiveCommand BeginCommand { get; }
|
||||
public IReactiveCommand ShowReportCommand { get; }
|
||||
public IReactiveCommand OpenReadmeCommand { get; }
|
||||
public IReactiveCommand VisitWebsiteCommand { get; }
|
||||
@ -104,22 +97,6 @@ namespace Wabbajack
|
||||
|
||||
MWVM = mainWindowVM;
|
||||
|
||||
Location = new FilePickerVM()
|
||||
{
|
||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.Off,
|
||||
PathType = FilePickerVM.PathTypeOptions.Folder,
|
||||
PromptTitle = "Select Installation Directory",
|
||||
};
|
||||
Location.AdditionalError = this.WhenAny(x => x.Location.TargetPath)
|
||||
.Select(x => Utils.IsDirectoryPathValid(x));
|
||||
DownloadLocation = new FilePickerVM()
|
||||
{
|
||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.Off,
|
||||
PathType = FilePickerVM.PathTypeOptions.Folder,
|
||||
PromptTitle = "Select a location for MO2 downloads",
|
||||
};
|
||||
DownloadLocation.AdditionalError = this.WhenAny(x => x.DownloadLocation.TargetPath)
|
||||
.Select(x => Utils.IsDirectoryPathValid(x));
|
||||
ModListPath = new FilePickerVM()
|
||||
{
|
||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.On,
|
||||
@ -127,22 +104,37 @@ namespace Wabbajack
|
||||
PromptTitle = "Select a modlist to install"
|
||||
};
|
||||
|
||||
// Load settings
|
||||
_CurrentSettings = this.WhenAny(x => x.ModListPath.TargetPath)
|
||||
.Select(path => path == null ? null : MWVM.Settings.Installer.ModlistSettings.TryCreate(path))
|
||||
.ToProperty(this, nameof(CurrentSettings));
|
||||
this.WhenAny(x => x.CurrentSettings)
|
||||
.Pairwise()
|
||||
.Subscribe(settingsPair =>
|
||||
// Swap to proper sub VM based on selected type
|
||||
_installer = this.WhenAny(x => x.TargetManager)
|
||||
// Delay so the initial VM swap comes in immediately, subVM comes right after
|
||||
.DelayInitial(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
|
||||
.Select<ModManager?, ISubInstallerVM>(type =>
|
||||
{
|
||||
SaveSettings(settingsPair.Previous);
|
||||
if (settingsPair.Current == null) return;
|
||||
Location.TargetPath = settingsPair.Current.InstallationLocation;
|
||||
DownloadLocation.TargetPath = settingsPair.Current.DownloadLocation;
|
||||
switch (type)
|
||||
{
|
||||
case ModManager.MO2:
|
||||
return new MO2InstallerVM(this);
|
||||
case ModManager.Vortex:
|
||||
return new VortexInstallerVM(this);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
// Unload old VM
|
||||
.Pairwise()
|
||||
.Do(pair =>
|
||||
{
|
||||
pair.Previous?.Unload();
|
||||
})
|
||||
.Select(p => p.Current)
|
||||
.ToProperty(this, nameof(Installer));
|
||||
|
||||
// Load settings
|
||||
MWVM.Settings.SaveSignal
|
||||
.Subscribe(_ => SaveSettings(CurrentSettings))
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
MWVM.Settings.Installer.LastInstalledListLocation = ModListPath.TargetPath;
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
||||
_modList = this.WhenAny(x => x.ModListPath.TargetPath)
|
||||
@ -161,17 +153,20 @@ namespace Wabbajack
|
||||
_htmlReport = this.WhenAny(x => x.ModList)
|
||||
.Select(modList => modList?.ReportHTML)
|
||||
.ToProperty(this, nameof(HTMLReport));
|
||||
_installing = this.WhenAny(x => x.ActiveInstallation)
|
||||
_installing = this.WhenAny(x => x.Installer.ActiveInstallation)
|
||||
.Select(compilation => compilation != null)
|
||||
.ObserveOnGuiThread()
|
||||
.ToProperty(this, nameof(Installing));
|
||||
_TargetManager = this.WhenAny(x => x.ModList)
|
||||
.Select(modList => modList?.ModManager)
|
||||
.ToProperty(this, nameof(TargetManager));
|
||||
|
||||
BackCommand = ReactiveCommand.Create(
|
||||
execute: () => mainWindowVM.ActivePane = mainWindowVM.ModeSelectionVM,
|
||||
canExecute: this.WhenAny(x => x.Installing)
|
||||
.Select(x => !x));
|
||||
|
||||
_percentCompleted = this.WhenAny(x => x.ActiveInstallation)
|
||||
_percentCompleted = this.WhenAny(x => x.Installer.ActiveInstallation)
|
||||
.StartWith(default(AInstaller))
|
||||
.Pairwise()
|
||||
.Select(c =>
|
||||
@ -233,36 +228,12 @@ namespace Wabbajack
|
||||
canExecute: this.WhenAny(x => x.ModList)
|
||||
.Select(modList => !string.IsNullOrEmpty(modList?.Readme))
|
||||
.ObserveOnGuiThread());
|
||||
BeginCommand = ReactiveCommand.CreateFromTask(
|
||||
execute: ExecuteBegin,
|
||||
canExecute: Observable.CombineLatest(
|
||||
this.WhenAny(x => x.Installing),
|
||||
this.WhenAny(x => x.Location.InError),
|
||||
this.WhenAny(x => x.DownloadLocation.InError),
|
||||
resultSelector: (installing, loc, download) =>
|
||||
{
|
||||
if (installing) return false;
|
||||
return !loc && !download;
|
||||
})
|
||||
.ObserveOnGuiThread());
|
||||
VisitWebsiteCommand = ReactiveCommand.Create(
|
||||
execute: () => Process.Start(ModList.Website),
|
||||
canExecute: this.WhenAny(x => x.ModList.Website)
|
||||
.Select(x => x?.StartsWith("https://") ?? false)
|
||||
.ObserveOnGuiThread());
|
||||
|
||||
// Have Installation location updates modify the downloads location if empty
|
||||
this.WhenAny(x => x.Location.TargetPath)
|
||||
.Skip(1) // Don't do it initially
|
||||
.Subscribe(installPath =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(DownloadLocation.TargetPath))
|
||||
{
|
||||
DownloadLocation.TargetPath = Path.Combine(installPath, "downloads");
|
||||
}
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
||||
_progressTitle = Observable.CombineLatest(
|
||||
this.WhenAny(x => x.Installing),
|
||||
this.WhenAny(x => x.InstallingMode),
|
||||
@ -274,7 +245,7 @@ namespace Wabbajack
|
||||
.ToProperty(this, nameof(ProgressTitle));
|
||||
|
||||
// Compile progress updates and populate ObservableCollection
|
||||
this.WhenAny(x => x.ActiveInstallation)
|
||||
this.WhenAny(x => x.Installer.ActiveInstallation)
|
||||
.SelectMany(c => c?.QueueStatus ?? Observable.Empty<CPUStatus>())
|
||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
||||
.ToObservableChangeSet(x => x.ID)
|
||||
@ -286,6 +257,16 @@ namespace Wabbajack
|
||||
.Bind(StatusList)
|
||||
.Subscribe()
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
||||
// When sub installer begins an install, mark state variable
|
||||
this.WhenAny(x => x.Installer.BeginCommand)
|
||||
.Select(x => x?.StartingExecution() ?? Observable.Empty<Unit>())
|
||||
.Switch()
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
InstallingMode = true;
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
}
|
||||
|
||||
private void ShowReport()
|
||||
@ -320,60 +301,5 @@ namespace Wabbajack
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ExecuteBegin()
|
||||
{
|
||||
InstallingMode = true;
|
||||
AInstaller installer;
|
||||
|
||||
try
|
||||
{
|
||||
installer = new MO2Installer(ModListPath.TargetPath, ModList.SourceModList, Location.TargetPath)
|
||||
{
|
||||
DownloadFolder = DownloadLocation.TargetPath
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null) ex = ex.InnerException;
|
||||
Utils.Log(ex.StackTrace);
|
||||
Utils.Log(ex.ToString());
|
||||
Utils.Log($"{ex.Message} - Can't continue");
|
||||
ActiveInstallation = null;
|
||||
return;
|
||||
}
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
IDisposable subscription = null;
|
||||
try
|
||||
{
|
||||
var workTask = installer.Begin();
|
||||
ActiveInstallation = installer;
|
||||
await workTask;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null) ex = ex.InnerException;
|
||||
Utils.Log(ex.StackTrace);
|
||||
Utils.Log(ex.ToString());
|
||||
Utils.Log($"{ex.Message} - Can't continue");
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Dispose of CPU tracking systems
|
||||
subscription?.Dispose();
|
||||
ActiveInstallation = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void SaveSettings(ModlistInstallationSettings settings)
|
||||
{
|
||||
MWVM.Settings.Installer.LastInstalledListLocation = ModListPath.TargetPath;
|
||||
if (settings == null) return;
|
||||
settings.InstallationLocation = Location.TargetPath;
|
||||
settings.DownloadLocation = DownloadLocation.TargetPath;
|
||||
}
|
||||
}
|
||||
}
|
153
Wabbajack/View Models/Installers/MO2InstallerVM.cs
Normal file
153
Wabbajack/View Models/Installers/MO2InstallerVM.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class MO2InstallerVM : ViewModel, ISubInstallerVM
|
||||
{
|
||||
private InstallerVM _installerVM;
|
||||
|
||||
public IReactiveCommand BeginCommand { get; }
|
||||
|
||||
[Reactive]
|
||||
public AInstaller ActiveInstallation { get; private set; }
|
||||
|
||||
private readonly ObservableAsPropertyHelper<Mo2ModlistInstallationSettings> _CurrentSettings;
|
||||
public Mo2ModlistInstallationSettings CurrentSettings => _CurrentSettings.Value;
|
||||
|
||||
public FilePickerVM Location { get; }
|
||||
|
||||
public FilePickerVM DownloadLocation { get; }
|
||||
|
||||
public MO2InstallerVM(InstallerVM installerVM)
|
||||
{
|
||||
_installerVM = installerVM;
|
||||
|
||||
Location = new FilePickerVM()
|
||||
{
|
||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.Off,
|
||||
PathType = FilePickerVM.PathTypeOptions.Folder,
|
||||
PromptTitle = "Select Installation Directory",
|
||||
};
|
||||
Location.AdditionalError = this.WhenAny(x => x.Location.TargetPath)
|
||||
.Select(x => Utils.IsDirectoryPathValid(x));
|
||||
DownloadLocation = new FilePickerVM()
|
||||
{
|
||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.Off,
|
||||
PathType = FilePickerVM.PathTypeOptions.Folder,
|
||||
PromptTitle = "Select a location for MO2 downloads",
|
||||
};
|
||||
DownloadLocation.AdditionalError = this.WhenAny(x => x.DownloadLocation.TargetPath)
|
||||
.Select(x => Utils.IsDirectoryPathValid(x));
|
||||
|
||||
BeginCommand = ReactiveCommand.CreateFromTask(
|
||||
canExecute: Observable.CombineLatest(
|
||||
this.WhenAny(x => x.Location.InError),
|
||||
this.WhenAny(x => x.DownloadLocation.InError),
|
||||
resultSelector: (loc, download) =>
|
||||
{
|
||||
return !loc && !download;
|
||||
})
|
||||
.ObserveOnGuiThread(),
|
||||
execute: async () =>
|
||||
{
|
||||
AInstaller installer;
|
||||
|
||||
try
|
||||
{
|
||||
installer = new MO2Installer(
|
||||
archive: installerVM.ModListPath.TargetPath,
|
||||
modList: installerVM.ModList.SourceModList,
|
||||
outputFolder: Location.TargetPath,
|
||||
downloadFolder: DownloadLocation.TargetPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null) ex = ex.InnerException;
|
||||
Utils.Log(ex.StackTrace);
|
||||
Utils.Log(ex.ToString());
|
||||
Utils.Log($"{ex.Message} - Can't continue");
|
||||
ActiveInstallation = null;
|
||||
return;
|
||||
}
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
IDisposable subscription = null;
|
||||
try
|
||||
{
|
||||
var workTask = installer.Begin();
|
||||
ActiveInstallation = installer;
|
||||
await workTask;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null) ex = ex.InnerException;
|
||||
Utils.Log(ex.StackTrace);
|
||||
Utils.Log(ex.ToString());
|
||||
Utils.Log($"{ex.Message} - Can't continue");
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Dispose of CPU tracking systems
|
||||
subscription?.Dispose();
|
||||
ActiveInstallation = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Have Installation location updates modify the downloads location if empty
|
||||
this.WhenAny(x => x.Location.TargetPath)
|
||||
.Skip(1) // Don't do it initially
|
||||
.Subscribe(installPath =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(DownloadLocation.TargetPath))
|
||||
{
|
||||
DownloadLocation.TargetPath = Path.Combine(installPath, "downloads");
|
||||
}
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
||||
// Load settings
|
||||
_CurrentSettings = installerVM.WhenAny(x => x.ModListPath.TargetPath)
|
||||
.Select(path => path == null ? null : installerVM.MWVM.Settings.Installer.Mo2ModlistSettings.TryCreate(path))
|
||||
.ToProperty(this, nameof(CurrentSettings));
|
||||
this.WhenAny(x => x.CurrentSettings)
|
||||
.Pairwise()
|
||||
.Subscribe(settingsPair =>
|
||||
{
|
||||
SaveSettings(settingsPair.Previous);
|
||||
if (settingsPair.Current == null) return;
|
||||
Location.TargetPath = settingsPair.Current.InstallationLocation;
|
||||
DownloadLocation.TargetPath = settingsPair.Current.DownloadLocation;
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
installerVM.MWVM.Settings.SaveSignal
|
||||
.Subscribe(_ => SaveSettings(CurrentSettings))
|
||||
.DisposeWith(CompositeDisposable);
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
SaveSettings(this.CurrentSettings);
|
||||
}
|
||||
|
||||
private void SaveSettings(Mo2ModlistInstallationSettings settings)
|
||||
{
|
||||
_installerVM.MWVM.Settings.Installer.LastInstalledListLocation = _installerVM.ModListPath.TargetPath;
|
||||
if (settings == null) return;
|
||||
settings.InstallationLocation = Location.TargetPath;
|
||||
settings.DownloadLocation = DownloadLocation.TargetPath;
|
||||
}
|
||||
}
|
||||
}
|
92
Wabbajack/View Models/Installers/VortexInstallerVM.cs
Normal file
92
Wabbajack/View Models/Installers/VortexInstallerVM.cs
Normal file
@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class VortexInstallerVM : ViewModel, ISubInstallerVM
|
||||
{
|
||||
public IReactiveCommand BeginCommand { get; }
|
||||
|
||||
[Reactive]
|
||||
public AInstaller ActiveInstallation { get; private set; }
|
||||
|
||||
private readonly ObservableAsPropertyHelper<string> _DownloadLocation;
|
||||
public string DownloadLocation => _DownloadLocation.Value;
|
||||
|
||||
private readonly ObservableAsPropertyHelper<string> _StagingLocation;
|
||||
public string StagingLocation => _StagingLocation.Value;
|
||||
|
||||
private readonly ObservableAsPropertyHelper<Game> _TargetGame;
|
||||
public Game TargetGame => _TargetGame.Value;
|
||||
|
||||
public VortexInstallerVM(InstallerVM installerVM)
|
||||
{
|
||||
_TargetGame = installerVM.WhenAny(x => x.ModList.SourceModList.GameType)
|
||||
.ToProperty(this, nameof(TargetGame));
|
||||
|
||||
BeginCommand = ReactiveCommand.CreateFromTask(
|
||||
canExecute: this.WhenAny(x => x.TargetGame)
|
||||
.Select(game => VortexCompiler.IsActiveVortexGame(game)),
|
||||
execute: async () =>
|
||||
{
|
||||
AInstaller installer;
|
||||
|
||||
try
|
||||
{
|
||||
var download = VortexCompiler.RetrieveDownloadLocation(TargetGame);
|
||||
var staging = VortexCompiler.RetrieveStagingLocation(TargetGame);
|
||||
installer = new VortexInstaller(
|
||||
archive: installerVM.ModListPath.TargetPath,
|
||||
modList: installerVM.ModList.SourceModList,
|
||||
outputFolder: staging,
|
||||
downloadFolder: download);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null) ex = ex.InnerException;
|
||||
Utils.Log(ex.StackTrace);
|
||||
Utils.Log(ex.ToString());
|
||||
Utils.Log($"{ex.Message} - Can't continue");
|
||||
ActiveInstallation = null;
|
||||
return;
|
||||
}
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
IDisposable subscription = null;
|
||||
try
|
||||
{
|
||||
var workTask = installer.Begin();
|
||||
ActiveInstallation = installer;
|
||||
await workTask;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null) ex = ex.InnerException;
|
||||
Utils.Log(ex.StackTrace);
|
||||
Utils.Log(ex.ToString());
|
||||
Utils.Log($"{ex.Message} - Can't continue");
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Dispose of CPU tracking systems
|
||||
subscription?.Dispose();
|
||||
ActiveInstallation = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -276,24 +276,27 @@
|
||||
x:Name="InstallationConfigurationView"
|
||||
Grid.Column="2"
|
||||
Background="{StaticResource WindowBackgroundBrush}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ScrollViewer
|
||||
Grid.Column="0"
|
||||
Margin="5"
|
||||
Background="Transparent"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Visibility="{Binding InstallingMode, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}">
|
||||
<Grid Margin="8">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" MinWidth="120" />
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="80" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
@ -311,45 +314,29 @@
|
||||
VerticalAlignment="Center"
|
||||
DataContext="{Binding ModListPath}"
|
||||
FontSize="14" />
|
||||
<TextBlock
|
||||
<ContentPresenter
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="Installation Location"
|
||||
TextAlignment="Center" />
|
||||
<local:FilePicker
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
Height="30"
|
||||
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}"
|
||||
FontSize="14" />
|
||||
<local:BeginButton
|
||||
Grid.Row="1"
|
||||
Grid.RowSpan="3"
|
||||
Grid.Column="4"
|
||||
Margin="0,0,25,0"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{Binding BeginCommand, Mode=OneWay}" />
|
||||
Grid.ColumnSpan="3"
|
||||
Margin="0"
|
||||
Content="{Binding Installer}">
|
||||
<ContentPresenter.Resources>
|
||||
<DataTemplate DataType="{x:Type local:MO2InstallerVM}">
|
||||
<local:MO2InstallerConfigView />
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type local:VortexInstallerVM}">
|
||||
<local:VortexInstallerConfigView />
|
||||
</DataTemplate>
|
||||
</ContentPresenter.Resources>
|
||||
</ContentPresenter>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
<local:BeginButton
|
||||
Grid.Column="2"
|
||||
Margin="0,0,25,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding Installer.BeginCommand, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid
|
52
Wabbajack/Views/Installers/MO2InstallerConfigView.xaml
Normal file
52
Wabbajack/Views/Installers/MO2InstallerConfigView.xaml
Normal file
@ -0,0 +1,52 @@
|
||||
<UserControl
|
||||
x:Class="Wabbajack.MO2InstallerConfigView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="120" />
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="Installation Location"
|
||||
TextAlignment="Center" />
|
||||
<local:FilePicker
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Height="30"
|
||||
VerticalAlignment="Center"
|
||||
DataContext="{Binding Location}"
|
||||
FontSize="14" />
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="Download Location"
|
||||
TextAlignment="Center" />
|
||||
<local:FilePicker
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Height="30"
|
||||
VerticalAlignment="Center"
|
||||
DataContext="{Binding DownloadLocation}"
|
||||
FontSize="14" />
|
||||
</Grid>
|
||||
</UserControl>
|
28
Wabbajack/Views/Installers/MO2InstallerConfigView.xaml.cs
Normal file
28
Wabbajack/Views/Installers/MO2InstallerConfigView.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MO2InstallerConfigView.xaml
|
||||
/// </summary>
|
||||
public partial class MO2InstallerConfigView : UserControl
|
||||
{
|
||||
public MO2InstallerConfigView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
14
Wabbajack/Views/Installers/VortexInstallerConfigView.xaml
Normal file
14
Wabbajack/Views/Installers/VortexInstallerConfigView.xaml
Normal file
@ -0,0 +1,14 @@
|
||||
<UserControl
|
||||
x:Class="Wabbajack.VortexInstallerConfigView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<!-- Nothing so far -->
|
||||
</Grid>
|
||||
</UserControl>
|
28
Wabbajack/Views/Installers/VortexInstallerConfigView.xaml.cs
Normal file
28
Wabbajack/Views/Installers/VortexInstallerConfigView.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for VortexInstallerConfigView.xaml
|
||||
/// </summary>
|
||||
public partial class VortexInstallerConfigView : UserControl
|
||||
{
|
||||
public VortexInstallerConfigView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -169,6 +169,12 @@
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Converters\EqualsToBoolConverter.cs" />
|
||||
<Compile Include="Views\Installers\MO2InstallerConfigView.xaml.cs">
|
||||
<DependentUpon>MO2InstallerConfigView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View Models\Installers\ISubInstallerVM.cs" />
|
||||
<Compile Include="View Models\Installers\MO2InstallerVM.cs" />
|
||||
<Compile Include="View Models\Installers\VortexInstallerVM.cs" />
|
||||
<Compile Include="View Models\ModListGalleryVM.cs" />
|
||||
<Compile Include="View Models\ModListMetadataVM.cs" />
|
||||
<Compile Include="Views\Common\HeatedBackgroundView.xaml.cs">
|
||||
@ -220,7 +226,7 @@
|
||||
<Compile Include="Views\Common\FilePicker.xaml.cs">
|
||||
<DependentUpon>FilePicker.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\InstallationView.xaml.cs">
|
||||
<Compile Include="Views\Installers\InstallationView.xaml.cs">
|
||||
<DependentUpon>InstallationView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View Models\Compilers\CompilerVM.cs" />
|
||||
@ -241,6 +247,13 @@
|
||||
<Compile Include="Views\Compilers\VortexCompilerConfigView.xaml.cs">
|
||||
<DependentUpon>VortexCompilerConfigView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Installers\VortexInstallerConfigView.xaml.cs">
|
||||
<DependentUpon>VortexInstallerConfigView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="Views\Installers\MO2InstallerConfigView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Common\HeatedBackgroundView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -285,7 +298,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\InstallationView.xaml">
|
||||
<Page Include="Views\Installers\InstallationView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
@ -301,7 +314,7 @@
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View Models\InstallerVM.cs" />
|
||||
<Compile Include="View Models\Installers\InstallerVM.cs" />
|
||||
<Compile Include="Util\AutoScrollBehavior.cs" />
|
||||
<Compile Include="Views\MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
@ -323,6 +336,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Installers\VortexInstallerConfigView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
|
Loading…
Reference in New Issue
Block a user