using System; using StardewModdingAPI.Framework; 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. /// Encapsulates monitoring and logging. /// The object which raised the event. /// The event arguments. internal static void InvokeResize(IMonitor monitor, object sender, EventArgs e) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.Resize)}", GraphicsEvents.Resize?.GetInvocationList(), sender, e); } /// Raise a event. /// Encapsulates monitoring and logging. internal static void InvokeDrawDebug(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.DrawDebug)}", GraphicsEvents.DrawDebug?.GetInvocationList()); } /// Raise a event. /// Encapsulates logging and monitoring. [Obsolete("Should not be used.")] public static void InvokeDrawTick(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.DrawTick)}", GraphicsEvents.DrawTick?.GetInvocationList()); } /// Raise a event. /// Encapsulates monitoring and logging. [Obsolete("Should not be used.")] public static void InvokeDrawInRenderTargetTick(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.DrawInRenderTargetTick)}", GraphicsEvents.DrawInRenderTargetTick?.GetInvocationList()); } /**** ** Main render events ****/ /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPreRenderEvent(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPreRenderEvent)}", GraphicsEvents.OnPreRenderEvent?.GetInvocationList()); } /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPostRenderEvent(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPostRenderEvent)}", GraphicsEvents.OnPostRenderEvent?.GetInvocationList()); } /**** ** HUD events ****/ /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPreRenderGuiEvent(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPreRenderGuiEvent)}", GraphicsEvents.OnPreRenderGuiEvent?.GetInvocationList()); } /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPreRenderGuiEventNoCheck(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPreRenderGuiEventNoCheck)}", GraphicsEvents.OnPreRenderGuiEventNoCheck?.GetInvocationList()); } /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPostRenderGuiEvent(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPostRenderGuiEvent)}", GraphicsEvents.OnPostRenderGuiEvent?.GetInvocationList()); } /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPostRenderGuiEventNoCheck(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPostRenderGuiEventNoCheck)}", GraphicsEvents.OnPostRenderGuiEventNoCheck?.GetInvocationList()); } /**** ** GUI events ****/ /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPreRenderHudEvent(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPreRenderHudEvent)}", GraphicsEvents.OnPreRenderHudEvent?.GetInvocationList()); } /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPreRenderHudEventNoCheck(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPreRenderHudEventNoCheck)}", GraphicsEvents.OnPreRenderHudEventNoCheck?.GetInvocationList()); } /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPostRenderHudEvent(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPostRenderHudEvent)}", GraphicsEvents.OnPostRenderHudEvent?.GetInvocationList()); } /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeOnPostRenderHudEventNoCheck(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GraphicsEvents)}.{nameof(GraphicsEvents.OnPostRenderHudEventNoCheck)}", GraphicsEvents.OnPostRenderHudEventNoCheck?.GetInvocationList()); } } }