#if !SMAPI_3_0_STRICT 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 { /********* ** Properties *********/ /// The core event manager. private static EventManager EventManager; /// Manages deprecation warnings. private static DeprecationManager DeprecationManager; /********* ** Events *********/ /// Raised before the game creates the save file. public static event EventHandler BeforeCreate { 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.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.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.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.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.DeprecationManager.WarnForOldEvents(); SaveEvents.EventManager.Legacy_AfterReturnToTitle.Add(value); } remove => SaveEvents.EventManager.Legacy_AfterReturnToTitle.Remove(value); } /********* ** Public methods *********/ /// Initialise the events. /// The core event manager. /// Manages deprecation warnings. internal static void Init(EventManager eventManager, DeprecationManager deprecationManager) { SaveEvents.EventManager = eventManager; SaveEvents.DeprecationManager = deprecationManager; } } } #endif