Fixed some bugs in game menu
parent
bd379b77df
commit
a649f3a2ec
|
@ -94,14 +94,19 @@ namespace stardew_access
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
original: AccessTools.Method(typeof(CoopMenu), nameof(CoopMenu.update), new Type[] { typeof(GameTime) }),
|
original: AccessTools.Method(typeof(CoopMenu), nameof(CoopMenu.update), new Type[] { typeof(GameTime) }),
|
||||||
postfix: new HarmonyMethod(typeof(TitleMenuPatches), nameof(TitleMenuPatches.CoopMenuPatch))
|
postfix: new HarmonyMethod(typeof(TitleMenuPatches), nameof(TitleMenuPatches.CoopMenuPatch))
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Game Menu Patches
|
#region Game Menu Patches
|
||||||
|
harmony.Patch(
|
||||||
|
original: AccessTools.Method(typeof(GameMenu), nameof(GameMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
||||||
|
postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.GameMenuPatch))
|
||||||
|
);
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
original: AccessTools.Method(typeof(OptionsPage), nameof(OptionsPage.draw), new Type[] { typeof(SpriteBatch) }),
|
original: AccessTools.Method(typeof(OptionsPage), nameof(OptionsPage.draw), new Type[] { typeof(SpriteBatch) }),
|
||||||
postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.OptionsPagePatch))
|
postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.OptionsPagePatch))
|
||||||
);
|
);
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
original: AccessTools.Method(typeof(ExitPage), nameof(ExitPage.draw), new Type[] { typeof(SpriteBatch) }),
|
original: AccessTools.Method(typeof(ExitPage), nameof(ExitPage.draw), new Type[] { typeof(SpriteBatch) }),
|
||||||
|
|
|
@ -131,6 +131,12 @@ namespace stardew_access.Patches
|
||||||
if (Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).GetCurrentPage() is CraftingPage)
|
if (Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).GetCurrentPage() is CraftingPage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).GetCurrentPage() is OptionsPage)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).GetCurrentPage() is ExitPage)
|
||||||
|
return;
|
||||||
|
|
||||||
if (Game1.activeClickableMenu is ItemGrabMenu)
|
if (Game1.activeClickableMenu is ItemGrabMenu)
|
||||||
return;
|
return;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -10,9 +10,42 @@ namespace stardew_access.Patches
|
||||||
{
|
{
|
||||||
internal static string hoveredItemQueryKey = "";
|
internal static string hoveredItemQueryKey = "";
|
||||||
internal static string geodeMenuQueryKey = "";
|
internal static string geodeMenuQueryKey = "";
|
||||||
|
internal static string gameMenuQueryKey = "";
|
||||||
internal static string itemGrabMenuQueryKey = "";
|
internal static string itemGrabMenuQueryKey = "";
|
||||||
internal static string craftingPageQueryKey = "";
|
internal static string craftingPageQueryKey = "";
|
||||||
internal static string inventoryPageQueryKey = "";
|
internal static string inventoryPageQueryKey = "";
|
||||||
|
internal static string exitPageQueryKey = "";
|
||||||
|
internal static string optionsPageQueryKey = "";
|
||||||
|
|
||||||
|
internal static void GameMenuPatch(GameMenu __instance)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Continue if only in the Inventory Page or Crafting Page
|
||||||
|
if (__instance.currentTab != 0 && __instance.currentTab != 4 && __instance.currentTab != 6 && __instance.currentTab != 7)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position
|
||||||
|
|
||||||
|
for(int i=0; i<__instance.tabs.Count; i++)
|
||||||
|
{
|
||||||
|
if(__instance.tabs[i].containsPoint(x, y))
|
||||||
|
{
|
||||||
|
string toSpeak = $"{GameMenu.getLabelOfTabFromIndex(i)} Tab";
|
||||||
|
if (gameMenuQueryKey != toSpeak)
|
||||||
|
{
|
||||||
|
gameMenuQueryKey = toSpeak;
|
||||||
|
ScreenReader.say(toSpeak, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal static void GeodeMenuPatch(GeodeMenu __instance)
|
internal static void GeodeMenuPatch(GeodeMenu __instance)
|
||||||
{
|
{
|
||||||
|
@ -122,6 +155,7 @@ namespace stardew_access.Patches
|
||||||
{
|
{
|
||||||
itemGrabMenuQueryKey = toSpeak;
|
itemGrabMenuQueryKey = toSpeak;
|
||||||
hoveredItemQueryKey = "";
|
hoveredItemQueryKey = "";
|
||||||
|
gameMenuQueryKey = "";
|
||||||
ScreenReader.say(toSpeak, true);
|
ScreenReader.say(toSpeak, true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -132,6 +166,7 @@ namespace stardew_access.Patches
|
||||||
if (itemGrabMenuQueryKey != toSpeak)
|
if (itemGrabMenuQueryKey != toSpeak)
|
||||||
{
|
{
|
||||||
itemGrabMenuQueryKey = toSpeak;
|
itemGrabMenuQueryKey = toSpeak;
|
||||||
|
gameMenuQueryKey = "";
|
||||||
hoveredItemQueryKey = "";
|
hoveredItemQueryKey = "";
|
||||||
ScreenReader.say(toSpeak, true);
|
ScreenReader.say(toSpeak, true);
|
||||||
}
|
}
|
||||||
|
@ -144,6 +179,7 @@ namespace stardew_access.Patches
|
||||||
if (itemGrabMenuQueryKey != toSpeak)
|
if (itemGrabMenuQueryKey != toSpeak)
|
||||||
{
|
{
|
||||||
itemGrabMenuQueryKey = toSpeak;
|
itemGrabMenuQueryKey = toSpeak;
|
||||||
|
gameMenuQueryKey = "";
|
||||||
hoveredItemQueryKey = "";
|
hoveredItemQueryKey = "";
|
||||||
ScreenReader.say(toSpeak, true);
|
ScreenReader.say(toSpeak, true);
|
||||||
Game1.playSound("sa_drop_item");
|
Game1.playSound("sa_drop_item");
|
||||||
|
@ -164,6 +200,7 @@ namespace stardew_access.Patches
|
||||||
if (itemGrabMenuQueryKey != toSpeak)
|
if (itemGrabMenuQueryKey != toSpeak)
|
||||||
{
|
{
|
||||||
itemGrabMenuQueryKey = toSpeak;
|
itemGrabMenuQueryKey = toSpeak;
|
||||||
|
gameMenuQueryKey = "";
|
||||||
hoveredItemQueryKey = "";
|
hoveredItemQueryKey = "";
|
||||||
ScreenReader.say(toSpeak, true);
|
ScreenReader.say(toSpeak, true);
|
||||||
}
|
}
|
||||||
|
@ -174,12 +211,14 @@ namespace stardew_access.Patches
|
||||||
#region Narrate hovered item
|
#region Narrate hovered item
|
||||||
if(narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true))
|
if(narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true))
|
||||||
{
|
{
|
||||||
|
gameMenuQueryKey = "";
|
||||||
itemGrabMenuQueryKey = "";
|
itemGrabMenuQueryKey = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (narrateHoveredItemInInventory(__instance.ItemsToGrabMenu.inventory, __instance.ItemsToGrabMenu.actualInventory, x, y, true))
|
if (narrateHoveredItemInInventory(__instance.ItemsToGrabMenu.inventory, __instance.ItemsToGrabMenu.actualInventory, x, y, true))
|
||||||
{
|
{
|
||||||
|
gameMenuQueryKey = "";
|
||||||
itemGrabMenuQueryKey = "";
|
itemGrabMenuQueryKey = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -317,6 +356,7 @@ namespace stardew_access.Patches
|
||||||
if (craftingPageQueryKey != toSpeak)
|
if (craftingPageQueryKey != toSpeak)
|
||||||
{
|
{
|
||||||
craftingPageQueryKey = toSpeak;
|
craftingPageQueryKey = toSpeak;
|
||||||
|
gameMenuQueryKey = "";
|
||||||
hoveredItemQueryKey = "";
|
hoveredItemQueryKey = "";
|
||||||
ScreenReader.say(toSpeak, true);
|
ScreenReader.say(toSpeak, true);
|
||||||
}
|
}
|
||||||
|
@ -327,6 +367,7 @@ namespace stardew_access.Patches
|
||||||
#region Narrate hovered item
|
#region Narrate hovered item
|
||||||
if (narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y))
|
if (narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y))
|
||||||
{
|
{
|
||||||
|
gameMenuQueryKey = "";
|
||||||
craftingPageQueryKey = "";
|
craftingPageQueryKey = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -366,6 +407,7 @@ namespace stardew_access.Patches
|
||||||
if (inventoryPageQueryKey != toSpeak)
|
if (inventoryPageQueryKey != toSpeak)
|
||||||
{
|
{
|
||||||
inventoryPageQueryKey = toSpeak;
|
inventoryPageQueryKey = toSpeak;
|
||||||
|
gameMenuQueryKey = "";
|
||||||
hoveredItemQueryKey = "";
|
hoveredItemQueryKey = "";
|
||||||
ScreenReader.say(toSpeak, true);
|
ScreenReader.say(toSpeak, true);
|
||||||
Game1.playSound("sa_drop_item");
|
Game1.playSound("sa_drop_item");
|
||||||
|
@ -461,6 +503,7 @@ namespace stardew_access.Patches
|
||||||
if (inventoryPageQueryKey != toSpeak)
|
if (inventoryPageQueryKey != toSpeak)
|
||||||
{
|
{
|
||||||
inventoryPageQueryKey = toSpeak;
|
inventoryPageQueryKey = toSpeak;
|
||||||
|
gameMenuQueryKey = "";
|
||||||
hoveredItemQueryKey = "";
|
hoveredItemQueryKey = "";
|
||||||
ScreenReader.say(toSpeak, true);
|
ScreenReader.say(toSpeak, true);
|
||||||
}
|
}
|
||||||
|
@ -472,6 +515,7 @@ namespace stardew_access.Patches
|
||||||
#region Narrate hovered item
|
#region Narrate hovered item
|
||||||
if (narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true))
|
if (narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true))
|
||||||
{
|
{
|
||||||
|
gameMenuQueryKey = "";
|
||||||
inventoryPageQueryKey = "";
|
inventoryPageQueryKey = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -520,8 +564,13 @@ namespace stardew_access.Patches
|
||||||
toSpeak = $"{toSpeak} Options:";
|
toSpeak = $"{toSpeak} Options:";
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenReader.sayWithChecker(toSpeak, true);
|
if (optionsPageQueryKey != toSpeak)
|
||||||
break;
|
{
|
||||||
|
gameMenuQueryKey = "";
|
||||||
|
optionsPageQueryKey = toSpeak;
|
||||||
|
ScreenReader.say(toSpeak, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,12 +587,26 @@ namespace stardew_access.Patches
|
||||||
if (__instance.exitToTitle.visible &&
|
if (__instance.exitToTitle.visible &&
|
||||||
__instance.exitToTitle.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
__instance.exitToTitle.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||||
{
|
{
|
||||||
ScreenReader.sayWithChecker("Exit to Title Button", true);
|
string toSpeak = "Exit to Title Button";
|
||||||
|
if (exitPageQueryKey != toSpeak)
|
||||||
|
{
|
||||||
|
gameMenuQueryKey = "";
|
||||||
|
exitPageQueryKey = toSpeak;
|
||||||
|
ScreenReader.say(toSpeak, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (__instance.exitToDesktop.visible &&
|
if (__instance.exitToDesktop.visible &&
|
||||||
__instance.exitToDesktop.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
__instance.exitToDesktop.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y))
|
||||||
{
|
{
|
||||||
ScreenReader.sayWithChecker("Exit to Desktop Button", true);
|
string toSpeak = "Exit to Desktop Button";
|
||||||
|
if (exitPageQueryKey != toSpeak)
|
||||||
|
{
|
||||||
|
gameMenuQueryKey = "";
|
||||||
|
exitPageQueryKey = toSpeak;
|
||||||
|
ScreenReader.say(toSpeak, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -670,10 +733,5 @@ namespace stardew_access.Patches
|
||||||
#endregion
|
#endregion
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool narrateHoveredCraftingRecipe()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,23 @@ namespace stardew_access.Patches
|
||||||
|
|
||||||
if (Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).GetCurrentPage() is CraftingPage)
|
if (Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).GetCurrentPage() is CraftingPage)
|
||||||
{
|
{
|
||||||
GameMenuPatches.craftingPageQueryKey = "";
|
GameMenuPatches.craftingPageQueryKey = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).GetCurrentPage() is ExitPage)
|
||||||
|
{
|
||||||
|
GameMenuPatches.exitPageQueryKey = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).GetCurrentPage() is CraftingPage)
|
||||||
|
{
|
||||||
|
GameMenuPatches.craftingPageQueryKey = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// This should be after checking all pages/tabs in the GameMenu
|
||||||
|
if (Game1.activeClickableMenu is GameMenu)
|
||||||
|
{
|
||||||
|
GameMenuPatches.gameMenuQueryKey = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(__instance is ItemGrabMenu)
|
if(__instance is ItemGrabMenu)
|
||||||
|
|
Loading…
Reference in New Issue