summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events/ControlEvents.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Events/ControlEvents.cs')
-rw-r--r--src/SMAPI/Events/ControlEvents.cs57
1 files changed, 48 insertions, 9 deletions
diff --git a/src/SMAPI/Events/ControlEvents.cs b/src/SMAPI/Events/ControlEvents.cs
index 56a4fa3f..c50d5bea 100644
--- a/src/SMAPI/Events/ControlEvents.cs
+++ b/src/SMAPI/Events/ControlEvents.cs
@@ -1,10 +1,12 @@
using System;
using Microsoft.Xna.Framework.Input;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// <summary>Events raised when the player uses a controller, keyboard, or mouse.</summary>
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class ControlEvents
{
/*********
@@ -13,6 +15,9 @@ namespace StardewModdingAPI.Events
/// <summary>The core event manager.</summary>
private static EventManager EventManager;
+ /// <summary>Manages deprecation warnings.</summary>
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -20,56 +25,88 @@ namespace StardewModdingAPI.Events
/// <summary>Raised when the <see cref="KeyboardState"/> changes. That happens when the player presses or releases a key.</summary>
public static event EventHandler<EventArgsKeyboardStateChanged> KeyboardChanged
{
- add => ControlEvents.EventManager.Legacy_KeyboardChanged.Add(value);
+ add
+ {
+ ControlEvents.DeprecationManager.WarnForOldEvents();
+ ControlEvents.EventManager.Legacy_KeyboardChanged.Add(value);
+ }
remove => ControlEvents.EventManager.Legacy_KeyboardChanged.Remove(value);
}
/// <summary>Raised after the player presses a keyboard key.</summary>
public static event EventHandler<EventArgsKeyPressed> KeyPressed
{
- add => ControlEvents.EventManager.Legacy_KeyPressed.Add(value);
+ add
+ {
+ ControlEvents.DeprecationManager.WarnForOldEvents();
+ ControlEvents.EventManager.Legacy_KeyPressed.Add(value);
+ }
remove => ControlEvents.EventManager.Legacy_KeyPressed.Remove(value);
}
/// <summary>Raised after the player releases a keyboard key.</summary>
public static event EventHandler<EventArgsKeyPressed> KeyReleased
{
- add => ControlEvents.EventManager.Legacy_KeyReleased.Add(value);
+ add
+ {
+ ControlEvents.DeprecationManager.WarnForOldEvents();
+ ControlEvents.EventManager.Legacy_KeyReleased.Add(value);
+ }
remove => ControlEvents.EventManager.Legacy_KeyReleased.Remove(value);
}
/// <summary>Raised when the <see cref="MouseState"/> changes. That happens when the player moves the mouse, scrolls the mouse wheel, or presses/releases a button.</summary>
public static event EventHandler<EventArgsMouseStateChanged> MouseChanged
{
- add => ControlEvents.EventManager.Legacy_MouseChanged.Add(value);
+ add
+ {
+ ControlEvents.DeprecationManager.WarnForOldEvents();
+ ControlEvents.EventManager.Legacy_MouseChanged.Add(value);
+ }
remove => ControlEvents.EventManager.Legacy_MouseChanged.Remove(value);
}
/// <summary>The player pressed a controller button. This event isn't raised for trigger buttons.</summary>
public static event EventHandler<EventArgsControllerButtonPressed> ControllerButtonPressed
{
- add => ControlEvents.EventManager.Legacy_ControllerButtonPressed.Add(value);
+ add
+ {
+ ControlEvents.DeprecationManager.WarnForOldEvents();
+ ControlEvents.EventManager.Legacy_ControllerButtonPressed.Add(value);
+ }
remove => ControlEvents.EventManager.Legacy_ControllerButtonPressed.Remove(value);
}
/// <summary>The player released a controller button. This event isn't raised for trigger buttons.</summary>
public static event EventHandler<EventArgsControllerButtonReleased> ControllerButtonReleased
{
- add => ControlEvents.EventManager.Legacy_ControllerButtonReleased.Add(value);
+ add
+ {
+ ControlEvents.DeprecationManager.WarnForOldEvents();
+ ControlEvents.EventManager.Legacy_ControllerButtonReleased.Add(value);
+ }
remove => ControlEvents.EventManager.Legacy_ControllerButtonReleased.Remove(value);
}
/// <summary>The player pressed a controller trigger button.</summary>
public static event EventHandler<EventArgsControllerTriggerPressed> ControllerTriggerPressed
{
- add => ControlEvents.EventManager.Legacy_ControllerTriggerPressed.Add(value);
+ add
+ {
+ ControlEvents.DeprecationManager.WarnForOldEvents();
+ ControlEvents.EventManager.Legacy_ControllerTriggerPressed.Add(value);
+ }
remove => ControlEvents.EventManager.Legacy_ControllerTriggerPressed.Remove(value);
}
/// <summary>The player released a controller trigger button.</summary>
public static event EventHandler<EventArgsControllerTriggerReleased> ControllerTriggerReleased
{
- add => ControlEvents.EventManager.Legacy_ControllerTriggerReleased.Add(value);
+ add
+ {
+ ControlEvents.DeprecationManager.WarnForOldEvents();
+ ControlEvents.EventManager.Legacy_ControllerTriggerReleased.Add(value);
+ }
remove => ControlEvents.EventManager.Legacy_ControllerTriggerReleased.Remove(value);
}
@@ -79,9 +116,11 @@ namespace StardewModdingAPI.Events
*********/
/// <summary>Initialise the events.</summary>
/// <param name="eventManager">The core event manager.</param>
- internal static void Init(EventManager eventManager)
+ /// <param name="deprecationManager">Manages deprecation warnings.</param>
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
ControlEvents.EventManager = eventManager;
+ ControlEvents.DeprecationManager = deprecationManager;
}
}
}