fix issue where changing the active menu inside a menu change handler didn't trigger a new event (#194)

This commit is contained in:
Jesse Plamondon-Willard 2016-12-18 17:42:51 -05:00
parent a8cc363699
commit 45ee74219e
1 changed files with 9 additions and 3 deletions

View File

@ -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