diff --git a/stardew-access/Features/ReadTile.cs b/stardew-access/Features/ReadTile.cs index 3771d85..b90919a 100644 --- a/stardew-access/Features/ReadTile.cs +++ b/stardew-access/Features/ReadTile.cs @@ -571,6 +571,9 @@ namespace stardew_access.Features case "pine cone": treeName = "Pine"; break; + default: + treeName = "Coconut"; + break; } if (treeStage == 1) diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index b78dd19..37e225b 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -130,7 +130,12 @@ namespace stardew_access ); harmony.Patch( - original: AccessTools.Constructor(typeof(NamingMenu), new Type[] { typeof(NamingMenu.doneNamingBehavior), typeof(string), typeof(string) }), + original: AccessTools.Method(typeof(TitleTextInputMenu), nameof(TitleTextInputMenu.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.TitleTextInputMenuPatch)) + ); + + harmony.Patch( + original: AccessTools.Method(typeof(NamingMenu), nameof(NamingMenu.draw), new Type[] { typeof(SpriteBatch) }), postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.NamingMenuPatch)) ); diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 8cbb62e..8c344be 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -184,6 +184,14 @@ namespace stardew_access if (!Context.IsPlayerFree) return; + // Narrate Current Location + if (Config.LocationKey.JustPressed()) + { + string toSpeak = $"{Game1.currentLocation.Name}"; + MainClass.GetScreenReader().Say(toSpeak, true); + return; + } + // Narrate Position if (Config.PositionKey.JustPressed()) { @@ -209,14 +217,6 @@ namespace stardew_access return; } - // Narrate Current Location - if (Config.LocationKey.JustPressed()) - { - string toSpeak = $"{Game1.currentLocation.Name}"; - MainClass.GetScreenReader().Say(toSpeak, true); - return; - } - // Narrate money at hand if (Config.MoneyKey.JustPressed()) { diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches.cs index a50aef0..3c258f6 100644 --- a/stardew-access/Patches/GameMenuPatches.cs +++ b/stardew-access/Patches/GameMenuPatches.cs @@ -1068,7 +1068,7 @@ namespace stardew_access.Patches } } // These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line) - bool edibleItem = producesItem != null && producesItem is StardewValley.Object && (int)((StardewValley.Object)producesItem).edibility != -300; + bool edibleItem = producesItem != null && producesItem is StardewValley.Object && (int)((StardewValley.Object)producesItem).Edibility != -300; string[]? buffIconsToDisplay = (edibleItem && Game1.objectInformation[((StardewValley.Object)producesItem).ParentSheetIndex].Split('/').Length > 7) ? producesItem.ModifyItemBuffs(Game1.objectInformation[((StardewValley.Object)producesItem).ParentSheetIndex].Split('/')[7].Split(' ')) : null; @@ -1513,7 +1513,7 @@ namespace stardew_access.Patches #region Add buff items (effects like +1 walking speed) // These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line) - bool edibleItem = actualInventory[i] != null && actualInventory[i] is StardewValley.Object && (int)((StardewValley.Object)actualInventory[i]).edibility != -300; + bool edibleItem = actualInventory[i] != null && actualInventory[i] is StardewValley.Object && (int)((StardewValley.Object)actualInventory[i]).Edibility != -300; string[]? buffIconsToDisplay = (edibleItem && Game1.objectInformation[((StardewValley.Object)actualInventory[i]).ParentSheetIndex].Split('/').Length > 7) ? actualInventory[i].ModifyItemBuffs(Game1.objectInformation[((StardewValley.Object)actualInventory[i]).ParentSheetIndex].Split('/')[7].Split(' ')) : null; if (buffIconsToDisplay != null) { diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index 6c4c1c0..a91f331 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -11,6 +11,7 @@ namespace stardew_access.Patches internal class MenuPatches { private static string currentLevelUpTitle = " "; + internal static bool firstTimeInNamingMenu = true; private static string animalQueryMenuQuery = " "; public static Vector2? prevTile = null; @@ -167,15 +168,61 @@ namespace stardew_access.Patches } } - internal static void NamingMenuPatch(NamingMenu __instance, string title, TextBox ___textBox) + internal static void TitleTextInputMenuPatch(TitleTextInputMenu __instance) { try { - __instance.textBoxCC.snapMouseCursor(); - ___textBox.SelectMe(); - string toSpeak = $"{title}"; + string toSpeak = ""; + int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + if (__instance.pasteButton != null && __instance.pasteButton.containsPoint(x, y)) + toSpeak = $"Paste button"; + + if (toSpeak != "") + MainClass.GetScreenReader().SayWithChecker(toSpeak, true); + } + catch (System.Exception e) + { + MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); + } + } + + internal static void NamingMenuPatch(NamingMenu __instance, TextBox ___textBox, string ___title) + { + try + { + string toSpeak = ""; + int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position + bool isEscPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape); // For escaping/unselecting from the animal name text box + + if (firstTimeInNamingMenu) + { + firstTimeInNamingMenu = false; + ___textBox.Selected = false; + } + + if (___textBox.Selected) + { + ___textBox.Update(); + toSpeak = ___textBox.Text; + + if (isEscPressed) + { + ___textBox.Selected = false; + } + } + else + { + if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y)) + toSpeak = $"{___title} text box"; + else if (__instance.doneNamingButton != null && __instance.doneNamingButton.containsPoint(x, y)) + toSpeak = $"Done naming button"; + else if (__instance.randomButton != null && __instance.randomButton.containsPoint(x, y)) + toSpeak = $"Random button"; + } + + if (toSpeak != "") + MainClass.GetScreenReader().SayWithChecker(toSpeak, true); } catch (Exception e) {