aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlyssa Milburn2010-12-01 18:21:49 +0000
committerAlyssa Milburn2010-12-01 18:21:49 +0000
commit4e3233fdba5982e57bcf930626dd882379fc00c2 (patch)
tree5676e1cef33072cd4e957474bec55e0d1689adfe /engines
parent3471d8ee45dee6097b4ba13e80648c600de9292c (diff)
downloadscummvm-rg350-4e3233fdba5982e57bcf930626dd882379fc00c2.tar.gz
scummvm-rg350-4e3233fdba5982e57bcf930626dd882379fc00c2.tar.bz2
scummvm-rg350-4e3233fdba5982e57bcf930626dd882379fc00c2.zip
MOHAWK: fix LBLiveTextItem drawing for LB 2+
svn-id: r54709
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/livingbooks.cpp68
-rw-r--r--engines/mohawk/livingbooks.h5
2 files changed, 60 insertions, 13 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index 1119261481..3065a6a07d 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -2085,7 +2085,7 @@ void LBPaletteItem::startPhase(uint phase) {
}
LBLiveTextItem::LBLiveTextItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
- _running = false;
+ _currentPhrase = 0xFFFF;
_currentWord = 0xFFFF;
debug(3, "new LBLiveTextItem");
}
@@ -2174,9 +2174,9 @@ bool LBLiveTextItem::contains(Common::Point point) {
}
void LBLiveTextItem::paletteUpdate(uint16 word, bool on) {
- // TODO: fix for v2/v3
- if (_vm->getGameType() != GType_LIVINGBOOKSV1) {
- warning("LiveText palettes aren't supported for V2/V3 yet");
+ if (_resourceId) {
+ // with a resource, we draw a bitmap in draw() rather than changing the palette
+ _vm->_needsRedraw = true;
return;
}
@@ -2191,7 +2191,6 @@ void LBLiveTextItem::update() {
if (_currentWord != 0xFFFF) {
uint16 soundId = _words[_currentWord].soundId;
if (soundId && !_vm->_sound->isPlaying(soundId)) {
- _vm->_sound->stopSound();
paletteUpdate(_currentWord, false);
_currentWord = 0xFFFF;
}
@@ -2200,8 +2199,49 @@ void LBLiveTextItem::update() {
LBItem::update();
}
+void LBLiveTextItem::draw() {
+ // this is only necessary when we are drawing using a bitmap
+ if (!_resourceId)
+ return;
+
+ if (_currentWord != 0xFFFF) {
+ uint yPos = 0;
+ if (_currentWord > 0) {
+ for (uint i = 0; i < _currentWord; i++) {
+ yPos += (_words[i].bounds.bottom - _words[i].bounds.top);
+ }
+ }
+ drawWord(_currentWord, yPos);
+ return;
+ }
+
+ if (_currentPhrase == 0xFFFF)
+ return;
+
+ uint wordStart = _phrases[_currentPhrase].wordStart;
+ uint wordCount = _phrases[_currentPhrase].wordCount;
+ if (wordStart + wordCount > _words.size())
+ error("phrase %d was invalid (%d words, from %d, out of only %d total)",
+ _currentPhrase, wordCount, wordStart, _words.size());
+
+ uint yPos = 0;
+ for (uint i = 0; i < wordStart + wordCount; i++) {
+ if (i >= wordStart)
+ drawWord(i, yPos);
+ yPos += (_words[i].bounds.bottom - _words[i].bounds.top);
+ }
+}
+
+void LBLiveTextItem::drawWord(uint word, uint yPos) {
+ Common::Rect srcRect(0, yPos, _words[word].bounds.right - _words[word].bounds.left,
+ yPos + _words[word].bounds.bottom - _words[word].bounds.top);
+ Common::Rect dstRect = _words[word].bounds;
+ dstRect.translate(_rect.left, _rect.top);
+ _vm->_gfx->copyImageSectionToScreen(_resourceId, srcRect, dstRect);
+}
+
void LBLiveTextItem::handleMouseDown(Common::Point pos) {
- if (_neverEnabled || !_enabled || _running)
+ if (_neverEnabled || !_enabled || _currentPhrase != 0xFFFF)
return LBItem::handleMouseDown(pos);
pos.x -= _rect.left;
@@ -2233,15 +2273,15 @@ bool LBLiveTextItem::togglePlaying(bool playing, bool restart) {
if (!playing)
return LBItem::togglePlaying(playing, restart);
if (_neverEnabled || !_enabled)
- return _running;
+ return (_currentPhrase != 0xFFFF);
// TODO: handle this properly
_vm->_sound->stopSound();
_currentWord = 0xFFFF;
- _running = true;
+ _currentPhrase = 0;
- return _running;
+ return true;
}
void LBLiveTextItem::stop() {
@@ -2251,26 +2291,32 @@ void LBLiveTextItem::stop() {
}
void LBLiveTextItem::notify(uint16 data, uint16 from) {
- if (_neverEnabled || !_enabled || !_running)
+ if (_neverEnabled || !_enabled || _currentPhrase == 0xFFFF)
return LBItem::notify(data, from);
if (_currentWord != 0xFFFF) {
+ // TODO: handle this properly
+ _vm->_sound->stopSound();
paletteUpdate(_currentWord, false);
_currentWord = 0xFFFF;
}
for (uint i = 0; i < _phrases.size(); i++) {
- // TODO
if (_phrases[i].highlightStart == data && _phrases[i].startId == from) {
debug(2, "Enabling phrase %d", i);
for (uint j = 0; j < _phrases[i].wordCount; j++) {
paletteUpdate(_phrases[i].wordStart + j, true);
}
+ _currentPhrase = i;
+ // TODO: not sure this is the correct logic
+ if (i == _phrases.size() - 1)
+ _currentPhrase = 0xFFFF;
} else if (_phrases[i].highlightEnd == data && _phrases[i].endId == from) {
debug(2, "Disabling phrase %d", i);
for (uint j = 0; j < _phrases[i].wordCount; j++) {
paletteUpdate(_phrases[i].wordStart + j, false);
}
+ _currentPhrase = 0xFFFF;
}
}
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 11210f0fa3..ce2284c0da 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -325,6 +325,7 @@ public:
bool contains(Common::Point point);
void update();
+ void draw();
void handleMouseDown(Common::Point pos);
bool togglePlaying(bool playing, bool restart);
void stop();
@@ -332,9 +333,9 @@ public:
protected:
void paletteUpdate(uint16 word, bool on);
+ void drawWord(uint word, uint yPos);
- bool _running;
- uint16 _currentWord;
+ uint16 _currentPhrase, _currentWord;
byte _backgroundColor[4];
byte _foregroundColor[4];