summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Events/ControlEvents.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Events/ControlEvents.cs')
-rw-r--r--src/StardewModdingAPI/Events/ControlEvents.cs41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/StardewModdingAPI/Events/ControlEvents.cs b/src/StardewModdingAPI/Events/ControlEvents.cs
index b7f69805..790bf193 100644
--- a/src/StardewModdingAPI/Events/ControlEvents.cs
+++ b/src/StardewModdingAPI/Events/ControlEvents.cs
@@ -1,6 +1,7 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
+using StardewModdingAPI.Framework;
namespace StardewModdingAPI.Events
{
@@ -39,69 +40,77 @@ namespace StardewModdingAPI.Events
** Internal methods
*********/
/// <summary>Raise a <see cref="KeyboardChanged"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="priorState">The previous keyboard state.</param>
/// <param name="newState">The current keyboard state.</param>
- internal static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState)
+ internal static void InvokeKeyboardChanged(IMonitor monitor, KeyboardState priorState, KeyboardState newState)
{
- ControlEvents.KeyboardChanged?.Invoke(null, new EventArgsKeyboardStateChanged(priorState, newState));
+ monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.KeyboardChanged)}", ControlEvents.KeyboardChanged?.GetInvocationList(), null, new EventArgsKeyboardStateChanged(priorState, newState));
}
/// <summary>Raise a <see cref="MouseChanged"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="priorState">The previous mouse state.</param>
/// <param name="newState">The current mouse state.</param>
/// <param name="priorPosition">The previous mouse position on the screen adjusted for the zoom level.</param>
/// <param name="newPosition">The current mouse position on the screen adjusted for the zoom level.</param>
- internal static void InvokeMouseChanged(MouseState priorState, MouseState newState, Point priorPosition, Point newPosition)
+ internal static void InvokeMouseChanged(IMonitor monitor, MouseState priorState, MouseState newState, Point priorPosition, Point newPosition)
{
- ControlEvents.MouseChanged?.Invoke(null, new EventArgsMouseStateChanged(priorState, newState, priorPosition, newPosition));
+ monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.MouseChanged)}", ControlEvents.MouseChanged?.GetInvocationList(), null, new EventArgsMouseStateChanged(priorState, newState, priorPosition, newPosition));
}
/// <summary>Raise a <see cref="KeyPressed"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="key">The keyboard button that was pressed.</param>
- internal static void InvokeKeyPressed(Keys key)
+ internal static void InvokeKeyPressed(IMonitor monitor, Keys key)
{
- ControlEvents.KeyPressed?.Invoke(null, new EventArgsKeyPressed(key));
+ monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.KeyPressed)}", ControlEvents.KeyPressed?.GetInvocationList(), null, new EventArgsKeyPressed(key));
}
/// <summary>Raise a <see cref="KeyReleased"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="key">The keyboard button that was released.</param>
- internal static void InvokeKeyReleased(Keys key)
+ internal static void InvokeKeyReleased(IMonitor monitor, Keys key)
{
- ControlEvents.KeyReleased?.Invoke(null, new EventArgsKeyPressed(key));
+ monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.KeyReleased)}", ControlEvents.KeyReleased?.GetInvocationList(), null, new EventArgsKeyPressed(key));
}
/// <summary>Raise a <see cref="ControllerButtonPressed"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="playerIndex">The player who pressed the button.</param>
/// <param name="button">The controller button that was pressed.</param>
- internal static void InvokeButtonPressed(PlayerIndex playerIndex, Buttons button)
+ internal static void InvokeButtonPressed(IMonitor monitor, PlayerIndex playerIndex, Buttons button)
{
- ControlEvents.ControllerButtonPressed?.Invoke(null, new EventArgsControllerButtonPressed(playerIndex, button));
+ monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerButtonPressed)}", ControlEvents.ControllerButtonPressed?.GetInvocationList(), null, new EventArgsControllerButtonPressed(playerIndex, button));
}
/// <summary>Raise a <see cref="ControllerButtonReleased"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="playerIndex">The player who released the button.</param>
/// <param name="button">The controller button that was released.</param>
- internal static void InvokeButtonReleased(PlayerIndex playerIndex, Buttons button)
+ internal static void InvokeButtonReleased(IMonitor monitor, PlayerIndex playerIndex, Buttons button)
{
- ControlEvents.ControllerButtonReleased?.Invoke(null, new EventArgsControllerButtonReleased(playerIndex, button));
+ monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerButtonReleased)}", ControlEvents.ControllerButtonReleased?.GetInvocationList(), null, new EventArgsControllerButtonReleased(playerIndex, button));
}
/// <summary>Raise a <see cref="ControllerTriggerPressed"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="playerIndex">The player who pressed the trigger button.</param>
/// <param name="button">The trigger button that was pressed.</param>
/// <param name="value">The current trigger value.</param>
- internal static void InvokeTriggerPressed(PlayerIndex playerIndex, Buttons button, float value)
+ internal static void InvokeTriggerPressed(IMonitor monitor, PlayerIndex playerIndex, Buttons button, float value)
{
- ControlEvents.ControllerTriggerPressed?.Invoke(null, new EventArgsControllerTriggerPressed(playerIndex, button, value));
+ monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerTriggerPressed)}", ControlEvents.ControllerTriggerPressed?.GetInvocationList(), null, new EventArgsControllerTriggerPressed(playerIndex, button, value));
}
/// <summary>Raise a <see cref="ControllerTriggerReleased"/> event.</summary>
+ /// <param name="monitor">Encapsulates monitoring and logging.</param>
/// <param name="playerIndex">The player who pressed the trigger button.</param>
/// <param name="button">The trigger button that was pressed.</param>
/// <param name="value">The current trigger value.</param>
- internal static void InvokeTriggerReleased(PlayerIndex playerIndex, Buttons button, float value)
+ internal static void InvokeTriggerReleased(IMonitor monitor, PlayerIndex playerIndex, Buttons button, float value)
{
- ControlEvents.ControllerTriggerReleased?.Invoke(null, new EventArgsControllerTriggerReleased(playerIndex, button, value));
+ monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerTriggerReleased)}", ControlEvents.ControllerTriggerReleased?.GetInvocationList(), null, new EventArgsControllerTriggerReleased(playerIndex, button, value));
}
}
}