summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Events/ModDisplayEvents.cs
blob: 54d40deef2596fff9034125f0ed20b493f114789 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using StardewModdingAPI.Events;
using StardewValley;

namespace StardewModdingAPI.Framework.Events
{
    /// <summary>Events related to UI and drawing to the screen.</summary>
    internal class ModDisplayEvents : ModEventsBase, IDisplayEvents
    {
        /*********
        ** Accessors
        *********/
        /// <summary>Raised after a game menu is opened, closed, or replaced.</summary>
        public event EventHandler<MenuChangedEventArgs> MenuChanged
        {
            add => this.EventManager.MenuChanged.Add(value, this.Mod);
            remove => this.EventManager.MenuChanged.Remove(value);
        }

        /// <summary>Raised before the game draws anything to the screen in a draw tick, as soon as the sprite batch is opened. The sprite batch may be closed and reopened multiple times after this event is called, but it's only raised once per draw tick. This event isn't useful for drawing to the screen, since the game will draw over it.</summary>
        public event EventHandler<RenderingEventArgs> Rendering
        {
            add => this.EventManager.Rendering.Add(value, this.Mod);
            remove => this.EventManager.Rendering.Remove(value);
        }

        /// <summary>Raised after the game draws to the sprite patch in a draw tick, just before the final sprite batch is rendered to the screen. Since the game may open/close the sprite batch multiple times in a draw tick, the sprite batch may not contain everything being drawn and some things may already be rendered to the screen. Content drawn to the sprite batch at this point will be drawn over all vanilla content (including menus, HUD, and cursor).</summary>
        public event EventHandler<RenderedEventArgs> Rendered
        {
            add => this.EventManager.Rendered.Add(value, this.Mod);
            remove => this.EventManager.Rendered.Remove(value);
        }

        /// <summary>Raised before the game world is drawn to the screen. This event isn't useful for drawing to the screen, since the game will draw over it.</summary>
        public event EventHandler<RenderingWorldEventArgs> RenderingWorld
        {
            add => this.EventManager.RenderingWorld.Add(value, this.Mod);
            remove => this.EventManager.RenderingWorld.Remove(value);
        }

        /// <summary>Raised after the game world is drawn to the sprite patch, before it's rendered to the screen. Content drawn to the sprite batch at this point will be drawn over the world, but under any active menu, HUD elements, or cursor.</summary>
        public event EventHandler<RenderedWorldEventArgs> RenderedWorld
        {
            add => this.EventManager.RenderedWorld.Add(value, this.Mod);
            remove => this.EventManager.RenderedWorld.Remove(value);
        }

        /// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised before that menu is drawn to the screen. This includes the game's internal menus like the title screen. Content drawn to the sprite batch at this point will appear under the menu.</summary>
        public event EventHandler<RenderingActiveMenuEventArgs> RenderingActiveMenu
        {
            add => this.EventManager.RenderingActiveMenu.Add(value, this.Mod);
            remove => this.EventManager.RenderingActiveMenu.Remove(value);
        }

        /// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen. Content drawn to the sprite batch at this point will appear over the menu and menu cursor.</summary>
        public event EventHandler<RenderedActiveMenuEventArgs> RenderedActiveMenu
        {
            add => this.EventManager.RenderedActiveMenu.Add(value, this.Mod);
            remove => this.EventManager.RenderedActiveMenu.Remove(value);
        }

        /// <summary>Raised before drawing the HUD (item toolbar, clock, etc) to the screen. The vanilla HUD may be hidden at this point (e.g. because a menu is open). Content drawn to the sprite batch at this point will appear under the HUD.</summary>
        public event EventHandler<RenderingHudEventArgs> RenderingHud
        {
            add => this.EventManager.RenderingHud.Add(value, this.Mod);
            remove => this.EventManager.RenderingHud.Remove(value);
        }

        /// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen. The vanilla HUD may be hidden at this point (e.g. because a menu is open). Content drawn to the sprite batch at this point will appear over the HUD.</summary>
        public event EventHandler<RenderedHudEventArgs> RenderedHud
        {
            add => this.EventManager.RenderedHud.Add(value, this.Mod);
            remove => this.EventManager.RenderedHud.Remove(value);
        }

        /// <summary>Raised after the game window is resized.</summary>
        public event EventHandler<WindowResizedEventArgs> WindowResized
        {
            add => this.EventManager.WindowResized.Add(value, this.Mod);
            remove => this.EventManager.WindowResized.Remove(value);
        }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="mod">The mod which uses this instance.</param>
        /// <param name="eventManager">The underlying event manager.</param>
        internal ModDisplayEvents(IModMetadata mod, EventManager eventManager)
            : base(mod, eventManager) { }
    }
}