From 7015e4ee8777c4a1c3934c1f3e9c3ceefcc1295d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 15 Mar 2018 20:58:43 -0400 Subject: show prerelease SMAPI updates when updating from an older prerelease of the same version (#457) --- src/SMAPI/Program.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Program.cs') diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index 4bd40710..e4b279f7 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -541,8 +541,10 @@ namespace StardewModdingAPI this.Monitor.Log("Couldn't check for a new version of SMAPI. This won't affect your game, but you may not be notified of new versions if this keeps happening.", LogLevel.Warn); this.Monitor.Log($"Error: {response.Error}"); } - else if (new SemanticVersion(response.Version).IsNewerThan(Constants.ApiVersion)) + else if (this.IsValidUpdate(Constants.ApiVersion, new SemanticVersion(response.Version))) this.Monitor.Log($"You can update SMAPI to {response.Version}: {response.Url}", LogLevel.Alert); + else if (response.PreviewVersion != null && this.IsValidUpdate(Constants.ApiVersion, new SemanticVersion(response.PreviewVersion))) + this.Monitor.Log($"You can update SMAPI to {response.PreviewVersion}: {response.Url}", LogLevel.Alert); else this.Monitor.Log(" SMAPI okay.", LogLevel.Trace); } @@ -656,6 +658,27 @@ namespace StardewModdingAPI }).Start(); } + /// Get whether a given version should be offered to the user as an update. + /// The current semantic version. + /// The target semantic version. + private bool IsValidUpdate(ISemanticVersion currentVersion, ISemanticVersion newVersion) + { + // basic eligibility + bool isNewer = newVersion.IsNewerThan(currentVersion); + bool isPrerelease = newVersion.Build != null; + bool isEquallyStable = !isPrerelease || currentVersion.Build != null; // don't update stable => prerelease + if (!isNewer || !isEquallyStable) + return false; + if (!isPrerelease) + return true; + + // prerelease eligible if same version (excluding prerelease tag) + return + newVersion.MajorVersion == currentVersion.MajorVersion + && newVersion.MinorVersion == currentVersion.MinorVersion + && newVersion.PatchVersion == currentVersion.PatchVersion; + } + /// Create a directory path if it doesn't exist. /// The directory path. private void VerifyPath(string path) -- cgit From 90cdbdf7b29ddeee80b213957a02e0e5c691282e Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 15 Mar 2018 21:23:36 -0400 Subject: link SMAPI update checks to smapi.io instead of GitHub (#457) --- src/SMAPI/Constants.cs | 4 ++-- src/SMAPI/Program.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/SMAPI/Program.cs') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index d91fa5fb..7a497a53 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -81,8 +81,8 @@ namespace StardewModdingAPI /**** ** Internal ****/ - /// The GitHub repository to check for updates. - internal const string GitHubRepository = "Pathoschild/SMAPI"; + /// The URL of the SMAPI home page. + internal const string HomePageUrl = "https://smapi.io"; /// The file path for the SMAPI configuration file. internal static string ApiConfigPath => Path.Combine(Constants.ExecutionPath, $"{typeof(Program).Assembly.GetName().Name}.config.json"); diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index e4b279f7..8c1ea238 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -542,9 +542,9 @@ namespace StardewModdingAPI this.Monitor.Log($"Error: {response.Error}"); } else if (this.IsValidUpdate(Constants.ApiVersion, new SemanticVersion(response.Version))) - this.Monitor.Log($"You can update SMAPI to {response.Version}: {response.Url}", LogLevel.Alert); + this.Monitor.Log($"You can update SMAPI to {response.Version}: {Constants.HomePageUrl}", LogLevel.Alert); else if (response.PreviewVersion != null && this.IsValidUpdate(Constants.ApiVersion, new SemanticVersion(response.PreviewVersion))) - this.Monitor.Log($"You can update SMAPI to {response.PreviewVersion}: {response.Url}", LogLevel.Alert); + this.Monitor.Log($"You can update SMAPI to {response.PreviewVersion}: {Constants.HomePageUrl}", LogLevel.Alert); else this.Monitor.Log(" SMAPI okay.", LogLevel.Trace); } -- cgit From 5126d56b3992acd3193aaae35f178bb5e9da1cae Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 23 Mar 2018 22:41:15 -0400 Subject: fix error when a mod removes an asset editor/loader (#460) --- docs/release-notes.md | 3 ++- src/SMAPI/Program.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/SMAPI/Program.cs') diff --git a/docs/release-notes.md b/docs/release-notes.md index c40e41be..33e66a14 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -18,7 +18,8 @@ ## 2.5.4 * For players: * Fixed tree textures not updated when changed through the content API. - * Fixed display bugs on Linux/Mac when mods overlay images through the content API. + * Fixed visual bug on Linux/Mac when mods overlay images through the content API. + * Fixed error when a mod removes an asset editor/loader. * For the [log parser][]: * Fixed error when log text contains certain tokens. diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index 8c1ea238..1b8cb2ba 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -953,7 +953,7 @@ namespace StardewModdingAPI { helper.ObservableAssetEditors.CollectionChanged += (sender, e) => { - if (e.NewItems.Count > 0) + if (e.NewItems?.Count > 0) { this.Monitor.Log("Invalidating cache entries for new asset editors...", LogLevel.Trace); this.ContentCore.InvalidateCacheFor(e.NewItems.Cast().ToArray(), new IAssetLoader[0]); @@ -961,7 +961,7 @@ namespace StardewModdingAPI }; helper.ObservableAssetLoaders.CollectionChanged += (sender, e) => { - if (e.NewItems.Count > 0) + if (e.NewItems?.Count > 0) { this.Monitor.Log("Invalidating cache entries for new asset loaders...", LogLevel.Trace); this.ContentCore.InvalidateCacheFor(new IAssetEditor[0], e.NewItems.Cast().ToArray()); -- cgit