mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Bunch of fixes for Masterstroke
This commit is contained in:
parent
83673f07da
commit
306e90f6ef
@ -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);
|
||||
}
|
||||
|
@ -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[]
|
||||
{
|
||||
|
@ -256,7 +256,7 @@ namespace Wabbajack
|
||||
.ObserveOnGuiThread()
|
||||
.Subscribe(update =>
|
||||
{
|
||||
StatusText = update.EventArgs.StatusText;
|
||||
StatusText = $"{update.EventArgs.StatusText} - {update.EventArgs.StepProgress}";
|
||||
StatusProgress = update.EventArgs.StepsProgress;
|
||||
});
|
||||
|
||||
|
@ -352,6 +352,7 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
|
||||
DownloadLoadction = Installer.DownloadLocation.TargetPath,
|
||||
Metadata = ModlistMetadata
|
||||
});
|
||||
await _settingsManager.Save(LastLoadedModlist, ModListLocation.TargetPath);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -53,6 +53,11 @@ namespace Wabbajack
|
||||
Environment.Exit(-1);
|
||||
};
|
||||
|
||||
Closed += (s, e) =>
|
||||
{
|
||||
Environment.Exit(0);
|
||||
};
|
||||
|
||||
MessageBus.Current.Listen<TaskBarUpdate>()
|
||||
.ObserveOnGuiThread()
|
||||
.Subscribe(u =>
|
||||
|
@ -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");
|
||||
|
@ -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("'", "'")
|
||||
.Replace("<br/>", "\n\n")
|
||||
.Replace("<br />", "\n\n")
|
||||
.Replace("!", "!");
|
||||
}
|
||||
|
||||
public override IEnumerable<string> MetaIni(Archive a, Nexus state)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user