summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release-notes.md3
-rw-r--r--src/StardewModdingAPI/Advanced/ConfigFile.cs4
-rw-r--r--src/StardewModdingAPI/Advanced/IConfigFile.cs5
-rw-r--r--src/StardewModdingAPI/Framework/ModHelper.cs15
-rw-r--r--src/StardewModdingAPI/Program.cs1
5 files changed, 24 insertions, 4 deletions
diff --git a/release-notes.md b/release-notes.md
index 7a936694..4f62182e 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -23,11 +23,12 @@ For mod developers:
* Added `SaveEvents.AfterReturnToTitle` and `TimeEvents.AfterDayStarted` events.
* Added a simpler API for console commands (see `helper.ConsoleCommands`).
* Added `GetPrivateProperty` reflection helper.
-* SMAPI now writes XNA input enums (`Buttons` and `Keys`) to JSON as strings, so mods no longer need to add a `StringEnumConverter` themselves for those.
+* SMAPI now writes XNA input enums (`Buttons` and `Keys`) to JSON as strings automatically, so mods no longer need to add a `StringEnumConverter` themselves for those.
* Logs now show the OS caption (like "Windows 10") instead of its internal version when available.
* Logs now always use `\r\n` to simplify crossplatform viewing.
* Several obsolete APIs have been removed (see [deprecation guide](http://canimod.com/guides/updating-a-smapi-mod)),
and all _notice_-level deprecations have been increased to _info_.
+* Deprecated the experimental `IConfigFile`.
For SMAPI developers:
* Added support for debugging with Visual Studio for Mac.
diff --git a/src/StardewModdingAPI/Advanced/ConfigFile.cs b/src/StardewModdingAPI/Advanced/ConfigFile.cs
index 1a2e6618..78cad26a 100644
--- a/src/StardewModdingAPI/Advanced/ConfigFile.cs
+++ b/src/StardewModdingAPI/Advanced/ConfigFile.cs
@@ -1,9 +1,11 @@
-using System.IO;
+using System;
+using System.IO;
using Newtonsoft.Json;
namespace StardewModdingAPI.Advanced
{
/// <summary>Wraps a configuration file with IO methods for convenience.</summary>
+ [Obsolete]
public abstract class ConfigFile : IConfigFile
{
/*********
diff --git a/src/StardewModdingAPI/Advanced/IConfigFile.cs b/src/StardewModdingAPI/Advanced/IConfigFile.cs
index 5bc31a88..1b424ace 100644
--- a/src/StardewModdingAPI/Advanced/IConfigFile.cs
+++ b/src/StardewModdingAPI/Advanced/IConfigFile.cs
@@ -1,6 +1,9 @@
-namespace StardewModdingAPI.Advanced
+using System;
+
+namespace StardewModdingAPI.Advanced
{
/// <summary>Wraps a configuration file with IO methods for convenience.</summary>
+ [Obsolete]
public interface IConfigFile
{
/*********
diff --git a/src/StardewModdingAPI/Framework/ModHelper.cs b/src/StardewModdingAPI/Framework/ModHelper.cs
index 04767de5..0d50201b 100644
--- a/src/StardewModdingAPI/Framework/ModHelper.cs
+++ b/src/StardewModdingAPI/Framework/ModHelper.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using StardewModdingAPI.Advanced;
using StardewModdingAPI.Framework.Reflection;
using StardewModdingAPI.Framework.Serialisation;
@@ -14,6 +15,9 @@ namespace StardewModdingAPI.Framework
/// <summary>Encapsulates SMAPI's JSON file parsing.</summary>
private readonly JsonHelper JsonHelper;
+ /// <summary>Manages deprecation warnings.</summary>
+ private static DeprecationManager DeprecationManager;
+
/*********
** Accessors
@@ -61,6 +65,13 @@ namespace StardewModdingAPI.Framework
this.ConsoleCommands = new CommandHelper(modName, commandManager);
}
+ /// <summary>Injects types required for backwards compatibility.</summary>
+ /// <param name="deprecationManager">Manages deprecation warnings.</param>
+ internal static void Shim(DeprecationManager deprecationManager)
+ {
+ ModHelper.DeprecationManager = deprecationManager;
+ }
+
/****
** Mod config file
****/
@@ -69,7 +80,9 @@ namespace StardewModdingAPI.Framework
public TConfig ReadConfig<TConfig>()
where TConfig : class, new()
{
- var config = this.ReadJsonFile<TConfig>("config.json") ?? new TConfig();
+ TConfig config = this.ReadJsonFile<TConfig>("config.json") ?? new TConfig();
+ if (config is IConfigFile)
+ ModHelper.DeprecationManager.Warn($"{nameof(IConfigFile)}", "1.9", DeprecationLevel.Info);
this.WriteConfig(config); // create file or fill in missing fields
return config;
}
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index 360f75f0..6ebeccd2 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -98,6 +98,7 @@ namespace StardewModdingAPI
InternalExtensions.Shim(this.ModRegistry);
Log.Shim(this.DeprecationManager, this.GetSecondaryMonitor("legacy mod"), this.ModRegistry);
Mod.Shim(this.DeprecationManager);
+ ModHelper.Shim(this.DeprecationManager);
ContentEvents.Shim(this.ModRegistry, this.Monitor);
PlayerEvents.Shim(this.DeprecationManager);
TimeEvents.Shim(this.DeprecationManager);