From c9c62d4fa9c2ff8c458edda1aa762b0201ebb1fc Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Tue, 21 Feb 2023 21:49:22 +0530 Subject: [PATCH] Removed previous text box code from other places --- stardew-access/ModEntry.cs | 8 ++--- .../Patches/BuildingNAnimalMenuPatches.cs | 8 +++-- .../CharacterCustomizationMenuPatches.cs | 31 ++--------------- stardew-access/Patches/ChatMenuPatches.cs | 3 +- stardew-access/Patches/MenuPatches.cs | 33 +++++++------------ 5 files changed, 24 insertions(+), 59 deletions(-) diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 3233e58..03364ed 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -218,21 +218,21 @@ namespace stardew_access #region Mouse Click Simulation // Main Keybinds - if (Config.LeftClickMainKey.JustPressed()) + if (!isAnyTextBoxActive && Config.LeftClickMainKey.JustPressed()) { Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true)); } - if (Config.RightClickMainKey.JustPressed()) + if (!isAnyTextBoxActive && Config.RightClickMainKey.JustPressed()) { Game1.activeClickableMenu.receiveRightClick(Game1.getMouseX(true), Game1.getMouseY(true)); } // Alternate Keybinds - if (!isCustomizingCharacter && !isAnyTextBoxActive && Config.LeftClickAlternateKey.JustPressed()) // Excluding the character creation menu + if (!isAnyTextBoxActive && Config.LeftClickAlternateKey.JustPressed()) // Excluding the character creation menu { Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true)); } - if (!isCustomizingCharacter && Game1.activeClickableMenu is not AnimalQueryMenu && Config.RightClickAlternateKey.JustPressed()) // Excluding the character creation menu + if (!isAnyTextBoxActive && Config.RightClickAlternateKey.JustPressed()) // Excluding the character creation menu { Game1.activeClickableMenu.receiveRightClick(Game1.getMouseX(true), Game1.getMouseY(true)); } diff --git a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs index d52e981..174f6f3 100644 --- a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs +++ b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs @@ -91,6 +91,8 @@ namespace stardew_access.Patches { try { + if (MainClass.isAnyTextBoxActive) return; + int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position purchaseAnimalsMenu = __instance; isOnFarm = ___onFarm; @@ -114,9 +116,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? value = ___textBox.Text; + // if (value != "" && value != null && value != "null") + // toSpeak = $"{toSpeak}, Value: {value}"; } if (purchaseAnimalMenuQuery != toSpeak) diff --git a/stardew-access/Patches/CharacterCustomizationMenuPatches.cs b/stardew-access/Patches/CharacterCustomizationMenuPatches.cs index 52c4323..fa2cc04 100644 --- a/stardew-access/Patches/CharacterCustomizationMenuPatches.cs +++ b/stardew-access/Patches/CharacterCustomizationMenuPatches.cs @@ -34,6 +34,8 @@ namespace stardew_access.Patches { { try { + if (MainClass.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 = ""; if (characterDesignToggleShouldSpeak) @@ -44,34 +46,7 @@ namespace stardew_access.Patches { string itemsToSpeak = ""; string changesToSpeak = ""; - if (___nameBox.Selected) - { - toSpeak = ___nameBox.Text; - - if (isEscPressed) - { - ___nameBox.Selected = false; - } - } - else if (___farmnameBox.Selected) - { - toSpeak = ___farmnameBox.Text; - - if (isEscPressed) - { - ___farmnameBox.Selected = false; - } - } - else if (___favThingBox.Selected) - { - toSpeak = ___favThingBox.Text; - - if (isEscPressed) - { - ___favThingBox.Selected = false; - } - } - else if (MainClass.Config.CharacterCreationMenuNextKey.JustPressed() && !isRunning) + if (MainClass.Config.CharacterCreationMenuNextKey.JustPressed() && !isRunning) { isRunning = true; itemsToSpeak =CycleThroughItems(true, __instance, ___skipIntro, ___startingCabinsLabel, ___difficultyModifierLabel, ___nameBox, ___farmnameBox, ___favThingBox); diff --git a/stardew-access/Patches/ChatMenuPatches.cs b/stardew-access/Patches/ChatMenuPatches.cs index 6155a70..9d3272d 100644 --- a/stardew-access/Patches/ChatMenuPatches.cs +++ b/stardew-access/Patches/ChatMenuPatches.cs @@ -1,5 +1,4 @@ -using StardewValley; -using StardewValley.Menus; +using StardewValley.Menus; namespace stardew_access.Patches { diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index e33a237..6e70087 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -420,35 +420,24 @@ namespace stardew_access.Patches { 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 (MainClass.isAnyTextBoxActive) return; - 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"; - } + 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 (__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.ScreenReader.SayWithChecker(toSpeak, true);