From d8cf9103472cf6f4328754d3b6e776694fc5f764 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 16 Mar 2019 19:09:45 -0400 Subject: set max game version to prepare for 1.4 release --- src/SMAPI/Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index d90eecf7..820579b8 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -26,7 +26,7 @@ namespace StardewModdingAPI public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.3.36"); /// The maximum supported version of Stardew Valley. - public static ISemanticVersion MaximumGameVersion { get; } = null; + public static ISemanticVersion MaximumGameVersion { get; } = new GameVersion("1.3.36"); /// The target game platform. public static GamePlatform TargetPlatform => (GamePlatform)Constants.Platform; -- cgit From 0d762faf603aac417a382ec680aaabdf7248493b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 16 Mar 2019 22:17:58 -0400 Subject: add support for suppressing warnings in mod DB --- src/SMAPI/Framework/IModMetadata.cs | 4 +++ src/SMAPI/Framework/ModLoading/AssemblyLoader.cs | 1 + src/SMAPI/Framework/ModLoading/ModMetadata.cs | 9 ++++++ src/SMAPI/Framework/ModLoading/ModWarning.cs | 37 ------------------------ src/SMAPI/Framework/SCore.cs | 4 ++- src/SMAPI/StardewModdingAPI.csproj | 1 - 6 files changed, 17 insertions(+), 39 deletions(-) delete mode 100644 src/SMAPI/Framework/ModLoading/ModWarning.cs (limited to 'src/SMAPI') diff --git a/src/SMAPI/Framework/IModMetadata.cs b/src/SMAPI/Framework/IModMetadata.cs index 7ada7dea..38514959 100644 --- a/src/SMAPI/Framework/IModMetadata.cs +++ b/src/SMAPI/Framework/IModMetadata.cs @@ -98,5 +98,9 @@ namespace StardewModdingAPI.Framework /// Whether the mod has at least one valid update key set. bool HasValidUpdateKeys(); + + /// Get whether the mod has a given warning and it hasn't been suppressed in the . + /// The warning to check. + bool HasUnsuppressWarning(ModWarning warning); } } diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs index 5e0571a0..878b3148 100644 --- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs +++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs @@ -8,6 +8,7 @@ using Mono.Cecil.Cil; using StardewModdingAPI.Framework.Exceptions; using StardewModdingAPI.Internal; using StardewModdingAPI.Metadata; +using StardewModdingAPI.Toolkit.Framework.ModData; namespace StardewModdingAPI.Framework.ModLoading { diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index 0cb62a75..4ff021b7 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -179,5 +179,14 @@ namespace StardewModdingAPI.Framework.ModLoading { return this.GetUpdateKeys(validOnly: true).Any(); } + + /// Get whether the mod has a given warning and it hasn't been suppressed in the . + /// The warning to check. + public bool HasUnsuppressWarning(ModWarning warning) + { + return + this.Warnings.HasFlag(warning) + && (this.DataRecord?.DataRecord == null || !this.DataRecord.DataRecord.SuppressWarnings.HasFlag(warning)); + } } } diff --git a/src/SMAPI/Framework/ModLoading/ModWarning.cs b/src/SMAPI/Framework/ModLoading/ModWarning.cs deleted file mode 100644 index e643cb05..00000000 --- a/src/SMAPI/Framework/ModLoading/ModWarning.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using StardewModdingAPI.Events; - -namespace StardewModdingAPI.Framework.ModLoading -{ - /// Indicates a detected non-error mod issue. - [Flags] - internal enum ModWarning - { - /// No issues detected. - None = 0, - - /// SMAPI detected incompatible code in the mod, but was configured to load it anyway. - BrokenCodeLoaded = 1, - - /// The mod affects the save serializer in a way that may make saves unloadable without the mod. - ChangesSaveSerialiser = 2, - - /// The mod patches the game in a way that may impact stability. - PatchesGame = 4, - - /// The mod uses the dynamic keyword which won't work on Linux/Mac. - UsesDynamic = 8, - - /// The mod references or which may impact stability. - UsesUnvalidatedUpdateTick = 16, - - /// The mod has no update keys set. - NoUpdateKeys = 32, - - /// Uses .NET APIs for filesystem access. - AccessesFilesystem = 64, - - /// Uses .NET APIs for shell or process access. - AccessesShell = 128 - } -} diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index e0347eb2..9ffa46a5 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -1107,7 +1107,9 @@ namespace StardewModdingAPI.Framework // issue block format logic void LogWarningGroup(ModWarning warning, LogLevel logLevel, string heading, params string[] blurb) { - IModMetadata[] matches = modsWithWarnings.Where(p => p.Warnings.HasFlag(warning)).ToArray(); + IModMetadata[] matches = modsWithWarnings + .Where(mod => mod.HasUnsuppressWarning(warning)) + .ToArray(); if (!matches.Any()) return; diff --git a/src/SMAPI/StardewModdingAPI.csproj b/src/SMAPI/StardewModdingAPI.csproj index 6692bc02..b6562eca 100644 --- a/src/SMAPI/StardewModdingAPI.csproj +++ b/src/SMAPI/StardewModdingAPI.csproj @@ -228,7 +228,6 @@ - -- cgit From 4a7fb8bad2eabb215240e6a6d3febd1e91b3c2d5 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 16 Mar 2019 23:42:00 -0400 Subject: remove reflected access to Game1.version (which is no longer const) --- src/SMAPI/Constants.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 820579b8..07557cd3 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -111,7 +111,7 @@ namespace StardewModdingAPI internal static string ModsPath { get; set; } /// The game's current semantic version. - internal static ISemanticVersion GameVersion { get; } = new GameVersion(Constants.GetGameVersion()); + internal static ISemanticVersion GameVersion { get; } = new GameVersion(Game1.version); /// The target game platform. internal static Platform Platform { get; } = EnvironmentUtility.DetectPlatform(); @@ -197,16 +197,6 @@ namespace StardewModdingAPI /********* ** Private methods *********/ - /// Get the game's current version string. - private static string GetGameVersion() - { - // we need reflection because it's a constant, so SMAPI's references to it are inlined at compile-time - FieldInfo field = typeof(Game1).GetField(nameof(Game1.version), BindingFlags.Public | BindingFlags.Static); - if (field == null) - throw new InvalidOperationException($"The {nameof(Game1)}.{nameof(Game1.version)} field could not be found."); - return (string)field.GetValue(null); - } - /// Get the name of the save folder, if any. internal static string GetSaveFolderName() { -- cgit From 4a494c67bdfe2c07ef5c49c55541a0f6e29627cf Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 17 Mar 2019 21:34:44 -0400 Subject: prepare for 2.11.1 release --- src/SMAPI/Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 07557cd3..ca541513 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -20,7 +20,7 @@ namespace StardewModdingAPI ** Public ****/ /// SMAPI's current semantic version. - public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("2.11.0"); + public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("2.11.1"); /// The minimum supported version of Stardew Valley. public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.3.36"); -- cgit