diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-02-08 00:11:46 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-02-08 00:11:46 -0500 |
commit | 366769e8a27e8de39842c82907cf40451c488a2c (patch) | |
tree | 574c1b0f278b48f508875c4586e319d0a3119a52 /src/StardewModdingAPI/Framework | |
parent | 2b7abc3af5d9fb636123b734cd60dbd38448abd2 (diff) | |
download | SMAPI-366769e8a27e8de39842c82907cf40451c488a2c.tar.gz SMAPI-366769e8a27e8de39842c82907cf40451c488a2c.tar.bz2 SMAPI-366769e8a27e8de39842c82907cf40451c488a2c.zip |
add SaveEvents.AfterReturnToTitle event (#231)
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r-- | src/StardewModdingAPI/Framework/SGame.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Framework/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs index 24abd4fd..6a751b85 100644 --- a/src/StardewModdingAPI/Framework/SGame.cs +++ b/src/StardewModdingAPI/Framework/SGame.cs @@ -37,6 +37,9 @@ namespace StardewModdingAPI.Framework /// <summary>Whether the player has loaded a save and the world has finished initialising.</summary> private bool IsWorldReady => this.AfterLoadTimer < 0; + /// <summary>Whether the game is returning to the menu.</summary> + private bool IsExiting = false; + /// <summary>The debug messages to add to the next debug output.</summary> internal static Queue<string> DebugMessageQueue { get; private set; } @@ -1160,6 +1163,19 @@ namespace StardewModdingAPI.Framework this.AfterLoadTimer--; } + // before exit to title + if (Game1.exitToTitle) + this.IsExiting = true; + + // after exit to title + if (this.IsWorldReady && this.IsExiting && Game1.activeClickableMenu is TitleMenu) + { + Console.WriteLine($"{Game1.currentGameTime.TotalGameTime}: after return to title"); + SaveEvents.InvokeAfterReturnToTitle(this.Monitor); + this.AfterLoadTimer = 5; + this.IsExiting = false; + } + // input events { // get latest state |