diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-03-01 14:10:46 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-03-01 14:10:46 -0500 |
commit | 10c7192bb9f06ff96b9b98a812d9f72a8d77ac76 (patch) | |
tree | 7d4c4ed3498d53e4e8a1c3167fa3937d51b25ecb /src/SMAPI/Framework/DeprecationManager.cs | |
parent | 84b9f4336d5b0c7f269a7bfbb94042360574bbaa (diff) | |
parent | 460b440c2ef4f8c7e2015375fa603095146d1f11 (diff) | |
download | SMAPI-10c7192bb9f06ff96b9b98a812d9f72a8d77ac76.tar.gz SMAPI-10c7192bb9f06ff96b9b98a812d9f72a8d77ac76.tar.bz2 SMAPI-10c7192bb9f06ff96b9b98a812d9f72a8d77ac76.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/DeprecationManager.cs')
-rw-r--r-- | src/SMAPI/Framework/DeprecationManager.cs | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/SMAPI/Framework/DeprecationManager.cs b/src/SMAPI/Framework/DeprecationManager.cs index fcdf722e..3153bbb4 100644 --- a/src/SMAPI/Framework/DeprecationManager.cs +++ b/src/SMAPI/Framework/DeprecationManager.cs @@ -14,7 +14,11 @@ namespace StardewModdingAPI.Framework private readonly HashSet<string> LoggedDeprecations = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase); /// <summary>Encapsulates monitoring and logging for a given module.</summary> +#if !SMAPI_3_0_STRICT + private readonly Monitor Monitor; +#else private readonly IMonitor Monitor; +#endif /// <summary>Tracks the installed mods.</summary> private readonly ModRegistry ModRegistry; @@ -22,6 +26,11 @@ namespace StardewModdingAPI.Framework /// <summary>The queued deprecation warnings to display.</summary> private readonly IList<DeprecationWarning> QueuedWarnings = new List<DeprecationWarning>(); +#if !SMAPI_3_0_STRICT + /// <summary>Whether the one-time deprecation message has been shown.</summary> + private bool DeprecationHeaderShown = false; +#endif + /********* ** Public methods @@ -29,7 +38,11 @@ namespace StardewModdingAPI.Framework /// <summary>Construct an instance.</summary> /// <param name="monitor">Encapsulates monitoring and logging for a given module.</param> /// <param name="modRegistry">Tracks the installed mods.</param> +#if !SMAPI_3_0_STRICT + public DeprecationManager(Monitor monitor, ModRegistry modRegistry) +#else public DeprecationManager(IMonitor monitor, ModRegistry modRegistry) +#endif { this.Monitor = monitor; this.ModRegistry = modRegistry; @@ -38,7 +51,7 @@ namespace StardewModdingAPI.Framework /// <summary>Log a deprecation warning for the old-style events.</summary> public void WarnForOldEvents() { - this.Warn("legacy events", "2.9", DeprecationLevel.Info); + this.Warn("legacy events", "2.9", DeprecationLevel.PendingRemoval); } /// <summary>Log a deprecation warning.</summary> @@ -68,15 +81,25 @@ namespace StardewModdingAPI.Framework /// <summary>Print any queued messages.</summary> public void PrintQueued() { +#if !SMAPI_3_0_STRICT + if (!this.DeprecationHeaderShown && this.QueuedWarnings.Any()) + { + this.Monitor.Newline(); + this.Monitor.Log("Some of your mods will break in the upcoming SMAPI 3.0. Please update your mods now, or notify the author if no update is available. See https://mods.smapi.io for links to the latest versions.", LogLevel.Warn); + this.Monitor.Newline(); + this.DeprecationHeaderShown = true; + } +#endif + foreach (DeprecationWarning warning in this.QueuedWarnings.OrderBy(p => p.ModName).ThenBy(p => p.NounPhrase)) { // build message #if SMAPI_3_0_STRICT - string message = $"{warning.ModName ?? "An unknown mod"} uses deprecated code ({warning.NounPhrase} is deprecated since SMAPI {warning.Version})."; + string message = $"{warning.ModName} uses deprecated code ({warning.NounPhrase} is deprecated since SMAPI {warning.Version})."; #else string message = warning.NounPhrase == "legacy events" - ? $"{warning.ModName ?? "An unknown mod"} uses deprecated code (legacy events are deprecated since SMAPI {warning.Version})." - : $"{warning.ModName ?? "An unknown mod"} uses deprecated code ({warning.NounPhrase} is deprecated since SMAPI {warning.Version})."; + ? $"{warning.ModName ?? "An unknown mod"} will break in the upcoming SMAPI 3.0 (legacy events are deprecated since SMAPI {warning.Version})." + : $"{warning.ModName ?? "An unknown mod"} will break in the upcoming SMAPI 3.0 ({warning.NounPhrase} is deprecated since SMAPI {warning.Version})."; #endif // get log level |