summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-02 21:43:56 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-02 21:43:56 -0400
commit627472c506944ca103dbb9a011e827a31d02dead (patch)
treedaeb52dfdc9a61eec33f9236744f8302b80c99ec /src/SMAPI/Framework
parent546b58778c9e1e983f1682f1b89cbc353939d9ea (diff)
downloadSMAPI-627472c506944ca103dbb9a011e827a31d02dead.tar.gz
SMAPI-627472c506944ca103dbb9a011e827a31d02dead.tar.bz2
SMAPI-627472c506944ca103dbb9a011e827a31d02dead.zip
add temporary hack to fix compatibility between old & new APIs for some mods
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/ContentCoordinator.cs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs
index cd1de4a8..88ed96da 100644
--- a/src/SMAPI/Framework/ContentCoordinator.cs
+++ b/src/SMAPI/Framework/ContentCoordinator.cs
@@ -655,6 +655,27 @@ namespace StardewModdingAPI.Framework
continue;
}
+ // HACK
+ //
+ // If two editors have the same priority, they're applied in registration order (so
+ // whichever was registered first is applied first). Mods often depend on this
+ // behavior, like Json Assets registering its interceptors before Content Patcher.
+ //
+ // Unfortunately the old & new content APIs have separate lists, so new-API
+ // interceptors always ran before old-API interceptors with the same priority,
+ // regardless of the registration order *between* APIs. Since the new API works in
+ // a fundamentally different way (i.e. loads/edits are defined on asset request
+ // instead of by registering a global 'editor' or 'loader' class), there's no way
+ // to track registration order between them.
+ //
+ // Until we drop the old content API in SMAPI 4.0.0, this sets the priority for
+ // specific legacy editors to maintain compatibility.
+ AssetEditPriority priority = editor.Data.GetType().FullName switch
+ {
+ "JsonAssets.Framework.ContentInjector1" => AssetEditPriority.Default - 1, // must be applied before Content Patcher
+ _ => AssetEditPriority.Default
+ };
+
// add operation
yield return new AssetOperationGroup(
mod: editor.Mod,
@@ -663,7 +684,7 @@ namespace StardewModdingAPI.Framework
{
new AssetEditOperation(
mod: editor.Mod,
- priority: AssetEditPriority.Default,
+ priority: priority,
onBehalfOf: null,
applyEdit: assetData => editor.Data.Edit<T>(
this.GetLegacyAssetData(assetData)