diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 11c2c08..9634a2d 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -132,6 +132,11 @@ namespace stardew_access postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.LevelUpMenuPatch)) ); + harmony.Patch( + original: AccessTools.Method(typeof(ConfirmationDialog), nameof(ConfirmationDialog.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.ConfirmationDialogPatch)) + ); + #endregion #region Custom Commands diff --git a/stardew-access/Patches/MenuPatch.cs b/stardew-access/Patches/MenuPatch.cs index 1539efe..44a4b56 100644 --- a/stardew-access/Patches/MenuPatch.cs +++ b/stardew-access/Patches/MenuPatch.cs @@ -16,6 +16,29 @@ namespace stardew_access.Patches private static string currentDailyQuestText = " "; private static string currentLevelUpTitle = " "; + internal static void ConfirmationDialogPatch(ConfirmationDialog __instance, string ___message) + { + try + { + int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; + + if(__instance.okButton.containsPoint(x, y)) + { + ScreenReader.sayWithMenuChecker("Ok Button", false); + } else if (__instance.cancelButton.containsPoint(x, y)) + { + ScreenReader.sayWithMenuChecker("Cancel Button", false); + } else + { + ScreenReader.sayWithMenuChecker(___message, true); + } + } + catch (Exception e) + { + MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); + } + } + internal static void ChatBoxPatch(ChatBox __instance, List ___messages) { try