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));
|
||||
}
|
||||
|
@ -377,4 +379,4 @@ namespace stardew_access
|
|||
monitor.Log(message, LogLevel.Debug);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,65 +27,54 @@ 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)
|
||||
if (isPrimaryInfoKeyPressed & !isNarratingAnimalInfo)
|
||||
{
|
||||
toSpeak = ___textBox.Text;
|
||||
|
||||
if (isEscPressed)
|
||||
string name = ___animal.displayName;
|
||||
string type = ___animal.displayType;
|
||||
int age = (___animal.GetDaysOwned() + 1) / 28 + 1;
|
||||
string ageText = (age <= 1) ? Game1.content.LoadString("Strings\\UI:AnimalQuery_Age1") : Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeN", age);
|
||||
string parent = "";
|
||||
if ((int)___animal.age.Value < (byte)___animal.ageWhenMature.Value)
|
||||
{
|
||||
___textBox.Selected = false;
|
||||
ageText += Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeBaby");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isPrimaryInfoKeyPressed & !isNarratingAnimalInfo)
|
||||
if (___parentName != null)
|
||||
{
|
||||
string name = ___animal.displayName;
|
||||
string type = ___animal.displayType;
|
||||
int age = (___animal.GetDaysOwned() + 1) / 28 + 1;
|
||||
string ageText = (age <= 1) ? Game1.content.LoadString("Strings\\UI:AnimalQuery_Age1") : Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeN", age);
|
||||
string parent = "";
|
||||
if ((int)___animal.age.Value < (byte)___animal.ageWhenMature.Value)
|
||||
{
|
||||
ageText += Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeBaby");
|
||||
}
|
||||
if (___parentName != null)
|
||||
{
|
||||
parent = Game1.content.LoadString("Strings\\UI:AnimalQuery_Parent", ___parentName);
|
||||
}
|
||||
|
||||
details = $"Name: {name} Type: {type} \n\t Age: {ageText} {parent}";
|
||||
animalQueryMenuQuery = " ";
|
||||
|
||||
isNarratingAnimalInfo = true;
|
||||
Task.Delay(200).ContinueWith(_ => { isNarratingAnimalInfo = false; });
|
||||
parent = Game1.content.LoadString("Strings\\UI:AnimalQuery_Parent", ___parentName);
|
||||
}
|
||||
|
||||
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
||||
toSpeak = "OK button";
|
||||
else if (__instance.sellButton != null && __instance.sellButton.containsPoint(x, y))
|
||||
toSpeak = $"Sell for {___animal.getSellPrice()}g button";
|
||||
else if (___confirmingSell && __instance.yesButton != null && __instance.yesButton.containsPoint(x, y))
|
||||
toSpeak = "Confirm selling animal";
|
||||
else if (___confirmingSell && __instance.noButton != null && __instance.noButton.containsPoint(x, y))
|
||||
toSpeak = "Cancel selling animal";
|
||||
else if (__instance.moveHomeButton != null && __instance.moveHomeButton.containsPoint(x, y))
|
||||
toSpeak = "Change home building button";
|
||||
else if (__instance.allowReproductionButton != null && __instance.allowReproductionButton.containsPoint(x, y))
|
||||
toSpeak = ((___animal.allowReproduction.Value) ? "Enabled" : "Disabled") + " allow reproduction button";
|
||||
else if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y))
|
||||
toSpeak = "Animal name text box";
|
||||
details = $"Name: {name} Type: {type} \n\t Age: {ageText} {parent}";
|
||||
animalQueryMenuQuery = " ";
|
||||
|
||||
isNarratingAnimalInfo = true;
|
||||
Task.Delay(200).ContinueWith(_ => { isNarratingAnimalInfo = false; });
|
||||
}
|
||||
|
||||
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
||||
toSpeak = "OK button";
|
||||
else if (__instance.sellButton != null && __instance.sellButton.containsPoint(x, y))
|
||||
toSpeak = $"Sell for {___animal.getSellPrice()}g button";
|
||||
else if (___confirmingSell && __instance.yesButton != null && __instance.yesButton.containsPoint(x, y))
|
||||
toSpeak = "Confirm selling animal";
|
||||
else if (___confirmingSell && __instance.noButton != null && __instance.noButton.containsPoint(x, y))
|
||||
toSpeak = "Cancel selling animal";
|
||||
else if (__instance.moveHomeButton != null && __instance.moveHomeButton.containsPoint(x, y))
|
||||
toSpeak = "Change home building button";
|
||||
else if (__instance.allowReproductionButton != null && __instance.allowReproductionButton.containsPoint(x, y))
|
||||
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)
|
||||
{
|
||||
animalQueryMenuQuery = toSpeak;
|
||||
|
@ -711,4 +700,4 @@ namespace stardew_access.Patches
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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