aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/actor_dialogue_queue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/bladerunner/actor_dialogue_queue.cpp')
-rw-r--r--engines/bladerunner/actor_dialogue_queue.cpp173
1 files changed, 173 insertions, 0 deletions
diff --git a/engines/bladerunner/actor_dialogue_queue.cpp b/engines/bladerunner/actor_dialogue_queue.cpp
new file mode 100644
index 0000000000..1dc7acc859
--- /dev/null
+++ b/engines/bladerunner/actor_dialogue_queue.cpp
@@ -0,0 +1,173 @@
+/* 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 "bladerunner/actor_dialogue_queue.h"
+
+#include "bladerunner/bladerunner.h"
+
+#include "bladerunner/actor.h"
+#include "bladerunner/audio_speech.h"
+#include "bladerunner/scene.h"
+
+#include "bladerunner/script/scene.h"
+
+namespace BladeRunner {
+
+ActorDialogueQueue::Entry::Entry() {
+ isNotPause = false;
+ isPause = false;
+ actorId = -1;
+ delay = -1;
+ sentenceId = -1;
+ animationMode = -1;
+}
+
+ActorDialogueQueue::ActorDialogueQueue(BladeRunnerEngine *vm) {
+ _vm = vm;
+ clear();
+}
+
+ActorDialogueQueue::~ActorDialogueQueue() {
+}
+
+void ActorDialogueQueue::add(int actorId, int sentenceId, int animationMode) {
+ if (actorId == 0 || actorId == BladeRunnerEngine::kActorVoiceOver) {
+ animationMode = -1;
+ }
+ if (_entries.size() < 25) {
+ Entry entry;
+ entry.isNotPause = true;
+ entry.isPause = false;
+ entry.actorId = actorId;
+ entry.sentenceId = sentenceId;
+ entry.animationMode = animationMode;
+ entry.delay = -1;
+
+ _entries.push_back(entry);
+ }
+}
+
+void ActorDialogueQueue::addPause(int delay) {
+ if (_entries.size() < 25) {
+ Entry entry;
+ entry.isNotPause = false;
+ entry.isPause = true;
+ entry.actorId = -1;
+ entry.sentenceId = -1;
+ entry.animationMode = -1;
+ entry.delay = delay;
+
+ _entries.push_back(entry);
+ }
+}
+
+void ActorDialogueQueue::flush(int a1, bool callScript) {
+ if (_isNotPause && _vm->_audioSpeech->isPlaying()) {
+ _vm->_audioSpeech->stopSpeech();
+ if (_animationModePrevious >= 0) {
+ _vm->_actors[_actorId]->changeAnimationMode(_animationModePrevious, false);
+ _animationModePrevious = -1;
+ }
+ _isNotPause = false;
+ _actorId = -1;
+ _sentenceId = -1;
+ _animationMode = -1;
+ }
+ if (_isPause) {
+ _isPause = false;
+ _delay = 0;
+ _timeLast = 0;
+ }
+ clear();
+ if (callScript) {
+ _vm->_sceneScript->DialogueQueueFlushed(a1);
+ }
+}
+
+void ActorDialogueQueue::tick() {
+ if (!_vm->_audioSpeech->isPlaying()) {
+ if (_isPause) {
+ int time = _vm->getTotalPlayTime();
+ int timeDiff = time - _timeLast;
+ _timeLast = time;
+ _delay -= timeDiff;
+ if (_delay > 0) {
+ return;
+ }
+ _isPause = false;
+ _delay = 0;
+ _timeLast = 0;
+ if (_entries.empty()) {
+ flush(0, true);
+ }
+ }
+ if (_isNotPause) {
+ if (_animationModePrevious >= 0) {
+ _vm->_actors[_actorId]->changeAnimationMode(_animationModePrevious, false);
+ _animationModePrevious = -1;
+ }
+ _isNotPause = false;
+ _actorId = -1;
+ _sentenceId = -1;
+ _animationMode = -1;
+ if (_entries.empty()) {
+ flush(0, true);
+ }
+ }
+ if (!_entries.empty()) {
+ Entry firstEntry = _entries.remove_at(0);
+ if (firstEntry.isNotPause) {
+ _animationMode = firstEntry.animationMode;
+ if (_vm->_actors[firstEntry.actorId]->getSetId() != _vm->_scene->getSetId()) {
+ _animationMode = -1;
+ }
+ _vm->_actors[firstEntry.actorId]->speechPlay(firstEntry.sentenceId, false);
+ _isNotPause = true;
+ _actorId = firstEntry.actorId;
+ _sentenceId = firstEntry.sentenceId;
+ if (_animationMode >= 0) {
+ _animationModePrevious = _vm->_actors[firstEntry.actorId]->getAnimationMode();
+ _vm->_actors[firstEntry.actorId]->changeAnimationMode(_animationMode, false);
+ } else {
+ _animationModePrevious = -1;
+ }
+ } else if (firstEntry.isPause) {
+ _isPause = true;
+ _delay = firstEntry.delay;
+ _timeLast = _vm->getTotalPlayTime();
+ }
+ }
+ }
+}
+
+void ActorDialogueQueue::clear() {
+ _entries.clear();
+ _isNotPause = false;
+ _actorId = -1;
+ _sentenceId = -1;
+ _animationMode = -1;
+ _animationModePrevious = -1;
+ _isPause = false;
+ _delay = 0;
+ _timeLast = 0;
+}
+} // End of namespace BladeRunner