diff --git a/stardew-access/CustomCommands.cs b/stardew-access/CustomCommands.cs index 5e8b200..fe90da5 100644 --- a/stardew-access/CustomCommands.cs +++ b/stardew-access/CustomCommands.cs @@ -356,7 +356,7 @@ namespace stardew_access helper.ConsoleCommands.Add("buildsel", "Select the building index which you want to upgrade/demolish/paint", (string command, string[] args) => { - if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu && Game1.activeClickableMenu is not AnimalQueryMenu) || !CarpenterMenuPatch.isOnFarm) + if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu && Game1.activeClickableMenu is not AnimalQueryMenu) || (!CarpenterMenuPatch.isOnFarm && !PurchaseAnimalsMenuPatch.isOnFarm && !AnimalQueryMenuPatch.isOnFarm)) { MainClass.InfoLog($"Cannot select building."); return; diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index 659cb28..23d1484 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -241,6 +241,11 @@ namespace stardew_access prefix: new HarmonyMethod(typeof(PurchaseAnimalsMenuPatch), nameof(PurchaseAnimalsMenuPatch.DrawPatch)) ); + harmony.Patch( + original: AccessTools.Method(typeof(PurchaseAnimalsMenu), nameof(PurchaseAnimalsMenu.receiveKeyPress), new Type[] { typeof(Keys) }), + prefix: new HarmonyMethod(typeof(PurchaseAnimalsMenuPatch), nameof(PurchaseAnimalsMenuPatch.RecieveKeyPressPatch)) + ); + harmony.Patch( original: AccessTools.Method(typeof(AnimalQueryMenu), nameof(AnimalQueryMenu.draw), new Type[] { typeof(SpriteBatch) }), postfix: new HarmonyMethod(typeof(AnimalQueryMenuPatch), nameof(AnimalQueryMenuPatch.DrawPatch)) diff --git a/stardew-access/Patches/OtherMenuPatches/PurchaseAnimalsMenuPatch.cs b/stardew-access/Patches/OtherMenuPatches/PurchaseAnimalsMenuPatch.cs index 8ff6dff..8a8b41a 100644 --- a/stardew-access/Patches/OtherMenuPatches/PurchaseAnimalsMenuPatch.cs +++ b/stardew-access/Patches/OtherMenuPatches/PurchaseAnimalsMenuPatch.cs @@ -24,7 +24,7 @@ namespace stardew_access.Patches if (___onFarm && ___namingAnimal) { - narrateNamingMenu(__instance, x, y); + narrateNamingMenu(__instance, ___textBox, x, y); } else if (___onFarm && !___namingAnimal) { @@ -42,7 +42,7 @@ namespace stardew_access.Patches } } - private static void narrateNamingMenu(PurchaseAnimalsMenu __instance, int x, int y) + private static void narrateNamingMenu(PurchaseAnimalsMenu __instance, TextBox ___textBox, int x, int y) { string toSpeak = ""; if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) @@ -60,9 +60,9 @@ namespace stardew_access.Patches else if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y)) { toSpeak = "Name Text Box"; - // string? value = ___textBox.Text; - // if (value != "" && value != null && value != "null") - // toSpeak = $"{toSpeak}, Value: {value}"; + string? name = ___textBox.Text; + if (name != null) + toSpeak = $"{toSpeak}, Value: {name}"; } if (purchaseAnimalMenuQuery == toSpeak) return; @@ -103,6 +103,16 @@ namespace stardew_access.Patches MainClass.ScreenReader.Say(toSpeak, true); } + internal static bool RecieveKeyPressPatch(PurchaseAnimalsMenu __instance, Microsoft.Xna.Framework.Input.Keys key) + { + if (TextBoxPatch.isAnyTextBoxActive && Game1.options.doesInputListContain(Game1.options.menuButton, key) && __instance.readyToClose()) + { + return false; + } + + return true; + } + internal static void Cleanup() { purchaseAnimalMenuQuery = "";