Previous work, plus the new discord link

This commit is contained in:
Timothy Baldridge 2022-03-28 22:25:29 -06:00
parent 147bd70e9d
commit d9c099273a
15 changed files with 110 additions and 20 deletions

View File

@ -1,5 +1,9 @@
### Changelog
#### Version - 2.5.3.10 - 3/26/2022
* Report file sizes before generating patches
* When displaying a browser, we now show the navigated to Url (and a copy to clipboard button)
#### Version - 2.5.3.9 - 2/27/2022
* Manual downloader is now more tolerant of LoversLab's inane server instability

View File

@ -6,8 +6,8 @@
<AssemblyName>wabbajack-cli</AssemblyName>
<Company>Wabbajack</Company>
<Platforms>x64</Platforms>
<AssemblyVersion>2.5.3.9</AssemblyVersion>
<FileVersion>2.5.3.9</FileVersion>
<AssemblyVersion>2.5.3.10</AssemblyVersion>
<FileVersion>2.5.3.10</FileVersion>
<Copyright>Copyright © 2019-2021</Copyright>
<Description>An automated ModList installer</Description>
<PublishReadyToRun>true</PublishReadyToRun>

View File

@ -4,8 +4,8 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<AssemblyVersion>2.5.3.9</AssemblyVersion>
<FileVersion>2.5.3.9</FileVersion>
<AssemblyVersion>2.5.3.10</AssemblyVersion>
<FileVersion>2.5.3.10</FileVersion>
<Copyright>Copyright © 2019-2020</Copyright>
<Description>Wabbajack Application Launcher</Description>
<PublishReadyToRun>true</PublishReadyToRun>

View File

@ -433,13 +433,21 @@ namespace Wabbajack.Lib
await VFS.Extract(iqueue, new[] {destFile}.ToHashSet(),
async (destvf, destsfn) =>
{
Info($"Patching {match.To}");
Status($"Patching {match.To}");
await using var srcStream = await sf.GetStream();
await using var destStream = await destsfn.GetStream();
Info($"Patching {match.To} ({srcStream.Length.ToFileSizeString()}");
Status($"Patching {match.To} ({srcStream.Length.ToFileSizeString()}");
try
{
var patchSize =
await Utils.CreatePatchCached(srcStream, vf.Hash, destStream, destvf.Hash);
Info($"Patch size {patchSize} for {match.To}");
}
catch (Exception ex)
{
Error($"Error while building patch for {match.To} ({srcStream.Length.ToFileSizeString()} {ex}");
throw;
}
});
}
});

View File

@ -69,10 +69,11 @@ namespace Wabbajack.Lib.Downloaders
{
}
public async Task<Helpers.Cookie[]> GetAndCacheCookies(IWebDriver browser, Action<string> updateStatus, CancellationToken cancel)
public async Task<Helpers.Cookie[]> GetAndCacheCookies(Action<Uri> syncFn, IWebDriver browser, Action<string> updateStatus, CancellationToken cancel)
{
updateStatus($"Please Log Into {SiteName}");
await browser.NavigateTo(_loginUri);
syncFn(_loginUri);
var cookies = new Helpers.Cookie[0];
while (true)
{

View File

@ -73,6 +73,9 @@ namespace Wabbajack.Lib.ModListRegistry
[JsonProperty("machineURL")]
public string MachineURL { get; set; } = string.Empty;
[JsonProperty("discordURL")]
public string DiscordURL { get; set; } = string.Empty;
}
public static async Task<List<ModlistMetadata>> LoadFromGithub()

View File

@ -85,10 +85,11 @@ namespace Wabbajack.Lib.NexusApi
return result;
}
public static async Task<string> SetupNexusLogin(IWebDriver browser, Action<string> updateStatus, CancellationToken cancel)
public static async Task<string> SetupNexusLogin(Action syncFn, IWebDriver browser, Action<string> updateStatus, CancellationToken cancel)
{
updateStatus("Please log into the Nexus");
await browser.NavigateTo(new Uri("https://users.nexusmods.com/auth/continue?client_id=nexus&redirect_uri=https://www.nexusmods.com/oauth/callback&response_type=code&referrer=//www.nexusmods.com"));
syncFn();
Helpers.Cookie[] cookies = {};
while (true)
@ -102,6 +103,7 @@ namespace Wabbajack.Lib.NexusApi
await browser.NavigateTo(new Uri("https://www.nexusmods.com/users/myaccount?tab=api"));
syncFn();
updateStatus("Saving login info");

View File

@ -87,6 +87,7 @@ namespace Wabbajack
// Command properties
public ReactiveCommand<Unit, Unit> ShowManifestCommand { get; }
public ReactiveCommand<Unit, Unit> OpenDiscordCommand { get; }
public ReactiveCommand<Unit, Unit> OpenReadmeCommand { get; }
public ReactiveCommand<Unit, Unit> VisitModListWebsiteCommand { get; }
@ -325,6 +326,13 @@ namespace Wabbajack
.Select(x => x?.SourceModList != null)
.ObserveOnGuiThread());
OpenDiscordCommand = ReactiveCommand.Create(() =>
{
Utils.OpenWebsite(new Uri(ModList.SourceModListMetadata.Links.DiscordURL));
}, this.WhenAny(x => x.ModList)
.Select(x => Uri.TryCreate(x?.SourceModListMetadata?.Links?.DiscordURL ?? "", UriKind.Absolute, out _))
.ObserveOnGuiThread());
OpenReadmeCommand = ReactiveCommand.Create(
execute: () => this.ModList?.OpenReadme(),
canExecute: this.WhenAny(x => x.ModList)

View File

@ -70,7 +70,8 @@ namespace Wabbajack
await WrapBrowserJob(c, async (vm, cancel) =>
{
await vm.Driver.WaitForInitialized();
var key = await NexusApiClient.SetupNexusLogin(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
var cef = new CefSharpWrapper(vm.Browser);
var key = await NexusApiClient.SetupNexusLogin(() => vm.SyncTo(cef), cef, m => vm.Instructions = m, cancel.Token);
c.Resume(key);
});
break;
@ -90,7 +91,8 @@ namespace Wabbajack
await WrapBrowserJob(c, async (vm, cancel) =>
{
await vm.Driver.WaitForInitialized();
var data = await c.Downloader.GetAndCacheCookies(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
var cef = new CefSharpWrapper(vm.Browser);
var data = await c.Downloader.GetAndCacheCookies(url => vm.SyncTo(cef), cef, m => vm.Instructions = m, cancel.Token);
c.Resume(data);
});
break;
@ -153,6 +155,7 @@ namespace Wabbajack
};
await wrapper.NavigateTo(new Uri(oa.AuthorizationEndpoint + $"?response_type=code&client_id={oa.ClientID}&state={state}&scope={scopes}"));
vm.SyncTo(wrapper);
while (!oa.Task.IsCanceled && !oa.Task.IsCompleted && !cancel.IsCancellationRequested)
await Task.Delay(250);
@ -176,6 +179,7 @@ namespace Wabbajack
using var _ = browser.SetDownloadHandler(new ManualDownloadHandler(result));
await browser.NavigateTo(new Uri(manuallyDownloadFile.State.Url));
vm.SyncTo(browser);
while (!cancel.IsCancellationRequested)
{
@ -232,6 +236,7 @@ namespace Wabbajack
using var _ = browser.SetDownloadHandler(new BlobDownloadHandler(manuallyDownloadFile.Destination, tcs));
await browser.NavigateTo(new Uri(manuallyDownloadFile.State.Url));
vm.SyncTo(browser);
while (!cancel.IsCancellationRequested && !tcs.Task.IsCompleted)
{
@ -263,6 +268,7 @@ namespace Wabbajack
await browser.NavigateTo(new Uri(manuallyDownloadFile.State.Url));
vm.SyncTo(browser);
while (!cancel.IsCancellationRequested && !tcs.Task.IsCompleted)
{
@ -328,6 +334,7 @@ namespace Wabbajack
var url = new Uri(@$"https://www.nexusmods.com/{game.NexusName}/mods/{state.ModID}?tab=files&file_id={state.FileID}");
await browser.NavigateTo(url);
vm.SyncTo(browser);
while (!cancel.IsCancellationRequested && !tcs.Task.IsCompleted) {
await Task.Delay(250);

View File

@ -6,6 +6,7 @@ using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
using CefSharp;
using CefSharp.Wpf;
using ReactiveUI;
@ -21,6 +22,9 @@ namespace Wabbajack
[Reactive]
public string Instructions { get; set; }
[Reactive]
public string UrlText { get; set; }
public IWebBrowser Browser { get; } = new ChromiumWebBrowser();
public CefSharpWrapper Driver => new CefSharpWrapper(Browser);
@ -50,5 +54,13 @@ namespace Wabbajack
Browser.Dispose();
base.Dispose();
}
public void SyncTo(CefSharpWrapper browser)
{
Dispatcher.CurrentDispatcher.Invoke(() =>
{
UrlText = browser.Location;
});
}
}
}

View File

@ -211,11 +211,12 @@
<ColumnDefinition Width="4" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Margin="10">
<Grid Grid.Column="0" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Row="0"
x:Name="OpenReadmePreInstallButton"
@ -283,6 +284,28 @@
Text="Manifest" />
</Grid>
</Button>
<Button Grid.Row="4"
x:Name="OpenDiscordButton"
Margin="30,5"
FontSize="20"
Style="{StaticResource LargeButtonStyle}"
ToolTip="Open a link to the official discord for this modlist">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="82" />
</Grid.ColumnDefinitions>
<icon:PackIconMaterial Grid.Column="0"
Width="30"
Height="30"
VerticalAlignment="Center"
Kind="Discord" />
<TextBlock Grid.Column="1"
Margin="10,0,0,0"
VerticalAlignment="Center"
Text="Discord" />
</Grid>
</Button>
</Grid>
<local:InstallationConfigurationView Grid.Column="2"
x:Name="InstallationConfigurationView"

View File

@ -106,6 +106,9 @@ namespace Wabbajack
this.WhenAny(x => x.ViewModel.ShowManifestCommand)
.BindToStrict(this, x => x.ShowManifestPreInstallButton.Command)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.OpenDiscordCommand)
.BindToStrict(this, x => x.OpenDiscordButton.Command)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.StartedInstallation)
.Select(started => started ? Visibility.Collapsed : Visibility.Visible)
.BindToStrict(this, x => x.InstallationConfigurationView.Visibility)

View File

@ -43,9 +43,10 @@
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid Background="White">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="47" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<wabbajack:TopProgressView Grid.Row="0" Grid.RowSpan="1"
@ -64,7 +65,20 @@
ToolTip="Back to main menu">
<iconPacks:PackIconMaterial Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Kind="ArrowLeft" />
</Button>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Margin="4" Click="CopyClick">
<iconPacks:PackIconMaterial Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Kind="ContentCopy" />
</Button>
<TextBox Grid.Column="1" Margin="4" IsEnabled="False" Text="{Binding UrlText}"/>
</Grid>
<!-- Do it this way so we can access the browser directly from the VM -->
<ContentControl Grid.Row="1" Content="{Binding Browser}" />
<Grid Grid.Row="2" Background="White">
<ContentControl Content="{Binding Browser}" />
</Grid>
</Grid>
</UserControl>

View File

@ -24,5 +24,10 @@ namespace Wabbajack
{
InitializeComponent();
}
private void CopyClick(object sender, RoutedEventArgs e)
{
Clipboard.SetText(((WebBrowserVM)DataContext).UrlText);
}
}
}

View File

@ -6,8 +6,8 @@
<UseWPF>true</UseWPF>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<AssemblyVersion>2.5.3.9</AssemblyVersion>
<FileVersion>2.5.3.9</FileVersion>
<AssemblyVersion>2.5.3.10</AssemblyVersion>
<FileVersion>2.5.3.10</FileVersion>
<Copyright>Copyright © 2019-2021</Copyright>
<Description>An automated ModList installer</Description>
<PublishReadyToRun>true</PublishReadyToRun>