From 9432b3420ba328c12aec285d901999d129728cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Thu, 12 Jun 2025 20:23:47 +0000 Subject: [PATCH] tts: only announce timer at 10s intervals (#5559) * tts: only announce timer at 30s 1. reading out every second doesn't have enough time to even say more than a number 2. tts is hard to hear the rest of the game over while it's counting non stop * under a minute announce every 10s --- soh/soh/Enhancements/tts/tts.cpp | 39 +++++++++++++++----------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index b8a43453f..978e5ca24 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -147,28 +147,25 @@ void RegisterOnInterfaceUpdateHook() { timer = gSaveContext.subTimerSeconds; } - if (timer > 0) { - if (timer > prevTimer || (timer % 30 == 0 && prevTimer != timer)) { - uint32_t minutes = timer / 60; - uint32_t seconds = timer % 60; - char* announceBuf = ttsAnnounceBuf; - char arg[8]; // at least big enough where no s8 string will overflow - if (minutes > 0) { - snprintf(arg, sizeof(arg), "%d", minutes); - auto translation = GetParameritizedText((minutes > 1) ? "minutes_plural" : "minutes_singular", - TEXT_BANK_MISC, arg); - announceBuf += snprintf(announceBuf, sizeof(ttsAnnounceBuf), "%s ", translation.c_str()); - } - if (seconds > 0) { - snprintf(arg, sizeof(arg), "%d", seconds); - auto translation = GetParameritizedText((seconds > 1) ? "seconds_plural" : "seconds_singular", - TEXT_BANK_MISC, arg); - announceBuf += snprintf(announceBuf, sizeof(ttsAnnounceBuf), "%s", translation.c_str()); - } - assert(announceBuf < ttsAnnounceBuf + sizeof(ttsAnnounceBuf)); - SpeechSynthesizer::Instance->Speak(ttsAnnounceBuf, GetLanguageCode()); - prevTimer = timer; + if (timer > 0 && timer % (timer < 60 ? 10 : 30) == 0 && timer != prevTimer) { + uint32_t minutes = timer / 60; + uint32_t seconds = timer % 60; + char* announceBuf = ttsAnnounceBuf; + char arg[8]; // at least big enough where no s8 string will overflow + if (minutes > 0) { + snprintf(arg, sizeof(arg), "%d", minutes); + auto translation = + GetParameritizedText((minutes > 1) ? "minutes_plural" : "minutes_singular", TEXT_BANK_MISC, arg); + announceBuf += snprintf(announceBuf, sizeof(ttsAnnounceBuf), "%s ", translation.c_str()); } + if (seconds > 0) { + snprintf(arg, sizeof(arg), "%d", seconds); + auto translation = + GetParameritizedText((seconds > 1) ? "seconds_plural" : "seconds_singular", TEXT_BANK_MISC, arg); + announceBuf += snprintf(announceBuf, sizeof(ttsAnnounceBuf), "%s", translation.c_str()); + } + assert(announceBuf < ttsAnnounceBuf + sizeof(ttsAnnounceBuf)); + SpeechSynthesizer::Instance->Speak(ttsAnnounceBuf, GetLanguageCode()); } prevTimer = timer;