From 4a14792e4db223f1d7faf4a22759268c91186e32 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 23 Apr 2022 16:47:24 -0400 Subject: fix ReplaceWith not working for legacy IAssetEditor implementations --- src/SMAPI/Framework/Content/AssetDataForObject.cs | 10 ++++++---- src/SMAPI/Framework/ContentCoordinator.cs | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/SMAPI/Framework/Content/AssetDataForObject.cs b/src/SMAPI/Framework/Content/AssetDataForObject.cs index e508ca30..6c40f5f9 100644 --- a/src/SMAPI/Framework/Content/AssetDataForObject.cs +++ b/src/SMAPI/Framework/Content/AssetDataForObject.cs @@ -25,8 +25,9 @@ namespace StardewModdingAPI.Framework.Content /// The content data being read. /// Normalizes an asset key to match the cache key. /// Simplifies access to private code. - public AssetDataForObject(string? locale, IAssetName assetName, object data, Func getNormalizedPath, Reflector reflection) - : base(locale, assetName, data, getNormalizedPath, onDataReplaced: null) + /// A callback to invoke when the data is replaced (if any). + public AssetDataForObject(string? locale, IAssetName assetName, object data, Func getNormalizedPath, Reflector reflection, Action? onDataReplaced = null) + : base(locale, assetName, data, getNormalizedPath, onDataReplaced) { this.Reflection = reflection; } @@ -36,8 +37,9 @@ namespace StardewModdingAPI.Framework.Content /// The content data being read. /// Normalizes an asset key to match the cache key. /// Simplifies access to private code. - public AssetDataForObject(IAssetInfo info, object data, Func getNormalizedPath, Reflector reflection) - : this(info.Locale, info.Name, data, getNormalizedPath, reflection) { } + /// A callback to invoke when the data is replaced (if any). + public AssetDataForObject(IAssetInfo info, object data, Func getNormalizedPath, Reflector reflection, Action? onDataReplaced = null) + : this(info.Locale, info.Name, data, getNormalizedPath, reflection, onDataReplaced) { } /// public IAssetDataForDictionary AsDictionary() diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs index aade7b36..93b6d9f3 100644 --- a/src/SMAPI/Framework/ContentCoordinator.cs +++ b/src/SMAPI/Framework/ContentCoordinator.cs @@ -716,7 +716,8 @@ namespace StardewModdingAPI.Framework assetName: legacyName, data: asset.Data, getNormalizedPath: this.MainContentManager.AssertAndNormalizeAssetName, - reflection: this.Reflection + reflection: this.Reflection, + onDataReplaced: asset.ReplaceWith ); } -- cgit