From c79decf0b28caf82fad180e2b57d7c1d9443a029 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Wed, 23 Feb 2022 16:11:25 -0700 Subject: [PATCH] Add prompt to ManualDownloader state --- Wabbajack.Lib/Downloaders/ManualDownloader.cs | 8 ++++++-- .../View Models/UserInterventionHandlers.cs | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Wabbajack.Lib/Downloaders/ManualDownloader.cs b/Wabbajack.Lib/Downloaders/ManualDownloader.cs index 34113416..6ff497b9 100644 --- a/Wabbajack.Lib/Downloaders/ManualDownloader.cs +++ b/Wabbajack.Lib/Downloaders/ManualDownloader.cs @@ -28,7 +28,8 @@ namespace Wabbajack.Lib.Downloaders public async Task GetDownloaderState(dynamic archiveINI, bool quickMode) { var url = archiveINI?.General?.manualURL; - return url != null ? new State(url) : null; + var prompt = archiveINI?.General?.prompt; + return url != null ? new State(url, prompt ?? "") : null; } public async Task Prepare() @@ -39,13 +40,15 @@ namespace Wabbajack.Lib.Downloaders public class State : AbstractDownloadState { public string Url { get; } + public string Prompt { get; } [JsonIgnore] public override object[] PrimaryKey => new object[] { Url }; - public State(string url) + public State(string url, string prompt) { Url = url; + Prompt = prompt; } public override bool IsWhitelisted(ServerWhitelist whitelist) @@ -89,6 +92,7 @@ namespace Wabbajack.Lib.Downloaders { "[General]", $"manualURL={Url}", + $"prompt={Prompt}" }; } } diff --git a/Wabbajack/View Models/UserInterventionHandlers.cs b/Wabbajack/View Models/UserInterventionHandlers.cs index 2257cc73..bf42be88 100644 --- a/Wabbajack/View Models/UserInterventionHandlers.cs +++ b/Wabbajack/View Models/UserInterventionHandlers.cs @@ -158,7 +158,13 @@ namespace Wabbajack private async Task HandleManualDownload(WebBrowserVM vm, CancellationTokenSource cancel, ManuallyDownloadFile manuallyDownloadFile) { var browser = new CefSharpWrapper(vm.Browser); - vm.Instructions = $"Please locate and download {manuallyDownloadFile.State.Url}"; + var prompt = manuallyDownloadFile.State.Prompt; + if (string.IsNullOrWhiteSpace(prompt)) + { + prompt = $"Please locate and download {manuallyDownloadFile.State.Url}"; + } + + vm.Instructions = prompt; var result = new TaskCompletionSource(); @@ -209,7 +215,13 @@ namespace Wabbajack private async Task HandleManualMegaDownload(WebBrowserVM vm, CancellationTokenSource cancel, ManuallyDownloadMegaFile manuallyDownloadFile) { var browser = new CefSharpWrapper(vm.Browser); - vm.Instructions = $"Please locate and download {manuallyDownloadFile.State.Url}"; + var prompt = manuallyDownloadFile.State.Prompt; + if (string.IsNullOrWhiteSpace(prompt)) + { + prompt = $"Please locate and download {manuallyDownloadFile.State.Url}"; + } + + vm.Instructions = prompt; await vm.Driver.WaitForInitialized(); var tcs = new TaskCompletionSource();