DIRECTOR: Add cast pointers to sprites

This commit is contained in:
Dmitry Iskrich 2016-05-27 17:00:57 +03:00 committed by Eugene Sandulenko
parent 5718268106
commit d17805e132
2 changed files with 52 additions and 59 deletions

View File

@ -64,10 +64,7 @@ Score::Score(Common::SeekableReadStream &stream) {
void Score::loadConfig(Common::SeekableReadStream &stream) { void Score::loadConfig(Common::SeekableReadStream &stream) {
/*uint16 unk1 = */ stream.readUint16BE(); /*uint16 unk1 = */ stream.readUint16BE();
/*ver1 = */ stream.readUint16BE(); /*ver1 = */ stream.readUint16BE();
_movieRect.top = stream.readUint16BE(); _movieRect = readRect(stream);
_movieRect.left = stream.readUint16BE();
_movieRect.bottom = stream.readUint16BE();
_movieRect.right = stream.readUint16BE();
_castArrayStart = stream.readUint16BE(); _castArrayStart = stream.readUint16BE();
_castArrayEnd = stream.readUint16BE(); _castArrayEnd = stream.readUint16BE();
@ -85,31 +82,38 @@ void Score::readVersion(uint32 rid) {
void Score::loadCastData(Common::SeekableReadStream &stream) { void Score::loadCastData(Common::SeekableReadStream &stream) {
for (uint16 id = _castArrayStart; id < _castArrayEnd; id++) { for (uint16 id = _castArrayStart; id < _castArrayEnd; id++) {
byte size = stream.readByte(); byte size = stream.readByte();
if (size > 0) { if (size == 0)
debug("%d", stream.pos()); continue;
uint8 castType = stream.readByte();
switch (castType) { uint8 castType = stream.readByte();
case kCastBitmap: switch (castType) {
_casts[id] = getBitmapCast(stream); case kCastBitmap:
_casts[id]->type = kCastBitmap; _casts[id] = getBitmapCast(stream);
break; _casts[id]->type = kCastBitmap;
case kCastText: break;
_casts[id] = getTextCast(stream); case kCastText:
_casts[id]->type = kCastText; _casts[id] = getTextCast(stream);
break; _casts[id]->type = kCastText;
case kCastShape: break;
_casts[id] = getShapeCast(stream); case kCastShape:
_casts[id]->type = kCastShape; _casts[id] = getShapeCast(stream);
break; _casts[id]->type = kCastShape;
case kCastButton: break;
_casts[id] = getButtonCast(stream); case kCastButton:
_casts[id]->type = kCastButton; _casts[id] = getButtonCast(stream);
break; _casts[id]->type = kCastButton;
default: break;
warning("Unhandled cast type: %d", castType); default:
stream.skip(size - 1); warning("Unhandled cast type: %d", castType);
break; stream.skip(size - 1);
} break;
}
}
//Set cast pointers to sprites
for (uint16 i = 0; i < _frames.size(); i++) {
for (uint16 j = 0; j < _frames[i]->_sprites.size(); j++) {
byte castId = _frames[i]->_sprites[j]->_castId;
_frames[i]->_sprites[j]->_cast = _casts[castId];
} }
} }
} }
@ -118,17 +122,8 @@ BitmapCast *Score::getBitmapCast(Common::SeekableReadStream &stream) {
BitmapCast *cast = new BitmapCast(); BitmapCast *cast = new BitmapCast();
/*byte flags = */ stream.readByte(); /*byte flags = */ stream.readByte();
/*uint16 someFlaggyThing = */ stream.readUint16BE(); /*uint16 someFlaggyThing = */ stream.readUint16BE();
cast->initialRect = readRect(stream);
cast->initialRect.top = stream.readUint16BE(); cast->boundingRect = readRect(stream);
cast->initialRect.left = stream.readUint16BE();
cast->initialRect.bottom = stream.readUint16BE();
cast->initialRect.right = stream.readUint16BE();
cast->boundingRect.top = stream.readUint16BE();
cast->boundingRect.left = stream.readUint16BE();
cast->boundingRect.bottom = stream.readUint16BE();
cast->boundingRect.right = stream.readUint16BE();
cast->regX = stream.readUint16BE(); cast->regX = stream.readUint16BE();
cast->regY = stream.readUint16BE(); cast->regY = stream.readUint16BE();
/*uint16 unk1 =*/ stream.readUint16BE(); /*uint16 unk1 =*/ stream.readUint16BE();
@ -146,12 +141,7 @@ TextCast *Score::getTextCast(Common::SeekableReadStream &stream) {
cast->textAlign = stream.readUint16BE(); cast->textAlign = stream.readUint16BE();
stream.skip(6); //palinfo stream.skip(6); //palinfo
/*uint32 unk1 = */ stream.readUint32BE(); /*uint32 unk1 = */ stream.readUint32BE();
cast->initialRect = readRect(stream);
cast->initialRect.top = stream.readUint16BE();
cast->initialRect.left = stream.readUint16BE();
cast->initialRect.bottom = stream.readUint16BE();
cast->initialRect.right = stream.readUint16BE();
cast->textShadow = stream.readByte(); cast->textShadow = stream.readByte();
cast->textFlags = stream.readByte(); cast->textFlags = stream.readByte();
/*uint16 unk2 =*/ stream.readUint16BE(); /*uint16 unk2 =*/ stream.readUint16BE();
@ -163,12 +153,7 @@ ShapeCast *Score::getShapeCast(Common::SeekableReadStream &stream) {
/*byte flags = */ stream.readByte(); /*byte flags = */ stream.readByte();
/*unk1 = */ stream.readByte(); /*unk1 = */ stream.readByte();
cast->shapeType = stream.readByte(); cast->shapeType = stream.readByte();
cast->initialRect = readRect(stream);
cast->initialRect.top = stream.readUint16BE();
cast->initialRect.left = stream.readUint16BE();
cast->initialRect.bottom = stream.readUint16BE();
cast->initialRect.right = stream.readUint16BE();
cast->pattern = stream.readUint16BE(); cast->pattern = stream.readUint16BE();
cast->fgCol = stream.readByte(); cast->fgCol = stream.readByte();
cast->bgCol = stream.readByte(); cast->bgCol = stream.readByte();
@ -188,12 +173,7 @@ ButtonCast *Score::getButtonCast(Common::SeekableReadStream &stream) {
cast->textAlign = stream.readUint16BE(); cast->textAlign = stream.readUint16BE();
stream.skip(6); //palinfo stream.skip(6); //palinfo
/*uint32 unk1 = */ stream.readUint32BE(); /*uint32 unk1 = */ stream.readUint32BE();
cast->initialRect = readRect(stream);
cast->initialRect.top = stream.readUint16BE();
cast->initialRect.left = stream.readUint16BE();
cast->initialRect.bottom = stream.readUint16BE();
cast->initialRect.right = stream.readUint16BE();
cast->textShadow = stream.readByte(); cast->textShadow = stream.readByte();
cast->textFlags = stream.readByte(); cast->textFlags = stream.readByte();
/*uint16 unk2 =*/ stream.readUint16BE(); /*uint16 unk2 =*/ stream.readUint16BE();
@ -201,6 +181,15 @@ ButtonCast *Score::getButtonCast(Common::SeekableReadStream &stream) {
return cast; return cast;
} }
Common::Rect Score::readRect(Common::SeekableReadStream &stream) {
Common::Rect rect;
rect.top = stream.readUint16BE();
rect.left = stream.readUint16BE();
rect.bottom = stream.readUint16BE();
rect.right = stream.readUint16BE();
return rect;
}
void Score::play() { void Score::play() {
initGraphics(800, 800, true); initGraphics(800, 800, true);
uint32 frameId = 0; uint32 frameId = 0;
@ -418,8 +407,10 @@ void Frame::display() {
for (uint16 i = 0; i < CHANNEL_COUNT; i++) { for (uint16 i = 0; i < CHANNEL_COUNT; i++) {
if (_sprites[i]->_enabled) { if (_sprites[i]->_enabled) {
DIBDecoder img; DIBDecoder img;
//TODO check cast type
uint32 castId = 1024 + _sprites[i]->_castId; uint32 castId = 1024 + _sprites[i]->_castId;
img.loadStream(*riff.getResource(MKTAG('D', 'I', 'B', ' '), castId)); img.loadStream(*riff.getResource(MKTAG('D', 'I', 'B', ' '), castId));
g_system->copyRectToScreen(img.getSurface()->getPixels(), img.getSurface()->pitch, g_system->copyRectToScreen(img.getSurface()->getPixels(), img.getSurface()->pitch,
_sprites[i]->_startPoint.x, _sprites[i]->_startPoint.x,
_sprites[i]->_startPoint.y, _sprites[i]->_startPoint.y,

View File

@ -114,8 +114,9 @@ public:
Sprite(); Sprite();
Sprite(const Sprite &sprite); Sprite(const Sprite &sprite);
bool _enabled; bool _enabled;
uint8 _castId; byte _castId;
//castType type; //castType type;
Cast *_cast;
uint16 _flags; uint16 _flags;
Common::Point _startPoint; Common::Point _startPoint;
uint16 _width; uint16 _width;
@ -165,6 +166,7 @@ private:
TextCast *getTextCast(Common::SeekableReadStream &stream); TextCast *getTextCast(Common::SeekableReadStream &stream);
ButtonCast *getButtonCast(Common::SeekableReadStream &stream); ButtonCast *getButtonCast(Common::SeekableReadStream &stream);
ShapeCast *getShapeCast(Common::SeekableReadStream &stream); ShapeCast *getShapeCast(Common::SeekableReadStream &stream);
Common::Rect readRect(Common::SeekableReadStream &stream);
public: public:
Common::Array<Frame *> _frames; Common::Array<Frame *> _frames;