2019-12-03 02:38:33 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2019-12-11 03:39:09 +00:00
|
|
|
|
public InstallerVM Parent { get; }
|
|
|
|
|
|
2019-12-03 02:38:33 +00:00
|
|
|
|
[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;
|
|
|
|
|
|
2019-12-11 04:59:15 +00:00
|
|
|
|
public bool SupportsAfterInstallNavigation => false;
|
|
|
|
|
|
2019-12-14 22:46:06 +00:00
|
|
|
|
public int ConfigVisualVerticalOffset => 0;
|
|
|
|
|
|
2019-12-19 01:14:21 +00:00
|
|
|
|
public IObservable<bool> CanInstall { get; }
|
|
|
|
|
|
2019-12-03 02:38:33 +00:00
|
|
|
|
public VortexInstallerVM(InstallerVM installerVM)
|
|
|
|
|
{
|
2019-12-11 03:39:09 +00:00
|
|
|
|
Parent = installerVM;
|
|
|
|
|
|
2019-12-03 02:38:33 +00:00
|
|
|
|
_TargetGame = installerVM.WhenAny(x => x.ModList.SourceModList.GameType)
|
|
|
|
|
.ToProperty(this, nameof(TargetGame));
|
|
|
|
|
|
2019-12-19 01:14:21 +00:00
|
|
|
|
CanInstall = Observable.CombineLatest(
|
|
|
|
|
this.WhenAny(x => x.TargetGame)
|
|
|
|
|
.Select(game => VortexCompiler.IsActiveVortexGame(game)),
|
|
|
|
|
installerVM.WhenAny(x => x.ModListLocation.InError),
|
|
|
|
|
resultSelector: (isVortexGame, modListErr) => isVortexGame && !modListErr);
|
2019-12-03 02:38:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Unload()
|
|
|
|
|
{
|
|
|
|
|
}
|
2019-12-11 04:59:15 +00:00
|
|
|
|
|
|
|
|
|
public void AfterInstallNavigation()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2019-12-19 01:14:21 +00:00
|
|
|
|
|
|
|
|
|
public async Task Install()
|
|
|
|
|
{
|
|
|
|
|
AInstaller installer;
|
|
|
|
|
|
|
|
|
|
var download = VortexCompiler.RetrieveDownloadLocation(TargetGame);
|
|
|
|
|
var staging = VortexCompiler.RetrieveStagingLocation(TargetGame);
|
|
|
|
|
installer = new VortexInstaller(
|
|
|
|
|
archive: Parent.ModListLocation.TargetPath,
|
|
|
|
|
modList: Parent.ModList.SourceModList,
|
|
|
|
|
outputFolder: staging,
|
|
|
|
|
downloadFolder: download);
|
|
|
|
|
|
|
|
|
|
await Task.Run(async () =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var workTask = installer.Begin();
|
|
|
|
|
ActiveInstallation = installer;
|
|
|
|
|
await workTask;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
ActiveInstallation = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-12-03 02:38:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|