aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/riven_card.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2016-08-04 06:28:04 +0200
committerEugene Sandulenko2017-07-03 08:50:10 +0200
commit1bb5424dddca2cf150fa1a09f4845e193b581e3e (patch)
tree33abe1c43bc93f9e649bc768a99d9d25bf9706b6 /engines/mohawk/riven_card.cpp
parentabe6889bbe640c15e0fdf454d3867eb22869db5c (diff)
downloadscummvm-rg350-1bb5424dddca2cf150fa1a09f4845e193b581e3e.tar.gz
scummvm-rg350-1bb5424dddca2cf150fa1a09f4845e193b581e3e.tar.bz2
scummvm-rg350-1bb5424dddca2cf150fa1a09f4845e193b581e3e.zip
MOHAWK: Move PLST handling to the RivenCard class
Diffstat (limited to 'engines/mohawk/riven_card.cpp')
-rw-r--r--engines/mohawk/riven_card.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp
index 90a6888f22..54b588c2a0 100644
--- a/engines/mohawk/riven_card.cpp
+++ b/engines/mohawk/riven_card.cpp
@@ -22,6 +22,9 @@
#include "mohawk/riven_card.h"
+#include "mohawk/riven_graphics.h"
+#include "mohawk/sound.h"
+
#include "mohawk/resource.h"
#include "mohawk/riven.h"
@@ -31,6 +34,7 @@ RivenCard::RivenCard(MohawkEngine_Riven *vm, uint16 id) :
_vm(vm),
_id(id) {
loadCardResource(id);
+ loadCardPictureList(id);
}
RivenCard::~RivenCard() {
@@ -48,7 +52,16 @@ void RivenCard::loadCardResource(uint16 id) {
}
void RivenCard::open() {
+ _vm->_activatedPLST = false;
+ _vm->_activatedSLST = false;
+
+ runScript(kCardLoadScript);
+ defaultLoadScript();
+
initializeZipMode();
+ _vm->_gfx->updateScreen();
+
+ runScript(kCardOpenScript);
}
void RivenCard::initializeZipMode() {
@@ -70,4 +83,49 @@ uint16 RivenCard::getId() const {
return _id;
}
+void RivenCard::defaultLoadScript() {
+ // Activate the first picture list if none have been activated
+ if (!_vm->_activatedPLST)
+ drawPicture(1);
+
+ // Activate the first sound list if none have been activated
+ if (!_vm->_activatedSLST)
+ _vm->_sound->playSLST(1, _id);
+}
+
+void RivenCard::loadCardPictureList(uint16 id) {
+ Common::SeekableReadStream* plst = _vm->getResource(ID_PLST, id);
+ uint16 recordCount = plst->readUint16BE();
+ _pictureList.resize(recordCount);
+
+ for (uint16 i = 0; i < recordCount; i++) {
+ Picture &picture = _pictureList[i];
+ picture.index = plst->readUint16BE();
+ picture.id = plst->readUint16BE();
+ picture.rect.left = plst->readUint16BE();
+ picture.rect.top = plst->readUint16BE();
+ picture.rect.right = plst->readUint16BE();
+ picture.rect.bottom = plst->readUint16BE();
+ }
+
+ delete plst;
+}
+
+void RivenCard::drawPicture(uint16 index, bool queue) {
+ if (index > 0 && index <= _pictureList.size()) {
+ RivenScriptPtr script = _vm->_scriptMan->createScriptFromData(1, 39, 1, index);
+ _vm->_scriptMan->runScript(script, queue);
+ }
+}
+
+RivenCard::Picture RivenCard::getPicture(uint16 index) const {
+ for (uint16 i = 0; i < _pictureList.size(); i++) {
+ if (_pictureList[i].index == index) {
+ return _pictureList[i];
+ }
+ }
+
+ error("Could not find picture %d in card %d", index, _id);
+}
+
} // End of namespace Mohawk