From 0b96c72137d5aa689836ad471edcf40894632fee Mon Sep 17 00:00:00 2001 From: shoaib11120 Date: Wed, 29 Dec 2021 19:57:22 +0530 Subject: [PATCH] Potential fix for Leos's problem "I dont know the reproducing step for this but, sometimes when i go to the seed shop, this message keeps looping when i talk to piere to buy things. Welcome to Pierre's! Need some supplies?" --- stardew-access/Patches/DialoguePatcher.cs | 8 +++++++- stardew-access/ScreenReader.cs | 14 +++++++++++++- stardew-access/manifest.json | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/stardew-access/Patches/DialoguePatcher.cs b/stardew-access/Patches/DialoguePatcher.cs index 27ef816..6733fae 100644 --- a/stardew-access/Patches/DialoguePatcher.cs +++ b/stardew-access/Patches/DialoguePatcher.cs @@ -199,7 +199,13 @@ namespace stardew_access.Patches #endregion #region Narrate toSpeak - ScreenReader.sayWithChecker(toSpeak.ToString(), true); + + // To prevent it from getting conflicted by two hover texts at the same time, two seperate methods are used. + // For example, sometimes `Welcome to Pierre's` and the items in seeds shop get conflicted causing it to speak infinitely. + if(Context.IsPlayerFree) + ScreenReader.sayWithChecker(toSpeak.ToString(), true); // Normal Checker + else + ScreenReader.sayWithMenuChecker(toSpeak.ToString(), true); // Normal Checker #endregion } catch (Exception e) diff --git a/stardew-access/ScreenReader.cs b/stardew-access/ScreenReader.cs index 557742d..a526ff2 100644 --- a/stardew-access/ScreenReader.cs +++ b/stardew-access/ScreenReader.cs @@ -6,7 +6,7 @@ namespace stardew_access internal class ScreenReader { public static IAccessibleOutput? screenReader = null; - internal static string prevText = "", prevTextTile = " ", prevChatText = ""; + internal static string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = ""; public static void initializeScreenReader() { @@ -65,6 +65,18 @@ namespace stardew_access } } + public static void sayWithMenuChecker(string text, bool interrupt) + { + if (screenReader == null) + return; + + if (prevMenuText != text) + { + prevMenuText = text; + screenReader.Speak(text, interrupt); + } + } + public static void sayWithChatChecker(string text, bool interrupt) { if (screenReader == null) diff --git a/stardew-access/manifest.json b/stardew-access/manifest.json index 94abb5c..0559b8b 100644 --- a/stardew-access/manifest.json +++ b/stardew-access/manifest.json @@ -1,7 +1,7 @@ { "Name": "Stardew Access", "Author": "Mohammad Shoaib", - "Version": "1.0.10-beta", + "Version": "1.0.11-beta", "Description": "An accessibility mod with screen reader support!", "UniqueID": "shoaib.stardewaccess", "EntryDll": "stardew-access.dll",