Bug which prevented from moving or purchasing animals fixed

master^2
Mohammad Shoaib Khan 2023-04-10 13:15:43 +05:30
parent 09001807cb
commit be8b9a9e41
No known key found for this signature in database
GPG Key ID: 4AD59D0913614FE6
3 changed files with 21 additions and 6 deletions

View File

@ -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) => 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."); MainClass.InfoLog($"Cannot select building.");
return; return;

View File

@ -241,6 +241,11 @@ namespace stardew_access
prefix: new HarmonyMethod(typeof(PurchaseAnimalsMenuPatch), nameof(PurchaseAnimalsMenuPatch.DrawPatch)) 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( harmony.Patch(
original: AccessTools.Method(typeof(AnimalQueryMenu), nameof(AnimalQueryMenu.draw), new Type[] { typeof(SpriteBatch) }), original: AccessTools.Method(typeof(AnimalQueryMenu), nameof(AnimalQueryMenu.draw), new Type[] { typeof(SpriteBatch) }),
postfix: new HarmonyMethod(typeof(AnimalQueryMenuPatch), nameof(AnimalQueryMenuPatch.DrawPatch)) postfix: new HarmonyMethod(typeof(AnimalQueryMenuPatch), nameof(AnimalQueryMenuPatch.DrawPatch))

View File

@ -24,7 +24,7 @@ namespace stardew_access.Patches
if (___onFarm && ___namingAnimal) if (___onFarm && ___namingAnimal)
{ {
narrateNamingMenu(__instance, x, y); narrateNamingMenu(__instance, ___textBox, x, y);
} }
else if (___onFarm && !___namingAnimal) 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 = ""; string toSpeak = "";
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) 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)) else if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y))
{ {
toSpeak = "Name Text Box"; toSpeak = "Name Text Box";
// string? value = ___textBox.Text; string? name = ___textBox.Text;
// if (value != "" && value != null && value != "null") if (name != null)
// toSpeak = $"{toSpeak}, Value: {value}"; toSpeak = $"{toSpeak}, Value: {name}";
} }
if (purchaseAnimalMenuQuery == toSpeak) return; if (purchaseAnimalMenuQuery == toSpeak) return;
@ -103,6 +103,16 @@ namespace stardew_access.Patches
MainClass.ScreenReader.Say(toSpeak, true); 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() internal static void Cleanup()
{ {
purchaseAnimalMenuQuery = ""; purchaseAnimalMenuQuery = "";