diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-18 17:42:51 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-18 17:42:51 -0500 |
commit | 45ee74219ee931b5fef3b67c08adf79d55aa091d (patch) | |
tree | 2124b962954f653c7b96c2a24c34d2a16aac0c61 | |
parent | a8cc3636995c9fc5eb08fa9d42129a05d79bb666 (diff) | |
download | SMAPI-45ee74219ee931b5fef3b67c08adf79d55aa091d.tar.gz SMAPI-45ee74219ee931b5fef3b67c08adf79d55aa091d.tar.bz2 SMAPI-45ee74219ee931b5fef3b67c08adf79d55aa091d.zip |
fix issue where changing the active menu inside a menu change handler didn't trigger a new event (#194)
-rw-r--r-- | src/StardewModdingAPI/Inheritance/SGame.cs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/StardewModdingAPI/Inheritance/SGame.cs b/src/StardewModdingAPI/Inheritance/SGame.cs index f70d0696..16803a73 100644 --- a/src/StardewModdingAPI/Inheritance/SGame.cs +++ b/src/StardewModdingAPI/Inheritance/SGame.cs @@ -913,11 +913,17 @@ namespace StardewModdingAPI.Inheritance // raise menu changed if (Game1.activeClickableMenu != this.PreviousActiveMenu) { + // raise events + IClickableMenu previousMenu = this.PreviousActiveMenu; + IClickableMenu newMenu = Game1.activeClickableMenu; if (Game1.activeClickableMenu != null) - MenuEvents.InvokeMenuChanged(this.Monitor, this.PreviousActiveMenu, Game1.activeClickableMenu); + MenuEvents.InvokeMenuChanged(this.Monitor, previousMenu, newMenu); else - MenuEvents.InvokeMenuClosed(this.Monitor, this.PreviousActiveMenu); - this.PreviousActiveMenu = Game1.activeClickableMenu; + MenuEvents.InvokeMenuClosed(this.Monitor, previousMenu); + + // update previous menu + // (if the menu was changed in one of the handlers, deliberately defer detection until the next update so mods can be notified of the new menu change) + this.PreviousActiveMenu = newMenu; } // raise location list changed |