using System; namespace StardewModdingAPI.Events { /// Events raised during the game's draw loop, when the game is rendering content to the window. public static class GraphicsEvents { /********* ** Events *********/ /**** ** Generic events ****/ /// Raised after the game window is resized. public static event EventHandler Resize; /// Raised when drawing debug information to the screen (when is true). This is called after the sprite batch is begun. If you just want to add debug info, use in your update loop. public static event EventHandler DrawDebug; /// Obsolete. [Obsolete("Use the other Pre/Post render events instead.")] public static event EventHandler DrawTick; /// Obsolete. [Obsolete("Use the other Pre/Post render events instead. All of them will automatically be drawn into the render target if needed.")] public static event EventHandler DrawInRenderTargetTick; /**** ** Main render events ****/ /// Raised before drawing everything to the screen during a draw loop. public static event EventHandler OnPreRenderEvent; /// Raised after drawing everything to the screen during a draw loop. public static event EventHandler OnPostRenderEvent; /**** ** HUD events ****/ /// Raised before drawing the HUD (item toolbar, clock, etc) to the screen. The HUD is available at this point, but not necessarily visible. (For example, the event is raised even if a menu is open.) public static event EventHandler OnPreRenderHudEvent; /// Equivalent to , but invoked even if the HUD isn't available. public static event EventHandler OnPreRenderHudEventNoCheck; /// Raised after drawing the HUD (item toolbar, clock, etc) to the screen. The HUD is available at this point, but not necessarily visible. (For example, the event is raised even if a menu is open.) public static event EventHandler OnPostRenderHudEvent; /// Equivalent to , but invoked even if the HUD isn't available. public static event EventHandler OnPostRenderHudEventNoCheck; /**** ** GUI events ****/ /// Raised before drawing a menu to the screen during a draw loop. This includes the game's internal menus like the title screen. public static event EventHandler OnPreRenderGuiEvent; /// Equivalent to , but invoked even if there's no menu being drawn. public static event EventHandler OnPreRenderGuiEventNoCheck; /// Raised after drawing a menu to the screen during a draw loop. This includes the game's internal menus like the title screen. public static event EventHandler OnPostRenderGuiEvent; /// Equivalent to , but invoked even if there's no menu being drawn. public static event EventHandler OnPostRenderGuiEventNoCheck; /********* ** Internal methods *********/ /**** ** Generic events ****/ /// Raise a event. /// The object which raised the event. /// The event arguments. internal static void InvokeResize(object sender, EventArgs e) { GraphicsEvents.Resize?.Invoke(sender, e); } /// Raise a event. /// The object which raised the event. /// The event arguments. internal static void InvokeDrawDebug(object sender, EventArgs e) { GraphicsEvents.DrawDebug?.Invoke(sender, e); } /// Raise a event. /// Encapsulates logging and monitoring. [Obsolete("Should not be used.")] public static void InvokeDrawTick(IMonitor monitor) { try { GraphicsEvents.DrawTick?.Invoke(null, EventArgs.Empty); } catch (Exception ex) { monitor.Log($"A mod crashed handling an event.\n{ex}", LogLevel.Error); } } /// Raise a event. [Obsolete("Should not be used.")] public static void InvokeDrawInRenderTargetTick() { GraphicsEvents.DrawInRenderTargetTick?.Invoke(null, EventArgs.Empty); } /**** ** Main render events ****/ /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPreRenderEvent(object sender, EventArgs e) { GraphicsEvents.OnPreRenderEvent?.Invoke(sender, e); } /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPostRenderEvent(object sender, EventArgs e) { GraphicsEvents.OnPostRenderEvent?.Invoke(sender, e); } /**** ** HUD events ****/ /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPreRenderGuiEvent(object sender, EventArgs e) { GraphicsEvents.OnPreRenderGuiEvent?.Invoke(sender, e); } /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPreRenderGuiEventNoCheck(object sender, EventArgs e) { GraphicsEvents.OnPreRenderGuiEventNoCheck?.Invoke(sender, e); } /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPostRenderGuiEvent(object sender, EventArgs e) { GraphicsEvents.OnPostRenderGuiEvent?.Invoke(sender, e); } /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPostRenderGuiEventNoCheck(object sender, EventArgs e) { GraphicsEvents.OnPostRenderGuiEventNoCheck?.Invoke(sender, e); } /**** ** GUI events ****/ /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPreRenderHudEvent(object sender, EventArgs e) { GraphicsEvents.OnPreRenderHudEvent?.Invoke(sender, e); } /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPreRenderHudEventNoCheck(object sender, EventArgs e) { GraphicsEvents.OnPreRenderHudEventNoCheck?.Invoke(sender, e); } /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPostRenderHudEvent(object sender, EventArgs e) { GraphicsEvents.OnPostRenderHudEvent?.Invoke(sender, e); } /// Raise an event. /// The object which raised the event. /// The event arguments. internal static void InvokeOnPostRenderHudEventNoCheck(object sender, EventArgs e) { GraphicsEvents.OnPostRenderHudEventNoCheck?.Invoke(sender, e); } } }