summaryrefslogtreecommitdiff
path: root/src/SMAPI/Patches
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Patches')
-rw-r--r--src/SMAPI/Patches/LoadContextPatch.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/SMAPI/Patches/LoadContextPatch.cs b/src/SMAPI/Patches/LoadContextPatch.cs
index 9fddcc50..28bc23b6 100644
--- a/src/SMAPI/Patches/LoadContextPatch.cs
+++ b/src/SMAPI/Patches/LoadContextPatch.cs
@@ -77,6 +77,12 @@ namespace StardewModdingAPI.Patches
prefix: new HarmonyMethod(this.GetType(), nameof(LoadContextPatch.Before_Game1_LoadForNewGame)),
postfix: new HarmonyMethod(this.GetType(), nameof(LoadContextPatch.After_Game1_LoadForNewGame))
);
+
+ // detect ReturningToTitle
+ harmony.Patch(
+ original: AccessTools.Method(typeof(Game1), nameof(Game1.CleanupReturningToTitle)),
+ prefix: new HarmonyMethod(this.GetType(), nameof(LoadContextPatch.Before_Game1_CleanupReturningToTitle))
+ );
}
@@ -110,6 +116,15 @@ namespace StardewModdingAPI.Patches
return true;
}
+ /// <summary>Called before <see cref="Game1.CleanupReturningToTitle"/>.</summary>
+ /// <returns>Returns whether to execute the original method.</returns>
+ /// <remarks>This method must be static for Harmony to work correctly. See the Harmony documentation before renaming arguments.</remarks>
+ private static bool Before_Game1_CleanupReturningToTitle()
+ {
+ LoadContextPatch.OnStageChanged(LoadStage.ReturningToTitle);
+ return true;
+ }
+
/// <summary>Called before <see cref="Game1.loadForNewGame"/>.</summary>
/// <returns>Returns whether to execute the original method.</returns>
/// <remarks>This method must be static for Harmony to work correctly. See the Harmony documentation before renaming arguments.</remarks>