Fixed bug for Museum menu patch

master
Mohammad Shoaib Khan 2023-03-09 13:12:07 +05:30
parent 2ddebd3615
commit 8970a2c441
No known key found for this signature in database
GPG Key ID: D8040D966320B620
1 changed files with 28 additions and 23 deletions

View File

@ -88,6 +88,8 @@ namespace stardew_access.Patches
{
if (__instance.heldItem != null) return;
if (narrateHoveredButtons(__instance, x, y)) return;
int hoveredItemIndex = InventoryUtils.narrateHoveredSlotAndReturnIndex(__instance.inventory, __instance.inventory.inventory, __instance.inventory.actualInventory, x, y,
handleHighlightedItem: true, highlightedItemPrefix: "Donatable ");
if (hoveredItemIndex != -9999)
@ -99,32 +101,35 @@ namespace stardew_access.Patches
manuallyDonateItem(__instance, hoveredItemIndex);
}
}
}
private static bool narrateHoveredButtons(MuseumMenu __instance, int x, int y)
{
string toSpeak = "";
bool isDropItemButton = false;
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";
isDropItemButton = true;
}
else
{
string toSpeak = "";
bool isDropItemButton = false;
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";
isDropItemButton = true;
}
else
{
return;
}
if (museumQueryKey != toSpeak)
{
museumQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true);
if (isDropItemButton) Game1.playSound("drop_item");
}
return false;
}
if (museumQueryKey != toSpeak)
{
museumQueryKey = toSpeak;
MainClass.ScreenReader.Say(toSpeak, true);
if (isDropItemButton) Game1.playSound("drop_item");
}
return true;
}
private static void manuallyDonateItem(MuseumMenu __instance, int i)