Fix up the load modlist button

This commit is contained in:
trawzified 2024-05-09 17:20:11 +02:00
parent ce72a6e80c
commit 7d206315af
5 changed files with 38 additions and 4 deletions

View File

@ -1,5 +1,8 @@
using ReactiveUI;
using System.IO;
using Wabbajack.Compiler;
using Wabbajack.DTOs.JsonConverters;
using Wabbajack.Paths;
namespace Wabbajack.Messages;
@ -11,6 +14,7 @@ public class LoadModlistForCompiling
CompilerSettings = cs;
}
public static void Send(CompilerSettings cs)
{
MessageBus.Current.SendMessage(new LoadModlistForCompiling(cs));

View File

@ -12,6 +12,7 @@ using System.Windows.Input;
using DynamicData;
using DynamicData.Binding;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAPICodePack.Dialogs;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using SteamKit2.GC.Dota.Internal;
@ -37,10 +38,13 @@ namespace Wabbajack
private readonly DTOSerializer _dtos;
public ICommand NewModListCommand { get; set; }
public ICommand LoadSettingsCommand { get; set; }
[Reactive]
public ObservableCollection<CreatedModlistVM> CreatedModlists { get; set; }
public FilePickerVM CompilerSettingsPicker { get; private set; }
public CreateModListVM(ILogger<CreateModListVM> logger, SettingsManager settingsManager,
IServiceProvider serviceProvider, DTOSerializer dtos)
{
@ -48,10 +52,33 @@ namespace Wabbajack
_settingsManager = settingsManager;
_serviceProvider = serviceProvider;
_dtos = dtos;
CompilerSettingsPicker = new FilePickerVM
{
ExistCheckOption = FilePickerVM.CheckOptions.On,
PathType = FilePickerVM.PathTypeOptions.File,
PromptTitle = "Select a compiler settings file"
};
CompilerSettingsPicker.Filters.AddRange([
new CommonFileDialogFilter("Compiler Settings File", "*" + Ext.CompilerSettings)
]);
NewModListCommand = ReactiveCommand.Create(() => {
NavigateToGlobal.Send(ScreenType.Compiler);
LoadModlistForCompiling.Send(new());
});
LoadSettingsCommand = ReactiveCommand.Create(() =>
{
CompilerSettingsPicker.SetTargetPathCommand.Execute(null);
if(CompilerSettingsPicker.TargetPath != default)
{
NavigateToGlobal.Send(ScreenType.Compiler);
var compilerSettings = _dtos.Deserialize<CompilerSettings>(File.ReadAllText(CompilerSettingsPicker.TargetPath.ToString()));
LoadModlistForCompiling.Send(compilerSettings);
}
});
this.WhenActivated(disposables =>
{
LoadAllCompilerSettings().DisposeWith(disposables);

View File

@ -139,9 +139,6 @@ namespace Wabbajack
.DisposeWith(disposables);
// Settings
this.Bind(ViewModel, vm => vm.Settings.ModListName, view => view.ModListNameSetting.Text)

View File

@ -60,7 +60,7 @@
</Grid>
</Border>
<Border Grid.Column="1" BorderBrush="{StaticResource PrimaryVariantBrush}" CornerRadius="8" BorderThickness="19" Margin="0, 0, 20, 20">
<Border Grid.Column="1" BorderBrush="{StaticResource PrimaryVariantBrush}" CornerRadius="8" BorderThickness="19" Margin="0, 0, 20, 20" x:Name="LoadSettingsBorder">
<Grid Background="{StaticResource PrimaryVariantBrush}" Margin="-1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>

View File

@ -39,6 +39,12 @@ namespace Wabbajack
.Select(args => Unit.Default)
.InvokeCommand(this, x => x.ViewModel.NewModListCommand)
.DisposeWith(dispose);
LoadSettingsBorder
.Events().MouseDown
.Select(args => Unit.Default)
.InvokeCommand(this, x => x.ViewModel.LoadSettingsCommand)
.DisposeWith(dispose);
});
}
}