Added new chat message narration
parent
655794fd17
commit
b9c29f1fed
|
@ -122,6 +122,10 @@ namespace stardew_access
|
|||
postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.CoopMenuPatch))
|
||||
);
|
||||
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(ChatBox), nameof(ChatBox.update), new Type[] { typeof(GameTime) }),
|
||||
postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.ChatBoxPatch))
|
||||
);
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -15,6 +15,26 @@ namespace stardew_access.Patches
|
|||
private static string currentLetterText = " ";
|
||||
private static string currentDailyQuestText = " ";
|
||||
|
||||
internal static void ChatBoxPatch(ChatBox __instance, List<ChatMessage> ___messages)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (___messages.Count - 1 < 0)
|
||||
return;
|
||||
|
||||
string toSpeak = "";
|
||||
___messages[___messages.Count - 1].message.ForEach(message =>
|
||||
{
|
||||
toSpeak += $"{message.message}, ";
|
||||
});
|
||||
ScreenReader.sayWithChatChecker(toSpeak, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void CoopMenuPatch(CoopMenu __instance, CoopMenu.Tab ___currentTab)
|
||||
{
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace stardew_access
|
|||
internal class ScreenReader
|
||||
{
|
||||
public static IAccessibleOutput? screenReader = null;
|
||||
internal static string prevText = "", prevTextTile = " ";
|
||||
internal static string prevText = "", prevTextTile = " ", prevChatText = "";
|
||||
|
||||
public static void initializeScreenReader()
|
||||
{
|
||||
|
@ -65,6 +65,18 @@ namespace stardew_access
|
|||
}
|
||||
}
|
||||
|
||||
public static void sayWithChatChecker(string text, bool interrupt)
|
||||
{
|
||||
if (screenReader == null)
|
||||
return;
|
||||
|
||||
if (prevChatText != text)
|
||||
{
|
||||
prevChatText = text;
|
||||
screenReader.Speak(text, interrupt);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sayWithTileQuery(string text, int x, int y, bool interrupt)
|
||||
{
|
||||
if (screenReader == null)
|
||||
|
|
Loading…
Reference in New Issue