diff --git a/stardew-access/Features/ReadTile.cs b/stardew-access/Features/ReadTile.cs
index c02fcb1..3771d85 100644
--- a/stardew-access/Features/ReadTile.cs
+++ b/stardew-access/Features/ReadTile.cs
@@ -859,7 +859,7 @@ namespace stardew_access.Features
{
if (Game1.currentLocation.resourceClumps[i].occupiesTile(x, y))
{
- int index = Game1.currentLocation.resourceClumps[i].parentSheetIndex;
+ int index = Game1.currentLocation.resourceClumps[i].parentSheetIndex.Value;
switch (index)
{
diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs
index 83c1223..b78dd19 100644
--- a/stardew-access/HarmonyPatches.cs
+++ b/stardew-access/HarmonyPatches.cs
@@ -153,6 +153,11 @@ namespace stardew_access
original: AccessTools.Method(typeof(MuseumMenu), nameof(MuseumMenu.draw), new Type[] { typeof(SpriteBatch) }),
postfix: new HarmonyMethod(typeof(MuseumMenuPatches), nameof(MuseumMenuPatches.MuseumMenuPatch))
);
+
+ harmony.Patch(
+ original: AccessTools.Method(typeof(AnimalQueryMenu), nameof(AnimalQueryMenu.draw), new Type[] { typeof(SpriteBatch) }),
+ postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.AnimalQueryMenuPatch))
+ );
#endregion
#region Quest Patches
diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs
index 2e3c61a..8cbb62e 100644
--- a/stardew-access/ModEntry.cs
+++ b/stardew-access/ModEntry.cs
@@ -170,11 +170,11 @@ namespace stardew_access
}
// Alternate Keybinds
- if (!isCustomizingChrachter && Config.LeftClickAlternateKey.JustPressed()) // Excluding the character creation menu
+ if (!isCustomizingChrachter && Game1.activeClickableMenu is not AnimalQueryMenu && Config.LeftClickAlternateKey.JustPressed()) // Excluding the character creation menu
{
Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
- if (!isCustomizingChrachter && Config.RightClickAlternateKey.JustPressed()) // Excluding the character creation menu
+ if (!isCustomizingChrachter && Game1.activeClickableMenu is not AnimalQueryMenu && Config.RightClickAlternateKey.JustPressed()) // Excluding the character creation menu
{
Game1.activeClickableMenu.receiveRightClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
diff --git a/stardew-access/Patches/DialoguePatches.cs b/stardew-access/Patches/DialoguePatches.cs
index 37ecb6d..a253d84 100644
--- a/stardew-access/Patches/DialoguePatches.cs
+++ b/stardew-access/Patches/DialoguePatches.cs
@@ -194,6 +194,9 @@ namespace stardew_access.Patches
if (Game1.activeClickableMenu is CraftingPage)
return;
+
+ if (Game1.activeClickableMenu is AnimalQueryMenu)
+ return;
#endregion
string toSpeak = " ";
diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches.cs
index 742171e..34edd8a 100644
--- a/stardew-access/Patches/GameMenuPatches.cs
+++ b/stardew-access/Patches/GameMenuPatches.cs
@@ -1081,8 +1081,8 @@ namespace stardew_access.Patches
}
// These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line)
bool edibleItem = producesItem != null && producesItem is StardewValley.Object && (int)((StardewValley.Object)producesItem).edibility != -300;
- string[]? buffIconsToDisplay = (edibleItem && Game1.objectInformation[((StardewValley.Object)producesItem).parentSheetIndex].Split('/').Length > 7)
- ? producesItem.ModifyItemBuffs(Game1.objectInformation[((StardewValley.Object)producesItem).parentSheetIndex].Split('/')[7].Split(' '))
+ string[]? buffIconsToDisplay = (edibleItem && Game1.objectInformation[((StardewValley.Object)producesItem).ParentSheetIndex].Split('/').Length > 7)
+ ? producesItem.ModifyItemBuffs(Game1.objectInformation[((StardewValley.Object)producesItem).ParentSheetIndex].Split('/')[7].Split(' '))
: null;
if (buffIconsToDisplay != null)
@@ -1496,7 +1496,7 @@ namespace stardew_access.Patches
#region Add buff items (effects like +1 walking speed)
// These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line)
bool edibleItem = actualInventory[i] != null && actualInventory[i] is StardewValley.Object && (int)((StardewValley.Object)actualInventory[i]).edibility != -300;
- string[]? buffIconsToDisplay = (edibleItem && Game1.objectInformation[((StardewValley.Object)actualInventory[i]).parentSheetIndex].Split('/').Length > 7) ? actualInventory[i].ModifyItemBuffs(Game1.objectInformation[((StardewValley.Object)actualInventory[i]).parentSheetIndex].Split('/')[7].Split(' ')) : null;
+ string[]? buffIconsToDisplay = (edibleItem && Game1.objectInformation[((StardewValley.Object)actualInventory[i]).ParentSheetIndex].Split('/').Length > 7) ? actualInventory[i].ModifyItemBuffs(Game1.objectInformation[((StardewValley.Object)actualInventory[i]).ParentSheetIndex].Split('/')[7].Split(' ')) : null;
if (buffIconsToDisplay != null)
{
for (int j = 0; j < buffIconsToDisplay.Length; j++)
diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs
index 27c559c..6c4c1c0 100644
--- a/stardew-access/Patches/MenuPatches.cs
+++ b/stardew-access/Patches/MenuPatches.cs
@@ -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
diff --git a/stardew-access/manifest.json b/stardew-access/manifest.json
index 27e0f9d..8cac695 100644
--- a/stardew-access/manifest.json
+++ b/stardew-access/manifest.json
@@ -1,7 +1,7 @@
{
"Name": "Stardew Access",
"Author": "Mohammad Shoaib",
- "Version": "1.1.3",
+ "Version": "1.1.4",
"Description": "An accessibility mod with screen reader support!",
"UniqueID": "shoaib.stardewaccess",
"EntryDll": "stardew-access.dll",
diff --git a/stardew-access/stardew-access.csproj b/stardew-access/stardew-access.csproj
index b723494..b3ab566 100644
--- a/stardew-access/stardew-access.csproj
+++ b/stardew-access/stardew-access.csproj
@@ -7,7 +7,8 @@
enable
preview
AnyCPU
- true
+
+