From 911c93a555126dedbda5dffc78d14cd59d4467c6 Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Fri, 24 Feb 2023 19:45:01 +0530 Subject: [PATCH] Moved game menu patch --- stardew-access/HarmonyPatches.cs | 2 +- .../GameMenuPatch.cs} | 10 +++++++--- stardew-access/Patches/IClickableMenuPatch.cs | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) rename stardew-access/Patches/{GameMenuPatches.cs => GameMenuPatches/GameMenuPatch.cs} (87%) diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index 395fe61..a993c81 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -65,7 +65,7 @@ namespace stardew_access #region Game Menu Patches harmony.Patch( original: AccessTools.Method(typeof(GameMenu), nameof(GameMenu.draw), new Type[] { typeof(SpriteBatch) }), - postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.GameMenuPatch)) + postfix: new HarmonyMethod(typeof(GameMenuPatch), nameof(GameMenuPatch.DrawPatch)) ); harmony.Patch( diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches/GameMenuPatch.cs similarity index 87% rename from stardew-access/Patches/GameMenuPatches.cs rename to stardew-access/Patches/GameMenuPatches/GameMenuPatch.cs index d12998b..f8918bf 100644 --- a/stardew-access/Patches/GameMenuPatches.cs +++ b/stardew-access/Patches/GameMenuPatches/GameMenuPatch.cs @@ -1,14 +1,13 @@ using StardewValley; using StardewValley.Menus; -using StardewValley.Objects; namespace stardew_access.Patches { - internal class GameMenuPatches + internal class GameMenuPatch { internal static string gameMenuQueryKey = ""; - internal static void GameMenuPatch(GameMenu __instance) + internal static void DrawPatch(GameMenu __instance) { try { @@ -38,5 +37,10 @@ namespace stardew_access.Patches MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); } } + + internal static void Cleanup() + { + gameMenuQueryKey = ""; + } } } diff --git a/stardew-access/Patches/IClickableMenuPatch.cs b/stardew-access/Patches/IClickableMenuPatch.cs index 04e6715..3260a80 100644 --- a/stardew-access/Patches/IClickableMenuPatch.cs +++ b/stardew-access/Patches/IClickableMenuPatch.cs @@ -33,7 +33,7 @@ namespace stardew_access.Patches } else if (menu is GameMenu) { - GameMenuPatches.gameMenuQueryKey = ""; + GameMenuPatch.Cleanup(); ExitPagePatch.Cleanup(); OptionsPagePatch.Cleanup(); SocialPagePatch.Cleanup();