summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-26 15:02:11 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-26 15:02:11 -0400
commit8d704153762fa73416a3ccb44ee71032952802eb (patch)
tree1435fe032cee1b88aa31ed567addaea6c2d6443b
parent4c64f9f644c2349d2ca2407ce3aff736ba3fc354 (diff)
downloadSMAPI-8d704153762fa73416a3ccb44ee71032952802eb.tar.gz
SMAPI-8d704153762fa73416a3ccb44ee71032952802eb.tar.bz2
SMAPI-8d704153762fa73416a3ccb44ee71032952802eb.zip
add deprecation notices for SMAPI 4.0.0 (#766)
-rw-r--r--docs/release-notes.md37
-rw-r--r--src/SMAPI/Constants.cs17
-rw-r--r--src/SMAPI/Framework/Content/AssetInfo.cs23
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentHelper.cs34
-rw-r--r--src/SMAPI/Framework/SCore.cs19
-rw-r--r--src/SMAPI/IAssetInfo.cs1
6 files changed, 103 insertions, 28 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 98392c17..464049b9 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -3,37 +3,32 @@
# Release notes
## Upcoming release
* For players:
- * Improved translations. Thanks to ChulkyBow (updated Ukrainian)!
- * Fixed `player_add` console command's handling of Journal Scraps and Secret Notes.
- * Fixed `set_farm_type` console command not updating warps if they moved.
- * Improved [command-line arguments](technical/smapi.md#command-line-arguments) on Linux/macOS:
+ * Fixed support for `_international` content assets (used in the movie theater).
+ * Fixed the warning text when a mod causes an asset load conflict with itself.
+ * Improved Linux/macOS [command-line arguments](technical/smapi.md#command-line-arguments):
* Added `--use-current-shell` to avoid opening a separate terminal window.
* Fixed `--no-terminal` still opening a terminal window, even if nothing is logged to it (thanks to Ryhon0!).
- * Fixed warning text when a mod causes an asset load conflict with itself.
- * Fixed support for `_international` content assets (used in the movie theater).
+ * Improved translations. Thanks to ChulkyBow (updated Ukrainian)!
+
+* For the Console Commands mod:
+ * Fixed `player_add` not handling journal scraps and secret notes correctly.
+ * Fixed `set_farm_type` not updating warps.
* For mod authors:
- * Added [content events](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Events#Content), which will replace `IAssetEditor` and `IAssetLoader` in SMAPI 4.0.0.
- _These include new features not supported by the old API like load conflict resolution, edit priority, and content pack labels. They also support new cases like easily detecting when an asset has been changed._
- * Overhauled [mod-provided APIs](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Integrations#Mod-provided_APIs) (thanks to Shockah!).
- _This adds support for many previously-unsupported cases: proxied interfaces in return values or input arguments, proxied enums if their values match, generic methods, and more._
+ * **Added [content events](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Events#Content), which will replace `IAssetEditor` and `IAssetLoader` in SMAPI 4.0.0.**
+ _These include new features not supported by the old API like load conflict resolution, edit priority, and content pack labels. They also support new cases like easily detecting when an asset has changed, and avoid data corruption issues in some edge cases._
+ * **Overhauled [mod-provided API](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Integrations#Mod-provided_APIs) proxying** (thanks to Shockah!).
+ _This adds support for many previously unsupported cases: proxied interfaces in return values or input arguments, proxied enums if their values match, generic methods, and more. Existing mod APIs should work fine as-is._
+ * **Deprecation warning:** The upcoming SMAPI 4.0 will remove deprecated APIs and break mods which haven't updated yet.
+ _See [_Migrate to SMAPI 4.0_](https://stardewvalleywiki.com/Modding:Migrate_to_SMAPI_4.0) for help updating your mod code. You can update your mod code now, there's no need to wait for the 4.0.0 release (which will happen in at least three months, and possibly later if needed to update open-source mods)._
* Added `Constants.ContentPath`.
- * Added `IAssetName Name` field to the info received by `IAssetEditor` and `IAssetLoader` methods.
+ * Added `IAssetName` fields to the info received by `IAssetEditor` and `IAssetLoader` methods.
_This adds methods for working with asset names, parsed locales, etc._
- * If an asset is loaded multiple times in the same tick, `IAssetLoader.CanLoad` and `IAssetEditor.CanEdit` are now cached unless invalidated via `helper.Content.InvalidateCache`.
+ * If an asset is loaded multiple times in the same tick, `IAssetLoader.CanLoad` and `IAssetEditor.CanEdit` are now cached unless invalidated by `helper.Content.InvalidateCache`.
* Fixed the `SDate` constructor being case-sensitive.
* Fixed support for using locale codes from custom languages in asset names (e.g. `Data/Achievements.eo-EU`).
* Fixed issue where suppressing `[Left|Right]Thumbstick[Down|Left]` keys would suppress the opposite direction instead.
-* **Deprecation warning for mod authors:**
- These APIs are now deprecated and will be removed in the upcoming SMAPI 4.0.0.
-
- API | how to update code
- :-- | :-----------------
- `Constants.ExecutionPath` | Use `Constants.GamePath` instead.
- `IAssetInfo.AssetName`<br />`IAssetData.AssetName` | Use `Name` instead, which changes the type from `string` to the new `AssetName`.
- `IAssetInfo.AssetNameEquals`<br />`IAssetData.AssetNameEquals` | Use `Name.IsEquivalentTo` instead.
-
* For the web UI:
* Updated the JSON validator/schema for Content Patcher 1.25.0.
* Added `data-*` attributes to log parser page for external tools.
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index b736ca59..3351e5c4 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -77,8 +77,21 @@ namespace StardewModdingAPI
public static GameFramework GameFramework { get; } = EarlyConstants.GameFramework;
/// <summary>The path to the game folder.</summary>
- [Obsolete($"Use {nameof(GamePath)} instead.")]
- public static string ExecutionPath => Constants.GamePath;
+ [Obsolete($"Use {nameof(Constants)}.{nameof(GamePath)} instead.")]
+ public static string ExecutionPath
+ {
+ get
+ {
+ SCore.DeprecationManager.Warn(
+ source: SCore.DeprecationManager.GetSourceNameFromStack(),
+ nounPhrase: $"{nameof(Constants)}.{nameof(Constants.ExecutionPath)}",
+ version: "3.14.0",
+ severity: DeprecationLevel.Notice
+ );
+
+ return Constants.GamePath;
+ }
+ }
/// <summary>The path to the game folder.</summary>
public static string GamePath { get; } = EarlyConstants.GamePath;
diff --git a/src/SMAPI/Framework/Content/AssetInfo.cs b/src/SMAPI/Framework/Content/AssetInfo.cs
index 556f1c2a..6e93c33c 100644
--- a/src/SMAPI/Framework/Content/AssetInfo.cs
+++ b/src/SMAPI/Framework/Content/AssetInfo.cs
@@ -27,7 +27,20 @@ namespace StardewModdingAPI.Framework.Content
/// <inheritdoc />
[Obsolete($"Use {nameof(Name)} or {nameof(NameWithoutLocale)} instead.")]
- public string AssetName => this.NameWithoutLocale.Name;
+ public string AssetName
+ {
+ get
+ {
+ SCore.DeprecationManager.Warn(
+ source: SCore.DeprecationManager.GetSourceNameFromStack(),
+ nounPhrase: $"{nameof(IAssetInfo)}.{nameof(IAssetInfo.AssetName)}",
+ version: "3.14.0",
+ severity: DeprecationLevel.Notice
+ );
+
+ return this.NameWithoutLocale.Name;
+ }
+ }
/// <inheritdoc />
public Type DataType { get; }
@@ -54,6 +67,14 @@ namespace StardewModdingAPI.Framework.Content
[Obsolete($"Use {nameof(Name)}.{nameof(IAssetName.IsEquivalentTo)} or {nameof(NameWithoutLocale)}.{nameof(IAssetName.IsEquivalentTo)} instead.")]
public bool AssetNameEquals(string path)
{
+ SCore.DeprecationManager.Warn(
+ source: SCore.DeprecationManager.GetSourceNameFromStack(),
+ nounPhrase: $"{nameof(IAssetInfo)}.{nameof(IAssetInfo.AssetNameEquals)}",
+ version: "3.14.0",
+ severity: DeprecationLevel.Notice
+ );
+
+
return this.NameWithoutLocale.IsEquivalentTo(path);
}
diff --git a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
index 3416c286..3727b909 100644
--- a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
@@ -44,16 +44,42 @@ namespace StardewModdingAPI.Framework.ModHelpers
public LocalizedContentManager.LanguageCode CurrentLocaleConstant => this.GameContentManager.Language;
/// <summary>The observable implementation of <see cref="AssetEditors"/>.</summary>
- internal ObservableCollection<IAssetEditor> ObservableAssetEditors { get; } = new ObservableCollection<IAssetEditor>();
+ internal ObservableCollection<IAssetEditor> ObservableAssetEditors { get; } = new();
/// <summary>The observable implementation of <see cref="AssetLoaders"/>.</summary>
- internal ObservableCollection<IAssetLoader> ObservableAssetLoaders { get; } = new ObservableCollection<IAssetLoader>();
+ internal ObservableCollection<IAssetLoader> ObservableAssetLoaders { get; } = new();
/// <inheritdoc />
- public IList<IAssetLoader> AssetLoaders => this.ObservableAssetLoaders;
+ public IList<IAssetLoader> AssetLoaders
+ {
+ get
+ {
+ SCore.DeprecationManager.Warn(
+ source: this.ModName,
+ nounPhrase: $"{nameof(IContentHelper)}.{nameof(IContentHelper.AssetLoaders)}",
+ version: "3.14.0",
+ severity: DeprecationLevel.Notice
+ );
+
+ return this.ObservableAssetLoaders;
+ }
+ }
/// <inheritdoc />
- public IList<IAssetEditor> AssetEditors => this.ObservableAssetEditors;
+ public IList<IAssetEditor> AssetEditors
+ {
+ get
+ {
+ SCore.DeprecationManager.Warn(
+ source: this.ModName,
+ nounPhrase: $"{nameof(IContentHelper)}.{nameof(IContentHelper.AssetEditors)}",
+ version: "3.14.0",
+ severity: DeprecationLevel.Notice
+ );
+
+ return this.ObservableAssetEditors;
+ }
+ }
/*********
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index dd952dee..eab977ac 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -1609,9 +1609,28 @@ namespace StardewModdingAPI.Framework
{
// ReSharper disable SuspiciousTypeConversion.Global
if (metadata.Mod is IAssetEditor editor)
+ {
+ SCore.DeprecationManager.Warn(
+ source: metadata.DisplayName,
+ nounPhrase: $"{nameof(IAssetEditor)}",
+ version: "3.14.0",
+ severity: DeprecationLevel.Notice
+ );
+
this.ContentCore.Editors.Add(new ModLinked<IAssetEditor>(metadata, editor));
+ }
+
if (metadata.Mod is IAssetLoader loader)
+ {
+ SCore.DeprecationManager.Warn(
+ source: metadata.DisplayName,
+ nounPhrase: $"{nameof(IAssetLoader)}",
+ version: "3.14.0",
+ severity: DeprecationLevel.Notice
+ );
+
this.ContentCore.Loaders.Add(new ModLinked<IAssetLoader>(metadata, loader));
+ }
// ReSharper restore SuspiciousTypeConversion.Global
helper.ObservableAssetEditors.CollectionChanged += (sender, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast<IAssetEditor>(), e.OldItems?.Cast<IAssetEditor>(), this.ContentCore.Editors);
diff --git a/src/SMAPI/IAssetInfo.cs b/src/SMAPI/IAssetInfo.cs
index c7b2ab62..c3753b97 100644
--- a/src/SMAPI/IAssetInfo.cs
+++ b/src/SMAPI/IAssetInfo.cs
@@ -12,6 +12,7 @@ namespace StardewModdingAPI
string Locale { get; }
/// <summary>The asset name being read.</summary>
+ /// <remarks>NOTE: when reading this field from an <see cref="IAssetLoader"/> or <see cref="IAssetEditor"/> implementation, it's always equivalent to <see cref="NameWithoutLocale"/> for backwards compatibility.</remarks>
public IAssetName Name { get; }
/// <summary>The <see cref="Name"/> with any locale codes stripped.</summary>