SUPERNOVA: Add Text To Speech support
This commit is contained in:
parent
7db6a06e01
commit
fa8845e367
5 changed files with 53 additions and 9 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include "supernova/supernova.h"
|
#include "supernova/supernova.h"
|
||||||
|
|
||||||
#define GAMEOPTION_IMPROVED GUIO_GAMEOPTIONS1
|
#define GAMEOPTION_IMPROVED GUIO_GAMEOPTIONS1
|
||||||
|
#define GAMEOPTION_TTS GUIO_GAMEOPTIONS2
|
||||||
|
|
||||||
static const DebugChannelDef debugFlagList[] = {
|
static const DebugChannelDef debugFlagList[] = {
|
||||||
{Supernova::kDebugGeneral, "general", "Supernova general debug channel"},
|
{Supernova::kDebugGeneral, "general", "Supernova general debug channel"},
|
||||||
|
@ -45,6 +46,16 @@ static const ADExtraGuiOptionsMap optionsList[] = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
GAMEOPTION_TTS,
|
||||||
|
{
|
||||||
|
_s("Enable Text to Speech"),
|
||||||
|
_s("Use TTS to read the descriptions (if TTS is available)"),
|
||||||
|
"tts_enabled",
|
||||||
|
false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
AD_EXTRA_GUI_OPTIONS_TERMINATOR
|
AD_EXTRA_GUI_OPTIONS_TERMINATOR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +75,7 @@ static const ADGameDescription gameDescriptions[] = {
|
||||||
Common::DE_DEU,
|
Common::DE_DEU,
|
||||||
Common::kPlatformDOS,
|
Common::kPlatformDOS,
|
||||||
ADGF_NO_FLAGS,
|
ADGF_NO_FLAGS,
|
||||||
GUIO2(GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
GUIO3(GAMEOPTION_TTS, GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"msn1",
|
"msn1",
|
||||||
|
@ -73,7 +84,7 @@ static const ADGameDescription gameDescriptions[] = {
|
||||||
Common::EN_ANY,
|
Common::EN_ANY,
|
||||||
Common::kPlatformDOS,
|
Common::kPlatformDOS,
|
||||||
ADGF_NO_FLAGS,
|
ADGF_NO_FLAGS,
|
||||||
GUIO2(GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
GUIO3(GAMEOPTION_TTS, GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"msn1",
|
"msn1",
|
||||||
|
@ -82,7 +93,7 @@ static const ADGameDescription gameDescriptions[] = {
|
||||||
Common::IT_ITA,
|
Common::IT_ITA,
|
||||||
Common::kPlatformDOS,
|
Common::kPlatformDOS,
|
||||||
ADGF_NO_FLAGS,
|
ADGF_NO_FLAGS,
|
||||||
GUIO2(GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
GUIO3(GAMEOPTION_TTS, GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
||||||
},
|
},
|
||||||
// Mission Supernova 2
|
// Mission Supernova 2
|
||||||
{
|
{
|
||||||
|
@ -92,7 +103,7 @@ static const ADGameDescription gameDescriptions[] = {
|
||||||
Common::DE_DEU,
|
Common::DE_DEU,
|
||||||
Common::kPlatformDOS,
|
Common::kPlatformDOS,
|
||||||
ADGF_NO_FLAGS,
|
ADGF_NO_FLAGS,
|
||||||
GUIO2(GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
GUIO3(GAMEOPTION_TTS, GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"msn2",
|
"msn2",
|
||||||
|
@ -101,7 +112,7 @@ static const ADGameDescription gameDescriptions[] = {
|
||||||
Common::EN_ANY,
|
Common::EN_ANY,
|
||||||
Common::kPlatformDOS,
|
Common::kPlatformDOS,
|
||||||
ADGF_NO_FLAGS,
|
ADGF_NO_FLAGS,
|
||||||
GUIO2(GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
GUIO3(GAMEOPTION_TTS, GAMEOPTION_IMPROVED, GUIO_NOMIDI)
|
||||||
},
|
},
|
||||||
AD_TABLE_END_MARKER
|
AD_TABLE_END_MARKER
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
|
#include "common/config-manager.h"
|
||||||
|
#include "common/text-to-speech.h"
|
||||||
#include "graphics/cursorman.h"
|
#include "graphics/cursorman.h"
|
||||||
#include "graphics/palette.h"
|
#include "graphics/palette.h"
|
||||||
#include "gui/message.h"
|
#include "gui/message.h"
|
||||||
|
@ -360,6 +362,8 @@ void GameManager::processInput() {
|
||||||
onInventoryArrowDown
|
onInventoryArrowDown
|
||||||
} mouseLocation;
|
} mouseLocation;
|
||||||
|
|
||||||
|
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
|
||||||
|
|
||||||
if (_mouseField >= 0 && _mouseField < 256)
|
if (_mouseField >= 0 && _mouseField < 256)
|
||||||
mouseLocation = onObject;
|
mouseLocation = onObject;
|
||||||
else if (_mouseField >= 256 && _mouseField < 512)
|
else if (_mouseField >= 256 && _mouseField < 512)
|
||||||
|
@ -529,12 +533,18 @@ void GameManager::processInput() {
|
||||||
case onInventory:
|
case onInventory:
|
||||||
_guiInventory[_mouseField - 512].setHighlight(true);
|
_guiInventory[_mouseField - 512].setHighlight(true);
|
||||||
_currentInputObject = _inventory.get(_mouseField - 512 + _inventoryScroll);
|
_currentInputObject = _inventory.get(_mouseField - 512 + _inventoryScroll);
|
||||||
|
if (ttsMan != nullptr && ConfMan.getBool("tts_enabled") && !isNullObject(_currentInputObject))
|
||||||
|
ttsMan->say(_vm->getGameString(_currentInputObject->_name), Common::kDos850);
|
||||||
break;
|
break;
|
||||||
case onCmdButton:
|
case onCmdButton:
|
||||||
_guiCommandButton[_mouseField - 256].setHighlight(true);
|
_guiCommandButton[_mouseField - 256].setHighlight(true);
|
||||||
|
if (ttsMan != nullptr && ConfMan.getBool("tts_enabled"))
|
||||||
|
ttsMan->say(_guiCommandButton[_mouseField - 256].getText(), Common::kDos850);
|
||||||
break;
|
break;
|
||||||
case onObject:
|
case onObject:
|
||||||
_currentInputObject = _currentRoom->getObject(_mouseField);
|
_currentInputObject = _currentRoom->getObject(_mouseField);
|
||||||
|
if (ttsMan != nullptr && ConfMan.getBool("tts_enabled") && !isNullObject(_currentInputObject))
|
||||||
|
ttsMan->say(_vm->getGameString(_currentInputObject->_name), Common::kDos850);
|
||||||
break;
|
break;
|
||||||
case onNone:
|
case onNone:
|
||||||
default:
|
default:
|
||||||
|
@ -555,13 +565,23 @@ bool GameManager::isNullObject(Object *obj) {
|
||||||
void GameManager::sentence(int number, bool brightness) {
|
void GameManager::sentence(int number, bool brightness) {
|
||||||
if (number < 0)
|
if (number < 0)
|
||||||
return;
|
return;
|
||||||
|
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
|
||||||
|
Common::String string;
|
||||||
|
|
||||||
_vm->renderBox(0, 141 + _rowsStart[number] * 10, 320, _rows[number] * 10 - 1, brightness ? kColorWhite44 : kColorWhite25);
|
_vm->renderBox(0, 141 + _rowsStart[number] * 10, 320, _rows[number] * 10 - 1, brightness ? kColorWhite44 : kColorWhite25);
|
||||||
if (_texts[_rowsStart[number]] == kStringDialogSeparator)
|
if (_texts[_rowsStart[number]] == kStringDialogSeparator) {
|
||||||
_vm->renderText(kStringConversationEnd, 1, 142 + _rowsStart[number] * 10, brightness ? kColorRed : kColorDarkRed);
|
_vm->renderText(kStringConversationEnd, 1, 142 + _rowsStart[number] * 10, brightness ? kColorRed : kColorDarkRed);
|
||||||
else {
|
string = _vm->getGameString(kStringConversationEnd);
|
||||||
for (int r = _rowsStart[number]; r < _rowsStart[number] + _rows[number]; ++r)
|
} else {
|
||||||
|
for (int r = _rowsStart[number]; r < _rowsStart[number] + _rows[number]; ++r) {
|
||||||
_vm->renderText(_texts[r], 1, 142 + r * 10, brightness ? kColorGreen : kColorDarkGreen);
|
_vm->renderText(_texts[r], 1, 142 + r * 10, brightness ? kColorGreen : kColorDarkGreen);
|
||||||
|
if (!string.empty())
|
||||||
|
string += " ";
|
||||||
|
string += _vm->getGameString(_texts[r]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (ttsMan != nullptr && ConfMan.getBool("tts_enabled") && brightness)
|
||||||
|
ttsMan->say(string, Common::TextToSpeechManager::QUEUE_NO_REPEAT, Common::kDos850);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameManager::say(int textId) {
|
void GameManager::say(int textId) {
|
||||||
|
|
|
@ -101,6 +101,7 @@ private:
|
||||||
|
|
||||||
class GameManager {
|
class GameManager {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GameManager(SupernovaEngine *vm, Sound *sound);
|
GameManager(SupernovaEngine *vm, Sound *sound);
|
||||||
virtual ~GameManager();
|
virtual ~GameManager();
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "graphics/palette.h"
|
#include "graphics/palette.h"
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
|
#include "common/text-to-speech.h"
|
||||||
|
|
||||||
#include "supernova/imageid.h"
|
#include "supernova/imageid.h"
|
||||||
#include "supernova/resman.h"
|
#include "supernova/resman.h"
|
||||||
|
@ -286,6 +287,7 @@ void Screen::renderMessage(int stringId, MessagePosition position,
|
||||||
text = Common::String::format(text.c_str(), var1.c_str());
|
text = Common::String::format(text.c_str(), var1.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
renderMessage(text, position);
|
renderMessage(text, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,6 +532,10 @@ void Screen::renderMessage(const char *text, MessagePosition position, int posit
|
||||||
int y = 0;
|
int y = 0;
|
||||||
byte textColor = 0;
|
byte textColor = 0;
|
||||||
|
|
||||||
|
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
|
||||||
|
if (ttsMan != nullptr && ConfMan.getBool("tts_enabled"))
|
||||||
|
ttsMan->say(text, Common::TextToSpeechManager::QUEUE_NO_REPEAT, Common::kDos850);
|
||||||
|
|
||||||
while (*p != '\0') {
|
while (*p != '\0') {
|
||||||
row[numRows] = p;
|
row[numRows] = p;
|
||||||
++numRows;
|
++numRows;
|
||||||
|
|
|
@ -33,7 +33,9 @@
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/translation.h"
|
#include "common/translation.h"
|
||||||
|
#include "common/text-to-speech.h"
|
||||||
#include "engines/util.h"
|
#include "engines/util.h"
|
||||||
|
#include "engines/advancedDetector.h"
|
||||||
#include "graphics/cursorman.h"
|
#include "graphics/cursorman.h"
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
#include "graphics/screen.h"
|
#include "graphics/screen.h"
|
||||||
|
@ -99,6 +101,7 @@ SupernovaEngine::SupernovaEngine(OSystem *syst)
|
||||||
_MSPart = 0;
|
_MSPart = 0;
|
||||||
|
|
||||||
_improved = ConfMan.getBool("improved");
|
_improved = ConfMan.getBool("improved");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SupernovaEngine::~SupernovaEngine() {
|
SupernovaEngine::~SupernovaEngine() {
|
||||||
|
@ -110,6 +113,10 @@ SupernovaEngine::~SupernovaEngine() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Error SupernovaEngine::run() {
|
Common::Error SupernovaEngine::run() {
|
||||||
|
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
|
||||||
|
if (ttsMan != nullptr)
|
||||||
|
ttsMan->setLanguage(ConfMan.get("language"));
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
while (!shouldQuit()) {
|
while (!shouldQuit()) {
|
||||||
|
@ -830,5 +837,4 @@ void SupernovaEngine::stopSound() {
|
||||||
_sound->stop();
|
_sound->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue