Dialogue Patch fixes

master
shoaib11120 2021-12-25 13:35:40 +05:30
parent 17d8c0d561
commit 8a288b76c5
1 changed files with 40 additions and 9 deletions

View File

@ -23,36 +23,67 @@ namespace stardew_access.Patches
// For Normal Character dialogues // For Normal Character dialogues
Dialogue dialogue = __instance.characterDialogue; Dialogue dialogue = __instance.characterDialogue;
string speakerName = dialogue.speaker.displayName; string speakerName = dialogue.speaker.displayName;
List<string> dialogues = dialogue.dialogues; string toSpeak = " ";
int dialogueIndex = dialogue.currentDialogueIndex; bool hasResponses = false;
string toSpeak = $"{speakerName} said, {dialogues[dialogueIndex]}";
if (currentDialogue != toSpeak) if (__instance.responses.Count > 0)
hasResponses = true;
if (currentDialogue != __instance.getCurrentString())
{ {
toSpeak = __instance.getCurrentString();
currentDialogue = toSpeak; 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 // For Dialogues with responses/answers like the dialogue when we click on tv
string toSpeak = " "; string toSpeak = " ";
bool hasResponses = false;
if (__instance.responses.Count > 0)
hasResponses = true;
if (currentDialogue != __instance.getCurrentString()) { if (currentDialogue != __instance.getCurrentString()) {
toSpeak = __instance.getCurrentString(); toSpeak = __instance.getCurrentString();
currentDialogue = toSpeak; currentDialogue = toSpeak;
ScreenReader.sayWithChecker(toSpeak, true);
} }
for (int i = 0; i < __instance.responses.Count; i++) for (int i = 0; i < __instance.responses.Count; i++)
{ {
if (i == __instance.selectedResponse) 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 else
{ {