[Scummvm-cvs-logs] SF.net SVN: scummvm:[54793] scummvm/trunk/engines/mohawk
fuzzie at users.sourceforge.net
fuzzie at users.sourceforge.net
Sun Dec 5 23:11:07 CET 2010
Revision: 54793
http://scummvm.svn.sourceforge.net/scummvm/?rev=54793&view=rev
Author: fuzzie
Date: 2010-12-05 22:11:07 +0000 (Sun, 05 Dec 2010)
Log Message:
-----------
MOHAWK: improve LBPaletteItem support
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/livingbooks.cpp
scummvm/trunk/engines/mohawk/livingbooks.h
Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp 2010-12-05 22:10:50 UTC (rev 54792)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp 2010-12-05 22:11:07 UTC (rev 54793)
@@ -2573,6 +2573,7 @@
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 @@
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,13 +2594,44 @@
}
}
-void LBPaletteItem::draw() {
- if (!_visible || !_globalVisible)
- return;
+bool LBPaletteItem::togglePlaying(bool playing, bool restart) {
+ // TODO: this likely isn't the right place
- _vm->_system->setPalette(_palette + _drawStart * 4, _drawStart, _drawCount);
+ if (playing) {
+ _fadeInStart = _vm->_system->getMillis();
+ _fadeInCurrent = 0;
+
+ return true;
+ }
+
+ return LBItem::togglePlaying(playing, restart);
}
+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) {
_currentPhrase = 0xFFFF;
_currentWord = 0xFFFF;
Modified: scummvm/trunk/engines/mohawk/livingbooks.h
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.h 2010-12-05 22:10:50 UTC (rev 54792)
+++ scummvm/trunk/engines/mohawk/livingbooks.h 2010-12-05 22:11:07 UTC (rev 54793)
@@ -365,10 +365,12 @@
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];
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list