Skip to content

Commit

Permalink
SUPERNOVA: Localize ttsMan and tts for objects in the game
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorzhancher committed Aug 15, 2021
1 parent 1e2b0c6 commit b7ee3ac
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 23 deletions.
37 changes: 37 additions & 0 deletions engines/sci/tts.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/


#include "sci/sci.h"
#include "common/text-to-speech.h"
#include "common/config-manager.h"
#include "common/system.h"
#include "sci/graphics/controls16.h"

namespace Sci {

void TTS_SAY(const char *text) {
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
ttsMan->say(text);
}

}
31 changes: 31 additions & 0 deletions engines/sci/tts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "sci/tts.cpp"
#include "common/text-to-speech.h"
#include "common/config-manager.h"
#include "common/system.h"


namespace Sci {
void TTS_SAY(const char *text);
}
16 changes: 8 additions & 8 deletions engines/supernova/game-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void GameManager::processInput() {
onInventoryArrowDown
} mouseLocation;

_ttsMan = g_system->getTextToSpeechManager();
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();

if (_mouseField >= 0 && _mouseField < 256)
mouseLocation = onObject;
Expand Down Expand Up @@ -529,19 +529,20 @@ void GameManager::processInput() {
case onInventoryArrowDown:
// Fallthrough
_guiInventoryArrow[_mouseField - 768].setHighlight(true);
_ttsMan->say(_guiInventoryArrow[_mouseField - 768].getText(), Common::TextToSpeechManager::INTERRUPT_NO_REPEAT, Common::kDos850);
break;
case onInventory:
_guiInventory[_mouseField - 512].setHighlight(true);
_currentInputObject = _inventory.get(_mouseField - 512 + _inventoryScroll);
_ttsMan->say(_guiInventory[_mouseField - 512].getText(), Common::TextToSpeechManager::INTERRUPT_NO_REPEAT, Common::kDos850);
break;
case onCmdButton:
_guiCommandButton[_mouseField - 256].setHighlight(true);
_ttsMan->say(_guiCommandButton[_mouseField - 256].getText(), Common::TextToSpeechManager::INTERRUPT_NO_REPEAT, Common::kDos850);
if (ttsMan != nullptr && ConfMan.getBool("tts_enabled"))
ttsMan->say(_guiCommandButton[_mouseField - 256].getText(), Common::kDos850);
break;
case onObject:
_currentInputObject = _currentRoom->getObject(_mouseField);
if (!isNullObject(_currentInputObject))
ttsMan->say(_vm->getGameString(_currentInputObject->_name), Common::kDos850);
break;
case onNone:
default:
Expand All @@ -562,8 +563,7 @@ bool GameManager::isNullObject(Object *obj) {
void GameManager::sentence(int number, bool brightness) {
if (number < 0)
return;

_ttsMan = g_system->getTextToSpeechManager();
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
Common::String string;

_vm->renderBox(0, 141 + _rowsStart[number] * 10, 320, _rows[number] * 10 - 1, brightness ? kColorWhite44 : kColorWhite25);
Expand All @@ -578,8 +578,8 @@ void GameManager::sentence(int number, bool brightness) {
string += _vm->getGameString(_texts[r]);
}
}
if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled") && brightness)
_ttsMan->say(string, Common::TextToSpeechManager::QUEUE_NO_REPEAT, Common::kDos850);
if (ttsMan != nullptr && ConfMan.getBool("tts_enabled") && brightness)
ttsMan->say(string, Common::TextToSpeechManager::QUEUE_NO_REPEAT, Common::kDos850);
}

void GameManager::say(int textId) {
Expand Down
1 change: 0 additions & 1 deletion engines/supernova/game-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class GuiElement : public Common::Rect {

class GameManager {
public:
Common::TextToSpeechManager *_ttsMan;

GameManager(SupernovaEngine *vm, Sound *sound);
virtual ~GameManager();
Expand Down
6 changes: 3 additions & 3 deletions engines/supernova/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ void Screen::renderMessage(const char *text, MessagePosition position, int posit
int y = 0;
byte textColor = 0;

_ttsMan = g_system->getTextToSpeechManager();
if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled"))
_ttsMan->say(text, Common::TextToSpeechManager::QUEUE_NO_REPEAT, Common::kDos850);
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') {
row[numRows] = p;
Expand Down
2 changes: 0 additions & 2 deletions engines/supernova/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ class Screen {
void update();
void changeCursor(ResourceManager::CursorId);

Common::TextToSpeechManager *_ttsMan;

private:
void renderImageSection(const MSNImage *image, int section, bool invert);

Expand Down
10 changes: 3 additions & 7 deletions engines/supernova/supernova.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ SupernovaEngine::SupernovaEngine(OSystem *syst)

_improved = ConfMan.getBool("improved");

_ttsMan = g_system->getTextToSpeechManager();
}

SupernovaEngine::~SupernovaEngine() {
Expand All @@ -114,8 +113,9 @@ SupernovaEngine::~SupernovaEngine() {
}

Common::Error SupernovaEngine::run() {
// if (_ttsMan != nullptr)
// _ttsMan->setLanguage(Common::getLanguageCode(getLanguage()));
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
if (ttsMan != nullptr)
ttsMan->setLanguage(ConfMan.get("language"));

init();

Expand Down Expand Up @@ -837,8 +837,4 @@ void SupernovaEngine::stopSound() {
_sound->stop();
}

// Common::Language SupernovaEngine::getLanguage() const {
// return _gameDescription->language;
// }

}
2 changes: 0 additions & 2 deletions engines/supernova/supernova.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ class SupernovaEngine : public Engine {
void renderBox(const GuiElement &guiElement);
void setColor63(byte value);
void stopSound();
// Common::Language getLanguage() const;
Common::TextToSpeechManager *_ttsMan;
};

}
Expand Down

0 comments on commit b7ee3ac

Please sign in to comment.