summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md1
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs29
2 files changed, 24 insertions, 6 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 340ebb62..4c5671ec 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -13,6 +13,7 @@
* For modders:
* Added support for `.json` data files in the content API (including Content Patcher).
+ * Added asset propagation for dialogue changes through the content API.
* 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 12abeb10..3821e4ab 100644
--- a/src/SMAPI/Metadata/CoreAssetPropagator.cs
+++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs
@@ -320,14 +320,16 @@ namespace StardewModdingAPI.Metadata
return this.ReloadNpcSprites(content, key, monster: true);
if (key.StartsWith(this.GetNormalisedPath("LooseSprites\\Fence"), StringComparison.InvariantCultureIgnoreCase))
- return this.ReloadFenceTextures(content, key);
+ return this.ReloadFenceTextures(key);
if (this.IsInFolder(key, "Portraits"))
return this.ReloadNpcPortraits(content, key);
// dynamic data
+ if (this.IsInFolder(key, "Characters\\Dialogue"))
+ return this.ReloadNpcDialogue(key);
if (this.IsInFolder(key, "Characters\\schedules"))
- return this.ReloadNpcSchedules(content, key);
+ return this.ReloadNpcSchedules(key);
return false;
}
@@ -416,10 +418,9 @@ namespace StardewModdingAPI.Metadata
}
/// <summary>Reload the sprites for a fence type.</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 ReloadFenceTextures(LocalizedContentManager content, string key)
+ private bool ReloadFenceTextures(string key)
{
// get fence type
if (!int.TryParse(this.GetSegments(key)[1].Substring("Fence".Length), out int fenceType))
@@ -508,11 +509,27 @@ namespace StardewModdingAPI.Metadata
/****
** Reload data methods
****/
+ /// <summary>Reload the dialogue data for matching NPCs.</summary>
+ /// <param name="key">The asset key to reload.</param>
+ /// <returns>Returns whether any assets were reloaded.</returns>
+ private bool ReloadNpcDialogue(string key)
+ {
+ // get NPCs
+ string name = Path.GetFileName(key);
+ NPC[] villagers = this.GetCharacters().Where(npc => npc.Name == name && npc.isVillager()).ToArray();
+ if (!villagers.Any())
+ return false;
+
+ // update dialogue
+ foreach (NPC villager in villagers)
+ villager.resetSeasonalDialogue(); // doesn't only affect seasonal dialogue
+ return true;
+ }
+
/// <summary>Reload the schedules for matching NPCs.</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 assets were reloaded.</returns>
- private bool ReloadNpcSchedules(LocalizedContentManager content, string key)
+ private bool ReloadNpcSchedules(string key)
{
// get NPCs
string name = Path.GetFileName(key);