diff options
author | Jaromir Wysoglad | 2019-07-12 12:52:18 +0200 |
---|---|---|
committer | Filippos Karapetis | 2019-09-01 22:47:55 +0300 |
commit | b5cebcbeaed5b1b860f2686379fc288c137a4c2f (patch) | |
tree | 190f839f6c3d8c3176db62db36de12715d371431 /gui/widgets/popup.cpp | |
parent | fa6faca76a35028e288753c3d74f2c81228ec5bb (diff) | |
download | scummvm-rg350-b5cebcbeaed5b1b860f2686379fc288c137a4c2f.tar.gz scummvm-rg350-b5cebcbeaed5b1b860f2686379fc288c137a4c2f.tar.bz2 scummvm-rg350-b5cebcbeaed5b1b860f2686379fc288c137a4c2f.zip |
TTS: Add text to speech to the GUI.
Diffstat (limited to 'gui/widgets/popup.cpp')
-rw-r--r-- | gui/widgets/popup.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp index a36a652e5b..fe51b39c10 100644 --- a/gui/widgets/popup.cpp +++ b/gui/widgets/popup.cpp @@ -45,6 +45,8 @@ protected: int _leftPadding; int _rightPadding; + int _lastRead; + public: PopUpDialog(PopUpWidget *boss, int clickX, int clickY); @@ -53,6 +55,7 @@ public: void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseWheel(int x, int y, int direction) override; // Scroll through entries with scroll wheel void handleMouseMoved(int x, int y, int button) override; // Redraw selections depending on mouse position + void handleMouseLeft(int button) override; void handleKeyDown(Common::KeyState state) override; // Scroll through entries with arrow keys etc. protected: @@ -64,6 +67,7 @@ protected: void moveUp(); void moveDown(); + void read(Common::String); }; PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY) @@ -145,6 +149,8 @@ PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY) // Remember original mouse position _clickX = clickX - _x; _clickY = clickY - _y; + + _lastRead = -1; } void PopUpDialog::drawDialog(DrawLayer layerToDraw) { @@ -207,6 +213,27 @@ void PopUpDialog::handleMouseMoved(int x, int y, int button) { // ...and update the selection accordingly setSelection(item); + if (_lastRead != item) { + read(_popUpBoss->_entries[item].name); + _lastRead = item; + } +} + +void PopUpDialog::handleMouseLeft(int button) { + _lastRead = -1; +} + +void PopUpDialog::read(Common::String str) { +#ifdef USE_TTS + if (ConfMan.hasKey("tts_enabled", "scummvm") && + ConfMan.getBool("tts_enabled", "scummvm")) { + int volume = (ConfMan.getInt("speech_volume", "scummvm") * 100) / 256; + if (ConfMan.hasKey("mute", "scummvm") && ConfMan.getBool("mute", "scummvm")) + volume = 0; + g_system->getTextToSpeechManager()->setVolume(volume); + g_system->getTextToSpeechManager()->say(str); + } +#endif } void PopUpDialog::handleKeyDown(Common::KeyState state) { |