Patched pond query menu

master
Mohammad Shoaib 2022-04-12 23:37:34 +05:30
parent 38f32c2b48
commit 3b55110e11
4 changed files with 87 additions and 34 deletions

View File

@ -180,6 +180,11 @@ namespace stardew_access
original: AccessTools.Method(typeof(TailoringMenu), nameof(TailoringMenu.draw), new Type[] { typeof(SpriteBatch) }), original: AccessTools.Method(typeof(TailoringMenu), nameof(TailoringMenu.draw), new Type[] { typeof(SpriteBatch) }),
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.TailoringMenuPatch)) postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.TailoringMenuPatch))
); );
harmony.Patch(
original: AccessTools.Method(typeof(PondQueryMenu), nameof(PondQueryMenu.draw), new Type[] { typeof(SpriteBatch) }),
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.PondQueryMenuPatch))
);
#endregion #endregion
#region Quest Patches #region Quest Patches

View File

@ -209,6 +209,9 @@ namespace stardew_access.Patches
if (Game1.activeClickableMenu is TailoringMenu) if (Game1.activeClickableMenu is TailoringMenu)
return; return;
if (Game1.activeClickableMenu is PondQueryMenu)
return;
#endregion #endregion
string toSpeak = " "; string toSpeak = " ";

View File

