add deprecation notices for SMAPI 4.0.0 (#766)

This commit is contained in:
Jesse Plamondon-Willard 2022-03-26 15:02:11 -04:00
parent 4c64f9f644
commit 8d70415376
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
6 changed files with 103 additions and 28 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}
}
/*********

View File

@ -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);

View File

@ -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>