fix asset propagation for map seats

This commit is contained in:
Jesse Plamondon-Willard 2021-02-13 16:54:57 -05:00
parent fa3305e1d8
commit b1876dec7a
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 25 additions and 3 deletions

View File

@ -13,8 +13,9 @@
* Fixed error running `install on Windows.bat` in very rare cases. * Fixed error running `install on Windows.bat` in very rare cases.
* For modders: * For modders:
* Fixed SMAPI toolkit defaulting the mod type incorrectly if a mod's `manifest.json` has neither `EntryDll` nor `ContentPackFor`. This only affects external tools, since SMAPI itself validates those fields separately. * Fixed asset propagation for `TileSheets/ChairTiles` not changing existing map seats.
* Fixed edge case when playing in non-English where translatable assets loaded via `IAssetLoader` would no longer be applied after returning to the title screen unless manually invalidated from the cache. * Fixed edge case when playing in non-English where translatable assets loaded via `IAssetLoader` would no longer be applied after returning to the title screen unless manually invalidated from the cache.
* Fixed SMAPI toolkit defaulting the mod type incorrectly if a mod's `manifest.json` has neither `EntryDll` nor `ContentPackFor`. This only affects external tools, since SMAPI itself validates those fields separately.
* For the ErrorHandler mod: * For the ErrorHandler mod:
* Added early detection of disposed textures so the crash stack trace shows the actual code which used them. * Added early detection of disposed textures so the crash stack trace shows the actual code which used them.

View File

@ -452,8 +452,7 @@ namespace StardewModdingAPI.Metadata
return true; return true;
case "tilesheets\\chairtiles": // Game1.LoadContent case "tilesheets\\chairtiles": // Game1.LoadContent
MapSeat.mapChairTexture = content.Load<Texture2D>(key); return this.ReloadChairTiles(content, key);
return true;
case "tilesheets\\craftables": // Game1.LoadContent case "tilesheets\\craftables": // Game1.LoadContent
Game1.bigCraftableSpriteSheet = content.Load<Texture2D>(key); Game1.bigCraftableSpriteSheet = content.Load<Texture2D>(key);
@ -691,6 +690,28 @@ namespace StardewModdingAPI.Metadata
return false; return false;
} }
/// <summary>Reload map seat textures.</summary>
/// <param name="content">The content manager through which to reload the asset.</param>
/// <param name="key">The asset key to reload.</param>
/// <returns>Returns whether any textures were reloaded.</returns>
private bool ReloadChairTiles(LocalizedContentManager content, string key)
{
MapSeat.mapChairTexture = content.Load<Texture2D>(key);
foreach (var location in this.GetLocations())
{
foreach (MapSeat seat in location.mapSeats.Where(p => p != null))
{
string curKey = this.NormalizeAssetNameIgnoringEmpty(seat._loadedTextureFile);
if (curKey == null || key.Equals(curKey, StringComparison.OrdinalIgnoreCase))
seat.overlayTexture = MapSeat.mapChairTexture;
}
}
return true;
}
/// <summary>Reload critter textures.</summary> /// <summary>Reload critter textures.</summary>
/// <param name="content">The content manager through which to reload the asset.</param> /// <param name="content">The content manager through which to reload the asset.</param>
/// <param name="key">The asset key to reload.</param> /// <param name="key">The asset key to reload.</param>