Added patch to disable left mouse sim key when a tex box is active
Also speak the content of the text box when activemaster
parent
07bd1bf1ef
commit
5296c4cabe
|
@ -285,6 +285,11 @@ namespace stardew_access
|
|||
original: AccessTools.Method(typeof(InstanceGame), nameof(InstanceGame.Exit)),
|
||||
prefix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.ExitEventPatch))
|
||||
);
|
||||
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(TextBox), nameof(TextBox.Draw)),
|
||||
prefix: new HarmonyMethod(typeof(TextBoxPatch), nameof(TextBoxPatch.DrawPatch))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ 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
|
||||
|
@ -226,7 +228,7 @@ namespace stardew_access
|
|||
}
|
||||
|
||||
// Alternate Keybinds
|
||||
if (!isCustomizingCharacter && Game1.activeClickableMenu is not AnimalQueryMenu && Config.LeftClickAlternateKey.JustPressed()) // Excluding the character creation menu
|
||||
if (!isCustomizingCharacter && !isAnyTextBoxActive && Config.LeftClickAlternateKey.JustPressed()) // Excluding the character creation menu
|
||||
{
|
||||
Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true));
|
||||
}
|
||||
|
|
|
@ -27,26 +27,16 @@ namespace stardew_access.Patches
|
|||
{
|
||||
try
|
||||
{
|
||||
if (MainClass.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
|
||||
bool isEscPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape); // For escaping/unselecting from the animal name text box
|
||||
string toSpeak = " ", details = " ";
|
||||
|
||||
isOnFarm = ___movingAnimal;
|
||||
animalQueryMenu = __instance;
|
||||
animalBeingPurchasedOrMoved = ___animal;
|
||||
|
||||
if (___textBox.Selected)
|
||||
{
|
||||
toSpeak = ___textBox.Text;
|
||||
|
||||
if (isEscPressed)
|
||||
{
|
||||
___textBox.Selected = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isPrimaryInfoKeyPressed & !isNarratingAnimalInfo)
|
||||
{
|
||||
string name = ___animal.displayName;
|
||||
|
@ -84,7 +74,6 @@ namespace stardew_access.Patches
|
|||
toSpeak = ((___animal.allowReproduction.Value) ? "Enabled" : "Disabled") + " allow reproduction button";
|
||||
else if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y))
|
||||
toSpeak = "Animal name text box";
|
||||
}
|
||||
|
||||
if (animalQueryMenuQuery != toSpeak)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
namespace stardew_access.Patches
|
||||
{
|
||||
internal class TextBoxPatch
|
||||
{
|
||||
internal static string textBoxQuery = " ";
|
||||
|
||||
internal static void DrawPatch(StardewValley.Menus.TextBox __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool isEscPressed = StardewValley.Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape); // For escaping/unselecting from the animal name text box
|
||||
string toSpeak = " ";
|
||||
if (__instance.Selected)
|
||||
{
|
||||
MainClass.isAnyTextBoxActive = true;
|
||||
toSpeak = __instance.Text;
|
||||
|
||||
if (isEscPressed)
|
||||
{
|
||||
__instance.Selected = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainClass.isAnyTextBoxActive = false;
|
||||
}
|
||||
|
||||
if (textBoxQuery != toSpeak)
|
||||
{
|
||||
textBoxQuery = toSpeak;
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainClass.ErrorLog($"An error occured in DrawPatch() in TextBoxPatch:\n{e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue