Enable website/readme buttons on launcher

This commit is contained in:
Timothy Baldridge
2021-11-09 16:58:36 -07:00
parent 2a297d45b2
commit 6253f3d2ee
12 changed files with 115 additions and 19 deletions

View File

@ -4,13 +4,14 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Wabbajack.App.Controls.ResourceView"> x:Class="Wabbajack.App.Controls.ResourceView">
<StackPanel Orientation="Horizontal"> <Grid ColumnDefinitions="Auto, Auto, 300" RowDefinitions="20, 20, 20">
<TextBlock x:Name="ResourceName" Width="100" HorizontalAlignment="Left" VerticalAlignment="Center" /> <TextBlock Grid.Row="0" Grid.Column="0" x:Name="ResourceName"/>
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Tasks:</Label> <TextBlock Grid.Row="0" Grid.Column="1" >Total Throughput:</TextBlock>
<TextBox x:Name="MaxTasks" Width="20" HorizontalAlignment="Left" VerticalAlignment="Center" /> <TextBlock Grid.Row="0" Grid.Column="2" x:Name="CurrentThrougput"/>
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Throughput:</Label> <TextBlock Grid.Row="1" Grid.Column="1">Tasks:</TextBlock>
<TextBox x:Name="MaxThroughput" Width="20" HorizontalAlignment="Left" VerticalAlignment="Center" /> <ButtonSpinner Grid.Row="1" Grid.Column="2"></ButtonSpinner>
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Status:</Label> <TextBlock Grid.Row="2" Grid.Column="1">Throughput:</TextBlock>
<TextBlock x:Name="CurrentThrougput" Width="50" HorizontalAlignment="Left" VerticalAlignment="Center" /> <Slider Grid.Row="2" Grid.Column="2" Minimum="0" Maximum="16384"></Slider>
</StackPanel>
</Grid>
</UserControl> </UserControl>

View File

@ -15,10 +15,20 @@ public partial class ResourceView : ReactiveUserControl<ResourceViewModel>, IAct
this.OneWayBind(ViewModel, vm => vm.Name, view => view.ResourceName.Text) this.OneWayBind(ViewModel, vm => vm.Name, view => view.ResourceName.Text)
.DisposeWith(disposables); .DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.MaxTasks, view => view.MaxTasks.Text) //this.Bind(ViewModel, vm => vm.MaxTasks, view => view.MaxTasks.Text)
.DisposeWith(disposables); // .DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.MaxThroughput, view => view.MaxThroughput.Text) /*this.Bind(ViewModel, vm => vm.MaxThroughput, view => view.MaxThroughput.Text,
.DisposeWith(disposables); l => l is 0 or long.MaxValue ? "∞" : (l / 1024 / 1024).ToString(),
v =>
{
v = v.Trim();
if (v is "0" or "∞" || v == long.MaxValue.ToString())
{
return long.MaxValue;
}
return long.TryParse(v, out var l) ? l * 1024 * 1024 : long.MaxValue;
})
.DisposeWith(disposables);*/
this.OneWayBind(ViewModel, vm => vm.CurrentThroughput, view => view.CurrentThrougput.Text, this.OneWayBind(ViewModel, vm => vm.CurrentThroughput, view => view.CurrentThrougput.Text,
val => val.FileSizeToString()) val => val.FileSizeToString())

View File

@ -24,9 +24,9 @@
<TextBox Grid.Column="1" Grid.Row="1" IsEnabled="False" Height="20" x:Name="InstallPath" /> <TextBox Grid.Column="1" Grid.Row="1" IsEnabled="False" Height="20" x:Name="InstallPath" />
<Grid Grid.Column="1" Grid.Row="3" Grid.ColumnDefinitions="*, *, *" HorizontalAlignment="Center"> <Grid Grid.Column="1" Grid.Row="3" Grid.ColumnDefinitions="*, *, *" HorizontalAlignment="Center">
<Button Grid.Column="0" x:Name="WebsiteButton">Website</Button> <Button Grid.Column="0" x:Name="WebsiteButton" Click="ShowWebsite">Website</Button>
<Button Grid.Column="1" x:Name="ReadmeButton">Readme</Button> <Button Grid.Column="1" x:Name="ReadmeButton" Click="ShowReadme">Readme</Button>
<Button Grid.Column="2" x:Name="LocalFilesButton">Local Files</Button> <Button Grid.Column="2" x:Name="LocalFilesButton" Click="ShowLocalFiles">Local Files</Button>
</Grid> </Grid>
<controls:LargeIconButton x:Name="PlayGame" Margin="40, 0, 0, 0" Grid.Row="0" Grid.Column="2" <controls:LargeIconButton x:Name="PlayGame" Margin="40, 0, 0, 0" Grid.Row="0" Grid.Column="2"

View File

@ -1,6 +1,10 @@
using System;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using Avalonia.Interactivity;
using ReactiveUI; using ReactiveUI;
using Wabbajack.App.Utilities;
using Wabbajack.App.Views; using Wabbajack.App.Views;
using Wabbajack.Installer;
namespace Wabbajack.App.Screens; namespace Wabbajack.App.Screens;
@ -25,4 +29,19 @@ public partial class LauncherView : ScreenBase<LauncherViewModel>
.DisposeWith(disposables); .DisposeWith(disposables);
}); });
} }
private void ShowWebsite(object? sender, RoutedEventArgs e)
{
OSUtil.OpenWebsite(ViewModel!.Setting!.StrippedModListData?.Website!);
}
private void ShowReadme(object? sender, RoutedEventArgs e)
{
OSUtil.OpenWebsite(new Uri(ViewModel!.Setting!.StrippedModListData?.Readme!));
}
private void ShowLocalFiles(object? sender, RoutedEventArgs e)
{
OSUtil.OpenFolder(ViewModel!.Setting!.Install);
}
} }