@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Input;
using stardew_access.Features; using stardew_access.Features;
using StardewModdingAPI; using StardewModdingAPI;
using StardewValley; using StardewValley;
using StardewValley.Buildings;
using StardewValley.Locations; using StardewValley.Locations;
using StardewValley.Menus; using StardewValley.Menus;
using StardewValley.Objects; using StardewValley.Objects;
@ -15,9 +16,62 @@ namespace stardew_access.Patches
internal static bool firstTimeInNamingMenu = true; internal static bool firstTimeInNamingMenu = true;
internal static string animalQueryMenuQuery = " "; internal static string animalQueryMenuQuery = " ";
internal static string tailoringMenuQuery = " "; internal static string tailoringMenuQuery = " ";
internal static bool isCyclingThroughInv = false; internal static string pondQueryMenuQuery = " ";
public static Vector2? prevTile = null; public static Vector2? prevTile = null;
internal static void PondQueryMenuPatch(PondQueryMenu __instance, StardewValley.Object ____fishItem, FishPond ____pond, string ____statusText, bool ___confirmingEmpty)
{
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);
bool isYPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Y);
bool isNPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.N);
string toSpeak = " ", extra = "";
if (___confirmingEmpty)
{
if (__instance.yesButton != null && __instance.yesButton.containsPoint(x, y))
toSpeak = "Confirm button";
else if (__instance.noButton != null && __instance.noButton.containsPoint(x, y))
toSpeak = "Cancel button";
}
else
{
if (isCPressed)
{
string pond_name_text = Game1.content.LoadString("Strings\\UI:PondQuery_Name", ____fishItem.DisplayName);
string population_text = Game1.content.LoadString("Strings\\UI:PondQuery_Population", string.Concat(____pond.FishCount), ____pond.maxOccupants.Value);
bool has_unresolved_needs = ____pond.neededItem.Value != null && ____pond.HasUnresolvedNeeds() && !____pond.hasCompletedRequest.Value;
string bring_text = "";
if (has_unresolved_needs && ____pond.neededItem.Value != null)
bring_text = Game1.content.LoadString("Strings\\UI:PondQuery_StatusRequest_Bring") + $": {____pond.neededItemCount} {____pond.neededItem.Value.DisplayName}";
extra = $"{pond_name_text} {population_text} {bring_text} Status: {____statusText}";
pondQueryMenuQuery = " ";
}
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
toSpeak = "Ok button";
else if (__instance.changeNettingButton != null && __instance.changeNettingButton.containsPoint(x, y))
toSpeak = "Change netting button";
else if (__instance.emptyButton != null && __instance.emptyButton.containsPoint(x, y))
toSpeak = "Empty pond button";
}
if (pondQueryMenuQuery != toSpeak)
{
pondQueryMenuQuery = toSpeak;
MainClass.ScreenReader.Say(extra + " \n\t" + toSpeak, true);
}
}
catch (System.Exception e)
{
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
}
}
internal static void TailoringMenuPatch(TailoringMenu __instance) internal static void TailoringMenuPatch(TailoringMenu __instance)
{ {
try try
@ -57,22 +111,22 @@ namespace stardew_access.Patches
{ {
toSpeak = "Hat Slot"; toSpeak = "Hat Slot";
if (((Hat)Game1.player.hat) != null) if (Game1.player.hat.Value != null)
toSpeak = $"{toSpeak}: {((Hat)Game1.player.hat).DisplayName}"; toSpeak = $"{toSpeak}: {Game1.player.hat.Value.DisplayName}";
} }
else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[1].containsPoint(x, y)) else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[1].containsPoint(x, y))
{ {
toSpeak = "Shirt Slot"; toSpeak = "Shirt Slot";
if (((Clothing)Game1.player.shirtItem) != null) if (Game1.player.shirtItem.Value != null)
toSpeak = $"{toSpeak}: {((Clothing)Game1.player.shirtItem).DisplayName}"; toSpeak = $"{toSpeak}: {Game1.player.shirtItem.Value.DisplayName}";
} }
else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[2].containsPoint(x, y)) else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[2].containsPoint(x, y))
{ {
toSpeak = "Pants Slot"; toSpeak = "Pants Slot";
if ((Clothing)Game1.player.pantsItem != null) if (Game1.player.pantsItem.Value != null)
toSpeak = $"{toSpeak}: {((Clothing)Game1.player.pantsItem).DisplayName}"; toSpeak = $"{toSpeak}: {Game1.player.pantsItem.Value.DisplayName}";
} }
else else
{ {
@ -535,18 +589,15 @@ namespace stardew_access.Patches
{ {
DialoguePatches.currentLetterText = " "; DialoguePatches.currentLetterText = " ";
} }
else if (menu is LevelUpMenu)
if (menu is LevelUpMenu)
{ {
currentLevelUpTitle = " "; currentLevelUpTitle = " ";
} }
else if (menu is Billboard)
if (menu is Billboard)
{ {
QuestPatches.currentDailyQuestText = " "; QuestPatches.currentDailyQuestText = " ";
} }
else if (menu is GameMenu)
if (menu is GameMenu)
{ {
GameMenuPatches.gameMenuQueryKey = ""; GameMenuPatches.gameMenuQueryKey = "";
GameMenuPatches.craftingPageQueryKey = ""; GameMenuPatches.craftingPageQueryKey = "";
@ -557,31 +608,26 @@ namespace stardew_access.Patches
GameMenuPatches.currentSelectedCraftingRecipe = -1; GameMenuPatches.currentSelectedCraftingRecipe = -1;
GameMenuPatches.isSelectingRecipe = false; GameMenuPatches.isSelectingRecipe = false;
} }
else if (menu is JunimoNoteMenu)
if (menu is JunimoNoteMenu)
{ {
BundleMenuPatches.currentIngredientListItem = -1; BundleMenuPatches.currentIngredientListItem = -1;
BundleMenuPatches.currentIngredientInputSlot = -1; BundleMenuPatches.currentIngredientInputSlot = -1;
BundleMenuPatches.currentInventorySlot = -1; BundleMenuPatches.currentInventorySlot = -1;
BundleMenuPatches.junimoNoteMenuQuery = ""; BundleMenuPatches.junimoNoteMenuQuery = "";
} }
else if (menu is ShopMenu)
if (menu is ShopMenu)
{ {
GameMenuPatches.shopMenuQueryKey = ""; GameMenuPatches.shopMenuQueryKey = "";
} }
else if (menu is ItemGrabMenu)
if (menu is ItemGrabMenu)
{ {
GameMenuPatches.itemGrabMenuQueryKey = ""; GameMenuPatches.itemGrabMenuQueryKey = "";
} }
else if (menu is GeodeMenu)
if (menu is GeodeMenu)
{ {
GameMenuPatches.geodeMenuQueryKey = ""; GameMenuPatches.geodeMenuQueryKey = "";
} }
else if (menu is CarpenterMenu)
if (menu is CarpenterMenu)
{ {
BuildingNAnimalMenuPatches.carpenterMenuQuery = ""; BuildingNAnimalMenuPatches.carpenterMenuQuery = "";
BuildingNAnimalMenuPatches.isUpgrading = false; BuildingNAnimalMenuPatches.isUpgrading = false;
@ -591,34 +637,33 @@ namespace stardew_access.Patches
BuildingNAnimalMenuPatches.isConstructing = false; BuildingNAnimalMenuPatches.isConstructing = false;
BuildingNAnimalMenuPatches.carpenterMenu = null; BuildingNAnimalMenuPatches.carpenterMenu = null;
} }
else if (menu is PurchaseAnimalsMenu)
if (menu is PurchaseAnimalsMenu)
{ {
BuildingNAnimalMenuPatches.purchaseAnimalMenuQuery = ""; BuildingNAnimalMenuPatches.purchaseAnimalMenuQuery = "";
BuildingNAnimalMenuPatches.firstTimeInNamingMenu = true; BuildingNAnimalMenuPatches.firstTimeInNamingMenu = true;
BuildingNAnimalMenuPatches.purchaseAnimalsMenu = null; BuildingNAnimalMenuPatches.purchaseAnimalsMenu = null;
} }
else if (menu is DialogueBox)
if (menu is DialogueBox)
{ {
DialoguePatches.isDialogueAppearingFirstTime = true; DialoguePatches.isDialogueAppearingFirstTime = true;
DialoguePatches.currentDialogue = " "; DialoguePatches.currentDialogue = " ";
} }
else if (menu is JojaCDMenu)
if (menu is JojaCDMenu)
{ {
BundleMenuPatches.jojaCDMenuQuery = ""; BundleMenuPatches.jojaCDMenuQuery = "";
} }
else if (menu is QuestLog)
if (menu is QuestLog)
{ {
QuestPatches.questLogQuery = " "; QuestPatches.questLogQuery = " ";
} }
else if (menu is TailoringMenu)
if (menu is TailoringMenu)
{ {
tailoringMenuQuery = " "; tailoringMenuQuery = " ";
} }
else if (menu is PondQueryMenu)
{
pondQueryMenuQuery = " ";
}
GameMenuPatches.hoveredItemQueryKey = ""; GameMenuPatches.hoveredItemQueryKey = "";
} }

View File

@ -1,7 +1,7 @@
{ {
"Name": "Stardew Access", "Name": "Stardew Access",
"Author": "Mohammad Shoaib", "Author": "Mohammad Shoaib",
"Version": "1.1.5", "Version": "1.1.6",
"Description": "An accessibility mod with screen reader support!", "Description": "An accessibility mod with screen reader support!",
"UniqueID": "shoaib.stardewaccess", "UniqueID": "shoaib.stardewaccess",
"EntryDll": "stardew-access.dll", "EntryDll": "stardew-access.dll",