diff options
-rw-r--r-- | engines/director/archive.cpp | 5 | ||||
-rw-r--r-- | engines/director/cast.cpp | 24 | ||||
-rw-r--r-- | engines/director/cast.h | 3 | ||||
-rw-r--r-- | engines/director/frame.cpp | 111 | ||||
-rw-r--r-- | graphics/macgui/macfontmanager.h | 9 |
5 files changed, 101 insertions, 51 deletions
diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp index 398b287b90..593fb638e4 100644 --- a/engines/director/archive.cpp +++ b/engines/director/archive.cpp @@ -408,7 +408,10 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff keyRes = &resources[resources.size() - 1]; else if (tag == MKTAG('C', 'A', 'S', '*')) casRes = &resources[resources.size() - 1]; - else + //or the children of + else if (tag == MKTAG('S', 'T', 'X', 'T') || + tag == MKTAG('B', 'I', 'T', 'D') || + tag == MKTAG('D', 'I', 'B', ' ')) _types[tag][i] = res; } diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp index 81637b9684..1434419e6c 100644 --- a/engines/director/cast.cpp +++ b/engines/director/cast.cpp @@ -62,10 +62,8 @@ BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, uint16 version) { } TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) { - if (version < 5) { - if (version <= 3) - flags1 = stream.readByte(); - + if (version < 4) { + flags1 = stream.readByte(); borderSize = static_cast<SizeType>(stream.readByte()); gutterSize = static_cast<SizeType>(stream.readByte()); boxShadow = static_cast<SizeType>(stream.readByte()); @@ -93,6 +91,24 @@ TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) { // TODO: FIXME: guesswork fontId = stream.readByte(); fontSize = stream.readByte(); + } else if (version < 5) { + borderSize = static_cast<SizeType>(stream.readByte()); + gutterSize = static_cast<SizeType>(stream.readByte()); + boxShadow = static_cast<SizeType>(stream.readByte()); + textType = static_cast<TextType>(stream.readByte()); + textAlign = static_cast<TextAlignType>(stream.readSint16()); //this is because 'right' is -1? or should that be 255? + stream.readUint16(); + stream.readUint16(); + stream.readUint16(); + stream.readUint16(); + + fontId = 1; //this is in STXT + + initialRect = Score::readRect(stream); + stream.readUint16(); + textShadow = static_cast<SizeType>(stream.readByte()); + byte flags = stream.readByte(); + fontSize = stream.readUint16(); } else { initialRect = Score::readRect(stream); boundingRect = Score::readRect(stream); diff --git a/engines/director/cast.h b/engines/director/cast.h index 0d06f23da8..6ca1d03d3b 100644 --- a/engines/director/cast.h +++ b/engines/director/cast.h @@ -121,8 +121,9 @@ struct TextCast : Cast { TextType textType; TextAlignType textAlign; SizeType textShadow; + byte textSlant; Common::Array<TextFlag> textFlags; - int16 palinfo1, palinfo2, palinfo3; + uint16 palinfo1, palinfo2, palinfo3; }; enum ButtonType { diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 7c52cf8ba7..1e80c80fb7 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -545,10 +545,10 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { if (_vm->getVersion() < 4) { switch (_sprites[i]->_spriteType) { case 0x01: - case 0x0c: //this is actually a mouse-over shape? I don't think it's a real button. castType = kCastBitmap; break; case 0x02: + case 0x0c: //this is actually a mouse-over shape? I don't think it's a real button. castType = kCastShape; break; case 0x07: @@ -730,11 +730,19 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) { return img; } - if (_vm->_currentScore->getArchive()->hasResource(MKTAG('B', 'I', 'T', 'D'), imgId)) { - Common::SeekableReadStream *pic = _vm->_currentScore->getArchive()->getResource(MKTAG('B', 'I', 'T', 'D'), imgId); + Common::SeekableReadStream *pic = NULL; + BitmapCast *bc = NULL; + if (_vm->getSharedBMP() != NULL && _vm->getSharedBMP()->contains(imgId)) { + pic = _vm->getSharedBMP()->getVal(imgId); + bc = static_cast<BitmapCast *>(_vm->getSharedCasts()->getVal(spriteId)); + } else if (_vm->_currentScore->getArchive()->hasResource(MKTAG('B', 'I', 'T', 'D'), imgId)) { + pic = _vm->_currentScore->getArchive()->getResource(MKTAG('B', 'I', 'T', 'D'), imgId); + bc = static_cast<BitmapCast *>(_vm->_currentScore->_casts[spriteId]); + } + + if (pic != NULL && bc != NULL) { if (_vm->getVersion() < 4) { - BitmapCast *bc = static_cast<BitmapCast *>(_vm->_currentScore->_casts[spriteId]); int w = bc->initialRect.width(), h = bc->initialRect.height(); debugC(2, kDebugImages, "id: %d, w: %d, h: %d, flags: %x, some: %x, unk1: %d, unk2: %d", @@ -763,12 +771,6 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) { return img; } - if (_vm->getSharedBMP() != NULL && _vm->getSharedBMP()->contains(imgId)) { - img = new Image::BitmapDecoder(); - img->loadStream(*_vm->getSharedBMP()->getVal(imgId)); - return img; - } - warning("Image %d not found", spriteId); return img; } @@ -783,6 +785,11 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID, uint1 textStream = _vm->getSharedSTXT()->getVal(spriteID + 1024); } + byte buf[1024]; + textStream->read(buf, textStream->size()); + textStream->seek(0); + Common::hexdump(buf, textStream->size()); + renderText(surface, spriteID, textStream, false); } @@ -792,8 +799,6 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID, Commo uint16 castID = _sprites[spriteID]->_castId; TextCast *textCast = static_cast<TextCast *>(_vm->_currentScore->_casts[castID]); - - uint32 unk1 = textStream->readUint32(); uint32 strLen = textStream->readUint32(); uint32 dataLen = textStream->readUint32(); @@ -811,6 +816,21 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID, Commo if (strLen < 200) debugC(3, kDebugText, "text: '%s'", text.c_str()); + if (_vm->getVersion() >= 4) { + uint16 a = textStream->readUint16(); + uint32 b = textStream->readUint32(); + uint16 c = textStream->readUint16(); + uint16 d = textStream->readUint16(); + textCast->fontId = textStream->readUint16(); + textCast->textSlant = textStream->readByte(); + textStream->readByte(); + textCast->fontSize = textStream->readUint16(); + + textCast->palinfo1 = textStream->readUint16(); + textCast->palinfo2 = textStream->readUint16(); + textCast->palinfo3 = textStream->readUint16(); + } + uint32 rectLeft = textCast->initialRect.left; uint32 rectTop = textCast->initialRect.top; @@ -819,7 +839,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID, Commo int height = _sprites[spriteID]->_height; int width = _sprites[spriteID]->_width; - Graphics::MacFont macFont(textCast->fontId, textCast->fontSize); + Graphics::MacFont macFont(textCast->fontId, textCast->fontSize, textCast->textSlant); if (_vm->_currentScore->_fontMap.contains(textCast->fontId)) { // Override @@ -830,48 +850,53 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID, Commo debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(macFont)); + uint16 boxShadow = (uint16)textCast->boxShadow; + uint16 borderSize = (uint16)textCast->borderSize; + uint16 padding = (uint16)textCast->gutterSize; + uint16 textShadow = (uint16)textCast->textShadow; + + int alignment = (int)textCast->textAlign; + if (alignment == 0xff) alignment = 3; + else alignment++; + + + if (textShadow > 0) { + font->drawString(&surface, text, + x + borderSize + padding + textShadow, + y + (borderSize / 2) + (padding / 2) + (textShadow - 1), + width, (_sprites[spriteID]->_ink == kInkTypeReverse ? 255 : 0), (Graphics::TextAlign)alignment); + } + //TODO: the colour is wrong here... need to determine the correct colour for all versions! - font->drawString(&surface, text, x, y, width, (_sprites[spriteID]->_ink == kInkTypeReverse ? 255 : 0), (Graphics::TextAlign)textCast->textAlign); + font->drawString(&surface, text, + x + borderSize + padding, + y + (borderSize / 2) + (padding / 2) - (textShadow > 0 ? 1 : 0), + width, (_sprites[spriteID]->_ink == kInkTypeReverse ? 255 : 0), (Graphics::TextAlign)alignment); if (isButtonLabel) return; - if (textCast->borderSize != kSizeNone) { - uint16 size = textCast->borderSize; - - // Indent from borders, measured in d4 - x -= 1; - y -= 4; + if (borderSize != kSizeNone) { + x += (borderSize / 2); + y += (borderSize / 2); - height += 4; - width += 1; + width += (padding * 2); + height += 6 + (padding); - while (size) { - surface.frameRect(Common::Rect(x, y, x + height, y + width), 0); - x--; - y--; + while (borderSize) { height += 2; width += 2; - size--; + x--; + y--; + surface.frameRect(Common::Rect(x, y, x + width, y + height), 0); + borderSize--; } } - if (textCast->gutterSize != kSizeNone) { - x -= 1; - y -= 4; - - height += 4; - width += 1; - uint16 size = textCast->gutterSize; - - surface.frameRect(Common::Rect(x, y, x + height, y + width), 0); - - while (size) { - surface.drawLine(x + width, y, x + width, y + height, 0); - surface.drawLine(x, y + height, x + width, y + height, 0); - x++; - y++; - size--; + if (boxShadow > 0) { + for (int loop = 0; loop < boxShadow; loop++) { + surface.drawLine(x + boxShadow, y + height + loop, x + width, y + height + loop, 0); + surface.drawLine(x + width + loop, y + boxShadow, x + width + loop, y + height + boxShadow - 1, 0); } } } diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h index 09fd0aeaca..7ae316bb04 100644 --- a/graphics/macgui/macfontmanager.h +++ b/graphics/macgui/macfontmanager.h @@ -48,8 +48,13 @@ enum { enum { kMacFontRegular, - kMacFontBold, - kMacFontItalic + kMacFontBold = 1, + kMacFontItalic = 2, + kMacFontUnderline = 4, + kMacFontOutline = 8, + kMacFontShadow = 16, + kMacFontCondense = 32, + kMacFontExtend = 64, }; class BdfFont; |