diff --git a/src/SMAPI/Events/ContentEvents.cs b/src/SMAPI/Events/ContentEvents.cs
index 3ee0560b..3bf3881b 100644
--- a/src/SMAPI/Events/ContentEvents.cs
+++ b/src/SMAPI/Events/ContentEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised when the game loads content.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class ContentEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,7 +24,11 @@ namespace StardewModdingAPI.Events
/// Raised after the content language changes.
public static event EventHandler> AfterLocaleChanged
{
- add => ContentEvents.EventManager.Legacy_LocaleChanged.Add(value);
+ add
+ {
+ ContentEvents.DeprecationManager.WarnForOldEvents();
+ ContentEvents.EventManager.Legacy_LocaleChanged.Add(value);
+ }
remove => ContentEvents.EventManager.Legacy_LocaleChanged.Remove(value);
}
@@ -29,9 +38,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
ContentEvents.EventManager = eventManager;
+ ContentEvents.DeprecationManager = deprecationManager;
}
}
}
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
{
/// Events raised when the player uses a controller, keyboard, or mouse.
+ [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
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -20,56 +25,88 @@ namespace StardewModdingAPI.Events
/// Raised when the changes. That happens when the player presses or releases a key.
public static event EventHandler 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);
}
/// Raised after the player presses a keyboard key.
public static event EventHandler 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);
}
/// Raised after the player releases a keyboard key.
public static event EventHandler 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);
}
/// Raised when the changes. That happens when the player moves the mouse, scrolls the mouse wheel, or presses/releases a button.
public static event EventHandler 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);
}
/// The player pressed a controller button. This event isn't raised for trigger buttons.
public static event EventHandler 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);
}
/// The player released a controller button. This event isn't raised for trigger buttons.
public static event EventHandler 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);
}
/// The player pressed a controller trigger button.
public static event EventHandler 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);
}
/// The player released a controller trigger button.
public static event EventHandler 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
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
ControlEvents.EventManager = eventManager;
+ ControlEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/GameEvents.cs b/src/SMAPI/Events/GameEvents.cs
index 952b3570..13f6bfb0 100644
--- a/src/SMAPI/Events/GameEvents.cs
+++ b/src/SMAPI/Events/GameEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised when the game changes state.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class GameEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,56 +24,88 @@ namespace StardewModdingAPI.Events
/// Raised when the game updates its state (≈60 times per second).
public static event EventHandler UpdateTick
{
- add => GameEvents.EventManager.Legacy_UpdateTick.Add(value);
+ add
+ {
+ GameEvents.DeprecationManager.WarnForOldEvents();
+ GameEvents.EventManager.Legacy_UpdateTick.Add(value);
+ }
remove => GameEvents.EventManager.Legacy_UpdateTick.Remove(value);
}
/// Raised every other tick (≈30 times per second).
public static event EventHandler SecondUpdateTick
{
- add => GameEvents.EventManager.Legacy_SecondUpdateTick.Add(value);
+ add
+ {
+ GameEvents.DeprecationManager.WarnForOldEvents();
+ GameEvents.EventManager.Legacy_SecondUpdateTick.Add(value);
+ }
remove => GameEvents.EventManager.Legacy_SecondUpdateTick.Remove(value);
}
/// Raised every fourth tick (≈15 times per second).
public static event EventHandler FourthUpdateTick
{
- add => GameEvents.EventManager.Legacy_FourthUpdateTick.Add(value);
+ add
+ {
+ GameEvents.DeprecationManager.WarnForOldEvents();
+ GameEvents.EventManager.Legacy_FourthUpdateTick.Add(value);
+ }
remove => GameEvents.EventManager.Legacy_FourthUpdateTick.Remove(value);
}
/// Raised every eighth tick (≈8 times per second).
public static event EventHandler EighthUpdateTick
{
- add => GameEvents.EventManager.Legacy_EighthUpdateTick.Add(value);
+ add
+ {
+ GameEvents.DeprecationManager.WarnForOldEvents();
+ GameEvents.EventManager.Legacy_EighthUpdateTick.Add(value);
+ }
remove => GameEvents.EventManager.Legacy_EighthUpdateTick.Remove(value);
}
/// Raised every 15th tick (≈4 times per second).
public static event EventHandler QuarterSecondTick
{
- add => GameEvents.EventManager.Legacy_QuarterSecondTick.Add(value);
+ add
+ {
+ GameEvents.DeprecationManager.WarnForOldEvents();
+ GameEvents.EventManager.Legacy_QuarterSecondTick.Add(value);
+ }
remove => GameEvents.EventManager.Legacy_QuarterSecondTick.Remove(value);
}
/// Raised every 30th tick (≈twice per second).
public static event EventHandler HalfSecondTick
{
- add => GameEvents.EventManager.Legacy_HalfSecondTick.Add(value);
+ add
+ {
+ GameEvents.DeprecationManager.WarnForOldEvents();
+ GameEvents.EventManager.Legacy_HalfSecondTick.Add(value);
+ }
remove => GameEvents.EventManager.Legacy_HalfSecondTick.Remove(value);
}
/// Raised every 60th tick (≈once per second).
public static event EventHandler OneSecondTick
{
- add => GameEvents.EventManager.Legacy_OneSecondTick.Add(value);
+ add
+ {
+ GameEvents.DeprecationManager.WarnForOldEvents();
+ GameEvents.EventManager.Legacy_OneSecondTick.Add(value);
+ }
remove => GameEvents.EventManager.Legacy_OneSecondTick.Remove(value);
}
/// Raised once after the game initialises and all methods have been called.
public static event EventHandler FirstUpdateTick
{
- add => GameEvents.EventManager.Legacy_FirstUpdateTick.Add(value);
+ add
+ {
+ GameEvents.DeprecationManager.WarnForOldEvents();
+ GameEvents.EventManager.Legacy_FirstUpdateTick.Add(value);
+ }
remove => GameEvents.EventManager.Legacy_FirstUpdateTick.Remove(value);
}
@@ -78,9 +115,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
GameEvents.EventManager = eventManager;
+ GameEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/GraphicsEvents.cs b/src/SMAPI/Events/GraphicsEvents.cs
index 53f04822..de79e42e 100644
--- a/src/SMAPI/Events/GraphicsEvents.cs
+++ b/src/SMAPI/Events/GraphicsEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised during the game's draw loop, when the game is rendering content to the window.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class GraphicsEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,7 +24,11 @@ namespace StardewModdingAPI.Events
/// Raised after the game window is resized.
public static event EventHandler Resize
{
- add => GraphicsEvents.EventManager.Legacy_Resize.Add(value);
+ add
+ {
+ GraphicsEvents.DeprecationManager.WarnForOldEvents();
+ GraphicsEvents.EventManager.Legacy_Resize.Add(value);
+ }
remove => GraphicsEvents.EventManager.Legacy_Resize.Remove(value);
}
@@ -29,14 +38,22 @@ namespace StardewModdingAPI.Events
/// Raised before drawing the world to the screen.
public static event EventHandler OnPreRenderEvent
{
- add => GraphicsEvents.EventManager.Legacy_OnPreRenderEvent.Add(value);
+ add
+ {
+ GraphicsEvents.DeprecationManager.WarnForOldEvents();
+ GraphicsEvents.EventManager.Legacy_OnPreRenderEvent.Add(value);
+ }
remove => GraphicsEvents.EventManager.Legacy_OnPreRenderEvent.Remove(value);
}
/// Raised after drawing the world to the screen.
public static event EventHandler OnPostRenderEvent
{
- add => GraphicsEvents.EventManager.Legacy_OnPostRenderEvent.Add(value);
+ add
+ {
+ GraphicsEvents.DeprecationManager.WarnForOldEvents();
+ GraphicsEvents.EventManager.Legacy_OnPostRenderEvent.Add(value);
+ }
remove => GraphicsEvents.EventManager.Legacy_OnPostRenderEvent.Remove(value);
}
@@ -46,14 +63,22 @@ namespace StardewModdingAPI.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
{
- add => GraphicsEvents.EventManager.Legacy_OnPreRenderHudEvent.Add(value);
+ add
+ {
+ GraphicsEvents.DeprecationManager.WarnForOldEvents();
+ GraphicsEvents.EventManager.Legacy_OnPreRenderHudEvent.Add(value);
+ }
remove => GraphicsEvents.EventManager.Legacy_OnPreRenderHudEvent.Remove(value);
}
/// 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
{
- add => GraphicsEvents.EventManager.Legacy_OnPostRenderHudEvent.Add(value);
+ add
+ {
+ GraphicsEvents.DeprecationManager.WarnForOldEvents();
+ GraphicsEvents.EventManager.Legacy_OnPostRenderHudEvent.Add(value);
+ }
remove => GraphicsEvents.EventManager.Legacy_OnPostRenderHudEvent.Remove(value);
}
@@ -63,14 +88,22 @@ namespace StardewModdingAPI.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
{
- add => GraphicsEvents.EventManager.Legacy_OnPreRenderGuiEvent.Add(value);
+ add
+ {
+ GraphicsEvents.DeprecationManager.WarnForOldEvents();
+ GraphicsEvents.EventManager.Legacy_OnPreRenderGuiEvent.Add(value);
+ }
remove => GraphicsEvents.EventManager.Legacy_OnPreRenderGuiEvent.Remove(value);
}
/// 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
{
- add => GraphicsEvents.EventManager.Legacy_OnPostRenderGuiEvent.Add(value);
+ add
+ {
+ GraphicsEvents.DeprecationManager.WarnForOldEvents();
+ GraphicsEvents.EventManager.Legacy_OnPostRenderGuiEvent.Add(value);
+ }
remove => GraphicsEvents.EventManager.Legacy_OnPostRenderGuiEvent.Remove(value);
}
@@ -80,9 +113,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
GraphicsEvents.EventManager = eventManager;
+ GraphicsEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/InputEvents.cs b/src/SMAPI/Events/InputEvents.cs
index 4c1781a5..788dde62 100644
--- a/src/SMAPI/Events/InputEvents.cs
+++ b/src/SMAPI/Events/InputEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised when the player uses a controller, keyboard, or mouse button.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class InputEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,14 +24,22 @@ namespace StardewModdingAPI.Events
/// Raised when the player presses a button on the keyboard, controller, or mouse.
public static event EventHandler ButtonPressed
{
- add => InputEvents.EventManager.Legacy_ButtonPressed.Add(value);
+ add
+ {
+ InputEvents.DeprecationManager.WarnForOldEvents();
+ InputEvents.EventManager.Legacy_ButtonPressed.Add(value);
+ }
remove => InputEvents.EventManager.Legacy_ButtonPressed.Remove(value);
}
/// Raised when the player releases a keyboard key on the keyboard, controller, or mouse.
public static event EventHandler ButtonReleased
{
- add => InputEvents.EventManager.Legacy_ButtonReleased.Add(value);
+ add
+ {
+ InputEvents.DeprecationManager.WarnForOldEvents();
+ InputEvents.EventManager.Legacy_ButtonReleased.Add(value);
+ }
remove => InputEvents.EventManager.Legacy_ButtonReleased.Remove(value);
}
@@ -36,9 +49,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
InputEvents.EventManager = eventManager;
+ InputEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/LocationEvents.cs b/src/SMAPI/Events/LocationEvents.cs
index 81f547ae..4aad5387 100644
--- a/src/SMAPI/Events/LocationEvents.cs
+++ b/src/SMAPI/Events/LocationEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised when the player transitions between game locations, a location is added or removed, or the objects in the current location change.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class LocationEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,21 +24,33 @@ namespace StardewModdingAPI.Events
/// Raised after a game location is added or removed.
public static event EventHandler LocationsChanged
{
- add => LocationEvents.EventManager.Legacy_LocationsChanged.Add(value);
+ add
+ {
+ LocationEvents.DeprecationManager.WarnForOldEvents();
+ LocationEvents.EventManager.Legacy_LocationsChanged.Add(value);
+ }
remove => LocationEvents.EventManager.Legacy_LocationsChanged.Remove(value);
}
/// Raised after buildings are added or removed in a location.
public static event EventHandler BuildingsChanged
{
- add => LocationEvents.EventManager.Legacy_BuildingsChanged.Add(value);
+ add
+ {
+ LocationEvents.DeprecationManager.WarnForOldEvents();
+ LocationEvents.EventManager.Legacy_BuildingsChanged.Add(value);
+ }
remove => LocationEvents.EventManager.Legacy_BuildingsChanged.Remove(value);
}
/// Raised after objects are added or removed in a location.
public static event EventHandler ObjectsChanged
{
- add => LocationEvents.EventManager.Legacy_ObjectsChanged.Add(value);
+ add
+ {
+ LocationEvents.DeprecationManager.WarnForOldEvents();
+ LocationEvents.EventManager.Legacy_ObjectsChanged.Add(value);
+ }
remove => LocationEvents.EventManager.Legacy_ObjectsChanged.Remove(value);
}
@@ -43,9 +60,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
LocationEvents.EventManager = eventManager;
+ LocationEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/MenuEvents.cs b/src/SMAPI/Events/MenuEvents.cs
index 362b5070..502ec340 100644
--- a/src/SMAPI/Events/MenuEvents.cs
+++ b/src/SMAPI/Events/MenuEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised when a game menu is opened or closed (including internal menus like the title screen).
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class MenuEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,14 +24,22 @@ namespace StardewModdingAPI.Events
/// Raised after a game menu is opened or replaced with another menu. This event is not invoked when a menu is closed.
public static event EventHandler MenuChanged
{
- add => MenuEvents.EventManager.Legacy_MenuChanged.Add(value);
+ add
+ {
+ MenuEvents.DeprecationManager.WarnForOldEvents();
+ MenuEvents.EventManager.Legacy_MenuChanged.Add(value);
+ }
remove => MenuEvents.EventManager.Legacy_MenuChanged.Remove(value);
}
/// Raised after a game menu is closed.
public static event EventHandler MenuClosed
{
- add => MenuEvents.EventManager.Legacy_MenuClosed.Add(value);
+ add
+ {
+ MenuEvents.DeprecationManager.WarnForOldEvents();
+ MenuEvents.EventManager.Legacy_MenuClosed.Add(value);
+ }
remove => MenuEvents.EventManager.Legacy_MenuClosed.Remove(value);
}
@@ -36,9 +49,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
MenuEvents.EventManager = eventManager;
+ MenuEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/MineEvents.cs b/src/SMAPI/Events/MineEvents.cs
index f5565a76..617c8013 100644
--- a/src/SMAPI/Events/MineEvents.cs
+++ b/src/SMAPI/Events/MineEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised when something happens in the mines.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class MineEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,7 +24,11 @@ namespace StardewModdingAPI.Events
/// Raised after the player warps to a new level of the mine.
public static event EventHandler MineLevelChanged
{
- add => MineEvents.EventManager.Legacy_MineLevelChanged.Add(value);
+ add
+ {
+ MineEvents.DeprecationManager.WarnForOldEvents();
+ MineEvents.EventManager.Legacy_MineLevelChanged.Add(value);
+ }
remove => MineEvents.EventManager.Legacy_MineLevelChanged.Remove(value);
}
@@ -29,9 +38,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
MineEvents.EventManager = eventManager;
+ MineEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/MultiplayerEvents.cs b/src/SMAPI/Events/MultiplayerEvents.cs
index 49de380e..14c58031 100644
--- a/src/SMAPI/Events/MultiplayerEvents.cs
+++ b/src/SMAPI/Events/MultiplayerEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised during the multiplayer sync process.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class MultiplayerEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,28 +24,44 @@ namespace StardewModdingAPI.Events
/// Raised before the game syncs changes from other players.
public static event EventHandler BeforeMainSync
{
- add => MultiplayerEvents.EventManager.Legacy_BeforeMainSync.Add(value);
+ add
+ {
+ MultiplayerEvents.DeprecationManager.WarnForOldEvents();
+ MultiplayerEvents.EventManager.Legacy_BeforeMainSync.Add(value);
+ }
remove => MultiplayerEvents.EventManager.Legacy_BeforeMainSync.Remove(value);
}
/// Raised after the game syncs changes from other players.
public static event EventHandler AfterMainSync
{
- add => MultiplayerEvents.EventManager.Legacy_AfterMainSync.Add(value);
+ add
+ {
+ MultiplayerEvents.DeprecationManager.WarnForOldEvents();
+ MultiplayerEvents.EventManager.Legacy_AfterMainSync.Add(value);
+ }
remove => MultiplayerEvents.EventManager.Legacy_AfterMainSync.Remove(value);
}
/// Raised before the game broadcasts changes to other players.
public static event EventHandler BeforeMainBroadcast
{
- add => MultiplayerEvents.EventManager.Legacy_BeforeMainBroadcast.Add(value);
+ add
+ {
+ MultiplayerEvents.DeprecationManager.WarnForOldEvents();
+ MultiplayerEvents.EventManager.Legacy_BeforeMainBroadcast.Add(value);
+ }
remove => MultiplayerEvents.EventManager.Legacy_BeforeMainBroadcast.Remove(value);
}
/// Raised after the game broadcasts changes to other players.
public static event EventHandler AfterMainBroadcast
{
- add => MultiplayerEvents.EventManager.Legacy_AfterMainBroadcast.Add(value);
+ add
+ {
+ MultiplayerEvents.DeprecationManager.WarnForOldEvents();
+ MultiplayerEvents.EventManager.Legacy_AfterMainBroadcast.Add(value);
+ }
remove => MultiplayerEvents.EventManager.Legacy_AfterMainBroadcast.Remove(value);
}
@@ -50,9 +71,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
MultiplayerEvents.EventManager = eventManager;
+ MultiplayerEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/PlayerEvents.cs b/src/SMAPI/Events/PlayerEvents.cs
index bfc1b569..4f5f4a37 100644
--- a/src/SMAPI/Events/PlayerEvents.cs
+++ b/src/SMAPI/Events/PlayerEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised when the player data changes.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class PlayerEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,21 +24,33 @@ namespace StardewModdingAPI.Events
/// Raised after the player's inventory changes in any way (added or removed item, sorted, etc).
public static event EventHandler InventoryChanged
{
- add => PlayerEvents.EventManager.Legacy_InventoryChanged.Add(value);
+ add
+ {
+ PlayerEvents.DeprecationManager.WarnForOldEvents();
+ PlayerEvents.EventManager.Legacy_InventoryChanged.Add(value);
+ }
remove => PlayerEvents.EventManager.Legacy_InventoryChanged.Remove(value);
}
/// Raised after the player levels up a skill. This happens as soon as they level up, not when the game notifies the player after their character goes to bed.
public static event EventHandler LeveledUp
{
- add => PlayerEvents.EventManager.Legacy_LeveledUp.Add(value);
+ add
+ {
+ PlayerEvents.DeprecationManager.WarnForOldEvents();
+ PlayerEvents.EventManager.Legacy_LeveledUp.Add(value);
+ }
remove => PlayerEvents.EventManager.Legacy_LeveledUp.Remove(value);
}
/// Raised after the player warps to a new location.
public static event EventHandler Warped
{
- add => PlayerEvents.EventManager.Legacy_PlayerWarped.Add(value);
+ add
+ {
+ PlayerEvents.DeprecationManager.WarnForOldEvents();
+ PlayerEvents.EventManager.Legacy_PlayerWarped.Add(value);
+ }
remove => PlayerEvents.EventManager.Legacy_PlayerWarped.Remove(value);
}
@@ -44,9 +61,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
PlayerEvents.EventManager = eventManager;
+ PlayerEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/SaveEvents.cs b/src/SMAPI/Events/SaveEvents.cs
index 731bf9d1..5b83efc8 100644
--- a/src/SMAPI/Events/SaveEvents.cs
+++ b/src/SMAPI/Events/SaveEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised before and after the player saves/loads the game.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class SaveEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,42 +24,66 @@ namespace StardewModdingAPI.Events
/// Raised before the game creates the save file.
public static event EventHandler BeforeCreate
{
- add => SaveEvents.EventManager.Legacy_BeforeCreateSave.Add(value);
+ add
+ {
+ SaveEvents.DeprecationManager.WarnForOldEvents();
+ SaveEvents.EventManager.Legacy_BeforeCreateSave.Add(value);
+ }
remove => SaveEvents.EventManager.Legacy_BeforeCreateSave.Remove(value);
}
/// Raised after the game finishes creating the save file.
public static event EventHandler AfterCreate
{
- add => SaveEvents.EventManager.Legacy_AfterCreateSave.Add(value);
+ add
+ {
+ SaveEvents.DeprecationManager.WarnForOldEvents();
+ SaveEvents.EventManager.Legacy_AfterCreateSave.Add(value);
+ }
remove => SaveEvents.EventManager.Legacy_AfterCreateSave.Remove(value);
}
/// Raised before the game begins writes data to the save file.
public static event EventHandler BeforeSave
{
- add => SaveEvents.EventManager.Legacy_BeforeSave.Add(value);
+ add
+ {
+ SaveEvents.DeprecationManager.WarnForOldEvents();
+ SaveEvents.EventManager.Legacy_BeforeSave.Add(value);
+ }
remove => SaveEvents.EventManager.Legacy_BeforeSave.Remove(value);
}
/// Raised after the game finishes writing data to the save file.
public static event EventHandler AfterSave
{
- add => SaveEvents.EventManager.Legacy_AfterSave.Add(value);
+ add
+ {
+ SaveEvents.DeprecationManager.WarnForOldEvents();
+ SaveEvents.EventManager.Legacy_AfterSave.Add(value);
+ }
remove => SaveEvents.EventManager.Legacy_AfterSave.Remove(value);
}
/// Raised after the player loads a save slot.
public static event EventHandler AfterLoad
{
- add => SaveEvents.EventManager.Legacy_AfterLoad.Add(value);
+ add
+ {
+ SaveEvents.DeprecationManager.WarnForOldEvents();
+ SaveEvents.EventManager.Legacy_AfterLoad.Add(value);
+ }
remove => SaveEvents.EventManager.Legacy_AfterLoad.Remove(value);
}
/// Raised after the game returns to the title screen.
public static event EventHandler AfterReturnToTitle
{
- add => SaveEvents.EventManager.Legacy_AfterReturnToTitle.Add(value);
+ add
+ {
+ SaveEvents.DeprecationManager.WarnForOldEvents();
+ SaveEvents.EventManager.Legacy_AfterReturnToTitle.Add(value);
+ }
remove => SaveEvents.EventManager.Legacy_AfterReturnToTitle.Remove(value);
}
@@ -64,9 +93,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
SaveEvents.EventManager = eventManager;
+ SaveEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/SpecialisedEvents.cs b/src/SMAPI/Events/SpecialisedEvents.cs
index bdf25ccb..482ac62e 100644
--- a/src/SMAPI/Events/SpecialisedEvents.cs
+++ b/src/SMAPI/Events/SpecialisedEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events serving specialised edge cases that shouldn't be used by most mods.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class SpecialisedEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,7 +24,11 @@ namespace StardewModdingAPI.Events
/// Raised when the game updates its state (≈60 times per second), regardless of normal SMAPI validation. This event is not thread-safe and may be invoked while game logic is running asynchronously. Changes to game state in this method may crash the game or corrupt an in-progress save. Do not use this event unless you're fully aware of the context in which your code will be run. Mods using this method will trigger a stability warning in the SMAPI console.
public static event EventHandler UnvalidatedUpdateTick
{
- add => SpecialisedEvents.EventManager.Legacy_UnvalidatedUpdateTick.Add(value);
+ add
+ {
+ SpecialisedEvents.DeprecationManager.WarnForOldEvents();
+ SpecialisedEvents.EventManager.Legacy_UnvalidatedUpdateTick.Add(value);
+ }
remove => SpecialisedEvents.EventManager.Legacy_UnvalidatedUpdateTick.Remove(value);
}
@@ -29,9 +38,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
SpecialisedEvents.EventManager = eventManager;
+ SpecialisedEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Events/TimeEvents.cs b/src/SMAPI/Events/TimeEvents.cs
index 311ffe9e..cca6a056 100644
--- a/src/SMAPI/Events/TimeEvents.cs
+++ b/src/SMAPI/Events/TimeEvents.cs
@@ -1,9 +1,11 @@
using System;
+using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.Events;
namespace StardewModdingAPI.Events
{
/// Events raised when the in-game date or time changes.
+ [Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.Events) + " instead. See https://smapi.io/3.0 for more info.")]
public static class TimeEvents
{
/*********
@@ -12,6 +14,9 @@ namespace StardewModdingAPI.Events
/// The core event manager.
private static EventManager EventManager;
+ /// Manages deprecation warnings.
+ private static DeprecationManager DeprecationManager;
+
/*********
** Events
@@ -19,14 +24,22 @@ namespace StardewModdingAPI.Events
/// Raised after the game begins a new day, including when loading a save.
public static event EventHandler AfterDayStarted
{
- add => TimeEvents.EventManager.Legacy_AfterDayStarted.Add(value);
+ add
+ {
+ TimeEvents.DeprecationManager.WarnForOldEvents();
+ TimeEvents.EventManager.Legacy_AfterDayStarted.Add(value);
+ }
remove => TimeEvents.EventManager.Legacy_AfterDayStarted.Remove(value);
}
/// Raised after the in-game clock changes.
public static event EventHandler TimeOfDayChanged
{
- add => TimeEvents.EventManager.Legacy_TimeOfDayChanged.Add(value);
+ add
+ {
+ TimeEvents.DeprecationManager.WarnForOldEvents();
+ TimeEvents.EventManager.Legacy_TimeOfDayChanged.Add(value);
+ }
remove => TimeEvents.EventManager.Legacy_TimeOfDayChanged.Remove(value);
}
@@ -36,9 +49,11 @@ namespace StardewModdingAPI.Events
*********/
/// Initialise the events.
/// The core event manager.
- internal static void Init(EventManager eventManager)
+ /// Manages deprecation warnings.
+ internal static void Init(EventManager eventManager, DeprecationManager deprecationManager)
{
TimeEvents.EventManager = eventManager;
+ TimeEvents.DeprecationManager = deprecationManager;
}
}
}
diff --git a/src/SMAPI/Framework/DeprecationManager.cs b/src/SMAPI/Framework/DeprecationManager.cs
index 0fde67ee..be564c22 100644
--- a/src/SMAPI/Framework/DeprecationManager.cs
+++ b/src/SMAPI/Framework/DeprecationManager.cs
@@ -35,6 +35,12 @@ namespace StardewModdingAPI.Framework
this.ModRegistry = modRegistry;
}
+ /// Log a deprecation warning for the old-style events.
+ public void WarnForOldEvents()
+ {
+ this.Warn("legacy events", "2.9", DeprecationLevel.Notice);
+ }
+
/// Log a deprecation warning.
/// A noun phrase describing what is deprecated.
/// The SMAPI version which deprecated it.
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index 4b95917b..827ed82c 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -181,19 +181,19 @@ namespace StardewModdingAPI.Framework
try
{
// hook up events
- ContentEvents.Init(this.EventManager);
- ControlEvents.Init(this.EventManager);
- GameEvents.Init(this.EventManager);
- GraphicsEvents.Init(this.EventManager);
- InputEvents.Init(this.EventManager);
- LocationEvents.Init(this.EventManager);
- MenuEvents.Init(this.EventManager);
- MineEvents.Init(this.EventManager);
- MultiplayerEvents.Init(this.EventManager);
- PlayerEvents.Init(this.EventManager);
- SaveEvents.Init(this.EventManager);
- SpecialisedEvents.Init(this.EventManager);
- TimeEvents.Init(this.EventManager);
+ ContentEvents.Init(this.EventManager, this.DeprecationManager);
+ ControlEvents.Init(this.EventManager, this.DeprecationManager);
+ GameEvents.Init(this.EventManager, this.DeprecationManager);
+ GraphicsEvents.Init(this.EventManager, this.DeprecationManager);
+ InputEvents.Init(this.EventManager, this.DeprecationManager);
+ LocationEvents.Init(this.EventManager, this.DeprecationManager);
+ MenuEvents.Init(this.EventManager, this.DeprecationManager);
+ MineEvents.Init(this.EventManager, this.DeprecationManager);
+ MultiplayerEvents.Init(this.EventManager, this.DeprecationManager);
+ PlayerEvents.Init(this.EventManager, this.DeprecationManager);
+ SaveEvents.Init(this.EventManager, this.DeprecationManager);
+ SpecialisedEvents.Init(this.EventManager, this.DeprecationManager);
+ TimeEvents.Init(this.EventManager, this.DeprecationManager);
// init JSON parser
JsonConverter[] converters = {
diff --git a/src/SMAPI/IModHelper.cs b/src/SMAPI/IModHelper.cs
index e4b5d390..7e82e0d0 100644
--- a/src/SMAPI/IModHelper.cs
+++ b/src/SMAPI/IModHelper.cs
@@ -14,7 +14,6 @@ namespace StardewModdingAPI
string DirectoryPath { get; }
/// Manages access to events raised by SMAPI, which let your mod react when something happens in the game.
- [Obsolete("This is an experimental interface which may change at any time. Don't depend on this for released mods.")]
IModEvents Events { get; }
/// An API for managing console commands.