diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-01-21 02:14:28 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-01-21 02:14:28 -0500 |
commit | d76476ca687a4936cc610380e2b3902db137bced (patch) | |
tree | c83550f3a86bad69471c72125d2d448d19abd17b /src/SMAPI/Events | |
parent | b3318af7d0e40462563e6d98c0c15fac48bb6770 (diff) | |
download | SMAPI-d76476ca687a4936cc610380e2b3902db137bced.tar.gz SMAPI-d76476ca687a4936cc610380e2b3902db137bced.tar.bz2 SMAPI-d76476ca687a4936cc610380e2b3902db137bced.zip |
add before/after save creation events (#429)
This supports mods like Custom Farm Types that need to intercept the very first save, which doesn't raise the normal save events since the world isn't fully initialised yet.
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r-- | src/SMAPI/Events/SaveEvents.cs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/SMAPI/Events/SaveEvents.cs b/src/SMAPI/Events/SaveEvents.cs index 50e6d729..99b6c8d2 100644 --- a/src/SMAPI/Events/SaveEvents.cs +++ b/src/SMAPI/Events/SaveEvents.cs @@ -1,4 +1,4 @@ -using System; +using System; using StardewModdingAPI.Framework; namespace StardewModdingAPI.Events @@ -9,6 +9,12 @@ namespace StardewModdingAPI.Events /********* ** Events *********/ + /// <summary>Raised before the game creates the save file.</summary> + public static event EventHandler BeforeCreate; + + /// <summary>Raised after the game finishes creating the save file.</summary> + public static event EventHandler AfterCreate; + /// <summary>Raised before the game begins writes data to the save file.</summary> public static event EventHandler BeforeSave; @@ -25,6 +31,20 @@ namespace StardewModdingAPI.Events /********* ** Internal methods *********/ + /// <summary>Raise a <see cref="BeforeCreate"/> event.</summary> + /// <param name="monitor">Encapsulates monitoring and logging.</param> + internal static void InvokeBeforeCreate(IMonitor monitor) + { + monitor.SafelyRaisePlainEvent($"{nameof(SaveEvents)}.{nameof(SaveEvents.BeforeCreate)}", SaveEvents.BeforeCreate?.GetInvocationList(), null, EventArgs.Empty); + } + + /// <summary>Raise a <see cref="AfterCreate"/> event.</summary> + /// <param name="monitor">Encapsulates monitoring and logging.</param> + internal static void InvokeAfterCreated(IMonitor monitor) + { + monitor.SafelyRaisePlainEvent($"{nameof(SaveEvents)}.{nameof(SaveEvents.AfterCreate)}", SaveEvents.AfterCreate?.GetInvocationList(), null, EventArgs.Empty); + } + /// <summary>Raise a <see cref="BeforeSave"/> event.</summary> /// <param name="monitor">Encapsulates monitoring and logging.</param> internal static void InvokeBeforeSave(IMonitor monitor) |