Add prompt to ManualDownloader state

This commit is contained in:
Timothy Baldridge 2022-02-23 16:11:25 -07:00
parent 9d251cda83
commit c79decf0b2
2 changed files with 20 additions and 4 deletions

View File

@ -28,7 +28,8 @@ namespace Wabbajack.Lib.Downloaders
public async Task<AbstractDownloadState?> 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}"
};
}
}

View File

@ -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<Uri>();
@ -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();