View File

@ -225,7 +225,8 @@ public class StandardInstallationViewModel : ViewModelBase
Install = config.Install, Install = config.Install,
Metadata = config.Metadata, Metadata = config.Metadata,
ModList = config.ModlistArchive, ModList = config.ModlistArchive,
Image = path Image = path,
StrippedModListData = config.ModList.Strip()
}); });
MessageBus.Current.SendMessage(new ConfigureLauncher(config.Install)); MessageBus.Current.SendMessage(new ConfigureLauncher(config.Install));

View File

@ -0,0 +1,38 @@
using System;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis;
using Wabbajack.Common;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
namespace Wabbajack.App.Utilities;
public static class OSUtil
{
public static void OpenWebsite(Uri uri)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var helper = new ProcessHelper()
{
Path = "cmd.exe".ToRelativePath().RelativeTo(KnownFolders.WindowsSystem32),
Arguments = new[] {"/C", $"rundll32 url.dll,FileProtocolHandler {uri}"}
};
helper.Start().FireAndForget();
}
}
public static void OpenFolder(AbsolutePath path)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var helper = new ProcessHelper()
{
Path = "explorer.exe".ToRelativePath().RelativeTo(KnownFolders.Windows),
Arguments = new object[] {path}
};
helper.Start().FireAndForget();
}
}
}

View File

@ -124,7 +124,8 @@ public class InstallConfigurationViewModel : ViewModelBase, IActivatableViewMode
ModList = ModListPath, ModList = ModListPath,
Downloads = Download, Downloads = Download,
Install = Install, Install = Install,
Metadata = metadata Metadata = metadata,
StrippedModListData = ModList?.Strip()
}); });
await _settingsManager.Save("last-install-path", ModListPath); await _settingsManager.Save("last-install-path", ModListPath);

View File

@ -97,5 +97,7 @@ public class NexusLoginViewModel : GuidedWebViewModel
Cookies = cookies, Cookies = cookies,
ApiKey = key ApiKey = key
}); });
MessageBus.Current.SendMessage(new NavigateBack());
} }
} }

View File

@ -9,8 +9,11 @@ using System.Web;
using CefNet; using CefNet;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Wabbajack.App.Extensions; using Wabbajack.App.Extensions;
using Wabbajack.App.Messages;
using Wabbajack.DTOs.Logins; using Wabbajack.DTOs.Logins;
using Wabbajack.Services.OSIntegrated; using Wabbajack.Services.OSIntegrated;
using Xunit.Sdk;
using MessageBus = ReactiveUI.MessageBus;
namespace Wabbajack.App.ViewModels; namespace Wabbajack.App.ViewModels;
@ -87,6 +90,8 @@ public abstract class OAuthLoginViewModel<TLoginType> : GuidedWebViewModel
Cookies = cookies, Cookies = cookies,
ResultState = data! ResultState = data!
}); });
MessageBus.Current.SendMessage(new NavigateBack());
} }
private class AsyncSchemeHandler : CefSchemeHandlerFactory private class AsyncSchemeHandler : CefSchemeHandlerFactory

View File

@ -66,4 +66,20 @@ public class ModList
/// Whether the Modlist is NSFW or not /// Whether the Modlist is NSFW or not
/// </summary> /// </summary>
public bool IsNSFW { get; set; } public bool IsNSFW { get; set; }
public ModList Strip()
{
return new ModList
{
Author = Author,
Description = Description,
GameType = GameType,
Name = Name,
Readme = Readme,
WabbajackVersion = WabbajackVersion,
Website = Website,
Version = Version,
IsNSFW = IsNSFW,
};
}
} }

View File

@ -20,5 +20,5 @@ public class InstallationConfigurationSetting
public ModlistMetadata? Metadata { get; set; } public ModlistMetadata? Metadata { get; set; }
public AbsolutePath Image { get; set; } public AbsolutePath Image { get; set; }
public ModList? StrippedModListData { get; set; }
} }

View File

@ -11,6 +11,9 @@ public static class KnownFolders
public static AbsolutePath AppDataLocal => public static AbsolutePath AppDataLocal =>
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).ToAbsolutePath(); Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).ToAbsolutePath();
public static AbsolutePath WindowsSystem32 => Environment.GetFolderPath(Environment.SpecialFolder.System).ToAbsolutePath();
public static AbsolutePath WabbajackAppLocal => AppDataLocal.Combine("Wabbajack"); public static AbsolutePath WabbajackAppLocal => AppDataLocal.Combine("Wabbajack");
public static AbsolutePath CurrentDirectory => Directory.GetCurrentDirectory().ToAbsolutePath(); public static AbsolutePath CurrentDirectory => Directory.GetCurrentDirectory().ToAbsolutePath();
public static AbsolutePath Windows => Environment.GetFolderPath(Environment.SpecialFolder.Windows).ToAbsolutePath();
} }