diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 41de1bc..c9f68a6 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -110,7 +110,22 @@ namespace stardew_access harmony.Patch( original: AccessTools.Method(typeof(CraftingPage), nameof(CraftingPage.draw), new Type[] { typeof(SpriteBatch) }), postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.CraftingPagePatch)) - ); + ); + + harmony.Patch( + original: AccessTools.Method(typeof(InventoryMenu), nameof(InventoryMenu.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.InventoryMenuPatch)) + ); + + /*harmony.Patch( + original: AccessTools.Method(typeof(MenuWithInventory), nameof(MenuWithInventory.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.MenuWithInventoryPatch)) + );*/ + + harmony.Patch( + original: AccessTools.Method(typeof(ItemGrabMenu), nameof(ItemGrabMenu.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.ItemGrabMenuPatch)) + ); #endregion #region Menu Patches diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches.cs index 10724fd..d5cb2a9 100644 --- a/stardew-access/Patches/GameMenuPatches.cs +++ b/stardew-access/Patches/GameMenuPatches.cs @@ -7,6 +7,47 @@ namespace stardew_access.Patches { internal class GameMenuPatches { + internal static void ItemGrabMenuPatch(ItemGrabMenu __instance) + { + try + { + int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + + if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) + { + ScreenReader.sayWithMenuChecker("Ok Button", true); + return; + } + if (__instance.trashCan != null && __instance.trashCan.containsPoint(x, y)) + { + ScreenReader.sayWithMenuChecker("Trash Can", true); + return; + } + + if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) + { + ScreenReader.sayWithMenuChecker("Drop Item", true); + return; + } + + if (__instance.shippingBin && Game1.getFarm().lastItemShipped != null && __instance.lastShippedHolder.containsPoint(x, y)) + { + Item lastShippedItem = Game1.getFarm().lastItemShipped; + string name = lastShippedItem.DisplayName; + int count = lastShippedItem.Stack; + + string toSpeak = $"Last Shipped: {count} {name}"; + + ScreenReader.sayWithMenuChecker(toSpeak, true); + return; + } + } + catch (Exception e) + { + MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); + } + } + internal static void CraftingPagePatch(CraftingPage __instance) { try @@ -43,6 +84,24 @@ namespace stardew_access.Patches } } + internal static void InventoryMenuPatch(InventoryMenu __instance) + { + try + { + int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + + if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) + { + ScreenReader.sayWithMenuChecker("Drop Item", true); + return; + } + } + catch (Exception e) + { + MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); + } + } + internal static void OptionsPagePatch(OptionsPage __instance) { try diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index 9376e96..6bbb0a8 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -1,8 +1,6 @@ -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; +using StardewModdingAPI; using StardewValley; using StardewValley.Menus; -using StardewValley.Quests; namespace stardew_access.Patches {