From 4637104e6d289ab42d5eb02e0f42f48133180542 Mon Sep 17 00:00:00 2001 From: johndoe123 Date: Thu, 17 May 2018 06:13:30 +1000 Subject: ILLUSIONS: BBDOU: Implement missing talkthread events (cherry picked from commit 87869cb) --- engines/illusions/threads/talkthread.cpp | 107 +++++++++++++++++++++++++++++++ engines/illusions/threads/talkthread.h | 4 ++ 2 files changed, 111 insertions(+) diff --git a/engines/illusions/threads/talkthread.cpp b/engines/illusions/threads/talkthread.cpp index 74fd162aae..7c2e01276e 100644 --- a/engines/illusions/threads/talkthread.cpp +++ b/engines/illusions/threads/talkthread.cpp @@ -241,7 +241,114 @@ if (true) { } return kTSTerminate; +} + +void TalkThread::onSuspend() { + switch (_status) { + case 1: + _voiceDurationElapsed = getDurationElapsed(_voiceStartTime, _voiceEndTime); + _status = 7; + break; + case 4: + _vm->_soundMan->stopCueingVoice(); + _status = 7; + break; + case 6: + case 7: + if (!(_flags & 4)) { + _vm->_soundMan->stopVoice(); + _flags |= 4; + } + if (!(_flags & 8)) { + _vm->_screenText->removeText(); + _flags |= 8; + } + _status = 7; + break; + default: + _status = 7; + break; + } +} + +void TalkThread::onPause() { + switch (_status) { + case 1: + _voiceDurationElapsed = getDurationElapsed(_voiceStartTime, _voiceEndTime); + break; + case 4: + _vm->_soundMan->stopCueingVoice(); + break; + case 6: + case 7: + if (!(_flags & 4)) { + // TODO audvocPauseVoice(); + } + if (!(_flags & 8)) { + _textDurationElapsed = getDurationElapsed(_textStartTime, _textEndTime); + } + break; + default: + break; + } +} +void TalkThread::onUnpause() { + switch (_status) { + case 1: + _voiceStartTime = getCurrentTime(); + if (_voiceDuration <= _voiceDurationElapsed) { + _voiceDurationElapsed = 0; + _voiceEndTime = _voiceStartTime; + } else { + _voiceDurationElapsed = 0; + _voiceEndTime = _voiceStartTime + _voiceDuration - _voiceDurationElapsed; + } + break; + case 4: + if (_vm->isSoundActive()) { + TalkEntry *talkEntry = getTalkResourceEntry(_talkId); + _vm->_soundMan->cueVoice((char*)talkEntry->_voiceName); + } + break; + case 6: + if (!(_flags & 4)) { + // TODO audvocUnpauseVoice(); + } + if (!(_flags & 8)) { + _textStartTime = getCurrentTime(); + if (_textDuration <= _textDurationElapsed) { + _textDurationElapsed = 0; + _textEndTime = _textStartTime; + } else { + _textDurationElapsed = 0; + _textEndTime = _textStartTime + _textDuration - _textDurationElapsed; + } + } + break; + } +} + +void TalkThread::onTerminated() { + if (_status == 4) { + _vm->_soundMan->stopCueingVoice(); + } else if (_status == 6) { + if (!(_flags & 4)) { + _vm->_soundMan->stopVoice(); + _flags |= 4; + } + if (!(_flags & 8)) { + _vm->_screenText->removeText(); + _flags |= 8; + } + if (!(_flags & 2)) { + if (_sequenceId2) { + Control *control = _vm->_dict->getObjectControl(_objectId); + control->startSequenceActor(_sequenceId2, 2, 0); + } + _flags |= 2; + } + } } void TalkThread::onKill() { diff --git a/engines/illusions/threads/talkthread.h b/engines/illusions/threads/talkthread.h index 1d6573c890..7f8a197001 100644 --- a/engines/illusions/threads/talkthread.h +++ b/engines/illusions/threads/talkthread.h @@ -42,6 +42,10 @@ public: int16 duration, uint32 objectId, uint32 talkId, uint32 sequenceId1, uint32 sequenceId2, uint32 namedPointId); virtual int onUpdate(); + virtual void onSuspend(); + virtual void onPause(); + virtual void onUnpause(); + virtual void onTerminated(); virtual void onKill(); virtual uint32 sendMessage(int msgNum, uint32 msgValue); public: -- cgit v1.2.3