Merge pull request #1668 from wabbajack-tools/issue-1664

Add Error page (issue #1664)
This commit is contained in:
Timothy Baldridge 2021-10-20 06:54:33 -06:00 committed by GitHub
commit 6831698e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 101 additions and 8 deletions

View File

@ -0,0 +1,8 @@
using System;
namespace Wabbajack.App.Messages;
public record Error(string Prefix, Exception Exception)
{
}

View File

@ -63,6 +63,7 @@ public class CompilationViewModel : ViewModelBase, IReceiverMarker, IReceiver<St
{
_logger.LogError(ex, "During Compilation: {Message}", ex.Message);
StatusText = $"ERRORED: {ex.Message}";
ErrorPageViewModel.Display("During compilation", ex);
}
}
}

View File

@ -0,0 +1,13 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Wabbajack.App.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Wabbajack.App.Screens.ErrorPageView">
<Grid RowDefinitions="Auto, Auto, *">
<TextBlock Grid.Row="0" x:Name="Prefix"></TextBlock>
<TextBlock Grid.Row="1" x:Name="Message"></TextBlock>
<controls:LogView Grid.Row="3"></controls:LogView>
</Grid>
</UserControl>

View File

@ -0,0 +1,20 @@
using System.Reactive.Disposables;
using ReactiveUI;
using Wabbajack.App.Views;
namespace Wabbajack.App.Screens;
public partial class ErrorPageView : ScreenBase<ErrorPageViewModel>
{
public ErrorPageView()
{
InitializeComponent();
this.WhenActivated(disposables =>
{
this.Bind(ViewModel, vm => vm.Prefix, view => view.Prefix.Text)
.DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.ShortMessage, view => view.Message.Text)
.DisposeWith(disposables);
});
}
}

View File

@ -0,0 +1,34 @@
using System;
using DynamicData.Kernel;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.App.Messages;
using Wabbajack.App.ViewModels;
namespace Wabbajack.App.Screens
{
public class ErrorPageViewModel : ViewModelBase, IActivatableViewModel, IReceiver<Error>
{
[Reactive]
public string ShortMessage { get; set; }
[Reactive]
public string Prefix { get; set; }
public ErrorPageViewModel()
{
Activator = new ViewModelActivator();
}
public void Receive(Error val)
{
Prefix = val.Prefix;
ShortMessage = val.Exception.Message;
}
public static void Display(string prefix, Exception ex)
{
MessageBus.Instance.Send(new Error(prefix, ex));
MessageBus.Instance.Send(new NavigateTo(typeof(ErrorPageViewModel)));
}
}
}

View File

@ -191,11 +191,19 @@ namespace Wabbajack.App.ViewModels
};
_logger.LogInformation("Installer created, starting the installation process");
var result = await _installer.Begin(CancellationToken.None);
if (result)
try
{
await SaveConfigAndContinue(_config);
var result = await _installer.Begin(CancellationToken.None);
if (!result) throw new Exception("Installation failed");
if (result)
{
await SaveConfigAndContinue(_config);
}
}
catch (Exception ex)
{
ErrorPageViewModel.Display("During installation", ex);
}
}

View File

@ -45,6 +45,7 @@ namespace Wabbajack.App
services.AddDTOSerializer();
services.AddSingleton<ModeSelectionViewModel>();
services.AddTransient<FileSelectionBoxViewModel>();
services.AddSingleton<IScreenView, ErrorPageView>();
services.AddSingleton<IScreenView, LogScreenView>();
services.AddSingleton<IScreenView, ModeSelectionView>();
services.AddSingleton<IScreenView, InstallConfigurationView>();
@ -59,6 +60,7 @@ namespace Wabbajack.App
services.AddSingleton<HttpClient>();
services.AddSingleton<LogScreenViewModel>();
services.AddAllSingleton<IReceiverMarker, ErrorPageViewModel>();
services.AddAllSingleton<IReceiverMarker, StandardInstallationViewModel>();
services.AddAllSingleton<IReceiverMarker, InstallConfigurationViewModel>();
services.AddAllSingleton<IReceiverMarker, CompilerConfigurationViewModel>();

View File

@ -127,7 +127,7 @@ namespace Wabbajack.App.ViewModels
if (throughput != 0)
{
sb.Append(
$"{limiter.Name}: [{next.Running}/{next.Pending}] {throughput.ToFileSizeString()}/sec ");
$"{limiter.Name}: [{next.Running}/{next.Pending + next.Running}] {throughput.ToFileSizeString()}/sec ");
}
}

View File

@ -45,6 +45,9 @@
<DependentUpon>StandardInstallationView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Screens\LogScreenView.axaml.cs">
<DependentUpon>LogScreenView.axaml</DependentUpon>
</Compile>
</ItemGroup>
<Target Name="AferBuild" AfterTargets="Build" Condition="!Exists('$(ProjectDir)$(OutDir)libcef.dll')">

View File

@ -285,9 +285,12 @@ namespace Wabbajack.Installer
}
_logger.LogInformation("Downloading {count} archives", missing.Count);
NextStep("Downloading files", missing.Count);
await missing.Where(a => a.State is not Manual)
.PDo(_parallelOptions, async archive =>
await missing
.OrderBy(a => a.Size)
.Where(a => a.State is not Manual)
.PDoAll(async archive =>
{
_logger.LogInformation("Downloading {archive}", archive.Name);
var outputPath = _configuration.Downloads.Combine(archive.Name);
@ -303,6 +306,7 @@ namespace Wabbajack.Installer
}
await DownloadArchive(archive, download, token, outputPath);
UpdateProgress(1);
});
}

View File

@ -38,7 +38,7 @@ namespace Wabbajack.Installer
base(logger, config, gameLocator, extractor, jsonSerializer, vfs, fileHashCache, downloadDispatcher,
parallelOptions, wjClient)
{
MaxSteps = 6;
MaxSteps = 7;
}