Used a different method to detect if any text box is active or not
This fixes the issue when more than one text boxes are present in a menumaster
parent
cf0e46ecdd
commit
8059e09089
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 = "";
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue