From 8a288b76c5d8277829f4604e634f1f3d1d35fbe8 Mon Sep 17 00:00:00 2001 From: shoaib11120 Date: Sat, 25 Dec 2021 13:35:40 +0530 Subject: [PATCH] Dialogue Patch fixes --- stardew-access/Patches/DialoguePatcher.cs | 49 ++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/stardew-access/Patches/DialoguePatcher.cs b/stardew-access/Patches/DialoguePatcher.cs index bfd6a4f..61d9b2b 100644 --- a/stardew-access/Patches/DialoguePatcher.cs +++ b/stardew-access/Patches/DialoguePatcher.cs @@ -23,36 +23,67 @@ namespace stardew_access.Patches // For Normal Character dialogues Dialogue dialogue = __instance.characterDialogue; string speakerName = dialogue.speaker.displayName; - List dialogues = dialogue.dialogues; - int dialogueIndex = dialogue.currentDialogueIndex; - string toSpeak = $"{speakerName} said, {dialogues[dialogueIndex]}"; + string toSpeak = " "; + bool hasResponses = false; - if (currentDialogue != toSpeak) + if (__instance.responses.Count > 0) + hasResponses = true; + + if (currentDialogue != __instance.getCurrentString()) { + toSpeak = __instance.getCurrentString(); currentDialogue = toSpeak; - ScreenReader.say(toSpeak, true); + toSpeak = $"{speakerName} said {toSpeak}"; + } + + if (__instance.responses.Count > 0) + { + for (int i = 0; i < __instance.responses.Count; i++) + { + if (i == __instance.selectedResponse) + { + toSpeak += $" \t\n Selected response: {__instance.responses[i].responseText}"; + } + } + } + + if (toSpeak != " ") + { + if (hasResponses) + ScreenReader.sayWithChecker(toSpeak, false); + else + ScreenReader.sayWithChecker(toSpeak, true); } } - else if (__instance.isQuestion || __instance.responses.Count > 0) + else if (__instance.isQuestion) { // For Dialogues with responses/answers like the dialogue when we click on tv string toSpeak = " "; + bool hasResponses = false; + + if (__instance.responses.Count > 0) + hasResponses = true; if (currentDialogue != __instance.getCurrentString()) { toSpeak = __instance.getCurrentString(); currentDialogue = toSpeak; - ScreenReader.sayWithChecker(toSpeak, true); } for (int i = 0; i < __instance.responses.Count; i++) { if (i == __instance.selectedResponse) { - toSpeak = $" \t\n Selected response: {__instance.responses[i].responseText}"; + toSpeak += $" \t\n Selected response: {__instance.responses[i].responseText}"; } } - ScreenReader.sayWithChecker(toSpeak, false); + if (toSpeak != " ") + { + if (hasResponses) + ScreenReader.sayWithChecker(toSpeak, false); + else + ScreenReader.sayWithChecker(toSpeak, true); + } } else {