fix asset changes not affecting cached asset loads in a specific case
This commit is contained in:
parent
9828f32bf7
commit
1003116f7f
|
@ -59,6 +59,7 @@ These changes have not been released yet.
|
|||
* Removed the `Monitor.ExitGameImmediately` method.
|
||||
* Updated dependencies (including Json.NET 11.0.2 → 12.0.2, Mono.Cecil 0.10.1 → 0.10.4).
|
||||
* Fixed issue where mod changes weren't tracked correctly for raising events in some cases. Events now reflect a frozen snapshot of the game state, and any mod changes are reflected in the next event tick.
|
||||
* Fixed issue where, when a mod's `IAssetEditor` uses `asset.ReplaceWith` on a texture asset while playing in non-English, any changes from that point won't affect subsequent cached asset loads.
|
||||
* Fixed `LoadStageChanged` event not raising correct flags in some cases when creating a new save.
|
||||
|
||||
## 2.11.3
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue