summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/ContentManagers/GameContentManager.cs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
index c64e9ba9..0b563555 100644
--- a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
@@ -184,10 +184,20 @@ namespace StardewModdingAPI.Framework.ContentManagers
return;
}
}
+
+ // save to cache
+ // Note: even if the asset was loaded and cached right before this method was called,
+ // we need to fully re-inject it here for two reasons:
+ // 1. So we can look up an asset by its base or localized key (the game/XNA logic
+ // only caches by the most specific key).
+ // 2. Because a mod asset loader/editor may have changed the asset in a way that
+ // doesn't change the instance stored in the cache, e.g. using `asset.ReplaceWith`.
+ string keyWithLocale = $"{assetName}.{this.GetLocale(language)}";
base.Inject(assetName, value, language);
+ if (this.Cache.ContainsKey(keyWithLocale))
+ base.Inject(keyWithLocale, value, language);
// track whether the injected asset is translatable for is-loaded lookups
- string keyWithLocale = $"{assetName}.{this.GetLocale(language)}";
if (this.Cache.ContainsKey(keyWithLocale))
{
this.IsLocalizableLookup[assetName] = true;