mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
ISubCompilerVM.Unload()
To save settings when swapping off a compiler VM
This commit is contained in:
parent
6d07c4be87
commit
2e9f222648
@ -1,4 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -58,7 +58,6 @@ namespace Wabbajack
|
||||
public class ModlistInstallationSettings
|
||||
{
|
||||
public string InstallationLocation { get; set; }
|
||||
public string StagingLocation { get; set; }
|
||||
public string DownloadLocation { get; set; }
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,13 @@ namespace Wabbajack
|
||||
return null;
|
||||
}
|
||||
})
|
||||
// Unload old VM
|
||||
.Pairwise()
|
||||
.Do(pair =>
|
||||
{
|
||||
pair.Previous?.Unload();
|
||||
})
|
||||
.Select(p => p.Current)
|
||||
.ToProperty(this, nameof(this.Compiler));
|
||||
|
||||
// Let sub VM determine what settings we're displaying and when
|
||||
|
@ -13,5 +13,6 @@ namespace Wabbajack
|
||||
IReactiveCommand BeginCommand { get; }
|
||||
bool Compiling { get; }
|
||||
ModlistSettingsEditorVM ModlistSettings { get; }
|
||||
void Unload();
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ namespace Wabbajack
|
||||
{
|
||||
public class MO2CompilerVM : ViewModel, ISubCompilerVM
|
||||
{
|
||||
private readonly MO2CompilationSettings settings;
|
||||
|
||||
private readonly ObservableAsPropertyHelper<string> _Mo2Folder;
|
||||
public string Mo2Folder => _Mo2Folder.Value;
|
||||
|
||||
@ -132,19 +134,14 @@ namespace Wabbajack
|
||||
.ToProperty(this, nameof(this.Compiling));
|
||||
|
||||
// Load settings
|
||||
var settings = parent.MWVM.Settings.Compiler.MO2Compilation;
|
||||
this.settings = parent.MWVM.Settings.Compiler.MO2Compilation;
|
||||
this.ModlistLocation.TargetPath = settings.LastCompiledProfileLocation;
|
||||
if (!string.IsNullOrWhiteSpace(settings.DownloadLocation))
|
||||
{
|
||||
this.DownloadLocation.TargetPath = settings.DownloadLocation;
|
||||
}
|
||||
parent.MWVM.Settings.SaveSignal
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
settings.DownloadLocation = this.DownloadLocation.TargetPath;
|
||||
settings.LastCompiledProfileLocation = this.ModlistLocation.TargetPath;
|
||||
this.ModlistSettings?.Save();
|
||||
})
|
||||
.Subscribe(_ => Unload())
|
||||
.DisposeWith(this.CompositeDisposable);
|
||||
|
||||
// Load custom modlist settings per MO2 profile
|
||||
@ -195,8 +192,13 @@ namespace Wabbajack
|
||||
}
|
||||
})
|
||||
.DisposeWith(this.CompositeDisposable);
|
||||
}
|
||||
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
settings.DownloadLocation = this.DownloadLocation.TargetPath;
|
||||
settings.LastCompiledProfileLocation = this.ModlistLocation.TargetPath;
|
||||
this.ModlistSettings?.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,7 @@ namespace Wabbajack
|
||||
public bool Compiling => throw new NotImplementedException();
|
||||
|
||||
public ModlistSettingsEditorVM ModlistSettings => throw new NotImplementedException();
|
||||
|
||||
public void Unload() => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user