summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r--src/StardewModdingAPI/Framework/SGame.cs16
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