Moved forge menu patch to its own class
parent
64300c58eb
commit
07fcc94296
|
@ -184,7 +184,7 @@ namespace stardew_access
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
original: AccessTools.Method(typeof(ForgeMenu), nameof(ForgeMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
original: AccessTools.Method(typeof(ForgeMenu), nameof(ForgeMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
||||||
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.ForgeMenuPatch))
|
postfix: new HarmonyMethod(typeof(ForgeMenuPatch), nameof(ForgeMenuPatch.DrawPatch))
|
||||||
);
|
);
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
using stardew_access.Features;
|
||||||
|
using StardewValley;
|
||||||
|
using StardewValley.Menus;
|
||||||
|
|
||||||
|
namespace stardew_access.Patches
|
||||||
|
{
|
||||||
|
internal class ForgeMenuPatch
|
||||||
|
{
|
||||||
|
private static string forgeMenuQuery = "";
|
||||||
|
|
||||||
|
internal static void DrawPatch(ForgeMenu __instance)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
||||||
|
|
||||||
|
if (narrateHoveredButton(__instance, x, y)) return;
|
||||||
|
|
||||||
|
if (InventoryUtils.narrateHoveredSlot(__instance.inventory, __instance.inventory.inventory, __instance.inventory.actualInventory, x, y))
|
||||||
|
{
|
||||||
|
Cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
MainClass.ErrorLog($"An error occured in forge menu patch:\n{e.Message}\n{e.StackTrace}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool narrateHoveredButton(ForgeMenu __instance, int x, int y)
|
||||||
|
{
|
||||||
|
string toSpeak = "";
|
||||||
|
bool isDropItemButton = false;
|
||||||
|
|
||||||
|
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";
|
||||||
|
isDropItemButton = true;
|
||||||
|
}
|
||||||
|
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
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forgeMenuQuery != toSpeak)
|
||||||
|
{
|
||||||
|
forgeMenuQuery = toSpeak;
|
||||||
|
MainClass.ScreenReader.Say(toSpeak, true);
|
||||||
|
|
||||||
|
if (isDropItemButton) Game1.playSound("drop_item");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Cleanup()
|
||||||
|
{
|
||||||
|
forgeMenuQuery = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -292,7 +292,7 @@ namespace stardew_access.Patches
|
||||||
}
|
}
|
||||||
else if (menu is ForgeMenu)
|
else if (menu is ForgeMenu)
|
||||||
{
|
{
|
||||||
MenuPatches.forgeMenuQuery = " ";
|
ForgeMenuPatch.Cleanup();
|
||||||
}
|
}
|
||||||
else if (menu is ItemListMenu)
|
else if (menu is ItemListMenu)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,93 +14,8 @@ namespace stardew_access.Patches
|
||||||
internal static bool isNarratingPondInfo = false;
|
internal static bool isNarratingPondInfo = false;
|
||||||
internal static string tailoringMenuQuery = " ";
|
internal static string tailoringMenuQuery = " ";
|
||||||
internal static string pondQueryMenuQuery = " ";
|
internal static string pondQueryMenuQuery = " ";
|
||||||
internal static string forgeMenuQuery = " ";
|
|
||||||
internal static int prevSlotIndex = -999;
|
internal static int prevSlotIndex = -999;
|
||||||
|
|
||||||
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}";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InventoryUtils.narrateHoveredSlot(__instance.inventory, __instance.inventory.inventory, __instance.inventory.actualInventory, x, y))
|
|
||||||
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)
|
internal static void PondQueryMenuPatch(PondQueryMenu __instance, StardewValley.Object ____fishItem, FishPond ____pond, string ____statusText, bool ___confirmingEmpty)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue