Actually make the recently compiled modlists section work, overhaul card view of compiled lists

This commit is contained in:
trawzified 2024-05-04 16:25:24 +02:00
parent e2106a0c14
commit 1e61bcaf45
7 changed files with 326 additions and 229 deletions

156
;
View File

@ -1,12 +1,144 @@
using System.Windows.Input;
using Wabbajack.Messages;
namespace Wabbajack.App.Wpf.Models.NavigationItems
{
public interface INavigationItem
{
public ICommand GoToCommand { get; }
public NavigateToGlobal.ScreenType Screen { get; }
public bool MainMenuItem { get; }
}
}
<rxui:ReactiveUserControl
x:Class="Wabbajack.CreatedModListTileView"
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:mahapps="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:rxui="http://reactiveui.net"
d:DesignHeight="450"
d:DesignWidth="800"
x:TypeArguments="local:CreatedModlistVM"
mc:Ignorable="d">
<Grid Margin="10, 0, 10, 16" x:Name="CompiledModListTile">
<Border Name="BorderMask2" CornerRadius="10" BorderThickness="0" Background="White" Margin="1" />
<StackPanel Orientation="Vertical" Background="{StaticResource DarkBackgroundBrush}">
<StackPanel.Effect>
<DropShadowEffect BlurRadius="25" Opacity="0.25" ShadowDepth="3" />
</StackPanel.Effect>
<StackPanel.OpacityMask>
<VisualBrush Visual="{Binding ElementName=BorderMask2}"/>
</StackPanel.OpacityMask>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Background="Transparent" BorderThickness="0">
<Border.Style>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="{StaticResource ButtonBorder}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<Setter Property="BorderBrush" Value="{StaticResource BorderInterestBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Border x:Name="MaskBorder" BorderThickness="0" BorderBrush="Transparent" Background="{StaticResource DarkSecondaryBrush}" Width="300" Height="169"/>
<Grid Width="300" Height="169" Background="Transparent" ClipToBounds="True">
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=MaskBorder}"/>
</Grid.OpacityMask>
<Grid ClipToBounds="True">
<mahapps:ProgressRing x:Name="LoadingProgress" />
<Border BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Border.Background>
<ImageBrush x:Name="ModlistImage" Stretch="UniformToFill"/>
</Border.Background>
</Border>
<Rectangle Height="120" Margin="-80, -75, -80, 0" VerticalAlignment="Top" Fill="White" Opacity="0.15">
<Rectangle.Effect>
<BlurEffect Radius="100" />
</Rectangle.Effect>
<Rectangle.Style>
<Style TargetType="Rectangle">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.3" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.15" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
<Rectangle Height="120" Margin="-80, 0, -80, -75" VerticalAlignment="Bottom" Fill="Black" Opacity="0.4">
<Rectangle.Effect>
<BlurEffect Radius="100" />
</Rectangle.Effect>
<Rectangle.Style>
<Style TargetType="Rectangle">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="0.7"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.4" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
<Label Margin="10,242,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Content="{Binding CompilerSettings.Version}" Opacity="0">
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
</Grid>
</Grid>
</Grid>
</Border>
</Grid>
<TextBlock FontSize="20" Text="{Binding CompilerSettings.ModListName}" Margin="10, 10, 10, 0"/>
<TextBlock Text="{Binding CompilerSettings.Source}" FontSize="14" Opacity="0.5" Margin="10, 10, 10, 10"/>
</StackPanel>
</Grid>
</rxui:ReactiveUserControl>

View File

@ -0,0 +1,18 @@
using ReactiveUI;
using Wabbajack.Compiler;
namespace Wabbajack.Messages;
public class LoadModlistForCompiling
{
public CompilerSettings CompilerSettings { get; set; }
public LoadModlistForCompiling(CompilerSettings cs)
{
CompilerSettings = cs;
}
public static void Send(CompilerSettings cs)
{
MessageBus.Current.SendMessage(new LoadModlistForCompiling(cs));
}
}

View File

