diff options
Diffstat (limited to 'src/SMAPI/Events/SaveEvents.cs')
-rw-r--r-- | src/SMAPI/Events/SaveEvents.cs | 45 |
1 files changed, 38 insertions, 7 deletions
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 { /// <summary>Events raised before and after the player saves/loads the game.</summary> + [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 /// <summary>The core event manager.</summary> private static EventManager EventManager; + /// <summary>Manages deprecation warnings.</summary> + private static DeprecationManager DeprecationManager; + /********* ** Events @@ -19,42 +24,66 @@ namespace StardewModdingAPI.Events /// <summary>Raised before the game creates the save file.</summary> 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); } /// <summary>Raised after the game finishes creating the save file.</summary> 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); } /// <summary>Raised before the game begins writes data to the save file.</summary> 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); } /// <summary>Raised after the game finishes writing data to the save file.</summary> 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); } /// <summary>Raised after the player loads a save slot.</summary> 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); } /// <summary>Raised after the game returns to the title screen.</summary> 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 *********/ /// <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) { SaveEvents.EventManager = eventManager; + SaveEvents.DeprecationManager = deprecationManager; } } } |