Bunch of fixes for Masterstroke

This commit is contained in:
Timothy Baldridge 2022-08-18 17:02:19 -06:00
parent 83673f07da
commit 306e90f6ef
7 changed files with 56 additions and 4 deletions

View File

@ -23,7 +23,11 @@ public class ManualDownloadHandler : BrowserWindowViewModel
Instructions = string.IsNullOrWhiteSpace(md.Prompt) ? $"Please download {archive.Name}" : md.Prompt;
await NavigateTo(md.Url);
var uri = await WaitForDownloadUri(token);
var uri = await WaitForDownloadUri(token, async () =>
{
await RunJavaScript("Array.from(document.getElementsByTagName(\"iframe\")).forEach(f => f.remove())");
});
Intervention.Finish(uri);
}

View File

@ -76,6 +76,11 @@ public abstract class BrowserWindowViewModel : ViewModel
_browser.NavigationCompleted -= Completed;
}
public async Task RunJavaScript(string script)
{
await _browser.ExecuteScriptAsync(script);
}
public async Task<Cookie[]> GetCookies(string domainEnding, CancellationToken token)
{
var cookies = (await _browser.CoreWebView2.CookieManager.GetCookiesAsync(""))
@ -103,7 +108,7 @@ public abstract class BrowserWindowViewModel : ViewModel
return doc;
}
public async Task<ManualDownload.BrowserDownloadState> WaitForDownloadUri(CancellationToken token)
public async Task<ManualDownload.BrowserDownloadState> WaitForDownloadUri(CancellationToken token, Func<Task>? whileWaiting)
{
var source = new TaskCompletionSource<Uri>();
var referer = _browser.Source;
@ -122,8 +127,22 @@ public abstract class BrowserWindowViewModel : ViewModel
args.Cancel = true;
args.Handled = true;
};
Uri uri;
while (true)
{
try
{
uri = await source.Task.WaitAsync(TimeSpan.FromMilliseconds(250), token);
break;
}
catch (TimeoutException)
{
if (whileWaiting != null)
await whileWaiting();
}
}
var uri = await source.Task.WaitAsync(token);
var cookies = await GetCookies(uri.Host, token);
return new ManualDownload.BrowserDownloadState(uri, cookies, new[]
{

View File

@ -256,7 +256,7 @@ namespace Wabbajack
.ObserveOnGuiThread()
.Subscribe(update =>
{
StatusText = update.EventArgs.StatusText;
StatusText = $"{update.EventArgs.StatusText} - {update.EventArgs.StepProgress}";
StatusProgress = update.EventArgs.StepsProgress;
});

View File

@ -352,6 +352,7 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
DownloadLoadction = Installer.DownloadLocation.TargetPath,
Metadata = ModlistMetadata
});
await _settingsManager.Save(LastLoadedModlist, ModListLocation.TargetPath);
try
{

View File

@ -53,6 +53,11 @@ namespace Wabbajack
Environment.Exit(-1);
};
Closed += (s, e) =>
{
Environment.Exit(0);
};
MessageBus.Current.Listen<TaskBarUpdate>()
.ObserveOnGuiThread()
.Subscribe(u =>

View File

@ -72,6 +72,9 @@ public class CompilerSettingsInferencer
if (file.FileName.WithoutExtension().ToString() == Consts.WABBAJACK_INCLUDE)
cs.Include = cs.Include.Add(file.Parent.RelativeTo(mo2Folder));
if (file.FileName.WithoutExtension().ToString() == Consts.WABBAJACK_NOMATCH_INCLUDE)
cs.NoMatchInclude = cs.NoMatchInclude.Add(file.Parent.RelativeTo(mo2Folder));
}
_logger.LogInformation("Finding Always Enabled mods");

View File

@ -180,6 +180,16 @@ public class NexusDownloader : ADownloader<Nexus>, IUrlDownloader
try
{
var fileInfo = await _api.FileInfo(state.Game.MetaData().NexusName!, state.ModID, state.FileID, token);
var (modInfo, _) = await _api.ModInfo(state.Game.MetaData().NexusName!, state.ModID, token);
state.Description = FixupSummary(modInfo.Summary);
state.Version = modInfo.Version;
state.Author = modInfo.Author;
state.ImageURL = new Uri(modInfo.PictureUrl);
state.Name = modInfo.Name;
state.IsNSFW = modInfo.ContainsAdultContent;
return fileInfo.info.FileId == state.FileID;
}
catch (HttpException)
@ -187,6 +197,16 @@ public class NexusDownloader : ADownloader<Nexus>, IUrlDownloader
return false;
}
}
public static string FixupSummary(string? argSummary)
{
if (argSummary == null)
return "";
return argSummary.Replace("&#39;", "'")
.Replace("<br/>", "\n\n")
.Replace("<br />", "\n\n")
.Replace("&#33;", "!");
}
public override IEnumerable<string> MetaIni(Archive a, Nexus state)
{