From 408cdbde665d4da9ab17de3cbecbbfc5e528fb1b Mon Sep 17 00:00:00 2001 From: shoaib11120 Date: Fri, 31 Dec 2021 20:45:52 +0530 Subject: [PATCH] Added naming menu title narration --- stardew-access/ModEntry.cs | 5 +++++ stardew-access/Patches/MenuPatch.cs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 97cfd5c..01721a0 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -137,6 +137,11 @@ namespace stardew_access postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.ConfirmationDialogPatch)) ); + harmony.Patch( + original: AccessTools.Constructor(typeof(NamingMenu), new Type[] { typeof(NamingMenu.doneNamingBehavior), typeof(string), typeof(string) }), + postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.NamingMenuPatch)) + ); + #endregion #region Custom Commands diff --git a/stardew-access/Patches/MenuPatch.cs b/stardew-access/Patches/MenuPatch.cs index 7243f73..ab544ee 100644 --- a/stardew-access/Patches/MenuPatch.cs +++ b/stardew-access/Patches/MenuPatch.cs @@ -17,6 +17,22 @@ namespace stardew_access.Patches private static string currentLevelUpTitle = " "; private const int MAX_COMPONENTS = 20; + internal static void NamingMenuPatch(NamingMenu __instance, string title, TextBox ___textBox) + { + try + { + __instance.textBoxCC.snapMouseCursor(); + ___textBox.SelectMe(); + string toSpeak = $"{title}"; + + ScreenReader.sayWithChecker(toSpeak, true); + } + catch (Exception e) + { + MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); + } + } + internal static void ConfirmationDialogPatch(ConfirmationDialog __instance, string ___message) { try