TTS: Fix crash when TextToSpeechManager is unavailable, clean up formatting

This commit is contained in:
Cameron Cawley 2020-05-25 18:29:41 +01:00 committed by Eugene Sandulenko
parent 30c00656e1
commit cc5abf5ebb
10 changed files with 70 additions and 54 deletions

View file

@ -553,13 +553,17 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
#endif
#ifdef USE_TTS
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr) {
ttsMan->pushState();
}
#endif
// Try to run the game
Common::Error result = runGame(plugin, system, specialDebug);
#ifdef USE_TTS
if (ttsMan != nullptr) {
ttsMan->popState();
}
#endif
#ifdef ENABLE_EVENTRECORDER

View file

@ -564,8 +564,10 @@ void Engine::openMainMenuDialog() {
_mainMenuDialog = new MainMenuDialog(this);
#ifdef USE_TTS
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr) {
ttsMan->pushState();
g_gui.initTextToSpeech();
}
#endif
setGameToLoadSlot(-1);
@ -590,6 +592,7 @@ void Engine::openMainMenuDialog() {
applyGameSettings();
syncSoundSettings();
#ifdef USE_TTS
if (ttsMan != nullptr)
ttsMan->popState();
#endif
}

View file

@ -115,7 +115,6 @@ static const LureGameDescription gameDescriptions[] = {
#else
GUIO0()
#endif
},
GF_FLOPPY | GF_EGA,
},

View file

@ -488,9 +488,11 @@ Surface *Surface::newDialog(uint16 width, uint8 numLines, const char **lines, bo
#ifdef USE_TTS
if (ConfMan.getBool("tts_narrator")) {
Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
_ttsMan->stop();
_ttsMan->say(text.c_str());
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr) {
ttsMan->stop();
ttsMan->say(text.c_str());
}
}
#endif

View file

@ -201,8 +201,9 @@ int TextDialog::estimatePieces(int maxLen) {
TextDialog::~TextDialog() {
#ifdef USE_TTS
if (ConfMan.getBool("tts_narrator")) {
Common::TextToSpeechManager* _ttsMan = g_system->getTextToSpeechManager();
_ttsMan->stop();
Common::TextToSpeechManager* ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr)
ttsMan->stop();
}
#endif
@ -389,9 +390,11 @@ void TextDialog::draw() {
#ifdef USE_TTS
if (ConfMan.getBool("tts_narrator")) {
Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
_ttsMan->stop();
_ttsMan->say(text.c_str());
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr) {
ttsMan->stop();
ttsMan->say(text.c_str());
}
}
#endif
}

View file

@ -2066,9 +2066,11 @@ void ScalpelUserInterface::printObjectDesc(const Common::String &str, bool first
#ifdef USE_TTS
if (ConfMan.getBool("tts_narrator")) {
Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
_ttsMan->stop();
_ttsMan->say(str.c_str());
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr) {
ttsMan->stop();
ttsMan->say(str.c_str());
}
}
#endif
}

View file

@ -359,9 +359,11 @@ void Talk::talkTo(const Common::String filename) {
#ifdef USE_TTS
if (_talkTo == -1 && ConfMan.getBool("tts_narrator")) {
Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
_ttsMan->stop();
_ttsMan->say(_statements[select]._reply.c_str());
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr) {
ttsMan->stop();
ttsMan->say(_statements[select]._reply.c_str());
}
}
#endif

View file

@ -200,6 +200,7 @@ void PopUpDialog::read(Common::String str) {
if (ConfMan.hasKey("tts_enabled", "scummvm") &&
ConfMan.getBool("tts_enabled", "scummvm")) {
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr)
ttsMan->say(str);
}
#endif