Moved item list menu patch to its own class
parent
a250cbd98d
commit
64300c58eb
|
@ -189,7 +189,7 @@ namespace stardew_access
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
original: AccessTools.Method(typeof(ItemListMenu), nameof(ItemListMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
original: AccessTools.Method(typeof(ItemListMenu), nameof(ItemListMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
||||||
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.ItemListMenuPatch))
|
postfix: new HarmonyMethod(typeof(ItemListMenuPatch), nameof(ItemListMenuPatch.DrawPatch))
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ namespace stardew_access.Patches
|
||||||
}
|
}
|
||||||
else if (menu is ItemListMenu)
|
else if (menu is ItemListMenu)
|
||||||
{
|
{
|
||||||
MenuPatches.itemListMenuQuery = " ";
|
ItemListMenuPatch.Cleanup();
|
||||||
}
|
}
|
||||||
else if (menu is FieldOfficeMenu)
|
else if (menu is FieldOfficeMenu)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
using StardewValley;
|
||||||
|
using StardewValley.Menus;
|
||||||
|
|
||||||
|
namespace stardew_access.Patches
|
||||||
|
{
|
||||||
|
internal class ItemListMenuPatch
|
||||||
|
{
|
||||||
|
private static string itemListMenuQuery = "";
|
||||||
|
|
||||||
|
internal static void DrawPatch(ItemListMenu __instance, string ___title, int ___currentTab, int ___totalValueOfItems, List<Item> ___itemsToList)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
||||||
|
string toSpeak = "", currentList = "";
|
||||||
|
|
||||||
|
for (int i = ___currentTab * __instance.itemsPerCategoryPage; i < ___currentTab * __instance.itemsPerCategoryPage + __instance.itemsPerCategoryPage; i++)
|
||||||
|
{
|
||||||
|
if (i == 0) currentList = ___title;
|
||||||
|
if (___itemsToList.Count <= i) continue;
|
||||||
|
|
||||||
|
if (___itemsToList[i] == null)
|
||||||
|
{
|
||||||
|
currentList = $"{currentList}, \n" + Game1.content.LoadString("Strings\\UI:ItemList_ItemsLostValue", ___totalValueOfItems);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentList = $"{currentList}, \n {___itemsToList[i].Stack} {___itemsToList[i].DisplayName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
||||||
|
toSpeak = $"Page {___currentTab + 1} of {((int)___itemsToList.Count / __instance.itemsPerCategoryPage) + 1} \n {currentList} \n ok button";
|
||||||
|
else if (__instance.forwardButton != null && __instance.forwardButton.containsPoint(x, y))
|
||||||
|
toSpeak = "Next page button";
|
||||||
|
else if (__instance.backButton != null && __instance.backButton.containsPoint(x, y))
|
||||||
|
toSpeak = "Previous page button";
|
||||||
|
|
||||||
|
if (itemListMenuQuery != toSpeak)
|
||||||
|
{
|
||||||
|
itemListMenuQuery = toSpeak;
|
||||||
|
MainClass.ScreenReader.Say(toSpeak, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Cleanup()
|
||||||
|
{
|
||||||
|
itemListMenuQuery = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,52 +15,8 @@ namespace stardew_access.Patches
|
||||||
internal static string tailoringMenuQuery = " ";
|
internal static string tailoringMenuQuery = " ";
|
||||||
internal static string pondQueryMenuQuery = " ";
|
internal static string pondQueryMenuQuery = " ";
|
||||||
internal static string forgeMenuQuery = " ";
|
internal static string forgeMenuQuery = " ";
|
||||||
internal static string itemListMenuQuery = " ";
|
|
||||||
internal static int prevSlotIndex = -999;
|
internal static int prevSlotIndex = -999;
|
||||||
|
|
||||||
internal static void ItemListMenuPatch(ItemListMenu __instance, string ___title, int ___currentTab, int ___totalValueOfItems, List<Item> ___itemsToList)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
|
||||||
string toSpeak = " ", currentList = " ";
|
|
||||||
|
|
||||||
for (int i = ___currentTab * __instance.itemsPerCategoryPage; i < ___currentTab * __instance.itemsPerCategoryPage + __instance.itemsPerCategoryPage; i++)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
currentList = ___title;
|
|
||||||
|
|
||||||
if (___itemsToList.Count > i)
|
|
||||||
{
|
|
||||||
if (___itemsToList[i] == null)
|
|
||||||
{
|
|
||||||
currentList = $"{currentList}, \n" + Game1.content.LoadString("Strings\\UI:ItemList_ItemsLostValue", ___totalValueOfItems);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentList = $"{currentList}, \n {___itemsToList[i].Stack} {___itemsToList[i].DisplayName}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
|
||||||
toSpeak = $"Page {___currentTab + 1} of {((int)___itemsToList.Count / __instance.itemsPerCategoryPage) + 1} \n {currentList} \n ok button";
|
|
||||||
else if (__instance.forwardButton != null && __instance.forwardButton.containsPoint(x, y))
|
|
||||||
toSpeak = "Next page button";
|
|
||||||
else if (__instance.backButton != null && __instance.backButton.containsPoint(x, y))
|
|
||||||
toSpeak = "Previous page button";
|
|
||||||
|
|
||||||
if (itemListMenuQuery != toSpeak)
|
|
||||||
{
|
|
||||||
itemListMenuQuery = toSpeak;
|
|
||||||
MainClass.ScreenReader.Say(toSpeak, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (System.Exception e)
|
|
||||||
{
|
|
||||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void ForgeMenuPatch(ForgeMenu __instance)
|
internal static void ForgeMenuPatch(ForgeMenu __instance)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -570,7 +526,5 @@ namespace stardew_access.Patches
|
||||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue