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;
|
||||
ModListReadme = cs.ModListReadme;
|
||||
ModListWebsite = cs.ModListWebsite;
|
||||
ModlistVersion = cs.ModlistVersion;
|
||||
ModlistVersion = cs.ModlistVersion?.ToString() ?? "";
|
||||
PublishUpdate = cs.PublishUpdate;
|
||||
MachineUrl = cs.MachineUrl;
|
||||
Profile = cs.Profile;
|
||||
@ -40,7 +40,7 @@ public class CompilerSettingsVM : ViewModel
|
||||
Include = cs.Include;
|
||||
Ignore = cs.Ignore;
|
||||
AlwaysEnabled = cs.AlwaysEnabled;
|
||||
Version = cs.Version;
|
||||
Version = cs.Version?.ToString() ?? "";
|
||||
Description = cs.Description;
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class CompilerSettingsVM : ViewModel
|
||||
[Reactive] public string ModListDescription { get; set; } = "";
|
||||
[Reactive] public string ModListReadme { 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 string MachineUrl { get; set; } = "";
|
||||
|
||||
@ -103,7 +103,7 @@ public class CompilerSettingsVM : ViewModel
|
||||
[Reactive] public RelativePath[] Ignore { 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; }
|
||||
|
||||
public CompilerSettings ToCompilerSettings()
|
||||
@ -125,7 +125,7 @@ public class CompilerSettingsVM : ViewModel
|
||||
ModListDescription = ModListDescription,
|
||||
ModListReadme = ModListReadme,
|
||||
ModListWebsite = ModListWebsite,
|
||||
ModlistVersion = ModlistVersion,
|
||||
ModlistVersion = System.Version.Parse(ModlistVersion),
|
||||
PublishUpdate = PublishUpdate,
|
||||
MachineUrl = MachineUrl,
|
||||
Profile = Profile,
|
||||
@ -134,10 +134,24 @@ public class CompilerSettingsVM : ViewModel
|
||||
Include = Include,
|
||||
Ignore = Ignore,
|
||||
AlwaysEnabled = AlwaysEnabled,
|
||||
Version = Version,
|
||||
Version = System.Version.Parse(Version),
|
||||
Description = Description
|
||||
};
|
||||
}
|
||||
public AbsolutePath CompilerSettingsPath => Source.Combine(ModListName).WithExtension(Ext.CompilerSettings);
|
||||
public AbsolutePath ProfilePath => Source.Combine("profiles").Combine(Profile).Combine("modlist").WithExtension(Ext.Txt);
|
||||
public AbsolutePath CompilerSettingsPath
|
||||
{
|
||||
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);
|
||||
|
||||
ExecuteCommand = ReactiveCommand.CreateFromTask(async () => await StartCompilation());
|
||||
ReInferSettingsCommand = ReactiveCommand.CreateFromTask(async () => await ReInferSettings(),
|
||||
/*ReInferSettingsCommand = ReactiveCommand.CreateFromTask(async () => await ReInferSettings(),
|
||||
|
||||
this.WhenAnyValue(vm => vm.Settings.Source)
|
||||
.ObserveOnGuiThread()
|
||||
.Select(v => v != default)
|
||||
@ -119,6 +120,7 @@ namespace Wabbajack
|
||||
.ObserveOnGuiThread()
|
||||
.Select(p => !string.IsNullOrWhiteSpace(p)))
|
||||
.Select(v => v.First && v.Second));
|
||||
*/
|
||||
|
||||
ModlistLocation = new FilePickerVM
|
||||
{
|
||||
@ -159,7 +161,7 @@ namespace Wabbajack
|
||||
{
|
||||
Settings = new CompilerSettingsVM(await InferModListFromLocation(p));
|
||||
}
|
||||
else await ReInferSettings();
|
||||
else if(p.FileName == "modlist.txt".ToRelativePath()) await ReInferSettings(p);
|
||||
})
|
||||
.DisposeWith(disposables);
|
||||
|
||||
@ -177,30 +179,45 @@ namespace Wabbajack
|
||||
.Throttle(TimeSpan.FromSeconds(2))
|
||||
.Subscribe(_ => SaveSettingsFile().FireAndForget())
|
||||
.DisposeWith(disposables);
|
||||
/*
|
||||
|
||||
this.WhenAnyValue(x => x.ModListImageLocation.TargetPath)
|
||||
.BindToStrict(this, vm => vm.Settings.ModListImage)
|
||||
.DisposeWith(disposables);
|
||||
ModListImageLocation.WhenAnyValue(x => x.TargetPath)
|
||||
.BindToStrict(this, vm => vm.Settings.ModListImage)
|
||||
.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(
|
||||
Settings.Source.Combine("profiles", Settings.Profile, "modlist.txt"));
|
||||
var newSettings = await _inferencer.InferModListFromLocation(filePath);
|
||||
|
||||
if (newSettings == null)
|
||||
{
|
||||
_logger.LogError("Cannot infer settings");
|
||||
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.Ignore = newSettings.Ignore;
|
||||
Settings.AlwaysEnabled = newSettings.AlwaysEnabled;
|
||||
@ -294,7 +311,7 @@ namespace Wabbajack
|
||||
_logger.LogInformation("Publishing List");
|
||||
var downloadMetadata = _dtos.Deserialize<DownloadMetadata>(
|
||||
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");
|
||||
|
||||
@ -334,18 +351,26 @@ namespace Wabbajack
|
||||
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;
|
||||
}
|
||||
|
||||
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 JsonSerializer.SerializeAsync(st, Settings.ToCompilerSettings(), _dtos.Options);
|
||||
|
||||
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);
|
||||
|
||||
await _settingsManager.Save(Consts.AllSavedCompilerSettingsPaths, allSavedCompilerSettings);
|
||||
|
@ -36,7 +36,7 @@ namespace Wabbajack
|
||||
private readonly CancellationToken _cancellationToken;
|
||||
private readonly DTOSerializer _dtos;
|
||||
|
||||
public ICommand CompileModListCommand { get; set; }
|
||||
public ICommand NewModListCommand { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public ObservableCollection<CreatedModlistVM> CreatedModlists { get; set; }
|
||||
@ -48,7 +48,10 @@ namespace Wabbajack
|
||||
_settingsManager = settingsManager;
|
||||
_serviceProvider = serviceProvider;
|
||||
_dtos = dtos;
|
||||
CompileModListCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(ScreenType.Compiler));
|
||||
NewModListCommand = ReactiveCommand.Create(() => {
|
||||
NavigateToGlobal.Send(ScreenType.Compiler);
|
||||
LoadModlistForCompiling.Send(new());
|
||||
});
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
LoadAllCompilerSettings().DisposeWith(disposables);
|
||||
|
@ -102,10 +102,18 @@ namespace Wabbajack
|
||||
ViewModel.WhenAnyValue(vm => vm.DownloadLocation)
|
||||
.BindToStrict(this, view => view.CompilerConfigView.DownloadsLocation.PickerVM)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
ViewModel.WhenAnyValue(vm => vm.Settings.Downloads)
|
||||
.BindToStrict(this, view => view.CompilerConfigView.DownloadsLocation.PickerVM.TargetPath)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
ViewModel.WhenAnyValue(vm => vm.OutputLocation)
|
||||
.BindToStrict(this, view => view.CompilerConfigView.OutputLocation.PickerVM)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
ViewModel.WhenAnyValue(vm => vm.Settings.OutputFile)
|
||||
.BindToStrict(this, view => view.CompilerConfigView.OutputLocation.PickerVM.TargetPath)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
UserInterventionsControl.Visibility = Visibility.Collapsed;
|
||||
|
||||
@ -145,14 +153,7 @@ namespace Wabbajack
|
||||
this.Bind(ViewModel, vm => vm.Settings.ModListAuthor, view => view.AuthorNameSetting.Text)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
this.Bind(ViewModel,
|
||||
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");
|
||||
})
|
||||
this.Bind(ViewModel, vm => vm.Settings.Version, view => view.VersionSetting.Text)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
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)
|
||||
.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)
|
||||
.DisposeWith(disposables);
|
||||
|
@ -29,7 +29,7 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
</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.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
|
@ -34,10 +34,10 @@ namespace Wabbajack
|
||||
.BindToStrict(this, x => x.CreatedModListsControl.ItemsSource)
|
||||
.DisposeWith(dispose);
|
||||
|
||||
CompileNewModListBorder
|
||||
NewModListBorder
|
||||
.Events().MouseDown
|
||||
.Select(args => Unit.Default)
|
||||
.InvokeCommand(this, x => x.ViewModel.CompileModListCommand)
|
||||
.InvokeCommand(this, x => x.ViewModel.NewModListCommand)
|
||||
.DisposeWith(dispose);
|
||||
});
|
||||
}
|
||||
|
@ -139,8 +139,6 @@ public class CompilerSettingsInferencer
|
||||
{
|
||||
cs.AdditionalProfiles = await otherProfilesFile.ReadAllLinesAsync().ToArray();
|
||||
}
|
||||
|
||||
cs.OutputFile = cs.Source.Parent.Combine(cs.Profile).WithExtension(Ext.Wabbajack);
|
||||
}
|
||||
|
||||
return cs;
|
||||
|
Loading…
Reference in New Issue
Block a user