diff options
-rw-r--r-- | docs/release-notes.md | 1 | ||||
-rw-r--r-- | src/SMAPI/Framework/Models/SConfig.cs | 2 | ||||
-rw-r--r-- | src/SMAPI/ISemanticVersion.cs | 3 | ||||
-rw-r--r-- | src/SMAPI/Program.cs | 2 | ||||
-rw-r--r-- | src/SMAPI/SemanticVersion.cs | 6 |
5 files changed, 12 insertions, 2 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index d13d9f8c..e913618a 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -12,6 +12,7 @@ * Added code analysis to mod build config package to flag common issues as warnings. * Added `Context.IsMultiplayer` and `Context.IsMainPlayer` flags. * Added `Constants.TargetPlatform` which says whether the game is running on Linux, Mac, or Windows. + * Added `semanticVersion.IsPrerelease()` method. * Fixed assets loaded by temporary content managers not being editable by mods. * Fixed assets not reloaded consistently when the player switches language. * Fixed console command input not saved to the log. diff --git a/src/SMAPI/Framework/Models/SConfig.cs b/src/SMAPI/Framework/Models/SConfig.cs index be84a6b9..b732921f 100644 --- a/src/SMAPI/Framework/Models/SConfig.cs +++ b/src/SMAPI/Framework/Models/SConfig.cs @@ -13,7 +13,7 @@ namespace StardewModdingAPI.Framework.Models public bool CheckForUpdates { get; set; } /// <summary>Whether to show beta versions as valid updates.</summary> - public bool UseBetaChannel { get; set; } = Constants.ApiVersion.Build != null; + public bool UseBetaChannel { get; set; } = Constants.ApiVersion.IsPrerelease(); /// <summary>SMAPI's GitHub project name, used to perform update checks.</summary> public string GitHubProjectName { get; set; } diff --git a/src/SMAPI/ISemanticVersion.cs b/src/SMAPI/ISemanticVersion.cs index 0483c97b..961ef777 100644 --- a/src/SMAPI/ISemanticVersion.cs +++ b/src/SMAPI/ISemanticVersion.cs @@ -24,6 +24,9 @@ namespace StardewModdingAPI /********* ** Accessors *********/ + /// <summary>Whether this is a pre-release version.</summary> + bool IsPrerelease(); + /// <summary>Get whether this version is older than the specified version.</summary> /// <param name="other">The version to compare with this instance.</param> bool IsOlderThan(ISemanticVersion other); diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index ba3e238d..64520ccf 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -670,7 +670,7 @@ namespace StardewModdingAPI return newVersion != null && newVersion.IsNewerThan(currentVersion) - && (useBetaChannel || newVersion.Build == null); + && (useBetaChannel || !newVersion.IsPrerelease()); } /// <summary>Create a directory path if it doesn't exist.</summary> diff --git a/src/SMAPI/SemanticVersion.cs b/src/SMAPI/SemanticVersion.cs index 0f2a5cb0..9db1cf14 100644 --- a/src/SMAPI/SemanticVersion.cs +++ b/src/SMAPI/SemanticVersion.cs @@ -55,6 +55,12 @@ namespace StardewModdingAPI public SemanticVersion(Version version) : this(new SemanticVersionImpl(version)) { } + /// <summary>Whether this is a pre-release version.</summary> + public bool IsPrerelease() + { + return !string.IsNullOrWhiteSpace(this.Build); + } + /// <summary>Get an integer indicating whether this version precedes (less than 0), supercedes (more than 0), or is equivalent to (0) the specified version.</summary> /// <param name="other">The version to compare with this instance.</param> /// <exception cref="ArgumentNullException">The <paramref name="other"/> value is null.</exception> |