summaryrefslogtreecommitdiff
path: root/src/SMAPI
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 /src/SMAPI
parent4c64f9f644c2349d2ca2407ce3aff736ba3fc354 (diff)
downloadSMAPI-8d704153762fa73416a3ccb44ee71032952802eb.tar.gz
SMAPI-8d704153762fa73416a3ccb44ee71032952802eb.tar.bz2
SMAPI-8d704153762fa73416a3ccb44ee71032952802eb.zip
add deprecation notices for SMAPI 4.0.0 (#766)
Diffstat (limited to 'src/SMAPI')
-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
5 files changed, 87 insertions, 7 deletions
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>