diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-08-12 01:31:52 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-08-12 01:31:52 -0400 |
commit | f7111a2488bd16b30c28be1025e7dbf9c4ca1306 (patch) | |
tree | 1ba6c04357a87e164a6689b83c1d96bb87b05785 | |
parent | 13f9a4d8d2155463f9ceaa41dd15d4526927476e (diff) | |
download | SMAPI-f7111a2488bd16b30c28be1025e7dbf9c4ca1306.tar.gz SMAPI-f7111a2488bd16b30c28be1025e7dbf9c4ca1306.tar.bz2 SMAPI-f7111a2488bd16b30c28be1025e7dbf9c4ca1306.zip |
add asset propagation for map tilesheets (#570)
-rw-r--r-- | docs/release-notes.md | 5 | ||||
-rw-r--r-- | src/SMAPI/Metadata/CoreAssetPropagator.cs | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index 9ac52ab1..ab47b5c7 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -13,7 +13,10 @@ * For modders: * Added support for `.json` data files in the content API (including Content Patcher). - * Fixed changes through the content API not propagating correctly for dialogue and child sprites. + * Added automatic propagation when changing assets through the content API for... + * child sprites; + * dialogue; + * map tilesheets. * Added `--mods-path` command-line argument to allow switching between mod folders. * All enums are now JSON-serialised by name, since that's more user-friendly. Previously only certain predefined enums were serialised that way. JSON files which already have integer enums will still be parsed fine. * Fixed false compatibility error when constructing multidimensional arrays. diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index e9d66975..8487b6be 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -13,6 +13,7 @@ using StardewValley.Menus; using StardewValley.Objects; using StardewValley.Projectiles; using StardewValley.TerrainFeatures; +using xTile.Tiles; namespace StardewModdingAPI.Metadata { @@ -63,6 +64,23 @@ namespace StardewModdingAPI.Metadata /// <returns>Returns any non-null value to indicate an asset was loaded.</returns> private object PropagateImpl(LocalizedContentManager content, string key) { + /**** + ** Special case: current map tilesheet + ** We only need to do this for the current location, since tilesheets are reloaded when you enter a location. + ** Just in case, we should still propagate by key even if a tilesheet is matched. + ****/ + if (Game1.currentLocation?.map?.TileSheets != null) + { + foreach (TileSheet tilesheet in Game1.currentLocation.map.TileSheets) + { + if (this.GetNormalisedPath(tilesheet.ImageSource) == key) + Game1.mapDisplayDevice.LoadTileSheet(tilesheet); + } + } + + /**** + ** Propagate by key + ****/ Reflector reflection = this.Reflection; switch (key.ToLower().Replace("/", "\\")) // normalised key so we can compare statically { |