mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Save/Load previous installer settings
This commit is contained in:
parent
de21eebe14
commit
8930db2a81
@ -8,6 +8,7 @@ using System.Windows.Media;
|
|||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -17,6 +18,7 @@ using Wabbajack.Common;
|
|||||||
using Wabbajack.DTOs;
|
using Wabbajack.DTOs;
|
||||||
using Wabbajack.DTOs.JsonConverters;
|
using Wabbajack.DTOs.JsonConverters;
|
||||||
using Wabbajack.Extensions;
|
using Wabbajack.Extensions;
|
||||||
|
using Wabbajack.Hashing.xxHash64;
|
||||||
using Wabbajack.Installer;
|
using Wabbajack.Installer;
|
||||||
using Wabbajack.Interventions;
|
using Wabbajack.Interventions;
|
||||||
using Wabbajack.Messages;
|
using Wabbajack.Messages;
|
||||||
@ -38,6 +40,7 @@ public enum ModManager
|
|||||||
public class InstallerVM : BackNavigatingVM, IBackNavigatingVM
|
public class InstallerVM : BackNavigatingVM, IBackNavigatingVM
|
||||||
{
|
{
|
||||||
private const string LastLoadedModlist = "last-loaded-modlist";
|
private const string LastLoadedModlist = "last-loaded-modlist";
|
||||||
|
private const string InstallSettingsPrefix = "install-settings-";
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public ModList ModList { get; set; }
|
public ModList ModList { get; set; }
|
||||||
@ -102,6 +105,8 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM
|
|||||||
|
|
||||||
BackCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModeSelectionView));
|
BackCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModeSelectionView));
|
||||||
|
|
||||||
|
BeginCommand = ReactiveCommand.Create(() => BeginInstall().FireAndForget());
|
||||||
|
|
||||||
OpenReadmeCommand = ReactiveCommand.Create(() =>
|
OpenReadmeCommand = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
UIUtils.OpenWebsite(new Uri(ModList!.Readme));
|
UIUtils.OpenWebsite(new Uri(ModList!.Readme));
|
||||||
@ -155,6 +160,17 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM
|
|||||||
{
|
{
|
||||||
ModList = await StandardInstaller.LoadFromFile(_dtos, path);
|
ModList = await StandardInstaller.LoadFromFile(_dtos, path);
|
||||||
ModListImage = BitmapFrame.Create(await StandardInstaller.ModListImageStream(path));
|
ModListImage = BitmapFrame.Create(await StandardInstaller.ModListImageStream(path));
|
||||||
|
|
||||||
|
var hex = (await ModListLocation.TargetPath.ToString().Hash()).ToHex();
|
||||||
|
var prevSettings = await _settingsManager.Load<SavedInstallSettings>(InstallSettingsPrefix + hex);
|
||||||
|
|
||||||
|
if (prevSettings.ModListLocation == path)
|
||||||
|
{
|
||||||
|
ModListLocation.TargetPath = prevSettings.ModListLocation;
|
||||||
|
Installer.Location.TargetPath = prevSettings.InstallLocation;
|
||||||
|
Installer.DownloadLocation.TargetPath = prevSettings.DownloadLoadction;
|
||||||
|
}
|
||||||
|
|
||||||
PopulateSlideShow(ModList);
|
PopulateSlideShow(ModList);
|
||||||
|
|
||||||
ll.Succeed();
|
ll.Succeed();
|
||||||
@ -167,6 +183,25 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task BeginInstall()
|
||||||
|
{
|
||||||
|
var postfix = (await ModListLocation.TargetPath.ToString().Hash()).ToHex();
|
||||||
|
await _settingsManager.Save(InstallSettingsPrefix + postfix, new SavedInstallSettings
|
||||||
|
{
|
||||||
|
ModListLocation = ModListLocation.TargetPath,
|
||||||
|
InstallLocation = Installer.Location.TargetPath,
|
||||||
|
DownloadLoadction = Installer.DownloadLocation.TargetPath
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class SavedInstallSettings
|
||||||
|
{
|
||||||
|
public AbsolutePath ModListLocation { get; set; }
|
||||||
|
public AbsolutePath InstallLocation { get; set; }
|
||||||
|
public AbsolutePath DownloadLoadction { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
private void PopulateSlideShow(ModList modList)
|
private void PopulateSlideShow(ModList modList)
|
||||||
{
|
{
|
||||||
SlideShowTitle = modList.Name;
|
SlideShowTitle = modList.Name;
|
||||||
|
@ -40,6 +40,10 @@ namespace Wabbajack
|
|||||||
.BindToStrict(this, view => view.ModlistLoadingRing.Visibility)
|
.BindToStrict(this, view => view.ModlistLoadingRing.Visibility)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
ViewModel.WhenAnyValue(vm => vm.BeginCommand)
|
||||||
|
.BindToStrict(this, view => view.InstallationConfigurationView.BeginButton.Command)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
// Slideshow
|
// Slideshow
|
||||||
ViewModel.WhenAnyValue(vm => vm.SlideShowTitle)
|
ViewModel.WhenAnyValue(vm => vm.SlideShowTitle)
|
||||||
.Select(f => f)
|
.Select(f => f)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Wabbajack.Hashing.xxHash64;
|
namespace Wabbajack.Hashing.xxHash64;
|
||||||
|
|
||||||
@ -30,4 +31,9 @@ public static class StringExtensions
|
|||||||
{
|
{
|
||||||
return Convert.FromBase64String(data);
|
return Convert.FromBase64String(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async ValueTask<Hash> Hash(this string s)
|
||||||
|
{
|
||||||
|
return await Encoding.UTF8.GetBytes(s).Hash();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user