diff options
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Constants.cs | 16 | ||||
-rw-r--r-- | src/SMAPI/Framework/IModMetadata.cs | 4 | ||||
-rw-r--r-- | src/SMAPI/Framework/ModLoading/AssemblyLoader.cs | 1 | ||||
-rw-r--r-- | src/SMAPI/Framework/ModLoading/ModMetadata.cs | 9 | ||||
-rw-r--r-- | src/SMAPI/Framework/ModLoading/ModWarning.cs | 37 | ||||
-rw-r--r-- | src/SMAPI/Framework/SCore.cs | 4 | ||||
-rw-r--r-- | src/SMAPI/StardewModdingAPI.csproj | 1 |
7 files changed, 20 insertions, 52 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index d90eecf7..ca541513 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -20,13 +20,13 @@ namespace StardewModdingAPI ** Public ****/ /// <summary>SMAPI's current semantic version.</summary> - public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("2.11.0"); + public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("2.11.1"); /// <summary>The minimum supported version of Stardew Valley.</summary> public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.3.36"); /// <summary>The maximum supported version of Stardew Valley.</summary> - public static ISemanticVersion MaximumGameVersion { get; } = null; + public static ISemanticVersion MaximumGameVersion { get; } = new GameVersion("1.3.36"); /// <summary>The target game platform.</summary> public static GamePlatform TargetPlatform => (GamePlatform)Constants.Platform; @@ -111,7 +111,7 @@ namespace StardewModdingAPI internal static string ModsPath { get; set; } /// <summary>The game's current semantic version.</summary> - internal static ISemanticVersion GameVersion { get; } = new GameVersion(Constants.GetGameVersion()); + internal static ISemanticVersion GameVersion { get; } = new GameVersion(Game1.version); /// <summary>The target game platform.</summary> internal static Platform Platform { get; } = EnvironmentUtility.DetectPlatform(); @@ -197,16 +197,6 @@ namespace StardewModdingAPI /********* ** Private methods *********/ - /// <summary>Get the game's current version string.</summary> - 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); - } - /// <summary>Get the name of the save folder, if any.</summary> internal static string GetSaveFolderName() { 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 /// <summary>Whether the mod has at least one valid update key set.</summary> bool HasValidUpdateKeys(); + + /// <summary>Get whether the mod has a given warning and it hasn't been suppressed in the <see cref="DataRecord"/>.</summary> + /// <param name="warning">The warning to check.</param> + 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(); } + + /// <summary>Get whether the mod has a given warning and it hasn't been suppressed in the <see cref="DataRecord"/>.</summary> + /// <param name="warning">The warning to check.</param> + 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 -{ - /// <summary>Indicates a detected non-error mod issue.</summary> - [Flags] - internal enum ModWarning - { - /// <summary>No issues detected.</summary> - None = 0, - - /// <summary>SMAPI detected incompatible code in the mod, but was configured to load it anyway.</summary> - BrokenCodeLoaded = 1, - - /// <summary>The mod affects the save serializer in a way that may make saves unloadable without the mod.</summary> - ChangesSaveSerialiser = 2, - - /// <summary>The mod patches the game in a way that may impact stability.</summary> - PatchesGame = 4, - - /// <summary>The mod uses the <c>dynamic</c> keyword which won't work on Linux/Mac.</summary> - UsesDynamic = 8, - - /// <summary>The mod references <see cref="ISpecialisedEvents.UnvalidatedUpdateTicking"/> or <see cref="ISpecialisedEvents.UnvalidatedUpdateTicked"/> which may impact stability.</summary> - UsesUnvalidatedUpdateTick = 16, - - /// <summary>The mod has no update keys set.</summary> - NoUpdateKeys = 32, - - /// <summary>Uses .NET APIs for filesystem access.</summary> - AccessesFilesystem = 64, - - /// <summary>Uses .NET APIs for shell or process access.</summary> - 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 @@ <Compile Include="Framework\ModLoading\IInstructionHandler.cs" /> <Compile Include="Framework\ModLoading\IncompatibleInstructionException.cs" /> <Compile Include="Framework\ModLoading\InstructionHandleResult.cs" /> - <Compile Include="Framework\ModLoading\ModWarning.cs" /> <Compile Include="Framework\ModLoading\PlatformAssemblyMap.cs" /> <Compile Include="Framework\ModLoading\RewriteHelper.cs" /> <Compile Include="Framework\ModLoading\Rewriters\FieldReplaceRewriter.cs" /> |