diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index fc08646..35db304 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -159,17 +159,17 @@ namespace stardew_access harmony.Patch( original: AccessTools.Method(typeof(MineElevatorMenu), nameof(MineElevatorMenu.draw), new Type[] { typeof(SpriteBatch) }), - postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.MineElevatorMenuPatch)) + postfix: new HarmonyMethod(typeof(MineElevatorMenuPatch), nameof(MineElevatorMenuPatch.DrawPatch)) ); harmony.Patch( original: AccessTools.Method(typeof(LanguageSelectionMenu), nameof(LanguageSelectionMenu.draw), new Type[] { typeof(SpriteBatch) }), - postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.LanguageSelectionMenuPatch)) + postfix: new HarmonyMethod(typeof(LanguageSelectionMenuPatch), nameof(LanguageSelectionMenuPatch.DrawPatch)) ); harmony.Patch( original: AccessTools.Method(typeof(ChooseFromListMenu), nameof(ChooseFromListMenu.draw), new Type[] { typeof(SpriteBatch) }), - postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.ChooseFromListMenuPatch)) + postfix: new HarmonyMethod(typeof(ChooseFromListMenuPatch), nameof(ChooseFromListMenuPatch.DrawPatch)) ); harmony.Patch( diff --git a/stardew-access/Patches/ChooseFromListMenuPatch.cs b/stardew-access/Patches/ChooseFromListMenuPatch.cs new file mode 100644 index 0000000..2e19781 --- /dev/null +++ b/stardew-access/Patches/ChooseFromListMenuPatch.cs @@ -0,0 +1,32 @@ +using StardewValley; +using StardewValley.Menus; + +namespace stardew_access.Patches +{ + internal class ChooseFromListMenuPatch + { + internal static void DrawPatch(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}"); + } + } + } +} diff --git a/stardew-access/Patches/LanguageSelectionMenuPatch.cs b/stardew-access/Patches/LanguageSelectionMenuPatch.cs new file mode 100644 index 0000000..968a171 --- /dev/null +++ b/stardew-access/Patches/LanguageSelectionMenuPatch.cs @@ -0,0 +1,41 @@ +using StardewValley; +using StardewValley.Menus; + +namespace stardew_access.Patches +{ + internal class LanguageSelectionMenuPatch + { + internal static void DrawPatch(LanguageSelectionMenu __instance) + { + try + { + int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position + + if (__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y)) + { + MainClass.ScreenReader.SayWithMenuChecker($"Next Page Button", true); + return; + } + + if (__instance.previousPageButton != null && __instance.previousPageButton.containsPoint(x, y)) + { + MainClass.ScreenReader.SayWithMenuChecker($"Previous Page Button", true); + return; + } + + for (int i = 0; i < __instance.languages.Count; i++) + { + if (__instance.languages[i].containsPoint(x, y)) + { + MainClass.ScreenReader.SayWithMenuChecker($"{__instance.languageList[i]} Button", true); + break; + } + } + } + catch (Exception e) + { + MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); + } + } + } +} diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index 420073d..6e343cd 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -13,82 +13,8 @@ namespace stardew_access.Patches internal static bool firstTimeInNamingMenu = true; internal static int prevSlotIndex = -999; - 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 LanguageSelectionMenuPatch(LanguageSelectionMenu __instance) - { - try - { - int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - - if (__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y)) - { - MainClass.ScreenReader.SayWithMenuChecker($"Next Page Button", true); - return; - } - - if (__instance.previousPageButton != null && __instance.previousPageButton.containsPoint(x, y)) - { - MainClass.ScreenReader.SayWithMenuChecker($"Previous Page Button", true); - return; - } - - for (int i = 0; i < __instance.languages.Count; i++) - { - if (__instance.languages[i].containsPoint(x, y)) - { - MainClass.ScreenReader.SayWithMenuChecker($"{__instance.languageList[i]} Button", true); - break; - } - } - } - catch (Exception e) - { - MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); - } - } - - internal static void MineElevatorMenuPatch(List ___elevators) - { - try - { - int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - for (int i = 0; i < ___elevators.Count; i++) - { - if (___elevators[i].containsPoint(x, y)) - { - MainClass.ScreenReader.SayWithMenuChecker($"{___elevators[i].name} level", true); - break; - } - } - } - catch (Exception e) - { - MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); - } - } internal static void TitleTextInputMenuPatch(TitleTextInputMenu __instance) { diff --git a/stardew-access/Patches/MineElevatorMenuPatch.cs b/stardew-access/Patches/MineElevatorMenuPatch.cs new file mode 100644 index 0000000..c1110f1 --- /dev/null +++ b/stardew-access/Patches/MineElevatorMenuPatch.cs @@ -0,0 +1,28 @@ +using StardewValley; +using StardewValley.Menus; + +namespace stardew_access.Patches +{ + internal class MineElevatorMenuPatch + { + internal static void DrawPatch(List ___elevators) + { + try + { + int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position + for (int i = 0; i < ___elevators.Count; i++) + { + if (___elevators[i].containsPoint(x, y)) + { + MainClass.ScreenReader.SayWithMenuChecker($"{___elevators[i].name} level", true); + break; + } + } + } + catch (Exception e) + { + MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); + } + } + } +}