Added drop item area detection and narration of lst shipped item

master
shoaib11120 2022-01-05 20:41:36 +05:30
parent 2049ed2b9e
commit 4ec08076a7
3 changed files with 76 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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
{