diff --git a/stardew-access/CustomSoundEffects.cs b/stardew-access/CustomSoundEffects.cs index de23067..11415cd 100644 --- a/stardew-access/CustomSoundEffects.cs +++ b/stardew-access/CustomSoundEffects.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework.Audio; -using StardewModdingAPI; using StardewValley; namespace stardew_access @@ -16,6 +15,9 @@ namespace stardew_access { try { + if (MainClass.ModHelper == null) + return; + Dictionary soundEffects = new Dictionary(); soundEffects.Add("drop_item", TYPE.Sound); diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index 37e225b..4cfaeb4 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -163,6 +163,11 @@ namespace stardew_access original: AccessTools.Method(typeof(AnimalQueryMenu), nameof(AnimalQueryMenu.draw), new Type[] { typeof(SpriteBatch) }), postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.AnimalQueryMenuPatch)) ); + + harmony.Patch( + original: AccessTools.Method(typeof(ChooseFromListMenu), nameof(ChooseFromListMenu.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.ChooseFromListMenuPatch)) + ); #endregion #region Quest Patches diff --git a/stardew-access/Patches/DialoguePatches.cs b/stardew-access/Patches/DialoguePatches.cs index acdf755..c805b7c 100644 --- a/stardew-access/Patches/DialoguePatches.cs +++ b/stardew-access/Patches/DialoguePatches.cs @@ -197,6 +197,12 @@ namespace stardew_access.Patches if (Game1.activeClickableMenu is AnimalQueryMenu) return; + + if (Game1.activeClickableMenu is ConfirmationDialog) + return; + + if (Game1.activeClickableMenu is ReadyCheckDialog) + return; #endregion string toSpeak = " "; diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index d929049..12d3415 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -15,6 +15,30 @@ namespace stardew_access.Patches private static string animalQueryMenuQuery = " "; public static Vector2? prevTile = null; + internal static void ChooseFromListMenuPatch(ChooseFromListMenu __instance, List ___options, int ___index, bool ___isJukebox) + { + try + { + int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position + string toSpeak = ""; + + if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) + toSpeak = "Select " + (___isJukebox ? Utility.getSongTitleFromCueName(___options[___index]) : ___options[___index]) + " button"; + else if (__instance.cancelButton != null && __instance.cancelButton.containsPoint(x, y)) + toSpeak = "Cancel button"; + else if (__instance.backButton != null && __instance.backButton.containsPoint(x, y)) + toSpeak = "Previous option: " + (___isJukebox ? Utility.getSongTitleFromCueName(___options[Math.Max(0, ___index - 1)]) : ___options[Math.Max(0, ___index - 1)]) + " button"; + else if (__instance.forwardButton != null && __instance.forwardButton.containsPoint(x, y)) + toSpeak = "Next option: " + (___isJukebox ? Utility.getSongTitleFromCueName(___options[Math.Min(___options.Count, ___index + 1)]) : ___options[Math.Min(___options.Count, ___index + 1)]) + " button"; + + MainClass.ScreenReader.SayWithMenuChecker(toSpeak, true); + } + catch (System.Exception e) + { + MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); + } + } + internal static void AnimalQueryMenuPatch(AnimalQueryMenu __instance, bool ___confirmingSell, FarmAnimal ___animal, TextBox ___textBox, string ___parentName) { try @@ -235,16 +259,18 @@ namespace stardew_access.Patches try { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); + string toSpeak = ___message; - MainClass.ScreenReader.SayWithMenuChecker(___message, true); if (__instance.okButton.containsPoint(x, y)) { - MainClass.ScreenReader.SayWithMenuChecker("Ok Button", false); + toSpeak += "\n\tOk Button"; } else if (__instance.cancelButton.containsPoint(x, y)) { - MainClass.ScreenReader.SayWithMenuChecker("Cancel Button", false); + toSpeak += "\n\tCancel Button"; } + + MainClass.ScreenReader.SayWithMenuChecker(toSpeak, true); } catch (Exception e) { diff --git a/stardew-access/manifest.json b/stardew-access/manifest.json index 8cac695..a795d8b 100644 --- a/stardew-access/manifest.json +++ b/stardew-access/manifest.json @@ -1,7 +1,7 @@ { "Name": "Stardew Access", "Author": "Mohammad Shoaib", - "Version": "1.1.4", + "Version": "1.1.5", "Description": "An accessibility mod with screen reader support!", "UniqueID": "shoaib.stardewaccess", "EntryDll": "stardew-access.dll",