From 15380e5b764f763eeed4d1468b049faccc1c97ec Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Fri, 24 Feb 2023 20:44:54 +0530 Subject: [PATCH] Improved game menu patch code - Added active suffix if the hovered tab button matches the current tab --- .../Patches/GameMenuPatches/GameMenuPatch.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/stardew-access/Patches/GameMenuPatches/GameMenuPatch.cs b/stardew-access/Patches/GameMenuPatches/GameMenuPatch.cs index f8918bf..0255dbb 100644 --- a/stardew-access/Patches/GameMenuPatches/GameMenuPatch.cs +++ b/stardew-access/Patches/GameMenuPatches/GameMenuPatch.cs @@ -11,26 +11,28 @@ namespace stardew_access.Patches { try { - // Continue if only in the Inventory Page or Crafting Page - if (__instance.currentTab != 0 && __instance.currentTab != 4 && __instance.currentTab != 6 && __instance.currentTab != 7) + // Skip if in map page + if (__instance.currentTab == 3) return; int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position for (int i = 0; i < __instance.tabs.Count; i++) { - if (__instance.tabs[i].containsPoint(x, y)) + if (!__instance.tabs[i].containsPoint(x, y)) + continue; + + string toSpeak = $"{GameMenu.getLabelOfTabFromIndex(i)} Tab" + ((i == __instance.currentTab) ? " Active" : ""); + if (gameMenuQueryKey != toSpeak) { - string toSpeak = $"{GameMenu.getLabelOfTabFromIndex(i)} Tab"; - if (gameMenuQueryKey != toSpeak) - { - MainClass.DebugLog("here"); - gameMenuQueryKey = toSpeak; - MainClass.ScreenReader.Say(toSpeak, true); - } - return; + gameMenuQueryKey = toSpeak; + MainClass.ScreenReader.Say(toSpeak, true); } + return; } + + // If not hovering on any tab button + Cleanup(); } catch (Exception e) {