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 = delegate { };
/// 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 = delegate { };
/// Obsolete.
[Obsolete("Use the other Pre/Post render events instead.")]
public static event EventHandler DrawTick = delegate { };
/// 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 = delegate { };
/****
** Main render events
****/
/// Raised before drawing everything to the screen during a draw loop.
public static event EventHandler OnPreRenderEvent = delegate { };
/// Raised after drawing everything to the screen during a draw loop.
public static event EventHandler OnPostRenderEvent = delegate { };
/****
** 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 = delegate { };
/// Equivalent to , but invoked even if the HUD isn't available.
public static event EventHandler OnPreRenderHudEventNoCheck = delegate { };
/// 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 = delegate { };
/// Equivalent to , but invoked even if the HUD isn't available.
public static event EventHandler OnPostRenderHudEventNoCheck = delegate { };
/****
** 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 = delegate { };
/// Equivalent to , but invoked even if there's no menu being drawn.
public static event EventHandler OnPreRenderGuiEventNoCheck = delegate { };
/// 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 = delegate { };
/// Equivalent to , but invoked even if there's no menu being drawn.
public static event EventHandler OnPostRenderGuiEventNoCheck = delegate { };
/*********
** 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.
[Obsolete("Should not be used.")]
public static void InvokeDrawTick()
{
try
{
GraphicsEvents.DrawTick.Invoke(null, EventArgs.Empty);
}
catch (Exception ex)
{
Log.AsyncR("An exception occured in a Mod's DrawTick: " + ex);
}
}
/// 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);
}
}
}