From f450cdf030487039ce8851bce26680d87755a20a Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Mon, 19 Sep 2022 17:47:54 -0600 Subject: [PATCH] #### Version - 3.0.1.1 - 9/19/2022 * Auto install WebView2 if Windows doesn't already have it installed * Save settings before exiting the app * Add more logging to the launcher --- CHANGELOG.md | 5 ++++ Wabbajack.App.Wpf/App.xaml.cs | 3 +++ .../WebUserInterventionBase.cs | 2 +- .../View Models/BrowserWindowViewModel.cs | 2 +- Wabbajack.App.Wpf/Views/MainWindow.xaml.cs | 6 ++++- Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj | 1 + .../NexusDownloader.cs | 1 + .../ViewModels/MainWindowViewModel.cs | 26 ++++++++++++++----- 8 files changed, 37 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31898cfc..bc552923 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ### Changelog +#### Version - 3.0.1.1 - 9/19/2022 +* Auto install WebView2 if Windows doesn't already have it installed +* Save settings before exiting the app +* Add more logging to the launcher + #### Version - 3.0.1.0 - 9/19/2022 * Official release of the 3.0 codebase diff --git a/Wabbajack.App.Wpf/App.xaml.cs b/Wabbajack.App.Wpf/App.xaml.cs index cca23b65..4c155bec 100644 --- a/Wabbajack.App.Wpf/App.xaml.cs +++ b/Wabbajack.App.Wpf/App.xaml.cs @@ -17,6 +17,7 @@ using Wabbajack.Models; using Wabbajack.Services.OSIntegrated; using Wabbajack.UserIntervention; using Wabbajack.Util; +using WebView2.Runtime.AutoInstaller; namespace Wabbajack { @@ -30,6 +31,8 @@ namespace Wabbajack public App() { + WebView2AutoInstaller.CheckAndInstallAsync(false, false).Wait(); + RxApp.MainThreadScheduler = new DispatcherScheduler(Dispatcher.CurrentDispatcher); _host = Host.CreateDefaultBuilder(Array.Empty()) .ConfigureLogging(AddLogging) diff --git a/Wabbajack.App.Wpf/UserIntervention/WebUserInterventionBase.cs b/Wabbajack.App.Wpf/UserIntervention/WebUserInterventionBase.cs index bf60aa82..28e764a5 100644 --- a/Wabbajack.App.Wpf/UserIntervention/WebUserInterventionBase.cs +++ b/Wabbajack.App.Wpf/UserIntervention/WebUserInterventionBase.cs @@ -29,7 +29,7 @@ where T : IUserIntervention public BrowserView? Browser { get; set; } - private WebView2 _browser => Browser!.Browser; + private Microsoft.Web.WebView2.Wpf.WebView2 _browser => Browser!.Browser; public async Task RunWrapper(CancellationToken token) { diff --git a/Wabbajack.App.Wpf/View Models/BrowserWindowViewModel.cs b/Wabbajack.App.Wpf/View Models/BrowserWindowViewModel.cs index 310d8f31..55791505 100644 --- a/Wabbajack.App.Wpf/View Models/BrowserWindowViewModel.cs +++ b/Wabbajack.App.Wpf/View Models/BrowserWindowViewModel.cs @@ -28,7 +28,7 @@ public abstract class BrowserWindowViewModel : ViewModel public BrowserWindow? Browser { get; set; } - private WebView2 _browser => Browser!.Browser; + private Microsoft.Web.WebView2.Wpf.WebView2 _browser => Browser!.Browser; public async Task RunWrapper(CancellationToken token) { diff --git a/Wabbajack.App.Wpf/Views/MainWindow.xaml.cs b/Wabbajack.App.Wpf/Views/MainWindow.xaml.cs index 954a9b57..10abf269 100644 --- a/Wabbajack.App.Wpf/Views/MainWindow.xaml.cs +++ b/Wabbajack.App.Wpf/Views/MainWindow.xaml.cs @@ -55,7 +55,11 @@ namespace Wabbajack Closed += (s, e) => { - Environment.Exit(0); + Task.Run(async () => + { + await Task.Delay(5000); + Environment.Exit(0); + }); }; MessageBus.Current.Listen() diff --git a/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj b/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj index 57fa17c5..6078e02b 100644 --- a/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj +++ b/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj @@ -85,6 +85,7 @@ + diff --git a/Wabbajack.Downloaders.Nexus/NexusDownloader.cs b/Wabbajack.Downloaders.Nexus/NexusDownloader.cs index ef635b04..471bbd3e 100644 --- a/Wabbajack.Downloaders.Nexus/NexusDownloader.cs +++ b/Wabbajack.Downloaders.Nexus/NexusDownloader.cs @@ -134,6 +134,7 @@ public class NexusDownloader : ADownloader, IUrlDownloader } catch (HttpRequestException ex) { + _logger.LogError(ex, "While downloading from the Nexus {Message}", ex.Message); if (ex.StatusCode == HttpStatusCode.Forbidden) { return await DownloadManually(archive, state, destination, job, token); diff --git a/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs b/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs index a1311a6c..6e41396c 100644 --- a/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs +++ b/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs @@ -220,6 +220,12 @@ public class MainWindowViewModel : ViewModelBase Version.TryParse(v.FileName.ToString(), out var ver) ? ver : new Version(0, 0, 0, 0)) .FirstOrDefault(); + if (wjFolder == default) + { + _errors.Add("No WJ install found"); + throw new Exception("No WJ install found"); + } + var filename = wjFolder.Combine("Wabbajack.exe"); await CreateBatchFile(filename); var info = new ProcessStartInfo @@ -231,8 +237,9 @@ public class MainWindowViewModel : ViewModelBase }; Process.Start(info); } - catch (Exception) + catch (Exception ex) { + _errors.Add(ex.Message); if (_errors.Count == 0) { Status = "Failed: Unknown error"; @@ -253,11 +260,18 @@ public class MainWindowViewModel : ViewModelBase private async Task CreateBatchFile(AbsolutePath filename) { - filename = filename.Parent.Combine("wabbajack-cli.exe"); - var data = $"\"{filename}\" %*"; - var file = Path.Combine(Directory.GetCurrentDirectory(), "wabbajack-cli.bat"); - if (File.Exists(file) && await File.ReadAllTextAsync(file) == data) return; - await File.WriteAllTextAsync(file, data); + try + { + filename = filename.Parent.Combine("wabbajack-cli.exe"); + var data = $"\"{filename}\" %*"; + var file = Path.Combine(Directory.GetCurrentDirectory(), "wabbajack-cli.bat"); + if (File.Exists(file) && await File.ReadAllTextAsync(file) == data) return; + await File.WriteAllTextAsync(file, data); + } + catch (Exception ex) + { + _errors.Add($"Creating Batch File : {ex}"); + } } private void UpdateProgress(object sender, DownloadProgressChangedEventArgs e)