Organised code for item grab menu patch
parent
6822bd4840
commit
5195313a5b
|
@ -25,103 +25,76 @@ namespace stardew_access.Patches
|
|||
__instance.inventory.inventory[0].snapMouseCursorToCenter();
|
||||
}
|
||||
|
||||
#region Narrate buttons in the menu
|
||||
if (narrateHoveredButton(__instance, x, y))
|
||||
{
|
||||
InventoryUtils.Cleanup();
|
||||
return;
|
||||
}
|
||||
if (narrateLastShippedItem(__instance, x, y))
|
||||
{
|
||||
InventoryUtils.Cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
if (InventoryUtils.narrateHoveredSlot(__instance.inventory, __instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true))
|
||||
{
|
||||
itemGrabMenuQueryKey = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (InventoryUtils.narrateHoveredSlot(__instance.ItemsToGrabMenu, __instance.ItemsToGrabMenu.inventory, __instance.ItemsToGrabMenu.actualInventory, x, y, true))
|
||||
{
|
||||
itemGrabMenuQueryKey = "";
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool narrateHoveredButton(ItemGrabMenu __instance, int x, int y)
|
||||
{
|
||||
string toSpeak = "";
|
||||
bool isDropItemButton = false;
|
||||
|
||||
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
||||
{
|
||||
string toSpeak = "Ok Button";
|
||||
if (itemGrabMenuQueryKey != toSpeak)
|
||||
{
|
||||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
toSpeak = "Ok Button";
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (__instance.trashCan != null && __instance.trashCan.containsPoint(x, y))
|
||||
else if (__instance.trashCan != null && __instance.trashCan.containsPoint(x, y))
|
||||
{
|
||||
string toSpeak = "Trash Can";
|
||||
if (itemGrabMenuQueryKey != toSpeak)
|
||||
{
|
||||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
toSpeak = "Trash Can";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.organizeButton != null && __instance.organizeButton.containsPoint(x, y))
|
||||
else if (__instance.organizeButton != null && __instance.organizeButton.containsPoint(x, y))
|
||||
{
|
||||
string toSpeak = "Organize Button";
|
||||
if (itemGrabMenuQueryKey != toSpeak)
|
||||
{
|
||||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
toSpeak = "Organize Button";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.fillStacksButton != null && __instance.fillStacksButton.containsPoint(x, y))
|
||||
else if (__instance.fillStacksButton != null && __instance.fillStacksButton.containsPoint(x, y))
|
||||
{
|
||||
string toSpeak = "Add to existing stacks button";
|
||||
if (itemGrabMenuQueryKey != toSpeak)
|
||||
{
|
||||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
toSpeak = "Add to existing stacks button";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.specialButton != null && __instance.specialButton.containsPoint(x, y))
|
||||
else if (__instance.specialButton != null && __instance.specialButton.containsPoint(x, y))
|
||||
{
|
||||
string toSpeak = "Special Button";
|
||||
if (itemGrabMenuQueryKey != toSpeak)
|
||||
{
|
||||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
toSpeak = "Special Button";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.colorPickerToggleButton != null && __instance.colorPickerToggleButton.containsPoint(x, y))
|
||||
else if (__instance.colorPickerToggleButton != null && __instance.colorPickerToggleButton.containsPoint(x, y))
|
||||
{
|
||||
|
||||
string toSpeak = "Color Picker: " + (__instance.chestColorPicker.visible ? "Enabled" : "Disabled");
|
||||
if (itemGrabMenuQueryKey != toSpeak)
|
||||
{
|
||||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
toSpeak = "Color Picker: " + (__instance.chestColorPicker.visible ? "Enabled" : "Disabled");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.junimoNoteIcon != null && __instance.junimoNoteIcon.containsPoint(x, y))
|
||||
else if (__instance.junimoNoteIcon != null && __instance.junimoNoteIcon.containsPoint(x, y))
|
||||
{
|
||||
|
||||
string toSpeak = "Community Center Button";
|
||||
if (itemGrabMenuQueryKey != toSpeak)
|
||||
{
|
||||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
toSpeak = "Community Center Button";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y))
|
||||
else if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y))
|
||||
{
|
||||
string toSpeak = "Drop Item";
|
||||
if (itemGrabMenuQueryKey != toSpeak)
|
||||
{
|
||||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
Game1.playSound("drop_item");
|
||||
toSpeak = "Drop Item";
|
||||
isDropItemButton = true;
|
||||
}
|
||||
return;
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME
|
||||
|
@ -143,11 +116,22 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
}*/
|
||||
#endregion
|
||||
|
||||
#region Narrate the last shipped item if in the shipping bin
|
||||
if (__instance.shippingBin && Game1.getFarm().lastItemShipped != null && __instance.lastShippedHolder.containsPoint(x, y))
|
||||
if (itemGrabMenuQueryKey == toSpeak) return true;
|
||||
|
||||
itemGrabMenuQueryKey = toSpeak;
|
||||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
if (isDropItemButton) Game1.playSound("drop_item");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool narrateLastShippedItem(ItemGrabMenu __instance, int x, int y)
|
||||
{
|
||||
if (!__instance.shippingBin || Game1.getFarm().lastItemShipped == null || !__instance.lastShippedHolder.containsPoint(x, y))
|
||||
return false;
|
||||
|
||||
Item lastShippedItem = Game1.getFarm().lastItemShipped;
|
||||
string name = lastShippedItem.DisplayName;
|
||||
int count = lastShippedItem.Stack;
|
||||
|
@ -160,29 +144,7 @@ namespace stardew_access.Patches
|
|||
hoveredItemQueryKey = "";
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Narrate hovered item
|
||||
if (InventoryUtils.narrateHoveredSlot(__instance.inventory, __instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true))
|
||||
{
|
||||
itemGrabMenuQueryKey = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (InventoryUtils.narrateHoveredSlot(__instance.ItemsToGrabMenu, __instance.ItemsToGrabMenu.inventory, __instance.ItemsToGrabMenu.actualInventory, x, y, true))
|
||||
{
|
||||
itemGrabMenuQueryKey = "";
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO Add color names
|
||||
|
@ -258,7 +220,8 @@ namespace stardew_access.Patches
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
internal static void Cleanup() {
|
||||
internal static void Cleanup()
|
||||
{
|
||||
hoveredItemQueryKey = "";
|
||||
itemGrabMenuQueryKey = "";
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace stardew_access.Patches
|
|||
{
|
||||
string toSpeak = "";
|
||||
bool isDropItemButton = false;
|
||||
|
||||
if (__instance.inventory.dropItemInvisibleButton != null && __instance.inventory.dropItemInvisibleButton.containsPoint(x, y))
|
||||
{
|
||||
toSpeak = "Drop Item";
|
||||
|
|
Loading…
Reference in New Issue