From 1e61bcaf4541fbb7c56b1f1c0f7799c382f981ac Mon Sep 17 00:00:00 2001
From: trawzified <55751269+tr4wzified@users.noreply.github.com>
Date: Sat, 4 May 2024 16:25:24 +0200
Subject: [PATCH] Actually make the recently compiled modlists section work,
overhaul card view of compiled lists
---
; | 156 ++++++++-
.../Messages/LoadModlistForCompiling.cs | 18 +
.../ViewModels/Compilers/CompilerVM.cs | 24 +-
.../ViewModels/Compilers/CreatedModlistVM.cs | 19 +-
.../Views/Common/BeginButton.xaml | 2 +-
.../Views/CreateModListTileView.xaml | 320 +++++++-----------
.../Views/CreateModListTileView.xaml.cs | 16 +-
7 files changed, 326 insertions(+), 229 deletions(-)
create mode 100644 Wabbajack.App.Wpf/Messages/LoadModlistForCompiling.cs
diff --git a/; b/;
index e9cb9dde..4bef29e0 100644
--- a/;
+++ b/;
@@ -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; }
- }
-}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Wabbajack.App.Wpf/Messages/LoadModlistForCompiling.cs b/Wabbajack.App.Wpf/Messages/LoadModlistForCompiling.cs
new file mode 100644
index 00000000..14bb0fef
--- /dev/null
+++ b/Wabbajack.App.Wpf/Messages/LoadModlistForCompiling.cs
@@ -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));
+ }
+}
\ No newline at end of file
diff --git a/Wabbajack.App.Wpf/ViewModels/Compilers/CompilerVM.cs b/Wabbajack.App.Wpf/ViewModels/Compilers/CompilerVM.cs
index 63ac5bcd..b9c0ba34 100644
--- a/Wabbajack.App.Wpf/ViewModels/Compilers/CompilerVM.cs
+++ b/Wabbajack.App.Wpf/ViewModels/Compilers/CompilerVM.cs
@@ -114,6 +114,10 @@ namespace Wabbajack
_inferencer = inferencer;
_wjClient = wjClient;
+ MessageBus.Current.Listen()
+ .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()
{
diff --git a/Wabbajack.App.Wpf/ViewModels/Compilers/CreatedModlistVM.cs b/Wabbajack.App.Wpf/ViewModels/Compilers/CreatedModlistVM.cs
index 47d987b9..c229060d 100644
--- a/Wabbajack.App.Wpf/ViewModels/Compilers/CreatedModlistVM.cs
+++ b/Wabbajack.App.Wpf/ViewModels/Compilers/CreatedModlistVM.cs
@@ -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);
}
}
}
diff --git a/Wabbajack.App.Wpf/Views/Common/BeginButton.xaml b/Wabbajack.App.Wpf/Views/Common/BeginButton.xaml
index 7ecb0cec..18d9c7b7 100644
--- a/Wabbajack.App.Wpf/Views/Common/BeginButton.xaml
+++ b/Wabbajack.App.Wpf/Views/Common/BeginButton.xaml
@@ -24,7 +24,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
-
diff --git a/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml.cs b/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml.cs
index 462c559f..66565f45 100644
--- a/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml.cs
+++ b/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml.cs
@@ -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);
});
}
}