diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-08-18 01:00:11 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-14 19:13:35 -0400 |
commit | 1003116f7f95d149b350642db8da2464d9ed9954 (patch) | |
tree | 4e74bb2507f734dc900206a42384e84e832bf3ae /src | |
parent | 9828f32bf7d49bbf660d394857dfa0394880fb41 (diff) | |
download | SMAPI-1003116f7f95d149b350642db8da2464d9ed9954.tar.gz SMAPI-1003116f7f95d149b350642db8da2464d9ed9954.tar.bz2 SMAPI-1003116f7f95d149b350642db8da2464d9ed9954.zip |
fix asset changes not affecting cached asset loads in a specific case
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI/Framework/ContentManagers/GameContentManager.cs | 12 |
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; |