MADS: Enable the optional use of TTS to read descriptions as a narrator in Rex Nebular

This commit is contained in:
neuromancer 2019-12-20 22:51:20 -03:00 committed by Filippos Karapetis
parent 4e7e0344de
commit e7ff394f33
3 changed files with 39 additions and 1 deletions

View File

@ -81,6 +81,10 @@ static const PlainGameDescriptor MADSGames[] = {
#define GAMEOPTION_NAUGHTY_MODE GUIO_GAMEOPTIONS4
//#define GAMEOPTION_GRAPHICS_DITHERING GUIO_GAMEOPTIONS5
#ifdef USE_TTS
#define GAMEOPTION_TTS_NARRATOR GUIO_GAMEOPTIONS5
#endif
#include "mads/detection_tables.h"
static const ADExtraGuiOptionsMap optionsList[] = {
@ -134,6 +138,18 @@ static const ADExtraGuiOptionsMap optionsList[] = {
}
},*/
#ifdef USE_TTS
{
GAMEOPTION_TTS_NARRATOR,
{
_s("TTS Narrator"),
_s("Use TTS to read the descriptions (if TTS is available)"),
"tts_narrator",
false
}
},
#endif
AD_EXTRA_GUI_OPTIONS_TERMINATOR
};

View File

@ -56,7 +56,11 @@ static const MADSGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
#ifdef USE_TTS
GUIO6(GUIO_NOSPEECH, GAMEOPTION_EASY_MOUSE, GAMEOPTION_ANIMATED_INVENTORY, GAMEOPTION_ANIMATED_INTERFACE, GAMEOPTION_NAUGHTY_MODE, GAMEOPTION_TTS_NARRATOR)
#else
GUIO5(GUIO_NOSPEECH, GAMEOPTION_EASY_MOUSE, GAMEOPTION_ANIMATED_INVENTORY, GAMEOPTION_ANIMATED_INTERFACE, GAMEOPTION_NAUGHTY_MODE)
#endif
},
GType_RexNebular,
0

View File

@ -26,6 +26,11 @@
#include "mads/screen.h"
#include "mads/msurface.h"
#include "mads/nebular/dialogs_nebular.h"
#include "common/config-manager.h"
#ifdef USE_TTS
#include "common/text-to-speech.h"
#endif
namespace MADS {
@ -338,6 +343,9 @@ void TextDialog::draw() {
// Draw the text lines
int lineYp = _position.y + 5;
#ifdef USE_TTS
Common::String text;
#endif
for (int lineNum = 0; lineNum <= _numLines; ++lineNum) {
if (_lineXp[lineNum] == -1) {
// Draw a line across the entire dialog
@ -353,7 +361,9 @@ void TextDialog::draw() {
if (_portrait != nullptr)
xp += _portrait->w + 5;
#ifdef USE_TTS
text += _lines[lineNum];
#endif
_font->writeString(_vm->_screen, _lines[lineNum],
Common::Point(xp, yp), 1);
@ -367,6 +377,14 @@ void TextDialog::draw() {
lineYp += _font->getHeight() + 1;
}
#ifdef USE_TTS
if (ConfMan.getBool("tts_narrator")) {
Common::TextToSpeechManager *_ttsMan = g_system->getTextToSpeechManager();
_ttsMan->stop();
_ttsMan->say(text.c_str());
}
#endif
}
void TextDialog::calculateBounds() {