diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 658db41..def28d6 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -30,8 +30,6 @@ namespace stardew_access internal static ModConfig Config { get => config; set => config = value; } public static IModHelper? ModHelper { get => modHelper; } - public static bool isAnyTextBoxActive = false; - public static StaticTiles STiles { get @@ -212,7 +210,7 @@ namespace stardew_access return; #region Simulate left and right clicks - if (Game1.activeClickableMenu != null && !isAnyTextBoxActive) + if (Game1.activeClickableMenu != null && !TextBoxPatch.isAnyTextBoxActive) { bool isCustomizingCharacter = Game1.activeClickableMenu is CharacterCustomization || (TitleMenu.subMenu != null && TitleMenu.subMenu is CharacterCustomization); @@ -229,7 +227,7 @@ namespace stardew_access #endregion } - if (Game1.currentMinigame != null && !isAnyTextBoxActive) + if (Game1.currentMinigame != null && !TextBoxPatch.isAnyTextBoxActive) { #region Mouse Click Simulation if (Config.LeftClickMainKey.JustPressed() || Config.LeftClickAlternateKey.JustPressed()) diff --git a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs index 174f6f3..352011f 100644 --- a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs +++ b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs @@ -27,7 +27,7 @@ namespace stardew_access.Patches { try { - if (MainClass.isAnyTextBoxActive) return; + if (TextBoxPatch.isAnyTextBoxActive) return; int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position bool isPrimaryInfoKeyPressed = MainClass.Config.PrimaryInfoKey.JustPressed(); // For narrating animal details @@ -91,7 +91,7 @@ namespace stardew_access.Patches { try { - if (MainClass.isAnyTextBoxActive) return; + if (TextBoxPatch.isAnyTextBoxActive) return; int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position purchaseAnimalsMenu = __instance; diff --git a/stardew-access/Patches/CharacterCustomizationMenuPatches.cs b/stardew-access/Patches/CharacterCustomizationMenuPatches.cs index 96852ff..fa3e13f 100644 --- a/stardew-access/Patches/CharacterCustomizationMenuPatches.cs +++ b/stardew-access/Patches/CharacterCustomizationMenuPatches.cs @@ -36,7 +36,7 @@ namespace stardew_access.Patches { try { - if (MainClass.isAnyTextBoxActive) return; + if (TextBoxPatch.isAnyTextBoxActive) return; bool isEscPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape); // For escaping/unselecting from the animal name text box string toSpeak = ""; diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index 6e70087..5625593 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -426,7 +426,7 @@ namespace stardew_access.Patches ___textBox.Selected = false; } - if (MainClass.isAnyTextBoxActive) return; + if (TextBoxPatch.isAnyTextBoxActive) return; string toSpeak = ""; int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position @@ -729,6 +729,7 @@ namespace stardew_access.Patches InventoryUtils.hoveredItemQueryKey = ""; InventoryUtils.prevSlotIndex = -999; + TextBoxPatch.activeTextBoxes = ""; } #endregion diff --git a/stardew-access/Patches/TextBoxPatch.cs b/stardew-access/Patches/TextBoxPatch.cs index eddc5e4..cc3de3e 100644 --- a/stardew-access/Patches/TextBoxPatch.cs +++ b/stardew-access/Patches/TextBoxPatch.cs @@ -3,18 +3,21 @@ namespace stardew_access.Patches internal class TextBoxPatch { internal static string textBoxQuery = " "; + internal static string activeTextBoxes = ""; + internal static bool isAnyTextBoxActive => activeTextBoxes != ""; internal static void DrawPatch(StardewValley.Menus.TextBox __instance) { try { + string uniqueIdentifier = $"{__instance.X}:{__instance.Y}:{__instance.Height}:{__instance.Width}"; if (!__instance.Selected) { - MainClass.isAnyTextBoxActive = false; + if (activeTextBoxes.Contains(uniqueIdentifier)) activeTextBoxes = activeTextBoxes.Replace(uniqueIdentifier, ""); return; } - MainClass.isAnyTextBoxActive = true; + if (!activeTextBoxes.Contains(uniqueIdentifier)) activeTextBoxes += uniqueIdentifier; bool isEscPressed = StardewValley.Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape); string toSpeak = __instance.Text;