diff --git a/base/main.cpp b/base/main.cpp index 3b80eed7d03..5307b76af1e 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -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(); - ttsMan->pushState(); + if (ttsMan != nullptr) { + ttsMan->pushState(); + } #endif // Try to run the game Common::Error result = runGame(plugin, system, specialDebug); #ifdef USE_TTS - ttsMan->popState(); + if (ttsMan != nullptr) { + ttsMan->popState(); + } #endif #ifdef ENABLE_EVENTRECORDER diff --git a/engines/engine.cpp b/engines/engine.cpp index c660d698681..658bc47866a 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -564,8 +564,10 @@ void Engine::openMainMenuDialog() { _mainMenuDialog = new MainMenuDialog(this); #ifdef USE_TTS Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager(); - ttsMan->pushState(); - g_gui.initTextToSpeech(); + if (ttsMan != nullptr) { + ttsMan->pushState(); + g_gui.initTextToSpeech(); + } #endif setGameToLoadSlot(-1); @@ -590,7 +592,8 @@ void Engine::openMainMenuDialog() { applyGameSettings(); syncSoundSettings(); #ifdef USE_TTS - ttsMan->popState(); + if (ttsMan != nullptr) + ttsMan->popState(); #endif } diff --git a/engines/lure/detection.cpp b/engines/lure/detection.cpp index d7337282635..9f397dcc45e 100644 --- a/engines/lure/detection.cpp +++ b/engines/lure/detection.cpp @@ -93,11 +93,11 @@ static const LureGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, - #ifdef USE_TTS - GUIO1(GAMEOPTION_TTS_NARRATOR) - #else - GUIO0() - #endif +#ifdef USE_TTS + GUIO1(GAMEOPTION_TTS_NARRATOR) +#else + GUIO0() +#endif }, GF_FLOPPY, }, @@ -110,12 +110,11 @@ static const LureGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, - #ifdef USE_TTS - GUIO1(GAMEOPTION_TTS_NARRATOR) - #else - GUIO0() - #endif - +#ifdef USE_TTS + GUIO1(GAMEOPTION_TTS_NARRATOR) +#else + GUIO0() +#endif }, GF_FLOPPY | GF_EGA, }, @@ -235,9 +234,9 @@ static const LureGameDescription gameDescriptions[] = { class LureMetaEngine : public AdvancedMetaEngine { public: LureMetaEngine() : AdvancedMetaEngine(Lure::gameDescriptions, sizeof(Lure::LureGameDescription), lureGames - #ifdef USE_TTS +#ifdef USE_TTS , optionsList - #endif +#endif ) { _md5Bytes = 1024; diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp index 9881256502d..ad5d0e4d96b 100644 --- a/engines/lure/surface.cpp +++ b/engines/lure/surface.cpp @@ -472,27 +472,29 @@ Surface *Surface::newDialog(uint16 width, uint8 numLines, const char **lines, bo Surface *s = new Surface(width, size.y); s->createDialog(); - #ifdef USE_TTS +#ifdef USE_TTS Common::String text; - #endif +#endif uint16 yP = Surface::textY(); for (uint8 ctr = 0; ctr < numLines; ++ctr) { - #ifdef USE_TTS +#ifdef USE_TTS text += lines[ctr]; - #endif +#endif s->writeString(Surface::textX(), yP, lines[ctr], true, color, varLength); yP += squashedLines ? FONT_HEIGHT - 1 : FONT_HEIGHT; } - #ifdef USE_TTS +#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 +#endif return s; } diff --git a/engines/mads/detection.cpp b/engines/mads/detection.cpp index 6cd44c107a2..fe65446cac4 100644 --- a/engines/mads/detection.cpp +++ b/engines/mads/detection.cpp @@ -138,7 +138,7 @@ static const ADExtraGuiOptionsMap optionsList[] = { } },*/ - #ifdef USE_TTS +#ifdef USE_TTS { GAMEOPTION_TTS_NARRATOR, { @@ -148,7 +148,7 @@ static const ADExtraGuiOptionsMap optionsList[] = { false } }, - #endif +#endif AD_EXTRA_GUI_OPTIONS_TERMINATOR }; diff --git a/engines/mads/detection_tables.h b/engines/mads/detection_tables.h index ad2a4ca2285..14ca68ca3d9 100644 --- a/engines/mads/detection_tables.h +++ b/engines/mads/detection_tables.h @@ -56,11 +56,11 @@ static const MADSGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, - #ifdef USE_TTS +#ifdef USE_TTS GUIO6(GUIO_NOSPEECH, GAMEOPTION_EASY_MOUSE, GAMEOPTION_ANIMATED_INVENTORY, GAMEOPTION_ANIMATED_INTERFACE, GAMEOPTION_NAUGHTY_MODE, GAMEOPTION_TTS_NARRATOR) - #else +#else GUIO5(GUIO_NOSPEECH, GAMEOPTION_EASY_MOUSE, GAMEOPTION_ANIMATED_INVENTORY, GAMEOPTION_ANIMATED_INTERFACE, GAMEOPTION_NAUGHTY_MODE) - #endif +#endif }, GType_RexNebular, 0 diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 5141e317183..cadb7ae0f03 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -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 @@ -350,9 +351,9 @@ void TextDialog::draw() { // Draw the text lines int lineYp = _position.y + 5; - #ifdef USE_TTS +#ifdef USE_TTS Common::String text; - #endif +#endif for (int lineNum = 0; lineNum <= _numLines; ++lineNum) { if (_lineXp[lineNum] == -1) { // Draw a line across the entire dialog @@ -387,13 +388,15 @@ void TextDialog::draw() { lineYp += _font->getHeight() + 1; } - #ifdef USE_TTS +#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 +#endif } void TextDialog::calculateBounds() { diff --git a/engines/sherlock/scalpel/scalpel_user_interface.cpp b/engines/sherlock/scalpel/scalpel_user_interface.cpp index 20ba4f53fa1..f819acf7f11 100644 --- a/engines/sherlock/scalpel/scalpel_user_interface.cpp +++ b/engines/sherlock/scalpel/scalpel_user_interface.cpp @@ -2064,13 +2064,15 @@ void ScalpelUserInterface::printObjectDesc(const Common::String &str, bool first SHERLOCK_SCREEN_HEIGHT)); } - #ifdef USE_TTS +#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 +#endif } void ScalpelUserInterface::printObjectDesc() { diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp index ec20f807df1..f92b7c142a9 100644 --- a/engines/sherlock/talk.cpp +++ b/engines/sherlock/talk.cpp @@ -356,14 +356,16 @@ void Talk::talkTo(const Common::String filename) { // Make a copy of the statement (in case the script frees the statement list), and then execute it Statement statement = _statements[select]; - - #ifdef USE_TTS + +#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()); - } - #endif + Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager(); + if (ttsMan != nullptr) { + ttsMan->stop(); + ttsMan->say(_statements[select]._reply.c_str()); + } + } +#endif doScript(_statements[select]._reply); diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp index aa87e1e8355..1931cb28ded 100644 --- a/gui/widgets/popup.cpp +++ b/gui/widgets/popup.cpp @@ -200,7 +200,8 @@ void PopUpDialog::read(Common::String str) { if (ConfMan.hasKey("tts_enabled", "scummvm") && ConfMan.getBool("tts_enabled", "scummvm")) { Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager(); - ttsMan->say(str); + if (ttsMan != nullptr) + ttsMan->say(str); } #endif }