Initial commit
This commit is contained in:
278
engines/dreamweb/talk.cpp
Normal file
278
engines/dreamweb/talk.cpp
Normal file
@@ -0,0 +1,278 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "dreamweb/sound.h"
|
||||
#include "dreamweb/dreamweb.h"
|
||||
#include "common/text-to-speech.h"
|
||||
#include "common/config-manager.h"
|
||||
|
||||
namespace DreamWeb {
|
||||
|
||||
void DreamWebEngine::talk() {
|
||||
_talkPos = 0;
|
||||
_inMapArea = 0;
|
||||
_character = _command;
|
||||
createPanel();
|
||||
showPanel();
|
||||
showMan();
|
||||
showExit();
|
||||
underTextLine();
|
||||
convIcons();
|
||||
startTalk();
|
||||
_commandType = 255;
|
||||
readMouse();
|
||||
showPointer();
|
||||
workToScreen();
|
||||
|
||||
RectWithCallback talkList[] = {
|
||||
{ 273,320,157,198,&DreamWebEngine::getBack1 },
|
||||
{ 240,290,2,44,&DreamWebEngine::moreTalk },
|
||||
{ 0,320,0,200,&DreamWebEngine::blank },
|
||||
{ 0xFFFF,0,0,0,nullptr }
|
||||
};
|
||||
|
||||
do {
|
||||
delPointer();
|
||||
readMouse();
|
||||
animPointer();
|
||||
showPointer();
|
||||
waitForVSync();
|
||||
dumpPointer();
|
||||
dumpTextLine();
|
||||
_getBack = 0;
|
||||
checkCoords(talkList);
|
||||
if (_quitRequested)
|
||||
break;
|
||||
} while (!_getBack);
|
||||
|
||||
if (_talkPos >= 4)
|
||||
_personData->b7 |= 128;
|
||||
|
||||
redrawMainScrn();
|
||||
workToScreenM();
|
||||
if (_speechLoaded) {
|
||||
_sound->cancelCh1();
|
||||
_sound->volumeChange(0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void DreamWebEngine::convIcons() {
|
||||
uint8 index = _character & 127;
|
||||
uint16 frame = getPersFrame(index);
|
||||
const GraphicsFile *base = findSource(frame);
|
||||
showFrame(*base, 234, 2, frame, 0);
|
||||
}
|
||||
|
||||
uint16 DreamWebEngine::getPersFrame(uint8 index) {
|
||||
return READ_LE_UINT16(&_personFramesLE[index]);
|
||||
}
|
||||
|
||||
void DreamWebEngine::startTalk() {
|
||||
_talkMode = 0;
|
||||
|
||||
const uint8 *str = getPersonText(_character & 0x7F, 0);
|
||||
uint16 y;
|
||||
|
||||
_charShift = 91+91;
|
||||
|
||||
if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_speech")) {
|
||||
const char *text = (const char *)str;
|
||||
const char *goodText = strchr(text, ':') + 1;
|
||||
_ttsMan->say(goodText, _textEncoding);
|
||||
}
|
||||
|
||||
if (getLanguage() == Common::RU_RUS)
|
||||
useCharsetIcons1();
|
||||
|
||||
y = 64;
|
||||
printDirect(&str, 66, &y, 241, true);
|
||||
|
||||
if (getLanguage() == Common::RU_RUS)
|
||||
resetCharset();
|
||||
|
||||
_charShift = 0;
|
||||
y = 80;
|
||||
printDirect(&str, 66, &y, 241, true);
|
||||
|
||||
if (hasSpeech()) {
|
||||
_speechLoaded = _sound->loadSpeech('R', _realLocation, 'C', 64*(_character & 0x7F));
|
||||
if (_speechLoaded) {
|
||||
_sound->volumeChange(6, 1);
|
||||
_sound->playChannel1(62);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const uint8 *DreamWebEngine::getPersonText(uint8 index, uint8 talkPos) {
|
||||
const uint8 *text = (const uint8 *)_personText.getString(index*64 + talkPos);
|
||||
if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_speech"))
|
||||
_ttsMan->say((const char *)text, Common::TextToSpeechManager::INTERRUPT, _textEncoding);
|
||||
return text;
|
||||
}
|
||||
|
||||
void DreamWebEngine::moreTalk() {
|
||||
if (_talkMode != 0) {
|
||||
redes();
|
||||
return;
|
||||
}
|
||||
|
||||
commandOnlyCond(49, 215);
|
||||
|
||||
if (_mouseButton == _oldButton)
|
||||
return; // nomore
|
||||
|
||||
if (!(_mouseButton & 1))
|
||||
return;
|
||||
|
||||
_talkMode = 2;
|
||||
_talkPos = 4;
|
||||
|
||||
if (_character >= 100)
|
||||
_talkPos = 48; // second part
|
||||
doSomeTalk();
|
||||
}
|
||||
|
||||
void DreamWebEngine::doSomeTalk() {
|
||||
// FIXME: This is for the CD version only
|
||||
|
||||
while (true) {
|
||||
const uint8 *str = getPersonText(_character & 0x7F, _talkPos);
|
||||
|
||||
if (*str == 0) {
|
||||
// endheartalk
|
||||
_pointerMode = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
createPanel();
|
||||
showPanel();
|
||||
showMan();
|
||||
showExit();
|
||||
convIcons();
|
||||
|
||||
printDirect(str, 164, 64, 144, false);
|
||||
|
||||
_speechLoaded = _sound->loadSpeech('R', _realLocation, 'C', (64 * (_character & 0x7F)) + _talkPos);
|
||||
if (_speechLoaded)
|
||||
_sound->playChannel1(62);
|
||||
|
||||
_pointerMode = 3;
|
||||
workToScreenM();
|
||||
if (hangOnPQ())
|
||||
return;
|
||||
|
||||
_talkPos++;
|
||||
|
||||
str = getPersonText(_character & 0x7F, _talkPos);
|
||||
if (*str == 0) {
|
||||
// endheartalk
|
||||
_pointerMode = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (*str != ':' && *str != 32) {
|
||||
createPanel();
|
||||
showPanel();
|
||||
showMan();
|
||||
showExit();
|
||||
convIcons();
|
||||
printDirect(str, 48, 128, 144, false);
|
||||
|
||||
_speechLoaded = _sound->loadSpeech('R', _realLocation, 'C', (64 * (_character & 0x7F)) + _talkPos);
|
||||
if (_speechLoaded)
|
||||
_sound->playChannel1(62);
|
||||
|
||||
_pointerMode = 3;
|
||||
workToScreenM();
|
||||
if (hangOnPQ())
|
||||
return;
|
||||
}
|
||||
|
||||
_talkPos++;
|
||||
}
|
||||
}
|
||||
|
||||
bool DreamWebEngine::hangOnPQ() {
|
||||
_getBack = 0;
|
||||
|
||||
RectWithCallback quitList[] = {
|
||||
{ 273,320,157,198,&DreamWebEngine::getBack1 },
|
||||
{ 0,320,0,200,&DreamWebEngine::blank },
|
||||
{ 0xFFFF,0,0,0,nullptr }
|
||||
};
|
||||
|
||||
uint16 speechFlag = 0;
|
||||
|
||||
do {
|
||||
delPointer();
|
||||
readMouse();
|
||||
animPointer();
|
||||
showPointer();
|
||||
waitForVSync();
|
||||
dumpPointer();
|
||||
dumpTextLine();
|
||||
checkCoords(quitList);
|
||||
|
||||
if (_getBack == 1 || _quitRequested) {
|
||||
// Quit conversation
|
||||
delPointer();
|
||||
_pointerMode = 0;
|
||||
_sound->cancelCh1();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_speechLoaded && !_sound->isChannel1Playing()) {
|
||||
speechFlag++;
|
||||
if (speechFlag == 40)
|
||||
break;
|
||||
}
|
||||
} while (!_mouseButton || _oldButton);
|
||||
|
||||
delPointer();
|
||||
_pointerMode = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void DreamWebEngine::redes() {
|
||||
if (_sound->isChannel1Playing() || _talkMode != 2) {
|
||||
blank();
|
||||
return;
|
||||
}
|
||||
|
||||
commandOnlyCond(50, 217);
|
||||
|
||||
if (!(_mouseButton & 1))
|
||||
return;
|
||||
|
||||
delPointer();
|
||||
createPanel();
|
||||
showPanel();
|
||||
showMan();
|
||||
showExit();
|
||||
convIcons();
|
||||
startTalk();
|
||||
readMouse();
|
||||
showPointer();
|
||||
workToScreen();
|
||||
delPointer();
|
||||
}
|
||||
|
||||
} // End of namespace DreamWeb
|
||||
Reference in New Issue
Block a user