Patched Animal Query Menu
This commit is contained in:
@@ -11,8 +11,77 @@ namespace stardew_access.Patches
|
||||
internal class MenuPatches
|
||||
{
|
||||
private static string currentLevelUpTitle = " ";
|
||||
private static string animalQueryMenuQuery = " ";
|
||||
public static Vector2? prevTile = null;
|
||||
|
||||
internal static void AnimalQueryMenuPatch(AnimalQueryMenu __instance, bool ___confirmingSell, FarmAnimal ___animal, TextBox ___textBox, string ___parentName)
|
||||
{
|
||||
try
|
||||
{
|
||||
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
||||
bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C); // 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 = " ";
|
||||
|
||||
if (___textBox.Selected)
|
||||
{
|
||||
toSpeak = ___textBox.Text;
|
||||
|
||||
if (isEscPressed)
|
||||
{
|
||||
___textBox.Selected = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isCPressed)
|
||||
{
|
||||
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 < (byte)___animal.ageWhenMature)
|
||||
{
|
||||
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 = " ";
|
||||
}
|
||||
|
||||
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;
|
||||
MainClass.GetScreenReader().Say($"{details} {toSpeak}", true);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool PlaySoundPatch(string cueName)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user