From bf9ca47dc437f11c11df2aff30a482858b127b9d Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Date: Tue, 12 Apr 2022 23:54:46 +0530 Subject: [PATCH] Patched forge menu --- stardew-access/HarmonyPatches.cs | 5 + stardew-access/Patches/DialoguePatches.cs | 65 ++++-------- stardew-access/Patches/MenuPatches.cs | 123 ++++++++++++++++++++++ 3 files changed, 151 insertions(+), 42 deletions(-) diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index c42454b..800c76f 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -185,6 +185,11 @@ namespace stardew_access original: AccessTools.Method(typeof(PondQueryMenu), nameof(PondQueryMenu.draw), new Type[] { typeof(SpriteBatch) }), postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.PondQueryMenuPatch)) ); + + harmony.Patch( + original: AccessTools.Method(typeof(ForgeMenu), nameof(ForgeMenu.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.ForgeMenuPatch)) + ); #endregion #region Quest Patches diff --git a/stardew-access/Patches/DialoguePatches.cs b/stardew-access/Patches/DialoguePatches.cs index 7f5dd8f..846f158 100644 --- a/stardew-access/Patches/DialoguePatches.cs +++ b/stardew-access/Patches/DialoguePatches.cs @@ -149,68 +149,49 @@ namespace stardew_access.Patches #region Skip narrating hover text for certain menus if (Game1.activeClickableMenu is TitleMenu && !(((TitleMenu)Game1.activeClickableMenu).GetChildMenu() is CharacterCustomization)) return; - - if (Game1.activeClickableMenu is LetterViewerMenu || Game1.activeClickableMenu is QuestLog) + else if (Game1.activeClickableMenu is LetterViewerMenu || Game1.activeClickableMenu is QuestLog) return; - - if (Game1.activeClickableMenu is Billboard) + else if (Game1.activeClickableMenu is Billboard) return; - - if (Game1.activeClickableMenu is GeodeMenu) + else if (Game1.activeClickableMenu is GeodeMenu) return; - - if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is InventoryPage) + else if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is InventoryPage) return; - - if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is CraftingPage) + else if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is CraftingPage) return; - - if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is OptionsPage) + else if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is OptionsPage) return; - - if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is ExitPage) + else if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is ExitPage) return; - - if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is SocialPage) + else if (Game1.activeClickableMenu is GameMenu && ((GameMenu)Game1.activeClickableMenu).GetCurrentPage() is SocialPage) return; - - if (Game1.activeClickableMenu is ItemGrabMenu) + else if (Game1.activeClickableMenu is ItemGrabMenu) return; - - if (Game1.activeClickableMenu is ShopMenu) + else if (Game1.activeClickableMenu is ShopMenu) return; - - if (Game1.activeClickableMenu is ConfirmationDialog) + else if (Game1.activeClickableMenu is ConfirmationDialog) return; - - if (Game1.activeClickableMenu is JunimoNoteMenu) + else if (Game1.activeClickableMenu is JunimoNoteMenu) return; - - if (Game1.activeClickableMenu is CarpenterMenu) + else if (Game1.activeClickableMenu is CarpenterMenu) return; - - if (Game1.activeClickableMenu is PurchaseAnimalsMenu) + else if (Game1.activeClickableMenu is PurchaseAnimalsMenu) return; - - if (Game1.activeClickableMenu is CraftingPage) + else if (Game1.activeClickableMenu is CraftingPage) return; - - if (Game1.activeClickableMenu is AnimalQueryMenu) + else if (Game1.activeClickableMenu is AnimalQueryMenu) return; - - if (Game1.activeClickableMenu is ConfirmationDialog) + else if (Game1.activeClickableMenu is ConfirmationDialog) return; - - if (Game1.activeClickableMenu is ReadyCheckDialog) + else if (Game1.activeClickableMenu is ReadyCheckDialog) return; - - if (Game1.activeClickableMenu is JojaCDMenu) + else if (Game1.activeClickableMenu is JojaCDMenu) return; - - if (Game1.activeClickableMenu is TailoringMenu) + else if (Game1.activeClickableMenu is TailoringMenu) return; - - if (Game1.activeClickableMenu is PondQueryMenu) + else if (Game1.activeClickableMenu is PondQueryMenu) + return; + else if (Game1.activeClickableMenu is ForgeMenu) return; #endregion diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index ecfd53b..680d6e8 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -17,8 +17,112 @@ namespace stardew_access.Patches internal static string animalQueryMenuQuery = " "; internal static string tailoringMenuQuery = " "; internal static string pondQueryMenuQuery = " "; + internal static string forgeMenuQuery = " "; public static Vector2? prevTile = null; + internal static void ForgeMenuPatch(ForgeMenu __instance) + { + try + { + int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position + string toSpeak = " "; + + if (__instance.leftIngredientSpot != null && __instance.leftIngredientSpot.containsPoint(x, y)) + { + if (__instance.leftIngredientSpot.item == null) + { + toSpeak = "Input weapon or tool here"; + } + else + { + Item item = __instance.leftIngredientSpot.item; + toSpeak = $"Weapon slot: {item.Stack} {item.DisplayName}"; + } + } + else if (__instance.rightIngredientSpot != null && __instance.rightIngredientSpot.containsPoint(x, y)) + { + if (__instance.rightIngredientSpot.item == null) + { + toSpeak = "Input gemstone here"; + } + else + { + Item item = __instance.rightIngredientSpot.item; + toSpeak = $"Gemstone slot: {item.Stack} {item.DisplayName}"; + } + } + else if (__instance.startTailoringButton != null && __instance.startTailoringButton.containsPoint(x, y)) + { + toSpeak = "Star forging button"; + } + else if (__instance.unforgeButton != null && __instance.unforgeButton.containsPoint(x, y)) + { + toSpeak = "Unforge button"; + } + else if (__instance.trashCan != null && __instance.trashCan.containsPoint(x, y)) + { + toSpeak = "Trashcan"; + } + else if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) + { + toSpeak = "ok button"; + } + else if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) + { + toSpeak = "drop item"; + } + else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[0].containsPoint(x, y)) + { + toSpeak = "Left ring Slot"; + + if (Game1.player.leftRing.Value != null) + toSpeak = $"{toSpeak}: {Game1.player.leftRing.Value.DisplayName}"; + } + else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[1].containsPoint(x, y)) + { + toSpeak = "Right ring Slot"; + + if (Game1.player.rightRing.Value != null) + toSpeak = $"{toSpeak}: {Game1.player.rightRing.Value.DisplayName}"; + } + else + { + for (int i = 0; i < __instance.inventory.inventory.Count; i++) + { + if (!__instance.inventory.inventory[i].containsPoint(x, y)) + continue; + + if (__instance.inventory.actualInventory[i] == null) + toSpeak = "Empty slot"; + else + toSpeak = $"{__instance.inventory.actualInventory[i].Stack} {__instance.inventory.actualInventory[i].DisplayName}"; + + if (forgeMenuQuery != $"{toSpeak}:{i}") + { + forgeMenuQuery = $"{toSpeak}:{i}"; + MainClass.ScreenReader.Say(toSpeak, true); + } + + return; + } + } + + + if (forgeMenuQuery != toSpeak) + { + forgeMenuQuery = toSpeak; + MainClass.ScreenReader.Say(toSpeak, true); + + if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) + Game1.playSound("drop_item"); + } + } + catch (System.Exception e) + { + MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); + } + } + internal static void PondQueryMenuPatch(PondQueryMenu __instance, StardewValley.Object ____fishItem, FishPond ____pond, string ____statusText, bool ___confirmingEmpty) { try @@ -107,6 +211,18 @@ namespace stardew_access.Patches { toSpeak = "Star tailoring button"; } + else if (__instance.trashCan != null && __instance.trashCan.containsPoint(x, y)) + { + toSpeak = "Trashcan"; + } + else if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) + { + toSpeak = "ok button"; + } + else if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) + { + toSpeak = "drop item"; + } else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[0].containsPoint(x, y)) { toSpeak = "Hat Slot"; @@ -155,6 +271,9 @@ namespace stardew_access.Patches { tailoringMenuQuery = toSpeak; MainClass.ScreenReader.Say(toSpeak, true); + + if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) + Game1.playSound("drop_item"); } } catch (System.Exception e) @@ -660,6 +779,10 @@ namespace stardew_access.Patches { tailoringMenuQuery = " "; } + else if (menu is ForgeMenu) + { + forgeMenuQuery = " "; + } else if (menu is PondQueryMenu) { pondQueryMenuQuery = " ";