summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Events/MenuEvents.cs
blob: 59f03449305be6dd1b973f58e342462112fee29e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using StardewValley.Menus;

namespace StardewModdingAPI.Events
{
    /// <summary>Events raised when a game menu is opened or closed (including internal menus like the title screen).</summary>
    public static class MenuEvents
    {
        /*********
        ** Events
        *********/
        /// <summary>Raised after a game menu is opened or replaced with another menu. This event is not invoked when a menu is closed.</summary>
        public static event EventHandler<EventArgsClickableMenuChanged> MenuChanged = delegate { };

        /// <summary>Raised after a game menu is closed.</summary>
        public static event EventHandler<EventArgsClickableMenuClosed> MenuClosed = delegate { };


        /*********
        ** Internal methods
        *********/
        /// <summary>Raise a <see cref="MenuChanged"/> event.</summary>
        /// <param name="priorMenu">The previous menu.</param>
        /// <param name="newMenu">The current menu.</param>
        internal static void InvokeMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu)
        {
            MenuEvents.MenuChanged.Invoke(null, new EventArgsClickableMenuChanged(priorMenu, newMenu));
        }

        /// <summary>Raise a <see cref="MenuClosed"/> event.</summary>
        /// <param name="priorMenu">The menu that was closed.</param>
        internal static void InvokeMenuClosed(IClickableMenu priorMenu)
        {
            MenuEvents.MenuClosed.Invoke(null, new EventArgsClickableMenuClosed(priorMenu));
        }
    }
}