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 ModOrganizer2Exe = (RelativePath)"ModOrganizer.exe";
|
||||||
public static RelativePath ModOrganizer2Ini = (RelativePath)"ModOrganizer.ini";
|
public static RelativePath ModOrganizer2Ini = (RelativePath)"ModOrganizer.ini";
|
||||||
public static string AuthorAPIKeyFile = "author-api-key.txt";
|
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 abstract class ACompiler : ABatchProcessor
|
||||||
{
|
{
|
||||||
public string? ModListName, ModListAuthor, ModListDescription, ModListWebsite, ModlistReadme;
|
public string? ModListName, ModListAuthor, ModListDescription, ModListWebsite, ModlistReadme;
|
||||||
|
public Version? ModlistVersion;
|
||||||
public AbsolutePath ModListImage;
|
public AbsolutePath ModListImage;
|
||||||
protected Version? WabbajackVersion;
|
protected Version? WabbajackVersion;
|
||||||
|
|
||||||
|
@ -188,6 +188,7 @@ namespace Wabbajack
|
|||||||
ModListWebsite = ModlistSettings.Website,
|
ModListWebsite = ModlistSettings.Website,
|
||||||
ModlistReadme = ModlistSettings.Readme,
|
ModlistReadme = ModlistSettings.Readme,
|
||||||
MO2DownloadsFolder = DownloadLocation.TargetPath,
|
MO2DownloadsFolder = DownloadLocation.TargetPath,
|
||||||
|
ModlistVersion = ModlistSettings.Version
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
Parent.MWVM.Settings.Performance.AttachToBatchProcessor(ActiveCompilation);
|
Parent.MWVM.Settings.Performance.AttachToBatchProcessor(ActiveCompilation);
|
||||||
|
@ -20,6 +20,9 @@ namespace Wabbajack
|
|||||||
[Reactive]
|
[Reactive]
|
||||||
public string VersionText { get; set; }
|
public string VersionText { get; set; }
|
||||||
|
|
||||||
|
private ObservableAsPropertyHelper<Version> _version;
|
||||||
|
public Version Version => _version.Value;
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string AuthorText { get; set; }
|
public string AuthorText { get; set; }
|
||||||
|
|
||||||
@ -46,18 +49,21 @@ namespace Wabbajack
|
|||||||
};
|
};
|
||||||
ImagePath.Filters.Add(new CommonFileDialogFilter("Banner image", "*.png"));
|
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)
|
InError = this.WhenAny(x => x.ImagePath.ErrorState)
|
||||||
.Select(err => err.Failed)
|
.Select(err => err.Failed)
|
||||||
.CombineLatest(
|
.CombineLatest(
|
||||||
this.WhenAny(x => x.VersionText)
|
this.WhenAny(x => x.VersionText)
|
||||||
.Select(x =>
|
.Select(x => Version.TryParse(x, out _)),
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(x))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var match = Consts.VersionRegex.Match(x);
|
|
||||||
return match.Success;
|
|
||||||
}),
|
|
||||||
(image, version) => !image && !version)
|
(image, version) => !image && !version)
|
||||||
.Publish()
|
.Publish()
|
||||||
.RefCount();
|
.RefCount();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user