aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorAlyssa Milburn2010-12-05 22:11:07 +0000
committerAlyssa Milburn2010-12-05 22:11:07 +0000
commit237925e5fddf21dba86155fc9d10aba7355cc9ed (patch)
tree23b41d11508fcaf970b76cdca0f897f1c8fd6705 /engines/mohawk
parent7c9dc9f117e4ad7f78d0069c38e707e43d35bf5b (diff)
downloadscummvm-rg350-237925e5fddf21dba86155fc9d10aba7355cc9ed.tar.gz
scummvm-rg350-237925e5fddf21dba86155fc9d10aba7355cc9ed.tar.bz2
scummvm-rg350-237925e5fddf21dba86155fc9d10aba7355cc9ed.zip
MOHAWK: improve LBPaletteItem support
svn-id: r54793
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/livingbooks.cpp44
-rw-r--r--engines/mohawk/livingbooks.h6
2 files changed, 42 insertions, 8 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index 2bbb27bbb9..ee340af2db 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -2573,6 +2573,7 @@ void LBGroupItem::stop() {
LBPaletteItem::LBPaletteItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
debug(3, "new LBPaletteItem");
+ _fadeInStart = 0;
}
void LBPaletteItem::readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream) {
@@ -2580,8 +2581,8 @@ void LBPaletteItem::readData(uint16 type, uint16 size, Common::SeekableSubReadSt
case kLBPaletteXData:
{
assert(size == 8 + 255 * 4);
- _start = stream->readUint16();
- _count = stream->readUint16();
+ _fadeInPeriod = stream->readUint16();
+ _fadeInStep = stream->readUint16();
_drawStart = stream->readUint16();
_drawCount = stream->readUint16();
stream->read(_palette, 255 * 4);
@@ -2593,11 +2594,42 @@ void LBPaletteItem::readData(uint16 type, uint16 size, Common::SeekableSubReadSt
}
}
-void LBPaletteItem::draw() {
- if (!_visible || !_globalVisible)
- return;
+bool LBPaletteItem::togglePlaying(bool playing, bool restart) {
+ // TODO: this likely isn't the right place
+
+ if (playing) {
+ _fadeInStart = _vm->_system->getMillis();
+ _fadeInCurrent = 0;
+
+ return true;
+ }
+
+ return LBItem::togglePlaying(playing, restart);
+}
- _vm->_system->setPalette(_palette + _drawStart * 4, _drawStart, _drawCount);
+void LBPaletteItem::update() {
+ if (_fadeInStart) {
+ uint32 elapsedTime = _vm->_system->getMillis() - _fadeInStart;
+ uint32 divTime = elapsedTime / _fadeInStep;
+
+ if (divTime > _fadeInPeriod)
+ divTime = _fadeInPeriod;
+
+ if (_fadeInCurrent != divTime) {
+ _fadeInCurrent = divTime;
+
+ // TODO: actual fading-in
+ if (_visible && _globalVisible)
+ _vm->_system->setPalette(_palette + _drawStart * 4, _drawStart, _drawCount);
+ }
+
+ if (elapsedTime >= (uint32)_fadeInPeriod * (uint32)_fadeInStep) {
+ // TODO: correct?
+ _fadeInStart = 0;
+ }
+ }
+
+ LBItem::update();
}
LBLiveTextItem::LBLiveTextItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 4215889574..db6948e2ad 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -365,10 +365,12 @@ public:
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
- void draw();
+ bool togglePlaying(bool playing, bool restart);
+ void update();
protected:
- uint16 _start, _count, _drawStart, _drawCount;
+ uint16 _fadeInPeriod, _fadeInStep, _drawStart, _drawCount;
+ uint32 _fadeInStart, _fadeInCurrent;
byte _palette[255 * 4];
};