Basic settings page that just shows logins for now

This commit is contained in:
Justin Swanson 2020-01-04 21:09:02 -06:00
parent 43aca88879
commit e49f1dd5ca
15 changed files with 195 additions and 157 deletions

View File

@ -5,11 +5,12 @@ using System.IO;
using System.Reactive;
using System.Reactive.Subjects;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack
{
[JsonObject(MemberSerialization.OptOut)]
public class MainSettings
public class MainSettings : ViewModel
{
private static string _filename = "settings.json";
@ -21,7 +22,7 @@ namespace Wabbajack
public CompilerSettings Compiler { get; set; } = new CompilerSettings();
private Subject<Unit> _saveSignal = new Subject<Unit>();
[JsonIgnoreAttribute]
[JsonIgnore]
public IObservable<Unit> SaveSignal => _saveSignal;
public static bool TryLoadTypicalSettings(out MainSettings settings)

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wabbajack.Common;
namespace Wabbajack.UserInterventions
{
public class ShowLoginManager : AUserIntervention
{
public override string ShortDescription => "User requested to show the login manager";
public override string ExtendedDescription => "User requested to show the UI for managing all the logins supported by Wabbajack";
public override void Cancel()
{
}
}
}

View File

@ -35,14 +35,15 @@ namespace Wabbajack
public readonly Lazy<CompilerVM> Compiler;
public readonly Lazy<InstallerVM> Installer;
public readonly Lazy<SettingsVM> SettingsPane;
public readonly Lazy<ModListGalleryVM> Gallery;
public readonly ModeSelectionVM ModeSelectionVM;
public readonly UserInterventionHandlers UserInterventionHandlers;
public readonly LoginManagerVM LoginManagerVM;
public ICommand CopyVersionCommand { get; }
public ICommand ShowLoginManagerVM { get; }
public ICommand OpenSettingsCommand { get; }
public string VersionDisplay { get; }
public MainWindowVM(MainWindow mainWindow, MainSettings settings)
@ -51,10 +52,10 @@ namespace Wabbajack
Settings = settings;
Installer = new Lazy<InstallerVM>(() => new InstallerVM(this));
Compiler = new Lazy<CompilerVM>(() => new CompilerVM(this));
SettingsPane = new Lazy<SettingsVM>(() => new SettingsVM(this));
Gallery = new Lazy<ModListGalleryVM>(() => new ModListGalleryVM(this));
ModeSelectionVM = new ModeSelectionVM(this);
UserInterventionHandlers = new UserInterventionHandlers(this);
LoginManagerVM = new LoginManagerVM(this);
// Set up logging
Utils.LogMessages
@ -123,6 +124,10 @@ namespace Wabbajack
{
Clipboard.SetText($"Wabbajack {VersionDisplay}\n{ThisAssembly.Git.Sha}");
});
OpenSettingsCommand = ReactiveCommand.Create(
canExecute: this.WhenAny(x => x.ActivePane)
.Select(active => !SettingsPane.IsValueCreated || !object.ReferenceEquals(active, SettingsPane.Value)),
execute: () => NavigateTo(SettingsPane.Value));
}
private static bool IsStartingFromModlist(out string modlistPath)
{

View File

@ -4,9 +4,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Lib;
using Wabbajack.Lib.Downloaders;
namespace Wabbajack
@ -15,8 +12,8 @@ namespace Wabbajack
{
public List<INeedsLogin> Downloaders { get; }
public LoginManagerVM(MainWindowVM mainWindowVM)
: base(mainWindowVM)
public LoginManagerVM(SettingsVM settingsVM)
: base(settingsVM.MWVM)
{
Downloaders = DownloadDispatcher.Downloaders.OfType<INeedsLogin>().ToList();
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ReactiveUI;
using Wabbajack.Lib;
namespace Wabbajack
{
public class SettingsVM : BackNavigatingVM
{
public MainWindowVM MWVM { get; }
public LoginManagerVM LoginManagerVM { get; }
public SettingsVM(MainWindowVM mainWindowVM)
: base(mainWindowVM)
{
MWVM = mainWindowVM;
LoginManagerVM = new LoginManagerVM(this);
}
}
}

View File

@ -11,7 +11,6 @@ using Wabbajack.Common;
using Wabbajack.Lib.Downloaders;
using Wabbajack.Lib.NexusApi;
using Wabbajack.Lib.WebAutomation;
using Wabbajack.UserInterventions;
namespace Wabbajack
{
@ -76,9 +75,6 @@ namespace Wabbajack
break;
case ConfirmationIntervention c:
break;
case ShowLoginManager c:
MainWindow.NavigateTo(MainWindow.LoginManagerVM);
break;
default:
throw new NotImplementedException($"No handler for {msg}");
}

View File

@ -12,22 +12,10 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="0"
Width="35"
Height="35"
Click="ConfigureLogins_Click"
Style="{StaticResource IconBareButtonStyle}">
<icon:PackIconMaterial
Width="25"
Height="25"
Kind="Cogs" />
</Button>
<Button
Grid.Column="1"
Width="35"
Width="40"
Height="35"
Click="GitHub_Click"
Style="{StaticResource IconBareButtonStyle}">
@ -37,8 +25,8 @@
Kind="GithubCircle" />
</Button>
<Button
Grid.Column="2"
Width="35"
Grid.Column="1"
Width="40"
Height="35"
Margin="4,0,0,0"
Click="Patreon_Click"
@ -49,8 +37,8 @@
Kind="Patreon" />
</Button>
<Button
Grid.Column="3"
Width="35"
Grid.Column="2"
Width="40"
Height="35"
Click="Discord_Click"
Style="{StaticResource IconBareButtonStyle}">

View File

@ -2,7 +2,6 @@
using System.Windows;
using System.Windows.Controls;
using Wabbajack.Common;
using Wabbajack.UserInterventions;
namespace Wabbajack
{
@ -30,10 +29,5 @@ namespace Wabbajack
{
Process.Start("https://www.patreon.com/user?u=11907933");
}
private void ConfigureLogins_Click(object sender, RoutedEventArgs e)
{
Utils.Log(new ShowLoginManager());
}
}
}

View File

@ -1,89 +0,0 @@
<UserControl x:Class="Wabbajack.LoginManagerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:wabbajack="clr-namespace:Wabbajack"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Color x:Key="TextBackgroundFill">#92000000</Color>
<SolidColorBrush x:Key="TextBackgroundFillBrush" Color="{StaticResource TextBackgroundFill}" />
<Color x:Key="TextBackgroundHoverFill">#DF000000</Color>
<Style x:Key="BackgroundBlurStyle" TargetType="TextBlock">
<Setter Property="Background" Value="{StaticResource TextBackgroundFillBrush}" />
<Setter Property="Foreground" Value="Transparent" />
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetProperty="(TextBlock.Background).(SolidColorBrush.Color)"
To="{StaticResource TextBackgroundHoverFill}"
Duration="0:0:0.06" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetProperty="(TextBlock.Background).(SolidColorBrush.Color)"
To="{StaticResource TextBackgroundFill}"
Duration="0:0:0.06" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="47" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<wabbajack:TopProgressView
Title="Login Manager"
Grid.Row="0"
Grid.RowSpan="2"
ShadowMargin="False" />
<Button
x:Name="BackButton"
Grid.Row="0"
Width="30"
Height="30"
Margin="7,5,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Command="{Binding BackCommand}"
Style="{StaticResource IconCircleButtonStyle}"
ToolTip="Back to main menu">
<iconPacks:PackIconMaterial Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Kind="ArrowLeft" />
</Button>
<!-- Do it this way so we can access the browser directly from the VM -->
<ListView Grid.Row="1" ItemsSource="{Binding Downloaders}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Height="30" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48"></ColumnDefinition>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Source="{Binding IconUrl, Mode=OneTime}"></Image>
<Label Grid.Column="1" Width="400" Content="{Binding SiteName, Mode=OneTime}" FontSize="14"></Label>
<Label Grid.Column="2" Width="400" Content="{Binding MetaInfo, Mode=OneWay}" FontSize="14"></Label>
<Button Grid.Column="3" Content="Login" Command="{Binding TriggerLogin}" Margin="5"></Button>
<Button Grid.Column="4" Content="Logout" Command="{Binding ClearLogin}" Margin="5"></Button>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</UserControl>

View File

@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:local="clr-namespace:Wabbajack"
xmlns:mahapps="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -39,18 +40,36 @@
<DataTemplate DataType="{x:Type local:WebBrowserVM}">
<local:WebBrowserView />
</DataTemplate>
<DataTemplate DataType="{x:Type local:SettingsVM}">
<local:SettingsView />
</DataTemplate>
</ContentPresenter.Resources>
</ContentPresenter>
<mahapps:MetroWindow.RightWindowCommands>
<mahapps:WindowCommands>
<Button Command="{Binding CopyVersionCommand}" Content="{Binding VersionDisplay}">
<mahapps:WindowCommands.Resources>
<Style BasedOn="{StaticResource IconBareButtonStyle}" TargetType="Button" />
</mahapps:WindowCommands.Resources>
<Button
Margin="5,0"
Command="{Binding CopyVersionCommand}"
Content="{Binding VersionDisplay}">
<Button.ToolTip>
<TextBlock>
Wabbajack Version<LineBreak />
Click to copy to clipboard</TextBlock>
</Button.ToolTip>
</Button>
<Button
Grid.Column="1"
Margin="5,0"
Command="{Binding OpenSettingsCommand}">
<icon:PackIconMaterial
Width="17"
Height="17"
Kind="Settings" />
</Button>
</mahapps:WindowCommands>
</mahapps:MetroWindow.RightWindowCommands>
</mahapps:MetroWindow>

View File

@ -0,0 +1,50 @@
<UserControl
x:Class="Wabbajack.LoginManagerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wabbajack"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid>
<!-- Do it this way so we can access the browser directly from the VM -->
<ListView Background="{StaticResource WindowBackgroundBrush}" ItemsSource="{Binding Downloaders}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Height="30" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Source="{Binding IconUrl, Mode=OneTime}" />
<Label
Grid.Column="1"
Width="400"
Content="{Binding SiteName, Mode=OneTime}"
FontSize="14" />
<Label
Grid.Column="2"
Width="400"
Content="{Binding MetaInfo, Mode=OneWay}"
FontSize="14" />
<Button
Grid.Column="3"
Margin="5"
Command="{Binding TriggerLogin}"
Content="Login" />
<Button
Grid.Column="4"
Margin="5"
Command="{Binding ClearLogin}"
Content="Logout" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</UserControl>

View File

@ -0,0 +1,37 @@
<UserControl
x:Class="Wabbajack.SettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:local="clr-namespace:Wabbajack"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="47" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<local:TopProgressView
Title="Settings"
Grid.Row="0"
Grid.RowSpan="2"
ShadowMargin="False" />
<Button
x:Name="BackButton"
Grid.Row="0"
Width="30"
Height="30"
Margin="7,5,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Command="{Binding BackCommand}"
Style="{StaticResource IconCircleButtonStyle}"
ToolTip="Back to main menu">
<iconPacks:PackIconMaterial Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Kind="ArrowLeft" />
</Button>
<local:LoginManagerView Grid.Row="1" DataContext="{Binding LoginManagerVM}" />
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Wabbajack
{
/// <summary>
/// Interaction logic for SettingsView.xaml
/// </summary>
public partial class SettingsView : UserControl
{
public SettingsView()
{
InitializeComponent();
}
}
}

View File

@ -173,6 +173,10 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="View Models\BackNavigatingVM.cs" />
<Compile Include="View Models\Settings\SettingsVM.cs" />
<Compile Include="Views\Settings\SettingsView.xaml.cs">
<DependentUpon>SettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Common\AttentionBorder.xaml.cs">
<DependentUpon>AttentionBorder.xaml</DependentUpon>
</Compile>
@ -180,10 +184,9 @@
<Compile Include="Views\Common\UnderMaintenanceOverlay.xaml.cs">
<DependentUpon>UnderMaintenanceOverlay.xaml</DependentUpon>
</Compile>
<Compile Include="UserInterventions\ShowLoginManager.cs" />
<Compile Include="Util\AsyncLazy.cs" />
<Compile Include="View Models\CPUDisplayVM.cs" />
<Compile Include="View Models\LoginManagerVM.cs" />
<Compile Include="View Models\Settings\LoginManagerVM.cs" />
<Compile Include="Views\Compilers\CompilationCompleteView.xaml.cs">
<DependentUpon>CompilationCompleteView.xaml</DependentUpon>
</Compile>
@ -219,9 +222,6 @@
<Compile Include="Views\LinksView.xaml.cs">
<DependentUpon>LinksView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\LoginManagerView.xaml.cs">
<DependentUpon>LoginManagerView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ModeSelectionView.xaml.cs">
<DependentUpon>ModeSelectionView.xaml</DependentUpon>
</Compile>
@ -270,6 +270,9 @@
<Compile Include="Views\ModListGalleryView.xaml.cs">
<DependentUpon>ModListGalleryView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Settings\LoginManagerView.xaml.cs">
<DependentUpon>LoginManagerView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TextViewer.xaml.cs">
<DependentUpon>TextViewer.xaml</DependentUpon>
</Compile>
@ -283,6 +286,10 @@
<Compile Include="Views\WebBrowserView.xaml.cs">
<DependentUpon>WebBrowserView.xaml</DependentUpon>
</Compile>
<Page Include="Views\Settings\SettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Common\AttentionBorder.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -327,10 +334,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\LoginManagerView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ModeSelectionView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -389,6 +392,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Settings\LoginManagerView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\TextViewer.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -574,5 +581,8 @@
<ItemGroup>
<SplashScreen Include="Resources\Wabba_Mouth_Small.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="UserInterventions\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>