@ -114,6 +114,10 @@ namespace Wabbajack
_inferencer = inferencer;
_wjClient = wjClient;
MessageBus.Current.Listen<LoadModlistForCompiling>()
.Subscribe(msg => LoadCompilerSettings(msg.CompilerSettings))
.DisposeWith(CompositeDisposable);
StatusText = "Compiler Settings";
StatusProgress = Percent.Zero;
@ -186,7 +190,7 @@ namespace Wabbajack
.BindToStrict(this, vm => vm.ErrorState)
.DisposeWith(disposables);
LoadLastSavedSettings().FireAndForget();
//LoadLastSavedSettings().FireAndForget();
});
}
@ -240,6 +244,16 @@ namespace Wabbajack
return;
}
LoadCompilerSettings(settings);
if (path.FileName == "modlist.txt".ToRelativePath())
{
await LoadLastSavedSettings();
}
}
private void LoadCompilerSettings(CompilerSettings settings)
{
BaseGame = settings.Game;
ModListName = settings.ModListName;
Version = settings.Version?.ToString() ?? "";
@ -249,7 +263,7 @@ namespace Wabbajack
Website = settings.ModListWebsite?.ToString() ?? "";
Readme = settings.ModListReadme?.ToString() ?? "";
IsNSFW = settings.ModlistIsNSFW;
Source = settings.Source;
DownloadLocation.TargetPath = settings.Downloads;
if (settings.OutputFile.Extension == Ext.Wabbajack)
@ -263,13 +277,8 @@ namespace Wabbajack
NoMatchInclude = settings.NoMatchInclude;
Include = settings.Include;
Ignore = settings.Ignore;
if (path.FileName == "modlist.txt".ToRelativePath())
{
await LoadLastSavedSettings();
}
}
private async Task StartCompilation()
{
var tsk = Task.Run(async () =>
@ -399,7 +408,6 @@ namespace Wabbajack
ModlistLocation.TargetPath = lastPath;
}
private CompilerSettings GetSettings()
{

View File

@ -1,17 +1,18 @@
using System.Linq;
using System.Threading;
using System.Windows.Input;
using Microsoft.Extensions.Logging;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Compiler;
using Wabbajack.DTOs;
using Wabbajack.Networking.WabbajackClientApi;
using Wabbajack.Services.OSIntegrated.Services;
using Wabbajack.Messages;
using Wabbajack.Models;
namespace Wabbajack
{
public class CreatedModlistVM
{
private ILogger _logger;
public LoadingLock LoadingImageLock { get; } = new();
public ICommand CompileModListCommand { get; set; }
[Reactive]
public CompilerSettings CompilerSettings { get; set; }
@ -19,6 +20,14 @@ namespace Wabbajack
{
_logger = logger;
CompilerSettings = compilerSettings;
CompileModListCommand = ReactiveCommand.Create(CompileModList);
}
private void CompileModList()
{
_logger.LogInformation($"Selected modlist {CompilerSettings.ModListName} for compilation, located in '{CompilerSettings.Source}'");
NavigateToGlobal.Send(ScreenType.Compiler);
LoadModlistForCompiling.Send(CompilerSettings);
}
}
}

View File

@ -24,7 +24,7 @@
<Style TargetType="Border">
<Setter Property="Opacity" Value="0.5" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=BeginButton}" Value="True">
<DataTrigger Binding="{Binding IsMouseOver, ElementName=BeginButtonPurpleGlow}" Value="True">
<Setter Property="Opacity" Value="0.8" />
</DataTrigger>
</Style.Triggers>

View File

@ -12,209 +12,133 @@
d:DesignWidth="800"
x:TypeArguments="local:CreatedModlistVM"
mc:Ignorable="d">
<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>
<Border BorderThickness="0" CornerRadius="6" Background="{StaticResource DarkPrimaryBrush}" Margin="10, 0, 10, 20">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border
x:Name="CompiledModListTile"
Margin="10, 0, 10, 16"
Background="Transparent"
BorderThickness="0">
<Border.Effect>
<DropShadowEffect
BlurRadius="25"
Opacity="0.25"
ShadowDepth="3" />
</Border.Effect>
<Border.Style>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="{StaticResource ButtonBorder}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<Setter Property="BorderBrush" Value="{StaticResource BorderInterestBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid Margin="10, 0, 10, 16" x:Name="CompiledModListTile">
<Border Name="BorderMask2" CornerRadius="10" BorderThickness="0" Background="White" Margin="1" />
<StackPanel Orientation="Vertical" Background="{StaticResource DarkBackgroundBrush}">
<StackPanel.Effect>
<DropShadowEffect BlurRadius="25" Opacity="0.25" ShadowDepth="3" />
</StackPanel.Effect>
<StackPanel.OpacityMask>
<VisualBrush Visual="{Binding ElementName=BorderMask2}"/>
</StackPanel.OpacityMask>
<Grid>
<Border x:Name="MaskBorder" BorderThickness="0" BorderBrush="Transparent" Background="{StaticResource DarkSecondaryBrush}" CornerRadius="10" Width="300" Height="169"/>
<Grid
Width="300"
Height="169"
Background="Transparent" ClipToBounds="True">
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=MaskBorder}"/>
</Grid.OpacityMask>
<Grid ClipToBounds="True">
<mahapps:ProgressRing x:Name="LoadingProgress" />
<Border
BorderThickness="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Border.Background>
<ImageBrush x:Name="ModlistImage" Stretch="UniformToFill"/>
</Border.Background>
</Border>
<Rectangle
Height="120"
Margin="-80, -75, -80, 0"
VerticalAlignment="Top"
Fill="White"
Opacity="0.15">
<Rectangle.Effect>
<BlurEffect Radius="100" />
</Rectangle.Effect>
<Rectangle.Style>
<Style TargetType="Rectangle">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="0.3"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="0.15"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
<Rectangle
Height="120"
Margin="-80, 0, -80, -75"
VerticalAlignment="Bottom"
Fill="Black"
Opacity="0.4">
<Rectangle.Effect>
<BlurEffect Radius="100" />
</Rectangle.Effect>
<Rectangle.Style>
<Style TargetType="Rectangle">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Background="Transparent" BorderThickness="0">
<Border.Style>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="{StaticResource ButtonBorder}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<Setter Property="BorderBrush" Value="{StaticResource BorderInterestBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Border x:Name="MaskBorder" BorderThickness="0" BorderBrush="Transparent" Background="{StaticResource DarkSecondaryBrush}" Width="300" Height="169"/>
<Grid Width="300" Height="169" Background="Transparent" ClipToBounds="True">
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=MaskBorder}"/>
</Grid.OpacityMask>
<Grid ClipToBounds="True">
<mahapps:ProgressRing x:Name="LoadingProgress" />
<Border BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Border.Background>
<ImageBrush x:Name="ModlistImage" Stretch="UniformToFill"/>
</Border.Background>
</Border>
<Rectangle Height="120" Margin="-80, -75, -80, 0" VerticalAlignment="Top" Fill="White" Opacity="0.15">
<Rectangle.Effect>
<BlurEffect Radius="100" />
</Rectangle.Effect>
<Rectangle.Style>
<Style TargetType="Rectangle">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.3" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.15" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
<Rectangle Height="120" Margin="-80, 0, -80, -75" VerticalAlignment="Bottom" Fill="Black" Opacity="0.4">
<Rectangle.Effect>
<BlurEffect Radius="100" />
</Rectangle.Effect>
<Rectangle.Style>
<Style TargetType="Rectangle">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="0.7"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="0.4"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
<Label
Margin="10,242,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="{Binding CompilerSettings.Version}"
Opacity="0">
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.4" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
<Label Margin="10,242,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Content="{Binding CompilerSettings.Version}" Opacity="0">
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=CompiledModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
</Grid>
</Grid>
</Grid>
</Grid>
</Border>
</Grid>
</Border>
<TextBlock
Text="{Binding CompilerSettings.ModListName}"
FontSize="16"
VerticalAlignment="Bottom"
Margin="10, 0, 0, 10"
Panel.ZIndex="1">
</TextBlock>
<TextBlock FontSize="20" Text="{Binding CompilerSettings.ModListName}" Margin="10, 10, 10, 0"/>
<TextBlock Text="{Binding CompilerSettings.Source}" FontSize="14" Opacity="0.5" Margin="10, 10, 10, 10"/>
</StackPanel>
</Grid>
</Border>
</rxui:ReactiveUserControl>

View File

@ -2,6 +2,8 @@
using System.Reactive.Linq;
using System.Windows;
using ReactiveUI;
using ReactiveMarbles.ObservableEvents;
using System.Reactive;
namespace Wabbajack
{
@ -13,20 +15,24 @@ namespace Wabbajack
public CreatedModListTileView()
{
InitializeComponent();
this.WhenActivated(disposables =>
this.WhenActivated(dispose =>
{
ViewModel.WhenAnyValue(vm => vm.CompilerSettings.ModListImage)
.Select(imagePath => { UIUtils.TryGetBitmapImageFromFile(imagePath, out var bitmapImage); return bitmapImage; })
.BindToStrict(this, v => v.ModlistImage.ImageSource)
.DisposeWith(disposables);
.DisposeWith(dispose);
CompiledModListTile
.Events().MouseDown
.Select(args => Unit.Default)
.InvokeCommand(this, x => x.ViewModel.CompileModListCommand)
.DisposeWith(dispose);
/*
ViewModel.WhenAnyValue(x => x.LoadingImageLock.IsLoading)
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
.BindToStrict(this, x => x.LoadingProgress.Visibility)
.DisposeWith(disposables);
*/
.DisposeWith(dispose);
});
}
}