diff --git a/Wabbajack.Common/Consts.cs b/Wabbajack.Common/Consts.cs index 66849eba..1b2e0c01 100644 --- a/Wabbajack.Common/Consts.cs +++ b/Wabbajack.Common/Consts.cs @@ -139,7 +139,5 @@ namespace Wabbajack.Common public static RelativePath ModOrganizer2Exe = (RelativePath)"ModOrganizer.exe"; public static RelativePath ModOrganizer2Ini = (RelativePath)"ModOrganizer.ini"; public static string AuthorAPIKeyFile = "author-api-key.txt"; - - public static Regex VersionRegex = new Regex(@"^(\d{1,3}\.?){1,3}[^\.]$"); } } diff --git a/Wabbajack.Lib/ACompiler.cs b/Wabbajack.Lib/ACompiler.cs index a45eb9a4..b3c7118d 100644 --- a/Wabbajack.Lib/ACompiler.cs +++ b/Wabbajack.Lib/ACompiler.cs @@ -16,6 +16,7 @@ namespace Wabbajack.Lib public abstract class ACompiler : ABatchProcessor { public string? ModListName, ModListAuthor, ModListDescription, ModListWebsite, ModlistReadme; + public Version? ModlistVersion; public AbsolutePath ModListImage; protected Version? WabbajackVersion; diff --git a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs index 1020646e..69bb833f 100644 --- a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs +++ b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs @@ -188,6 +188,7 @@ namespace Wabbajack ModListWebsite = ModlistSettings.Website, ModlistReadme = ModlistSettings.Readme, MO2DownloadsFolder = DownloadLocation.TargetPath, + ModlistVersion = ModlistSettings.Version }) { Parent.MWVM.Settings.Performance.AttachToBatchProcessor(ActiveCompilation); diff --git a/Wabbajack/View Models/Compilers/ModlistSettingsEditorVM.cs b/Wabbajack/View Models/Compilers/ModlistSettingsEditorVM.cs index 1aae9160..623bed28 100644 --- a/Wabbajack/View Models/Compilers/ModlistSettingsEditorVM.cs +++ b/Wabbajack/View Models/Compilers/ModlistSettingsEditorVM.cs @@ -20,6 +20,9 @@ namespace Wabbajack [Reactive] public string VersionText { get; set; } + private ObservableAsPropertyHelper _version; + public Version Version => _version.Value; + [Reactive] public string AuthorText { get; set; } @@ -46,18 +49,21 @@ namespace Wabbajack }; ImagePath.Filters.Add(new CommonFileDialogFilter("Banner image", "*.png")); + _version = this.WhenAny(x => x.VersionText) + .Select(x => + { + if (string.IsNullOrWhiteSpace(x)) + return new Version(0, 0); + + return !Version.TryParse(x, out var version) ? new Version(0, 0) : version; + }).ObserveOnGuiThread() + .ToProperty(this, x => x.Version); + InError = this.WhenAny(x => x.ImagePath.ErrorState) .Select(err => err.Failed) .CombineLatest( this.WhenAny(x => x.VersionText) - .Select(x => - { - if (string.IsNullOrWhiteSpace(x)) - return false; - - var match = Consts.VersionRegex.Match(x); - return match.Success; - }), + .Select(x => Version.TryParse(x, out _)), (image, version) => !image && !version) .Publish() .RefCount();