mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix CriticalFailureIntervention never being handled
Can also specify if Wabbajack should exit
This commit is contained in:
parent
ba41972a8c
commit
a5c6b6c05c
@ -70,21 +70,19 @@ namespace Wabbajack.Lib
|
||||
var otherGame = Game.CommonlyConfusedWith.Where(g => g.MetaData().IsInstalled).Select(g => g.MetaData()).FirstOrDefault();
|
||||
if (otherGame != null)
|
||||
{
|
||||
await Utils.Log(new CriticalFailureIntervention(
|
||||
$"In order to do a proper install Wabbajack needs to know where your {Game.HumanFriendlyGameName} folder resides. However this game doesn't seem to be installed, we did however find a installed " +
|
||||
$"copy of {otherGame.HumanFriendlyGameName}, did you install the wrong game?",
|
||||
$"Could not locate {Game.HumanFriendlyGameName}"))
|
||||
.Task;
|
||||
Utils.Error(new CriticalFailureIntervention(
|
||||
$"In order to do a proper install Wabbajack needs to know where your {Game.HumanFriendlyGameName} folder resides. However this game doesn't seem to be installed, we did however find an installed " +
|
||||
$"copy of {otherGame.HumanFriendlyGameName}, did you install the wrong game?",
|
||||
$"Could not locate {Game.HumanFriendlyGameName}"));
|
||||
}
|
||||
else
|
||||
{
|
||||
await Utils.Log(new CriticalFailureIntervention(
|
||||
$"In order to do a proper install Wabbajack needs to know where your {Game.HumanFriendlyGameName} folder resides. However this game doesn't seem to be installed",
|
||||
$"Could not locate {Game.HumanFriendlyGameName}"))
|
||||
.Task;
|
||||
Utils.Error(new CriticalFailureIntervention(
|
||||
$"In order to do a proper install Wabbajack needs to know where your {Game.HumanFriendlyGameName} folder resides. However this game doesn't seem to be installed.",
|
||||
$"Could not locate {Game.HumanFriendlyGameName}"));
|
||||
}
|
||||
|
||||
Utils.Log("Exiting because we couldn't find the game folder.");
|
||||
Utils.Error("Exiting because we couldn't find the game folder.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,13 +12,17 @@ namespace Wabbajack.Lib
|
||||
private TaskCompletionSource<ConfirmationIntervention.Choice> _source = new TaskCompletionSource<ConfirmationIntervention.Choice>();
|
||||
public Task<ConfirmationIntervention.Choice> Task => _source.Task;
|
||||
|
||||
public CriticalFailureIntervention(string description, string title)
|
||||
public CriticalFailureIntervention(string description, string title, bool exit = false)
|
||||
{
|
||||
ExtendedDescription = description;
|
||||
ShortDescription = title;
|
||||
ExitApplication = exit;
|
||||
}
|
||||
|
||||
public override string ShortDescription { get; }
|
||||
public override string ExtendedDescription { get; }
|
||||
public bool ExitApplication { get; }
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
_source.SetResult(ConfirmationIntervention.Choice.Abort);
|
||||
|
@ -97,13 +97,19 @@ namespace Wabbajack
|
||||
|
||||
public InstallerVM(MainWindowVM mainWindowVM) : base(mainWindowVM)
|
||||
{
|
||||
|
||||
if (Path.GetDirectoryName(Assembly.GetEntryAssembly().Location.ToLower()) == KnownFolders.Downloads.Path.ToLower())
|
||||
if (AbsolutePath.EntryPoint.IsChildOf(new AbsolutePath(KnownFolders.Downloads.Path)))
|
||||
{
|
||||
Utils.Error(new CriticalFailureIntervention(
|
||||
"Wabbajack is running inside your Downloads folder. This folder is often highly monitored by antivirus software and these can often " +
|
||||
"conflict with the operations Wabbajack needs to perform. Please move this executable outside of your Downloads folder and then restart the app.",
|
||||
"Cannot run inside Downloads"));
|
||||
"conflict with the operations Wabbajack needs to perform. Please move Wabbajack outside of your Downloads folder and then restart the app.",
|
||||
"Cannot run inside Downloads", true));
|
||||
}
|
||||
else if (AbsolutePath.EntryPoint.IsChildOf(new AbsolutePath(KnownFolders.SkyDrive.Path)))
|
||||
{
|
||||
Utils.Error(new CriticalFailureIntervention(
|
||||
$"Wabbajack is running inside a OneDrive folder \"{new AbsolutePath(KnownFolders.SkyDrive.Path)}\". This folder is known to cause issues with Wabbajack. " +
|
||||
"Please move Wabbajack outside of your OneDrive folder and then restart the app.",
|
||||
"Cannot run inside OneDrive", true));
|
||||
}
|
||||
|
||||
MWVM = mainWindowVM;
|
||||
|
@ -77,9 +77,9 @@ namespace Wabbajack
|
||||
.Bind(Log)
|
||||
.Subscribe()
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
||||
|
||||
Utils.LogMessages
|
||||
.OfType<IUserIntervention>()
|
||||
.Where(a => a is IUserIntervention or CriticalFailureIntervention)
|
||||
.ObserveOnGuiThread()
|
||||
.SelectTask(async msg =>
|
||||
{
|
||||
@ -93,9 +93,9 @@ namespace Wabbajack
|
||||
Utils.Error(ex, $"Error while handling user intervention of type {msg?.GetType()}");
|
||||
try
|
||||
{
|
||||
if (!msg.Handled)
|
||||
if (msg is IUserIntervention {Handled: false} intervention)
|
||||
{
|
||||
msg.Cancel();
|
||||
intervention.Cancel();
|
||||
}
|
||||
}
|
||||
catch (Exception cancelEx)
|
||||
|
@ -10,6 +10,7 @@ using System.Windows.Threading;
|
||||
using CefSharp;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.StatusFeed;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.LibCefHelpers;
|
||||
@ -57,12 +58,12 @@ namespace Wabbajack
|
||||
MainWindow.NavigateTo(oldPane);
|
||||
}
|
||||
|
||||
public async Task Handle(IUserIntervention msg)
|
||||
public async Task Handle(IStatusMessage msg)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case RequestNexusAuthorization c:
|
||||
await WrapBrowserJob(msg, async (vm, cancel) =>
|
||||
await WrapBrowserJob(c, async (vm, cancel) =>
|
||||
{
|
||||
await vm.Driver.WaitForInitialized();
|
||||
var key = await NexusApiClient.SetupNexusLogin(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
|
||||
@ -70,13 +71,13 @@ namespace Wabbajack
|
||||
});
|
||||
break;
|
||||
case ManuallyDownloadNexusFile c:
|
||||
await WrapBrowserJob(msg, (vm, cancel) => HandleManualNexusDownload(vm, cancel, c));
|
||||
await WrapBrowserJob(c, (vm, cancel) => HandleManualNexusDownload(vm, cancel, c));
|
||||
break;
|
||||
case ManuallyDownloadFile c:
|
||||
await WrapBrowserJob(msg, (vm, cancel) => HandleManualDownload(vm, cancel, c));
|
||||
await WrapBrowserJob(c, (vm, cancel) => HandleManualDownload(vm, cancel, c));
|
||||
break;
|
||||
case AbstractNeedsLoginDownloader.RequestSiteLogin c:
|
||||
await WrapBrowserJob(msg, async (vm, cancel) =>
|
||||
await WrapBrowserJob(c, async (vm, cancel) =>
|
||||
{
|
||||
await vm.Driver.WaitForInitialized();
|
||||
var data = await c.Downloader.GetAndCacheCookies(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
|
||||
@ -87,6 +88,7 @@ namespace Wabbajack
|
||||
MessageBox.Show(c.ExtendedDescription, c.ShortDescription, MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
c.Cancel();
|
||||
if (c.ExitApplication) await MainWindow.ShutdownApplication();
|
||||
break;
|
||||
case ConfirmationIntervention c:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user