mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Replaced VersionRegex with Version.TryParse
This commit is contained in:
parent
50613fa438
commit
8aa8013725
@ -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}[^\.]$");
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -188,6 +188,7 @@ namespace Wabbajack
|
||||
ModListWebsite = ModlistSettings.Website,
|
||||
ModlistReadme = ModlistSettings.Readme,
|
||||
MO2DownloadsFolder = DownloadLocation.TargetPath,
|
||||
ModlistVersion = ModlistSettings.Version
|
||||
})
|
||||
{
|
||||
Parent.MWVM.Settings.Performance.AttachToBatchProcessor(ActiveCompilation);
|
||||
|
@ -20,6 +20,9 @@ namespace Wabbajack
|
||||
[Reactive]
|
||||
public string VersionText { get; set; }
|
||||
|
||||
private ObservableAsPropertyHelper<Version> _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();
|
||||
|
Loading…
Reference in New Issue
Block a user