DIRECTOR: More debug output and code tidying up

This commit is contained in:
Eugene Sandulenko 2019-12-24 22:47:06 +01:00
parent cdcce73ff8
commit 578d013e9c
5 changed files with 40 additions and 23 deletions

View File

@ -249,9 +249,11 @@ void TextCast::setText(const char *text) {
}
ShapeCast::ShapeCast(Common::ReadStreamEndian &stream, uint16 version) {
byte flags, unk1;
if (version < 4) {
/*byte flags = */ stream.readByte();
/*unk1 = */ stream.readByte();
flags = stream.readByte();
unk1 = stream.readByte();
_shapeType = static_cast<ShapeType>(stream.readByte());
_initialRect = Score::readRect(stream);
_pattern = stream.readUint16BE();
@ -261,8 +263,8 @@ ShapeCast::ShapeCast(Common::ReadStreamEndian &stream, uint16 version) {
_lineThickness = stream.readByte();
_lineDirection = stream.readByte();
} else {
stream.readByte();
stream.readByte();
flags = stream.readByte();
unk1 = stream.readByte();
_initialRect = Score::readRect(stream);
_boundingRect = Score::readRect(stream);
@ -275,6 +277,12 @@ ShapeCast::ShapeCast(Common::ReadStreamEndian &stream, uint16 version) {
_lineDirection = 0;
}
_modified = 0;
debugC(3, kDebugLoading, "ShapeCast: fl: %x unk1: %x type: %d pat: %d fg: %d bg: %d fill: %d thick: %d dir: %d",
flags, unk1, _shapeType, _pattern, _fgCol, _bgCol, _fillType, _lineThickness, _lineDirection);
if (debugChannelSet(3, kDebugLoading))
_initialRect.debugPrint(0, "ShapeCast: rect:");
}
ButtonCast::ButtonCast(Common::ReadStreamEndian &stream, uint16 version) : TextCast(stream, version) {

View File

@ -68,13 +68,6 @@ public:
uint32 _tag;
};
enum ShapeType {
kShapeRectangle,
kShapeRoundRect,
kShapeOval,
kShapeLine
};
class ShapeCast : public Cast {
public:
ShapeCast(Common::ReadStreamEndian &stream, uint16 version = 2);

View File

@ -649,27 +649,34 @@ void Frame::addDrawRect(uint16 spriteId, Common::Rect &rect) {
}
void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
Common::Rect shapeRect = Common::Rect(_sprites[spriteId]->_startPoint.x,
_sprites[spriteId]->_startPoint.y,
_sprites[spriteId]->_startPoint.x + _sprites[spriteId]->_width,
_sprites[spriteId]->_startPoint.y + _sprites[spriteId]->_height);
Sprite *sp = _sprites[spriteId];
if (sp->_shapeCast == NULL) {
warning("Frame::renderShape(): missing shapecast in sprite id: %d", spriteId);
return;
}
Common::Rect shapeRect = Common::Rect(sp->_startPoint.x,
sp->_startPoint.y,
sp->_startPoint.x + sp->_width,
sp->_startPoint.y + sp->_height);
Graphics::ManagedSurface tmpSurface;
tmpSurface.create(shapeRect.width(), shapeRect.height(), Graphics::PixelFormat::createFormatCLUT8());
if (_vm->getVersion() <= 3 && _sprites[spriteId]->_spriteType == kOutlinedRectangleSprite) {
if (_vm->getVersion() <= 3 && sp->_spriteType == kOutlinedRectangleSprite) {
tmpSurface.fillRect(Common::Rect(shapeRect.width(), shapeRect.height()), (_vm->getCurrentScore()->_currentMouseDownSpriteId == spriteId ? 0 : 0xff));
//tmpSurface.frameRect(Common::Rect(shapeRect.width(), shapeRect.height()), 0);
// TODO: don't override, work out how to display correctly.
_sprites[spriteId]->_ink = kInkTypeReverse;
sp->_ink = kInkTypeReverse;
} else {
// No minus one on the pattern here! MacPlotData will do that for us!
Graphics::MacPlotData pd(&tmpSurface, &_vm->getPatterns(), _sprites[spriteId]->_castId, 1, _sprites[spriteId]->_backColor);
Graphics::MacPlotData pd(&tmpSurface, &_vm->getPatterns(), sp->_castId, 1, sp->_shapeCast->_bgCol);
Common::Rect fillRect(shapeRect.width(), shapeRect.height());
Graphics::drawFilledRect(fillRect, _sprites[spriteId]->_foreColor, Graphics::macDrawPixel, &pd);
Graphics::drawFilledRect(fillRect, sp->_shapeCast->_fgCol, Graphics::macDrawPixel, &pd);
}
if (_sprites[spriteId]->_lineSize > 0) {
for (int rr = 0; rr < (_sprites[spriteId]->_lineSize - 1); rr++)
if (sp->_lineSize > 0) {
for (int rr = 0; rr < (sp->_lineSize - 1); rr++)
tmpSurface.frameRect(Common::Rect(rr, rr, shapeRect.width() - (rr * 2), shapeRect.height() - (rr * 2)), 0);
}

View File

@ -140,7 +140,6 @@ void Score::loadArchive() {
assert(_movieArchive->hasResource(MKTAG('V', 'W', 'S', 'C'), -1));
loadFrames(*_movieArchive->getFirstResource(MKTAG('V', 'W', 'S', 'C')));
if (_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'F'), -1)) {
loadConfig(*_movieArchive->getFirstResource(MKTAG('V', 'W', 'C', 'F')));
} else {
@ -464,7 +463,7 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) {
frame->readChannels(str);
delete str;
debugC(3, kDebugLoading, "Frame %d actionId: %d", _frames.size(), frame->_actionId);
debugC(8, kDebugLoading, "Frame %d actionId: %d", _frames.size(), frame->_actionId);
_frames.push_back(frame);
} else {
@ -546,6 +545,9 @@ void Score::setSpriteCasts() {
for (uint16 j = 0; j < _frames[i]->_sprites.size(); j++) {
uint16 castId = _frames[i]->_sprites[j]->_castId;
if (castId == 0)
continue;
if (_vm->getSharedScore() != nullptr && _vm->getSharedScore()->_loadedBitmaps->contains(castId)) {
_frames[i]->_sprites[j]->_bitmapCast = _vm->getSharedScore()->_loadedBitmaps->getVal(castId);
} else if (_loadedBitmaps->contains(castId)) {

View File

@ -51,6 +51,13 @@ enum ScriptType {
kMaxScriptType = 4 // Sync with score.cpp:45, array scriptTypes[]
};
enum ShapeType {
kShapeRectangle,
kShapeRoundRect,
kShapeOval,
kShapeLine
};
enum TextType {
kTextTypeAdjustToFit,
kTextTypeScrolling,