GLK: Add engine options to enable TTS

This commit is contained in:
Thierry Crozat 2020-06-21 21:48:22 +01:00
parent 56f1049c21
commit ceb5299811
5 changed files with 36 additions and 3 deletions

View File

@ -1,3 +1,4 @@
engines/glk/detection.cpp
engines/glk/glk_api.cpp
engines/glk/quetzal.cpp
engines/glk/streams.cpp

View File

@ -216,7 +216,8 @@ void Conf::get(const Common::String &key, int &field, int defaultVal) {
}
void Conf::get(const Common::String &key, bool &field, bool defaultVal) {
field = ConfMan.hasKey(key) ? strToInt(ConfMan.get(key).c_str()) != 0 : defaultVal;
if (!ConfMan.hasKey(key) || !Common::parseBool(ConfMan.get(key), field))
field = defaultVal;
}
void Conf::get(const Common::String &key, FACES &field, FACES defaultFont) {

View File

@ -66,6 +66,7 @@
#include "graphics/surface.h"
#include "common/config-manager.h"
#include "common/file.h"
#include "common/translation.h"
namespace Glk {
@ -338,6 +339,27 @@ void GlkMetaEngine::detectClashes() const {
Glk::ZCode::ZCodeMetaEngine::detectClashes(map);
}
const ExtraGuiOptions GlkMetaEngine::getExtraGuiOptions(const Common::String &) const {
ExtraGuiOptions options;
#if defined(USE_TTS)
static const ExtraGuiOption ttsSpeakOptions = {
_s("Enable Text to Speech"),
_s("Use TTS to read the text"),
"speak",
false
};
static const ExtraGuiOption ttsSpeakInputOptions = {
_s("Also read input text"),
_s("Use TTS to read the input text"),
"speak_input",
false
};
options.push_back(ttsSpeakOptions);
options.push_back(ttsSpeakInputOptions);
#endif
return options;
}
SaveStateList GlkMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;

View File

@ -77,6 +77,11 @@ public:
* Calls each sub-engine in turn to ensure no game Id accidentally shares the same Id
*/
void detectClashes() const;
/**
* Return a list of extra GUI options for the specified target.
*/
const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const override;
};
namespace Glk {

View File

@ -50,11 +50,15 @@ TextBufferWindow::TextBufferWindow(Windows *windows, uint rock) : TextWindow(win
_attrs = _lines[0]._attrs;
Common::copy(&g_conf->_tStyles[0], &g_conf->_tStyles[style_NUMSTYLES], _styles);
gli_initialize_tts();
if (g_conf->_speak)
gli_initialize_tts();
}
TextBufferWindow::~TextBufferWindow() {
gli_free_tts();
if (g_conf->_speak)
gli_free_tts();
if (_inBuf) {
if (g_vm->gli_unregister_arr)
(*g_vm->gli_unregister_arr)(_inBuf, _inMax, "&+#!Cn", _inArrayRock);