From ae01396d9db77789937ff26cfc1cdf90feea68b2 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 13 Jul 2017 17:26:36 -0400 Subject: fix crash in unique-ID check when mod has no manifest (#323) --- src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs index b75453b7..16c397be 100644 --- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs +++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs @@ -161,7 +161,7 @@ namespace StardewModdingAPI.Framework.ModLoading #if !SMAPI_1_x { var duplicatesByID = mods - .GroupBy(mod => mod.Manifest.UniqueID?.Trim(), mod => mod, StringComparer.InvariantCultureIgnoreCase) + .GroupBy(mod => mod.Manifest?.UniqueID?.Trim(), mod => mod, StringComparer.InvariantCultureIgnoreCase) .Where(p => p.Count() > 1); foreach (var group in duplicatesByID) { -- cgit From 48ced0336c5e0f41efd2ecf3b5a03f11596d79d1 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 13 Jul 2017 18:30:46 -0400 Subject: use more readable colours if player has a light-backgrounded terminal (#327) --- release-notes.md | 1 + src/StardewModdingAPI/Framework/Monitor.cs | 61 +++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/release-notes.md b/release-notes.md index 924ecb90..6e6d87ab 100644 --- a/release-notes.md +++ b/release-notes.md @@ -4,6 +4,7 @@ For players: * The SMAPI console is now much simpler and easier-to-read. +* The SMAPI console now uses more readable colors in terminals with a light background. For mod developers: * Added API to edit XNB images & data loaded by the game (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Content)). diff --git a/src/StardewModdingAPI/Framework/Monitor.cs b/src/StardewModdingAPI/Framework/Monitor.cs index 5ae24a73..c2c3a689 100644 --- a/src/StardewModdingAPI/Framework/Monitor.cs +++ b/src/StardewModdingAPI/Framework/Monitor.cs @@ -25,15 +25,7 @@ namespace StardewModdingAPI.Framework private static readonly int MaxLevelLength = (from level in Enum.GetValues(typeof(LogLevel)).Cast() select level.ToString().Length).Max(); /// The console text color for each log level. - private static readonly Dictionary Colors = new Dictionary - { - [LogLevel.Trace] = ConsoleColor.DarkGray, - [LogLevel.Debug] = ConsoleColor.DarkGray, - [LogLevel.Info] = ConsoleColor.White, - [LogLevel.Warn] = ConsoleColor.Yellow, - [LogLevel.Error] = ConsoleColor.Red, - [LogLevel.Alert] = ConsoleColor.Magenta - }; + private static readonly IDictionary Colors = Monitor.GetConsoleColorScheme(); /// Propagates notification that SMAPI should exit. private readonly CancellationTokenSource ExitTokenSource; @@ -172,5 +164,56 @@ namespace StardewModdingAPI.Framework if (this.WriteToFile) this.LogFile.WriteLine(fullMessage); } + + /// Get the color scheme to use for the current console. + private static IDictionary GetConsoleColorScheme() + { +#if !SMAPI_1_x + // scheme for dark console background + if (Monitor.IsDark(Console.BackgroundColor)) + { +#endif + return new Dictionary + { + [LogLevel.Trace] = ConsoleColor.DarkGray, + [LogLevel.Debug] = ConsoleColor.DarkGray, + [LogLevel.Info] = ConsoleColor.White, + [LogLevel.Warn] = ConsoleColor.Yellow, + [LogLevel.Error] = ConsoleColor.Red, + [LogLevel.Alert] = ConsoleColor.Magenta + }; +#if !SMAPI_1_x + } + + // scheme for light console background + return new Dictionary + { + [LogLevel.Trace] = ConsoleColor.DarkGray, + [LogLevel.Debug] = ConsoleColor.DarkGray, + [LogLevel.Info] = ConsoleColor.Black, + [LogLevel.Warn] = ConsoleColor.DarkYellow, + [LogLevel.Error] = ConsoleColor.Red, + [LogLevel.Alert] = ConsoleColor.DarkMagenta + }; +#endif + } + + /// Get whether a console color should be considered dark, which is subjectively defined as 'white looks better than black on this text'. + /// The color to check. + private static bool IsDark(ConsoleColor color) + { + switch (color) + { + case ConsoleColor.Black: + case ConsoleColor.Blue: + case ConsoleColor.DarkBlue: + case ConsoleColor.DarkRed: + case ConsoleColor.Red: + return true; + + default: + return false; + } + } } } -- cgit From f050f4ba31e8e1287f084fe8508632e3547a23ec Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 13 Jul 2017 19:44:59 -0400 Subject: simplify SMAPI 2.0 release notes --- release-notes.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/release-notes.md b/release-notes.md index 6e6d87ab..0cc3b2a2 100644 --- a/release-notes.md +++ b/release-notes.md @@ -7,17 +7,13 @@ For players: * The SMAPI console now uses more readable colors in terminals with a light background. For mod developers: -* Added API to edit XNB images & data loaded by the game (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Content)). -* Added API to inject new XNB images & data (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Content)). -* Added `InputEvents` which unify keyboard, mouse, and controller input for much simpler input handling (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Input_events)). -* Added useful `InputEvents` metadata like the cursor position, grab tile, etc. -* Added ability to prevent the game from handling a button press via `InputEvents`. -* In `manifest.json`: - * Dependencies can now be optional. - * The version can now be a string like `"1.0-alpha"` instead of a structure. - * The `Name`, `Version,` and `UniqueID` fields are no longer optional. - * The `UniqueID` field must now be unique (case-insensitive). If two installed mods have the same ID, SMAPI will show an error and load neither. +* Added APIs to edit or inject XNBs loaded by the game at runtime, which let mods do anything previously only possible with XNB mods. +* Added `InputEvents` which combine keyboard + mouse + controller input for simpler input handling; add metadata like the cursor position and grab tile for simpler click handling; and add an option to suppress input from the game. +* Added support for optional dependencies. +* Added support for string versions (like `"1.0-alpha"`) in `manifest.json`. * Removed all deprecated code. +* Removed support for mods with no `Name`, `Version`, or `UniqueID` in their manifest. +* Removed support for mods with a non-unique `UniqueID` value in their manifest. ## 1.15.1 For players: -- cgit From 5726ebe20ee65e1d9f73678bc72210fa73d50fc0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 13 Jul 2017 22:42:13 -0400 Subject: remove TrainerMod's save and load commands in 2.0 --- release-notes.md | 1 + src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs | 4 +++- src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/release-notes.md b/release-notes.md index 0cc3b2a2..610426d7 100644 --- a/release-notes.md +++ b/release-notes.md @@ -14,6 +14,7 @@ For mod developers: * Removed all deprecated code. * Removed support for mods with no `Name`, `Version`, or `UniqueID` in their manifest. * Removed support for mods with a non-unique `UniqueID` value in their manifest. +* Removed the TrainerMod `save` and `load` commands. ## 1.15.1 For players: diff --git a/src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs b/src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs index 121ad9a6..ad79b4af 100644 --- a/src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs +++ b/src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs @@ -1,4 +1,5 @@ -using StardewModdingAPI; +#if SMAPI_1_x +using StardewModdingAPI; using StardewValley; using StardewValley.Menus; @@ -26,3 +27,4 @@ namespace TrainerMod.Framework.Commands.Saves } } } +#endif \ No newline at end of file diff --git a/src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs b/src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs index 5f6941e9..ea2bd6a8 100644 --- a/src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs +++ b/src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs @@ -1,4 +1,5 @@ -using StardewModdingAPI; +#if SMAPI_1_x +using StardewModdingAPI; using StardewValley; namespace TrainerMod.Framework.Commands.Saves @@ -25,3 +26,4 @@ namespace TrainerMod.Framework.Commands.Saves } } } +#endif \ No newline at end of file -- cgit From 24b824644d708a514614b4e30b41567ea87902cc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 20 Jul 2017 00:01:40 -0400 Subject: make semantic versions equatable in 2.0 --- release-notes.md | 1 + src/StardewModdingAPI/ISemanticVersion.cs | 3 +++ src/StardewModdingAPI/SemanticVersion.cs | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/release-notes.md b/release-notes.md index 610426d7..9d9131ca 100644 --- a/release-notes.md +++ b/release-notes.md @@ -11,6 +11,7 @@ For mod developers: * Added `InputEvents` which combine keyboard + mouse + controller input for simpler input handling; add metadata like the cursor position and grab tile for simpler click handling; and add an option to suppress input from the game. * Added support for optional dependencies. * Added support for string versions (like `"1.0-alpha"`) in `manifest.json`. +* Added `IEquatable` to `ISemanticVersion`. * Removed all deprecated code. * Removed support for mods with no `Name`, `Version`, or `UniqueID` in their manifest. * Removed support for mods with a non-unique `UniqueID` value in their manifest. diff --git a/src/StardewModdingAPI/ISemanticVersion.cs b/src/StardewModdingAPI/ISemanticVersion.cs index 27a2f67d..c1a4ca3a 100644 --- a/src/StardewModdingAPI/ISemanticVersion.cs +++ b/src/StardewModdingAPI/ISemanticVersion.cs @@ -4,6 +4,9 @@ namespace StardewModdingAPI { /// A semantic version with an optional release tag. public interface ISemanticVersion : IComparable +#if !SMAPI_1_x + , IEquatable +#endif { /********* ** Accessors diff --git a/src/StardewModdingAPI/SemanticVersion.cs b/src/StardewModdingAPI/SemanticVersion.cs index 4b27c819..f30c43cd 100644 --- a/src/StardewModdingAPI/SemanticVersion.cs +++ b/src/StardewModdingAPI/SemanticVersion.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Text.RegularExpressions; namespace StardewModdingAPI @@ -178,6 +178,16 @@ namespace StardewModdingAPI return this.IsBetween(new SemanticVersion(min), new SemanticVersion(max)); } +#if !SMAPI_1_x + /// Indicates whether the current object is equal to another object of the same type. + /// true if the current object is equal to the parameter; otherwise, false. + /// An object to compare with this object. + public bool Equals(ISemanticVersion other) + { + return other != null && this.CompareTo(other) == 0; + } +#endif + /// Get a string representation of the version. public override string ToString() { -- cgit From d0e0e9427e9d407e1613a1cb9265beed103bd80f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 20 Jul 2017 00:03:41 -0400 Subject: rename ManifestFieldConverter for broader usage --- src/StardewModdingAPI/Framework/Models/Manifest.cs | 6 +- .../Serialisation/ManifestFieldConverter.cs | 99 ---------------------- .../Framework/Serialisation/SFieldConverter.cs | 99 ++++++++++++++++++++++ src/StardewModdingAPI/StardewModdingAPI.csproj | 2 +- 4 files changed, 103 insertions(+), 103 deletions(-) delete mode 100644 src/StardewModdingAPI/Framework/Serialisation/ManifestFieldConverter.cs create mode 100644 src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs diff --git a/src/StardewModdingAPI/Framework/Models/Manifest.cs b/src/StardewModdingAPI/Framework/Models/Manifest.cs index 1b5c2646..29c3517e 100644 --- a/src/StardewModdingAPI/Framework/Models/Manifest.cs +++ b/src/StardewModdingAPI/Framework/Models/Manifest.cs @@ -21,18 +21,18 @@ namespace StardewModdingAPI.Framework.Models public string Author { get; set; } /// The mod version. - [JsonConverter(typeof(ManifestFieldConverter))] + [JsonConverter(typeof(SFieldConverter))] public ISemanticVersion Version { get; set; } /// The minimum SMAPI version required by this mod, if any. - [JsonConverter(typeof(ManifestFieldConverter))] + [JsonConverter(typeof(SFieldConverter))] public ISemanticVersion MinimumApiVersion { get; set; } /// The name of the DLL in the directory that has the method. public string EntryDll { get; set; } /// The other mods that must be loaded before this mod. - [JsonConverter(typeof(ManifestFieldConverter))] + [JsonConverter(typeof(SFieldConverter))] public IManifestDependency[] Dependencies { get; set; } /// The unique mod ID. diff --git a/src/StardewModdingAPI/Framework/Serialisation/ManifestFieldConverter.cs b/src/StardewModdingAPI/Framework/Serialisation/ManifestFieldConverter.cs deleted file mode 100644 index 6947311b..00000000 --- a/src/StardewModdingAPI/Framework/Serialisation/ManifestFieldConverter.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using StardewModdingAPI.Framework.Exceptions; -using StardewModdingAPI.Framework.Models; - -namespace StardewModdingAPI.Framework.Serialisation -{ - /// Overrides how SMAPI reads and writes and fields. - internal class ManifestFieldConverter : JsonConverter - { - /********* - ** Accessors - *********/ - /// Whether this converter can write JSON. - public override bool CanWrite => false; - - - /********* - ** Public methods - *********/ - /// Get whether this instance can convert the specified object type. - /// The object type. - public override bool CanConvert(Type objectType) - { - return objectType == typeof(ISemanticVersion) || objectType == typeof(IManifestDependency[]); - } - - /// Reads the JSON representation of the object. - /// The JSON reader. - /// The object type. - /// The object being read. - /// The calling serializer. - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - // semantic version - if (objectType == typeof(ISemanticVersion)) - { - JToken token = JToken.Load(reader); - switch (token.Type) - { - case JTokenType.Object: - { - JObject obj = (JObject)token; - int major = obj.Value(nameof(ISemanticVersion.MajorVersion)); - int minor = obj.Value(nameof(ISemanticVersion.MinorVersion)); - int patch = obj.Value(nameof(ISemanticVersion.PatchVersion)); - string build = obj.Value(nameof(ISemanticVersion.Build)); - return new SemanticVersion(major, minor, patch, build); - } - - case JTokenType.String: - { - string str = token.Value(); - if (string.IsNullOrWhiteSpace(str)) - return null; - if (!SemanticVersion.TryParse(str, out ISemanticVersion version)) - throw new SParseException($"Can't parse semantic version from invalid value '{str}', should be formatted like 1.2, 1.2.30, or 1.2.30-beta."); - return version; - } - - default: - throw new SParseException($"Can't parse semantic version from {token.Type}, must be an object or string."); - } - } - - // manifest dependency - if (objectType == typeof(IManifestDependency[])) - { - List result = new List(); - foreach (JObject obj in JArray.Load(reader).Children()) - { - string uniqueID = obj.Value(nameof(IManifestDependency.UniqueID)); - string minVersion = obj.Value(nameof(IManifestDependency.MinimumVersion)); -#if SMAPI_1_x - result.Add(new ManifestDependency(uniqueID, minVersion)); -#else - bool required = obj.Value(nameof(IManifestDependency.IsRequired)) ?? true; - result.Add(new ManifestDependency(uniqueID, minVersion, required)); -#endif - } - return result.ToArray(); - } - - // unknown - throw new NotSupportedException($"Unknown type '{objectType?.FullName}'."); - } - - /// Writes the JSON representation of the object. - /// The JSON writer. - /// The value. - /// The calling serializer. - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new InvalidOperationException("This converter does not write JSON."); - } - } -} diff --git a/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs new file mode 100644 index 00000000..9dc62b6a --- /dev/null +++ b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using StardewModdingAPI.Framework.Exceptions; +using StardewModdingAPI.Framework.Models; + +namespace StardewModdingAPI.Framework.Serialisation +{ + /// Overrides how SMAPI reads and writes and fields. + internal class SFieldConverter : JsonConverter + { + /********* + ** Accessors + *********/ + /// Whether this converter can write JSON. + public override bool CanWrite => false; + + + /********* + ** Public methods + *********/ + /// Get whether this instance can convert the specified object type. + /// The object type. + public override bool CanConvert(Type objectType) + { + return objectType == typeof(ISemanticVersion) || objectType == typeof(IManifestDependency[]); + } + + /// Reads the JSON representation of the object. + /// The JSON reader. + /// The object type. + /// The object being read. + /// The calling serializer. + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + // semantic version + if (objectType == typeof(ISemanticVersion)) + { + JToken token = JToken.Load(reader); + switch (token.Type) + { + case JTokenType.Object: + { + JObject obj = (JObject)token; + int major = obj.Value(nameof(ISemanticVersion.MajorVersion)); + int minor = obj.Value(nameof(ISemanticVersion.MinorVersion)); + int patch = obj.Value(nameof(ISemanticVersion.PatchVersion)); + string build = obj.Value(nameof(ISemanticVersion.Build)); + return new SemanticVersion(major, minor, patch, build); + } + + case JTokenType.String: + { + string str = token.Value(); + if (string.IsNullOrWhiteSpace(str)) + return null; + if (!SemanticVersion.TryParse(str, out ISemanticVersion version)) + throw new SParseException($"Can't parse semantic version from invalid value '{str}', should be formatted like 1.2, 1.2.30, or 1.2.30-beta."); + return version; + } + + default: + throw new SParseException($"Can't parse semantic version from {token.Type}, must be an object or string."); + } + } + + // manifest dependency + if (objectType == typeof(IManifestDependency[])) + { + List result = new List(); + foreach (JObject obj in JArray.Load(reader).Children()) + { + string uniqueID = obj.Value(nameof(IManifestDependency.UniqueID)); + string minVersion = obj.Value(nameof(IManifestDependency.MinimumVersion)); +#if SMAPI_1_x + result.Add(new ManifestDependency(uniqueID, minVersion)); +#else + bool required = obj.Value(nameof(IManifestDependency.IsRequired)) ?? true; + result.Add(new ManifestDependency(uniqueID, minVersion, required)); +#endif + } + return result.ToArray(); + } + + // unknown + throw new NotSupportedException($"Unknown type '{objectType?.FullName}'."); + } + + /// Writes the JSON representation of the object. + /// The JSON writer. + /// The value. + /// The calling serializer. + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new InvalidOperationException("This converter does not write JSON."); + } + } +} diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj index f778660d..9047aea4 100644 --- a/src/StardewModdingAPI/StardewModdingAPI.csproj +++ b/src/StardewModdingAPI/StardewModdingAPI.csproj @@ -159,7 +159,7 @@ - + -- cgit From 6ddcef61e94a81711ad25a378f0fa03d7799f2dc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 20 Jul 2017 00:05:39 -0400 Subject: simplify mod compatibility model parsing --- .../Framework/ModLoading/ModResolver.cs | 6 ++-- .../Framework/Models/ModCompatibility.cs | 35 ++++------------------ 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs index 16c397be..cf43eb45 100644 --- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs +++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs @@ -72,8 +72,8 @@ namespace StardewModdingAPI.Framework.ModLoading from mod in compatibilityRecords where mod.ID.Contains(key, StringComparer.InvariantCultureIgnoreCase) - && (mod.LowerSemanticVersion == null || !manifest.Version.IsOlderThan(mod.LowerSemanticVersion)) - && !manifest.Version.IsNewerThan(mod.UpperSemanticVersion) + && (mod.LowerVersion == null || !manifest.Version.IsOlderThan(mod.LowerVersion)) + && !manifest.Version.IsNewerThan(mod.UpperVersion) select mod ).FirstOrDefault(); } @@ -113,7 +113,7 @@ namespace StardewModdingAPI.Framework.ModLoading bool hasUnofficialUrl = !string.IsNullOrWhiteSpace(mod.Compatibility.UnofficialUpdateUrl); string reasonPhrase = compatibility.ReasonPhrase ?? "it's not compatible with the latest version of the game or SMAPI"; - string error = $"{reasonPhrase}. Please check for a version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion} here:"; + string error = $"{reasonPhrase}. Please check for a version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()} here:"; if (hasOfficialUrl) error += !hasUnofficialUrl ? $" {compatibility.UpdateUrl}" : $"{Environment.NewLine}- official mod: {compatibility.UpdateUrl}"; if (hasUnofficialUrl) diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs index 90cbd237..eb312eff 100644 --- a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs +++ b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs @@ -1,5 +1,5 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; +using Newtonsoft.Json; +using StardewModdingAPI.Framework.Serialisation; namespace StardewModdingAPI.Framework.Models { @@ -19,10 +19,12 @@ namespace StardewModdingAPI.Framework.Models public string Name { get; set; } /// The oldest incompatible mod version, or null for all past versions. - public string LowerVersion { get; set; } + [JsonConverter(typeof(SFieldConverter))] + public ISemanticVersion LowerVersion { get; set; } /// The most recent incompatible mod version. - public string UpperVersion { get; set; } + [JsonConverter(typeof(SFieldConverter))] + public ISemanticVersion UpperVersion { get; set; } /// A label to show to the user instead of , when the manifest version differs from the user-facing version. public string UpperVersionLabel { get; set; } @@ -39,30 +41,5 @@ namespace StardewModdingAPI.Framework.Models /// Indicates how SMAPI should consider the mod. public ModCompatibilityType Compatibility { get; set; } - - - /**** - ** Injected - ****/ - /// The semantic version corresponding to . - [JsonIgnore] - public ISemanticVersion LowerSemanticVersion { get; set; } - - /// The semantic version corresponding to . - [JsonIgnore] - public ISemanticVersion UpperSemanticVersion { get; set; } - - - /********* - ** Private methods - *********/ - /// The method called when the model finishes deserialising. - /// The deserialisation context. - [OnDeserialized] - private void OnDeserialized(StreamingContext context) - { - this.LowerSemanticVersion = this.LowerVersion != null ? new SemanticVersion(this.LowerVersion) : null; - this.UpperSemanticVersion = this.UpperVersion != null ? new SemanticVersion(this.UpperVersion) : null; - } } } -- cgit From 7d73b0bf0c545b281d9d84bc73ad40932764b483 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 20 Jul 2017 00:37:58 -0400 Subject: simplify compatibility skip message in 2.0 & combine update URL fields --- .../Framework/ModLoading/ModResolver.cs | 18 +++- .../Framework/Models/ModCompatibility.cs | 7 +- .../StardewModdingAPI.config.json | 104 +++++++++------------ 3 files changed, 62 insertions(+), 67 deletions(-) diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs index cf43eb45..fdcbdaa7 100644 --- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs +++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs @@ -109,15 +109,25 @@ namespace StardewModdingAPI.Framework.ModLoading ModCompatibility compatibility = mod.Compatibility; if (compatibility?.Compatibility == ModCompatibilityType.AssumeBroken) { - bool hasOfficialUrl = !string.IsNullOrWhiteSpace(mod.Compatibility.UpdateUrl); - bool hasUnofficialUrl = !string.IsNullOrWhiteSpace(mod.Compatibility.UnofficialUpdateUrl); +#if SMAPI_1_x + bool hasOfficialUrl = mod.Compatibility.UpdateUrls.Length > 0; + bool hasUnofficialUrl = mod.Compatibility.UpdateUrls.Length > 1; string reasonPhrase = compatibility.ReasonPhrase ?? "it's not compatible with the latest version of the game or SMAPI"; string error = $"{reasonPhrase}. Please check for a version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()} here:"; if (hasOfficialUrl) - error += !hasUnofficialUrl ? $" {compatibility.UpdateUrl}" : $"{Environment.NewLine}- official mod: {compatibility.UpdateUrl}"; + error += !hasUnofficialUrl ? $" {compatibility.UpdateUrls[0]}" : $"{Environment.NewLine}- official mod: {compatibility.UpdateUrls[0]}"; if (hasUnofficialUrl) - error += $"{Environment.NewLine}- unofficial update: {compatibility.UnofficialUpdateUrl}"; + error += $"{Environment.NewLine}- unofficial update: {compatibility.UpdateUrls[1]}"; +#else + string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible"; + string error = $"{reasonPhrase}. Please check for a "; + if (mod.Manifest.Version.Equals(compatibility.UpperVersion) && compatibility.UpperVersionLabel == null) + error += "newer version"; + else + error += $"version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()}"; + error += " at " + string.Join(" or ", compatibility.UpdateUrls); +#endif mod.SetStatus(ModMetadataStatus.Failed, error); continue; diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs index eb312eff..72b6f2af 100644 --- a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs +++ b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs @@ -29,11 +29,8 @@ namespace StardewModdingAPI.Framework.Models /// A label to show to the user instead of , when the manifest version differs from the user-facing version. public string UpperVersionLabel { get; set; } - /// The URL the user can check for an official updated version. - public string UpdateUrl { get; set; } - - /// The URL the user can check for an unofficial updated version. - public string UnofficialUpdateUrl { get; set; } + /// The URLs the user can check for a newer version. + public string[] UpdateUrls { get; set; } /// The reason phrase to show in the warning, or null to use the default value. /// "this version is incompatible with the latest version of the game" diff --git a/src/StardewModdingAPI/StardewModdingAPI.config.json b/src/StardewModdingAPI/StardewModdingAPI.config.json index 4e871636..90bf29c9 100644 --- a/src/StardewModdingAPI/StardewModdingAPI.config.json +++ b/src/StardewModdingAPI/StardewModdingAPI.config.json @@ -54,8 +54,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "AccessChestAnywhere" ], "UpperVersion": "1.1", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/257", - "UnofficialUpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/518", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/257", "http://www.nexusmods.com/stardewvalley/mods/518" ], "Notes": "Needs update for SDV 1.1." }, { @@ -63,7 +62,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "AlmightyTool.dll" ], "UpperVersion": "1.1.1", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/439", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/439" ], "Notes": "Needs update for SDV 1.2." }, { @@ -71,8 +70,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "SPDSprinklersMod", /*since 2.3*/ "Speeder.BetterSprinklers" ], "UpperVersion": "2.3.1-pathoschild-update", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/41", - "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/132096", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/41", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2 and to migrate broken TimeEvents.AfterDayOfMonthChanged." }, { @@ -80,8 +78,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "005e02dc-d900-425c-9c68-1ff55c5a295d" ], "UpperVersion": "1.2.2", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/276", - "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/132096", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/276", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2." }, { @@ -89,8 +86,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "SPDChestLabel" ], "UpperVersion": "1.6", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/242", - "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/132096", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/242", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.1." }, { @@ -98,7 +94,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "ChestPooling.dll" ], "UpperVersion": "1.2", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/threads/111988", + "UpdateUrls": [ "http://community.playstarbound.com/threads/111988" ], "Notes": "Needs update for SDV 1.2." }, { @@ -106,7 +102,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "ChestsAnywhere", /*since 1.9*/ "Pathoschild.ChestsAnywhere" ], "UpperVersion": "1.9-beta", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/518", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/518" ], "Notes": "Needs update for SDV 1.2." }, { @@ -114,22 +110,21 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "CJBAutomation" ], "UpperVersion": "1.4", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/211", - "UnofficialUpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/1063", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/211", "http://www.nexusmods.com/stardewvalley/mods/1063" ], "Notes": "Needs update for SDV 1.2." }, { "Name": "CJB Cheats Menu", "ID": [ "CJBCheatsMenu" ], "UpperVersion": "1.12", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/4", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/4" ], "Notes": "Needs update for SDV 1.1." }, { "Name": "CJB Item Spawner", "ID": [ "CJBItemSpawner" ], "UpperVersion": "1.5", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/93", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/93" ], "Notes": "Needs update for SDV 1.1." }, { @@ -137,7 +132,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "CJBShowItemSellPrice" ], "UpperVersion": "1.6", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/93", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/93" ], "Notes": "Needs update for SDV 1.2." }, { @@ -145,7 +140,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "CookingSkill" ], "UpperVersion": "1.0.3", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/522", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/522" ], "Notes": "Needs update for SDV 1.2." }, { @@ -153,8 +148,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "20d6b8a3-b6e7-460b-a6e4-07c2b0cb6c63" ], "UpperVersion": "1.0.4", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/569", - "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/132096", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/569", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2." }, { @@ -162,8 +156,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "SPDHealthBar" ], "UpperVersion": "1.7", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/193", - "UnofficialUrl": "http://community.playstarbound.com/threads/132096", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/193", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2." }, { @@ -171,7 +164,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "eacdb74b-4080-4452-b16b-93773cda5cf9", /*since ???*/ "Entoarox.EntoaroxFramework" ], "UpperVersion": "1.7.5", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/resources/4228", + "UpdateUrls": [ "http://community.playstarbound.com/resources/4228" ], "Notes": "Needs update for SDV 1.2." }, { @@ -180,7 +173,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "UpperVersion": "1.0", "UpperVersionLabel": "0.94", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/485", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/485" ], "Notes": "Needs update for SDV 1.2. Actual upper version is 0.94, but mod incorrectly sets it to 1.0 in the manifest." }, { @@ -188,7 +181,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "FarmAutomation.ItemCollector.dll", /*since 0.4*/ "Maddy99.FarmAutomation.ItemCollector" ], "UpperVersion": "0.4", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/threads/125172", + "UpdateUrls": [ "http://community.playstarbound.com/threads/125172" ], "Notes": "Needs update for SDV 1.2." }, { @@ -196,8 +189,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "InstantGeode" ], "UpperVersion": "1.12", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/threads/109038", - "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/132096", + "UpdateUrls": [ "http://community.playstarbound.com/threads/109038", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2." }, { @@ -205,7 +197,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "GateOpener.dll", /*since 1.1*/ "mralbobo.GateOpener" ], "UpperVersion": "1.0.1", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/threads/111988", + "UpdateUrls": [ "http://community.playstarbound.com/threads/111988" ], "Notes": "Needs update for SDV 1.2." }, { @@ -213,7 +205,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "GetDressed.dll", /*since 3.3*/ "Advize.GetDressed" ], "UpperVersion": "3.3", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/331", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/331" ], "Notes": "Needs update for SDV 1.2." }, { @@ -221,7 +213,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "8008db57-fa67-4730-978e-34b37ef191d6" ], "UpperVersion": "2.3.1", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/229", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/229" ], "Notes": "Needs update for SDV 1.2." }, { @@ -229,7 +221,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "LookupAnything", /*since 1.10.1*/ "Pathoschild.LookupAnything" ], "UpperVersion": "1.10.1", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/541", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/541" ], "Notes": "Needs update for SDV 1.2." }, { @@ -237,7 +229,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "StardewValleyMP", /*since 0.3*/ "spacechase0.StardewValleyMP" ], "Compatibility": "AssumeBroken", "UpperVersion": "0.3.3", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/501", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/501" ], "Notes": "Needs update for SDV 1.2." }, { @@ -245,8 +237,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "289dee03-5f38-4d8e-8ffc-e440198e8610" ], "UpperVersion": "0.5", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/237", - "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/132096", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/237", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2, and uses Assembly.GetExecutingAssembly().Location." }, { @@ -255,7 +246,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "LowerVersion": "1.42", "UpperVersion": "1.43", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/239", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/239" ], "ReasonPhrase": "These versions have an update check error which crash the game." }, { @@ -263,7 +254,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "SB_PotC" ], "UpperVersion": "1.0.8", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/923", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/923" ], "ReasonPhrase": "Needs update for SDV 1.2." }, { @@ -271,7 +262,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "PointAndPlant.dll" ], "UpperVersion": "1.0.2", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/572", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/572" ], "Notes": "Needs update for SDV 1.2." }, { @@ -279,8 +270,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "PrairieKingMadeEasy.dll" ], "UpperVersion": "1.0.0", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/resources/3594", - "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/132096", + "UpdateUrls": [ "http://community.playstarbound.com/resources/3594", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2." }, { @@ -288,7 +278,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "RushOrders", /*since 1.1*/ "spacechase0.RushOrders" ], "UpperVersion": "1.1", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/605", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/605" ], "Notes": "Needs update for SDV 1.2." }, { @@ -296,7 +286,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "SaveAnywhere" ], "UpperVersion": "2.3", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/444", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/444" ], "Notes": "Needs update for SDV 1.2." }, { @@ -304,7 +294,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "SimpleSprinkler.dll" ], "UpperVersion": "1.4", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/76", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/76" ], "Notes": "Needs update for SDV 1.2." }, { @@ -312,8 +302,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "SPDSprintAndDash" ], "UpperVersion": "1.0", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/resources/3531", - "UnofficialUpdateUrl": "http://community.playstarbound.com/resources/4201", + "UpdateUrls": [ "http://community.playstarbound.com/resources/3531", "http://community.playstarbound.com/resources/4201" ], "Notes": "Needs update for SDV 1.2." }, { @@ -321,7 +310,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "SPDSprintAndDash" ], "UpperVersion": "1.2", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/resources/4201", + "UpdateUrls": [ "http://community.playstarbound.com/resources/4201" ], "Notes": "Needs update for SDV 1.2." }, { @@ -329,7 +318,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "StackSplitX.dll" ], "UpperVersion": "1.2", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/798", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/798" ], "Notes": "Needs update for SDV 1.2." }, { @@ -337,7 +326,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "Teleporter" ], "UpperVersion": "1.0.2", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/resources/4374", + "UpdateUrls": [ "http://community.playstarbound.com/resources/4374" ], "Notes": "Needs update for SDV 1.2." }, { @@ -345,7 +334,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "TimeSpeed.dll", /* since 2.0.3 */ "4108e859-333c-4fec-a1a7-d2e18c1019fe", /*since 2.1*/ "community.TimeSpeed" ], "UpperVersion": "2.2", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/169", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/169" ], "Notes": "Needs update for SDV 1.2 and to migrate broken TimeEvents.AfterDayOfMonthChanged." }, { @@ -354,7 +343,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "UpperVersion": "0.5", "UpperVersionLabel": "1.0", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://www.nexusmods.com/stardewvalley/mods/1023", + "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/1023" ], "Notes": "Needs update for SDV 1.2. Actual upper version is 1.0, but mod incorrectly sets it to 0.5 in the manifest." }, { @@ -362,8 +351,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "WeatherController.dll" ], "UpperVersion": "1.0.2", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/threads/111526", - "UnofficialUpdateUrl": "http://community.playstarbound.com/threads/132096", + "UpdateUrls": [ "http://community.playstarbound.com/threads/111526", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2." }, { @@ -371,7 +359,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "zdailyincrease" ], "UpperVersion": "1.2", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/resources/4247", + "UpdateUrls": [ "http://community.playstarbound.com/resources/4247" ], "Notes": "Needs update for SDV 1.2." }, { @@ -379,7 +367,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "ZoomMod" ], "UpperVersion": "0.1", "Compatibility": "AssumeBroken", - "UpdateUrl": "http://community.playstarbound.com/threads/115028", + "UpdateUrls": [ "http://community.playstarbound.com/threads/115028" ], "Notes": "Needs update for SDV 1.2." }, { @@ -387,7 +375,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "76b6d1e1-f7ba-4d72-8c32-5a1e6d2716f6", /*since 1.6*/ "Zoryn.BetterRNG" ], "UpperVersion": "1.6", "Compatibility": "AssumeBroken", - "UpdateUrl": "https://github.com/Zoryn4163/SMAPI-Mods/releases", + "UpdateUrls": [ "https://github.com/Zoryn4163/SMAPI-Mods/releases" ], "Notes": "Needs update for SDV 1.2." }, { @@ -395,7 +383,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "a41c01cd-0437-43eb-944f-78cb5a53002a", /*since 1.6*/ "Zoryn.CalendarAnywhere" ], "UpperVersion": "1.6", "Compatibility": "AssumeBroken", - "UpdateUrl": "https://github.com/Zoryn4163/SMAPI-Mods/releases", + "UpdateUrls": [ "https://github.com/Zoryn4163/SMAPI-Mods/releases" ], "Notes": "Needs update for SDV 1.2." }, { @@ -403,7 +391,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "HealthBars.dll", /*since 1.6*/ "Zoryn.HealthBars" ], "UpperVersion": "1.6", "Compatibility": "AssumeBroken", - "UpdateUrl": "https://github.com/Zoryn4163/SMAPI-Mods/releases", + "UpdateUrls": [ "https://github.com/Zoryn4163/SMAPI-Mods/releases" ], "Notes": "Needs update for SDV 1.2." }, { @@ -411,7 +399,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "f93a4fe8-cade-4146-9335-b5f82fbbf7bc", /*since 1.6*/ "Zoryn.JunimoDepositAnywhere" ], "UpperVersion": "1.7", "Compatibility": "AssumeBroken", - "UpdateUrl": "https://github.com/Zoryn4163/SMAPI-Mods/releases", + "UpdateUrls": [ "https://github.com/Zoryn4163/SMAPI-Mods/releases" ], "Notes": "Needs update for SDV 1.2." }, { @@ -419,7 +407,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "8a632929-8335-484f-87dd-c29d2ba3215d", /*since 1.6*/ "Zoryn.MovementModifier" ], "UpperVersion": "1.6", "Compatibility": "AssumeBroken", - "UpdateUrl": "https://github.com/Zoryn4163/SMAPI-Mods/releases", + "UpdateUrls": [ "https://github.com/Zoryn4163/SMAPI-Mods/releases" ], "Notes": "Needs update for SDV 1.2." }, { @@ -427,7 +415,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": [ "dfac4383-1b6b-4f33-ae4e-37fc23e5252e", /*since 1.6*/ "Zoryn.RegenMod" ], "UpperVersion": "1.6", "Compatibility": "AssumeBroken", - "UpdateUrl": "https://github.com/Zoryn4163/SMAPI-Mods/releases", + "UpdateUrls": [ "https://github.com/Zoryn4163/SMAPI-Mods/releases" ], "Notes": "Needs update for SDV 1.2." } ] -- cgit From 7c1ac555a401819bf01ebe0e515b02416bc49b15 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 20 Jul 2017 00:47:28 -0400 Subject: simplify compatibility list by defaulting compatibility type, update readme --- README.md | 14 +++++-- .../Framework/Models/ModCompatibility.cs | 2 +- .../StardewModdingAPI.config.json | 47 +--------------------- 3 files changed, 14 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index bc5da52e..332a3754 100644 --- a/README.md +++ b/README.md @@ -142,14 +142,22 @@ on the wiki for the first-time setup. ## Advanced usage ### Configuration file You can customise the SMAPI behaviour by editing the `StardewModdingAPI.config.json` file in your -game folder. It contains these fields: +game folder. + +Basic fields: field | purpose ----- | ------- `DeveloperMode` | Default `false` (except in _SMAPI for developers_ releases). Whether to enable features intended for mod developers (mainly more detailed console logging). `CheckForUpdates` | Default `true`. Whether SMAPI should check for a newer version when you load the game. If a new version is available, a small message will appear in the console. This doesn't affect the load time even if your connection is offline or slow, because it happens in the background. -`ModCompatibility` | A list of mod versions SMAPI should consider compatible or broken regardless of whether it detects incompatible code. Each record can be set to `AssumeCompatible` or `AssumeBroken`. Changing this field is not recommended and may destabilise your game. -`VerboseLogging` | Whether SMAPI should log more information about the game context. +`VerboseLogging` | Default `false`. Whether SMAPI should log more information about the game context. + +Advanced fields (changing these isn't recommended and may destabilise your game): + +field | purpose +----- | ------- +`DisabledMods` | A list of mods to consider obsolete and not load. +`ModCompatibility` | A list of mod versions SMAPI should consider compatible or broken regardless of whether it detects incompatible code. This can be used to force SMAPI to load an incompatible mod, though that isn't recommended. ### Command-line arguments SMAPI recognises the following command-line arguments. These are intended for internal use or diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs index 72b6f2af..91be1d38 100644 --- a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs +++ b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs @@ -37,6 +37,6 @@ namespace StardewModdingAPI.Framework.Models public string ReasonPhrase { get; set; } /// Indicates how SMAPI should consider the mod. - public ModCompatibilityType Compatibility { get; set; } + public ModCompatibilityType Compatibility { get; set; } = ModCompatibilityType.AssumeBroken; } } diff --git a/src/StardewModdingAPI/StardewModdingAPI.config.json b/src/StardewModdingAPI/StardewModdingAPI.config.json index 90bf29c9..ed03d936 100644 --- a/src/StardewModdingAPI/StardewModdingAPI.config.json +++ b/src/StardewModdingAPI/StardewModdingAPI.config.json @@ -45,7 +45,8 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha /** * A list of mod versions SMAPI should consider compatible or broken regardless of whether it - * detects incompatible code. Each record can be set to `AssumeCompatible` or `AssumeBroken`. + * detects incompatible code. The default for each record is to assume broken; to force SMAPI to + * load a mod regardless of compatibility checks, add a "Compatibility": "AssumeCompatible" field. * Changing this field is not recommended and may destabilise your game. */ "ModCompatibility": [ @@ -53,7 +54,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "AccessChestAnywhere", "ID": [ "AccessChestAnywhere" ], "UpperVersion": "1.1", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/257", "http://www.nexusmods.com/stardewvalley/mods/518" ], "Notes": "Needs update for SDV 1.1." }, @@ -61,7 +61,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "Almighty Tool", "ID": [ "AlmightyTool.dll" ], "UpperVersion": "1.1.1", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/439" ], "Notes": "Needs update for SDV 1.2." }, @@ -69,7 +68,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "Better Sprinklers", "ID": [ "SPDSprinklersMod", /*since 2.3*/ "Speeder.BetterSprinklers" ], "UpperVersion": "2.3.1-pathoschild-update", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/41", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2 and to migrate broken TimeEvents.AfterDayOfMonthChanged." }, @@ -77,7 +75,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "Birthday Mail", "ID": [ "005e02dc-d900-425c-9c68-1ff55c5a295d" ], "UpperVersion": "1.2.2", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/276", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.2." }, @@ -85,7 +82,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "Chest Label System", "ID": [ "SPDChestLabel" ], "UpperVersion": "1.6", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/242", "http://community.playstarbound.com/threads/132096" ], "Notes": "Needs update for SDV 1.1." }, @@ -93,7 +89,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "Chest Pooling", "ID": [ "ChestPooling.dll" ], "UpperVersion": "1.2", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://community.playstarbound.com/threads/111988" ], "Notes": "Needs update for SDV 1.2." }, @@ -101,7 +96,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "Chests Anywhere", "ID": [ "ChestsAnywhere", /*since 1.9*/ "Pathoschild.ChestsAnywhere" ], "UpperVersion": "1.9-beta", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/518" ], "Notes": "Needs update for SDV 1.2." }, @@ -109,7 +103,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "CJB Automation", "ID": [ "CJBAutomation" ], "UpperVersion": "1.4", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/211", "http://www.nexusmods.com/stardewvalley/mods/1063" ], "Notes": "Needs update for SDV 1.2." }, @@ -131,7 +124,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "CJB Show Item Sell Price", "ID": [ "CJBShowItemSellPrice" ], "UpperVersion": "1.6", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/93" ], "Notes": "Needs update for SDV 1.2." }, @@ -139,7 +131,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "Cooking Skill", "ID": [ "CookingSkill" ], "UpperVersion": "1.0.3", - "Compatibility": "AssumeBroken", "UpdateUrls": [ "http://www.nexusmods.com/stardewvalley/mods/522" ], "Notes": "Needs update for SDV 1.2." }, @@ -147,7 +138,6 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "Name": "Cooking Skill Prestige Adapter", "ID": [ "20d6b8a3-b6e7-460b-a6e4-07c2b0cb6c63" ], "UpperVersion": "1.0.4", - "Compatibility"