mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Miscellaneous fixes for not saving and loading modlists correctly
This commit is contained in:
parent
836f102ec6
commit
ce72a6e80c
@ -31,7 +31,7 @@ public class CompilerSettingsVM : ViewModel
|
|||||||
ModListDescription = cs.ModListDescription;
|
ModListDescription = cs.ModListDescription;
|
||||||
ModListReadme = cs.ModListReadme;
|
ModListReadme = cs.ModListReadme;
|
||||||
ModListWebsite = cs.ModListWebsite;
|
ModListWebsite = cs.ModListWebsite;
|
||||||
ModlistVersion = cs.ModlistVersion;
|
ModlistVersion = cs.ModlistVersion?.ToString() ?? "";
|
||||||
PublishUpdate = cs.PublishUpdate;
|
PublishUpdate = cs.PublishUpdate;
|
||||||
MachineUrl = cs.MachineUrl;
|
MachineUrl = cs.MachineUrl;
|
||||||
Profile = cs.Profile;
|
Profile = cs.Profile;
|
||||||
@ -40,7 +40,7 @@ public class CompilerSettingsVM : ViewModel
|
|||||||
Include = cs.Include;
|
Include = cs.Include;
|
||||||
Ignore = cs.Ignore;
|
Ignore = cs.Ignore;
|
||||||
AlwaysEnabled = cs.AlwaysEnabled;
|
AlwaysEnabled = cs.AlwaysEnabled;
|
||||||
Version = cs.Version;
|
Version = cs.Version?.ToString() ?? "";
|
||||||
Description = cs.Description;
|
Description = cs.Description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ public class CompilerSettingsVM : ViewModel
|
|||||||
[Reactive] public string ModListDescription { get; set; } = "";
|
[Reactive] public string ModListDescription { get; set; } = "";
|
||||||
[Reactive] public string ModListReadme { get; set; } = "";
|
[Reactive] public string ModListReadme { get; set; } = "";
|
||||||
[Reactive] public Uri? ModListWebsite { get; set; }
|
[Reactive] public Uri? ModListWebsite { get; set; }
|
||||||
[Reactive] public Version ModlistVersion { get; set; } = Version.Parse("0.0.1.0");
|
[Reactive] public string ModlistVersion { get; set; } = "";
|
||||||
[Reactive] public bool PublishUpdate { get; set; } = false;
|
[Reactive] public bool PublishUpdate { get; set; } = false;
|
||||||
[Reactive] public string MachineUrl { get; set; } = "";
|
[Reactive] public string MachineUrl { get; set; } = "";
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ public class CompilerSettingsVM : ViewModel
|
|||||||
[Reactive] public RelativePath[] Ignore { get; set; } = Array.Empty<RelativePath>();
|
[Reactive] public RelativePath[] Ignore { get; set; } = Array.Empty<RelativePath>();
|
||||||
|
|
||||||
[Reactive] public RelativePath[] AlwaysEnabled { get; set; } = Array.Empty<RelativePath>();
|
[Reactive] public RelativePath[] AlwaysEnabled { get; set; } = Array.Empty<RelativePath>();
|
||||||
[Reactive] public Version Version { get; set; }
|
[Reactive] public string Version { get; set; }
|
||||||
[Reactive] public string Description { get; set; }
|
[Reactive] public string Description { get; set; }
|
||||||
|
|
||||||
public CompilerSettings ToCompilerSettings()
|
public CompilerSettings ToCompilerSettings()
|
||||||
@ -125,7 +125,7 @@ public class CompilerSettingsVM : ViewModel
|
|||||||
ModListDescription = ModListDescription,
|
ModListDescription = ModListDescription,
|
||||||
ModListReadme = ModListReadme,
|
ModListReadme = ModListReadme,
|
||||||
ModListWebsite = ModListWebsite,
|
ModListWebsite = ModListWebsite,
|
||||||
ModlistVersion = ModlistVersion,
|
ModlistVersion = System.Version.Parse(ModlistVersion),
|
||||||
PublishUpdate = PublishUpdate,
|
PublishUpdate = PublishUpdate,
|
||||||
MachineUrl = MachineUrl,
|
MachineUrl = MachineUrl,
|
||||||
Profile = Profile,
|
Profile = Profile,
|
||||||
@ -134,10 +134,24 @@ public class CompilerSettingsVM : ViewModel
|
|||||||
Include = Include,
|
Include = Include,
|
||||||
Ignore = Ignore,
|
Ignore = Ignore,
|
||||||
AlwaysEnabled = AlwaysEnabled,
|
AlwaysEnabled = AlwaysEnabled,
|
||||||
Version = Version,
|
Version = System.Version.Parse(Version),
|
||||||
Description = Description
|
Description = Description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public AbsolutePath CompilerSettingsPath => Source.Combine(ModListName).WithExtension(Ext.CompilerSettings);
|
public AbsolutePath CompilerSettingsPath
|
||||||
public AbsolutePath ProfilePath => Source.Combine("profiles").Combine(Profile).Combine("modlist").WithExtension(Ext.Txt);
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Source == default || string.IsNullOrEmpty(Profile)) return default;
|
||||||
|
return Source.Combine(ModListName).WithExtension(Ext.CompilerSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public AbsolutePath ProfilePath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Source == default || string.IsNullOrEmpty(Profile)) return default;
|
||||||
|
return Source.Combine("profiles").Combine(Profile).Combine("modlist").WithExtension(Ext.Txt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,8 @@ namespace Wabbajack
|
|||||||
SubCompilerVM = new MO2CompilerVM(this);
|
SubCompilerVM = new MO2CompilerVM(this);
|
||||||
|
|
||||||
ExecuteCommand = ReactiveCommand.CreateFromTask(async () => await StartCompilation());
|
ExecuteCommand = ReactiveCommand.CreateFromTask(async () => await StartCompilation());
|
||||||
ReInferSettingsCommand = ReactiveCommand.CreateFromTask(async () => await ReInferSettings(),
|
/*ReInferSettingsCommand = ReactiveCommand.CreateFromTask(async () => await ReInferSettings(),
|
||||||
|
|
||||||
this.WhenAnyValue(vm => vm.Settings.Source)
|
this.WhenAnyValue(vm => vm.Settings.Source)
|
||||||
.ObserveOnGuiThread()
|
.ObserveOnGuiThread()
|
||||||
.Select(v => v != default)
|
.Select(v => v != default)
|
||||||
@ -119,6 +120,7 @@ namespace Wabbajack
|
|||||||
.ObserveOnGuiThread()
|
.ObserveOnGuiThread()
|
||||||
.Select(p => !string.IsNullOrWhiteSpace(p)))
|
.Select(p => !string.IsNullOrWhiteSpace(p)))
|
||||||
.Select(v => v.First && v.Second));
|
.Select(v => v.First && v.Second));
|
||||||
|
*/
|
||||||
|
|
||||||
ModlistLocation = new FilePickerVM
|
ModlistLocation = new FilePickerVM
|
||||||
{
|
{
|
||||||
@ -159,7 +161,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
Settings = new CompilerSettingsVM(await InferModListFromLocation(p));
|
Settings = new CompilerSettingsVM(await InferModListFromLocation(p));
|
||||||
}
|
}
|
||||||
else await ReInferSettings();
|
else if(p.FileName == "modlist.txt".ToRelativePath()) await ReInferSettings(p);
|
||||||
})
|
})
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
@ -177,30 +179,45 @@ namespace Wabbajack
|
|||||||
.Throttle(TimeSpan.FromSeconds(2))
|
.Throttle(TimeSpan.FromSeconds(2))
|
||||||
.Subscribe(_ => SaveSettingsFile().FireAndForget())
|
.Subscribe(_ => SaveSettingsFile().FireAndForget())
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
/*
|
||||||
|
|
||||||
this.WhenAnyValue(x => x.ModListImageLocation.TargetPath)
|
ModListImageLocation.WhenAnyValue(x => x.TargetPath)
|
||||||
.BindToStrict(this, vm => vm.Settings.ModListImage)
|
.BindToStrict(this, vm => vm.Settings.ModListImage)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
DownloadLocation.WhenAnyValue(x => x.TargetPath)
|
||||||
|
.BindToStrict(this, vm => vm.Settings.Downloads)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
Settings.WhenAnyValue(x => x.Downloads)
|
||||||
|
.BindToStrict(this, vm => vm.DownloadLocation.TargetPath)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
*/
|
||||||
|
|
||||||
this.WhenAnyValue(x => x.DownloadLocation.TargetPath)
|
|
||||||
.BindToStrict(this, vm => vm.Settings.Downloads)
|
|
||||||
.DisposeWith(disposables);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async Task ReInferSettings()
|
private async Task ReInferSettings(AbsolutePath filePath)
|
||||||
{
|
{
|
||||||
var newSettings = await _inferencer.InferModListFromLocation(
|
var newSettings = await _inferencer.InferModListFromLocation(filePath);
|
||||||
Settings.Source.Combine("profiles", Settings.Profile, "modlist.txt"));
|
|
||||||
|
|
||||||
if (newSettings == null)
|
if (newSettings == null)
|
||||||
{
|
{
|
||||||
_logger.LogError("Cannot infer settings");
|
_logger.LogError("Cannot infer settings");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings.Source = newSettings.Source;
|
||||||
|
Settings.Downloads = newSettings.Downloads;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Settings.ModListName))
|
||||||
|
Settings.OutputFile = newSettings.OutputFile.Combine(newSettings.Profile).WithExtension(Ext.Wabbajack);
|
||||||
|
else
|
||||||
|
Settings.OutputFile = newSettings.OutputFile.Combine(newSettings.ModListName).WithExtension(Ext.Wabbajack);
|
||||||
|
|
||||||
|
Settings.Game = newSettings.Game;
|
||||||
Settings.Include = newSettings.Include;
|
Settings.Include = newSettings.Include;
|
||||||
Settings.Ignore = newSettings.Ignore;
|
Settings.Ignore = newSettings.Ignore;
|
||||||
Settings.AlwaysEnabled = newSettings.AlwaysEnabled;
|
Settings.AlwaysEnabled = newSettings.AlwaysEnabled;
|
||||||
@ -294,7 +311,7 @@ namespace Wabbajack
|
|||||||
_logger.LogInformation("Publishing List");
|
_logger.LogInformation("Publishing List");
|
||||||
var downloadMetadata = _dtos.Deserialize<DownloadMetadata>(
|
var downloadMetadata = _dtos.Deserialize<DownloadMetadata>(
|
||||||
await Settings.OutputFile.WithExtension(Ext.Meta).WithExtension(Ext.Json).ReadAllTextAsync())!;
|
await Settings.OutputFile.WithExtension(Ext.Meta).WithExtension(Ext.Json).ReadAllTextAsync())!;
|
||||||
await _wjClient.PublishModlist(Settings.MachineUrl, Settings.Version, Settings.OutputFile, downloadMetadata);
|
await _wjClient.PublishModlist(Settings.MachineUrl, Version.Parse(Settings.Version), Settings.OutputFile, downloadMetadata);
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Compiler Finished");
|
_logger.LogInformation("Compiler Finished");
|
||||||
|
|
||||||
@ -334,18 +351,26 @@ namespace Wabbajack
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!Version.TryParse(Settings.Version, out var version))
|
||||||
|
{
|
||||||
|
_logger.LogError("Preflight Check failed, version {Version} was not valid", Settings.Version);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveSettingsFile()
|
private async Task SaveSettingsFile()
|
||||||
{
|
{
|
||||||
if (Settings.Source == default) return;
|
if (Settings.Source == default || Settings.CompilerSettingsPath == default) return;
|
||||||
|
|
||||||
await using var st = Settings.CompilerSettingsPath.Open(FileMode.Create, FileAccess.Write, FileShare.None);
|
await using var st = Settings.CompilerSettingsPath.Open(FileMode.Create, FileAccess.Write, FileShare.None);
|
||||||
await JsonSerializer.SerializeAsync(st, Settings.ToCompilerSettings(), _dtos.Options);
|
await JsonSerializer.SerializeAsync(st, Settings.ToCompilerSettings(), _dtos.Options);
|
||||||
|
|
||||||
var allSavedCompilerSettings = await _settingsManager.Load<List<AbsolutePath>>(Consts.AllSavedCompilerSettingsPaths);
|
var allSavedCompilerSettings = await _settingsManager.Load<List<AbsolutePath>>(Consts.AllSavedCompilerSettingsPaths);
|
||||||
allSavedCompilerSettings.Remove(Settings.CompilerSettingsPath);
|
|
||||||
|
// Don't simply remove Settings.CompilerSettingsPath here, because WJ sometimes likes to make default compiler settings files
|
||||||
|
allSavedCompilerSettings.RemoveAll(path => path.Parent == Settings.Source);
|
||||||
allSavedCompilerSettings.Insert(0, Settings.CompilerSettingsPath);
|
allSavedCompilerSettings.Insert(0, Settings.CompilerSettingsPath);
|
||||||
|
|
||||||
await _settingsManager.Save(Consts.AllSavedCompilerSettingsPaths, allSavedCompilerSettings);
|
await _settingsManager.Save(Consts.AllSavedCompilerSettingsPaths, allSavedCompilerSettings);
|
||||||
|
@ -36,7 +36,7 @@ namespace Wabbajack
|
|||||||
private readonly CancellationToken _cancellationToken;
|
private readonly CancellationToken _cancellationToken;
|
||||||
private readonly DTOSerializer _dtos;
|
private readonly DTOSerializer _dtos;
|
||||||
|
|
||||||
public ICommand CompileModListCommand { get; set; }
|
public ICommand NewModListCommand { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public ObservableCollection<CreatedModlistVM> CreatedModlists { get; set; }
|
public ObservableCollection<CreatedModlistVM> CreatedModlists { get; set; }
|
||||||
@ -48,7 +48,10 @@ namespace Wabbajack
|
|||||||
_settingsManager = settingsManager;
|
_settingsManager = settingsManager;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_dtos = dtos;
|
_dtos = dtos;
|
||||||
CompileModListCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(ScreenType.Compiler));
|
NewModListCommand = ReactiveCommand.Create(() => {
|
||||||
|
NavigateToGlobal.Send(ScreenType.Compiler);
|
||||||
|
LoadModlistForCompiling.Send(new());
|
||||||
|
});
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
LoadAllCompilerSettings().DisposeWith(disposables);
|
LoadAllCompilerSettings().DisposeWith(disposables);
|
||||||
|
@ -102,10 +102,18 @@ namespace Wabbajack
|
|||||||
ViewModel.WhenAnyValue(vm => vm.DownloadLocation)
|
ViewModel.WhenAnyValue(vm => vm.DownloadLocation)
|
||||||
.BindToStrict(this, view => view.CompilerConfigView.DownloadsLocation.PickerVM)
|
.BindToStrict(this, view => view.CompilerConfigView.DownloadsLocation.PickerVM)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
ViewModel.WhenAnyValue(vm => vm.Settings.Downloads)
|
||||||
|
.BindToStrict(this, view => view.CompilerConfigView.DownloadsLocation.PickerVM.TargetPath)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
ViewModel.WhenAnyValue(vm => vm.OutputLocation)
|
ViewModel.WhenAnyValue(vm => vm.OutputLocation)
|
||||||
.BindToStrict(this, view => view.CompilerConfigView.OutputLocation.PickerVM)
|
.BindToStrict(this, view => view.CompilerConfigView.OutputLocation.PickerVM)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
ViewModel.WhenAnyValue(vm => vm.Settings.OutputFile)
|
||||||
|
.BindToStrict(this, view => view.CompilerConfigView.OutputLocation.PickerVM.TargetPath)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
UserInterventionsControl.Visibility = Visibility.Collapsed;
|
UserInterventionsControl.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
@ -145,14 +153,7 @@ namespace Wabbajack
|
|||||||
this.Bind(ViewModel, vm => vm.Settings.ModListAuthor, view => view.AuthorNameSetting.Text)
|
this.Bind(ViewModel, vm => vm.Settings.ModListAuthor, view => view.AuthorNameSetting.Text)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.Bind(ViewModel,
|
this.Bind(ViewModel, vm => vm.Settings.Version, view => view.VersionSetting.Text)
|
||||||
vm => vm.Settings.Version,
|
|
||||||
view => view.VersionSetting.Text,
|
|
||||||
vmVersion => vmVersion?.ToString() ?? "",
|
|
||||||
viewVersion => {
|
|
||||||
Version.TryParse(viewVersion, out var version);
|
|
||||||
return version ?? Version.Parse("1.0.0");
|
|
||||||
})
|
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.Settings.ModListDescription, view => view.DescriptionSetting.Text)
|
this.Bind(ViewModel, vm => vm.Settings.ModListDescription, view => view.DescriptionSetting.Text)
|
||||||
@ -161,6 +162,9 @@ namespace Wabbajack
|
|||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.ModListImageLocation, view => view.ImageFilePicker.PickerVM)
|
this.Bind(ViewModel, vm => vm.ModListImageLocation, view => view.ImageFilePicker.PickerVM)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.Settings.ModListImage, view => view.ImageFilePicker.PickerVM.TargetPath)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.Settings.ModListWebsite, view => view.WebsiteSetting.Text)
|
this.Bind(ViewModel, vm => vm.Settings.ModListWebsite, view => view.WebsiteSetting.Text)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Border Grid.Column="0" BorderBrush="{StaticResource PrimaryVariantBrush}" CornerRadius="8" BorderThickness="19" Margin="0, 0, 20, 20" x:Name="CompileNewModListBorder">
|
<Border Grid.Column="0" BorderBrush="{StaticResource PrimaryVariantBrush}" CornerRadius="8" BorderThickness="19" Margin="0, 0, 20, 20" x:Name="NewModListBorder">
|
||||||
<Grid Background="{StaticResource PrimaryVariantBrush}" Margin="-1">
|
<Grid Background="{StaticResource PrimaryVariantBrush}" Margin="-1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
|
@ -34,10 +34,10 @@ namespace Wabbajack
|
|||||||
.BindToStrict(this, x => x.CreatedModListsControl.ItemsSource)
|
.BindToStrict(this, x => x.CreatedModListsControl.ItemsSource)
|
||||||
.DisposeWith(dispose);
|
.DisposeWith(dispose);
|
||||||
|
|
||||||
CompileNewModListBorder
|
NewModListBorder
|
||||||
.Events().MouseDown
|
.Events().MouseDown
|
||||||
.Select(args => Unit.Default)
|
.Select(args => Unit.Default)
|
||||||
.InvokeCommand(this, x => x.ViewModel.CompileModListCommand)
|
.InvokeCommand(this, x => x.ViewModel.NewModListCommand)
|
||||||
.DisposeWith(dispose);
|
.DisposeWith(dispose);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -139,8 +139,6 @@ public class CompilerSettingsInferencer
|
|||||||
{
|
{
|
||||||
cs.AdditionalProfiles = await otherProfilesFile.ReadAllLinesAsync().ToArray();
|
cs.AdditionalProfiles = await otherProfilesFile.ReadAllLinesAsync().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
cs.OutputFile = cs.Source.Parent.Combine(cs.Profile).WithExtension(Ext.Wabbajack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cs;
|
return cs;
|
||||||
|
Loading…
Reference in New Issue
Block a user