TTS: Add correct language switching

This commit is contained in:
Jaromir Wysoglad 2019-07-14 23:39:26 +02:00 committed by Filippos Karapetis
parent 5ee30a1b73
commit 5e44796d6b
2 changed files with 19 additions and 13 deletions

View file

@ -625,16 +625,21 @@ void GuiManager::setLastMousePos(int16 x, int16 y) {
#ifdef USE_TTS
void GuiManager::initTextToSpeech() {
#if defined(USE_TRANSLATION) && defined(USE_LINUX_TTS)
if(ConfMan.hasKey("gui_language") && ConfMan.get("gui_language") != "C")
warning("TTS on linux is supported only for english");
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
#ifdef USE_TRANSLATION
Common::String currentLanguage = TransMan.getCurrentLanguage();
if (currentLanguage != "C") {
currentLanguage.setChar('\0', 2);
debug("%s", TransMan.getCurrentCharset().c_str());
ttsMan->setLanguage(currentLanguage);
}
#endif
int voice;
if(ConfMan.hasKey("tts_voice"))
voice = ConfMan.getInt("tts_voice", "scummvm");
else
voice = 0;
g_system->getTextToSpeechManager()->setVoice(voice);
ttsMan->setVoice(voice);
}
#endif

View file

@ -2149,19 +2149,20 @@ void GlobalOptionsDialog::apply() {
error.runModal();
}
#ifdef USE_TTS
bool ttsCheckboxChanged = _ttsCheckbox->getState() &&
(!ConfMan.hasKey("tts_enabled") || !ConfMan.getBool("tts_enabled"));
bool languageChanged = (newLang != oldLang);
if (ttsCheckboxChanged || languageChanged) {
#if defined(USE_TRANSLATION) && defined(USE_LINUX_TTS)
if (ConfMan.get("gui_language") != "C")
warning("TTS on linux is supported only for english");
#endif
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (newLang != oldLang) {
if (newLang == "C")
ttsMan->setLanguage("en");
else {
Common::String guiLang = newLang;
guiLang.setChar('\0', 2);
ttsMan->setLanguage(guiLang);
}
}
ConfMan.setBool("tts_enabled", _ttsCheckbox->getState(), _domain);
int selectedVoice = _ttsVoiceSelectionPopUp->getSelectedTag();
ConfMan.setInt("tts_voice", selectedVoice, _domain);
g_system->getTextToSpeechManager()->setVoice(selectedVoice);
ttsMan->setVoice(selectedVoice);
#endif
if (isRebuildNeeded) {