aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorstevenhoefel2017-02-06 14:45:13 +1100
committerstevenhoefel2017-02-06 14:45:13 +1100
commit6bf2ddde13e9872359fa139e813a0ed94164c5ea (patch)
tree25d0e141fe5323f7bca4f14dc57d1e1c958b4219 /engines
parentc48273d9134b8739fa57e5b29c48aa23bdac3d28 (diff)
downloadscummvm-rg350-6bf2ddde13e9872359fa139e813a0ed94164c5ea.tar.gz
scummvm-rg350-6bf2ddde13e9872359fa139e813a0ed94164c5ea.tar.bz2
scummvm-rg350-6bf2ddde13e9872359fa139e813a0ed94164c5ea.zip
DIRECTOR: Use Text rect for buttons. Adjust sizing appropriately.
Diffstat (limited to 'engines')
-rw-r--r--engines/director/cast.cpp5
-rw-r--r--engines/director/frame.cpp46
-rw-r--r--engines/director/frame.h2
3 files changed, 34 insertions, 19 deletions
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 4522eaeeb6..453ca08a07 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -180,8 +180,9 @@ ButtonCast::ButtonCast(Common::ReadStreamEndian &stream, uint16 version) : TextC
stream.readByte();
stream.readByte();
- initialRect = Score::readRect(stream);
- boundingRect = Score::readRect(stream);
+ //This has already been populated in the super TextCast constructor
+ //initialRect = Score::readRect(stream);
+ //boundingRect = Score::readRect(stream);
buttonType = static_cast<ButtonType>(stream.readUint16BE());
}
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 8992806ea8..3b121e0121 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -661,8 +661,6 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
}
void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 textId) {
- renderText(surface, spriteId, _vm->getMainArchive()->getResource(MKTAG('S', 'T', 'X', 'T'), textId), true);
-
uint16 castId = _sprites[spriteId]->_castId;
ButtonCast *button = static_cast<ButtonCast *>(_vm->_currentScore->_casts[castId]);
@@ -671,8 +669,15 @@ void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uin
int x = _sprites[spriteId]->_startPoint.x + rectLeft;
int y = _sprites[spriteId]->_startPoint.y + rectTop;
- int height = _sprites[spriteId]->_height;
- int width = _sprites[spriteId]->_width;
+ int height = button->initialRect.height(); // _sprites[spriteId]->_height;
+ int width = button->initialRect.width() + 3; //_sprites[spriteId]->_width;
+
+ Common::Rect textRect(0, 0, width, height);
+ //pass the rect of the button into the label.
+ renderText(surface, spriteId, _vm->getMainArchive()->getResource(MKTAG('S', 'T', 'X', 'T'), textId), &textRect);
+
+ //TODO: review all cases to confirm if we should use text height.
+ //height = textRect.height();
Common::Rect _rect;
@@ -684,7 +689,7 @@ void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uin
addDrawRect(spriteId, _rect);
break;
case kTypeButton: {
- _rect = Common::Rect(x, y, x + width - 1, y + height + 5);
+ _rect = Common::Rect(x, y, x + width, y + height + 3);
Graphics::MacPlotData pd(&surface, &_vm->getMacWindowManager()->getPatterns(), Graphics::MacGUIConstants::kPatternSolid, 1);
Graphics::drawRoundRect(_rect, 4, 0, false, Graphics::macDrawPixel, &pd);
addDrawRect(spriteId, _rect);
@@ -800,10 +805,10 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, uint1
textStream = _vm->getSharedSTXT()->getVal(spriteId + 1024);
}
- renderText(surface, spriteId, textStream, false);
+ renderText(surface, spriteId, textStream, NULL);
}
-void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, bool isButtonLabel) {
+void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, Common::Rect *textSize) {
if (textStream == NULL)
return;
@@ -894,14 +899,10 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
int x = _sprites[spriteId]->_startPoint.x; // +rectLeft;
int y = _sprites[spriteId]->_startPoint.y; // +rectTop;
-
int height = _sprites[spriteId]->_height;
- if (_vm->getVersion() >= 4 && !isButtonLabel) height = textCast->initialRect.bottom;
- height += textShadow;
-
int width = _sprites[spriteId]->_width;
- if (_vm->getVersion() >= 4 && !isButtonLabel)
+ if (_vm->getVersion() >= 4 && textSize != NULL)
width = textCast->initialRect.right;
if (_vm->_currentScore->_fontMap.contains(textCast->fontId)) {
@@ -922,16 +923,28 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
else
alignment++;
+ if (_vm->getVersion() >= 4) {
+ if (textSize == NULL)
+ width = textCast->initialRect.right;
+ else {
+ width = textSize->width();
+ }
+ }
+
Graphics::MacText mt(ftext, _vm->_wm, font, 0x00, 0xff, width, (Graphics::TextAlign)alignment);
mt.setInterLinear(1);
mt.render();
const Graphics::ManagedSurface *textSurface = mt.getSurface();
height = textSurface->h;
+ if (textSize != NULL) {
+ //TODO: this offset could be due to incorrect fonts loaded!
+ textSize->bottom = height + (mt.getLineCount() - 2);
+ }
uint16 textX = 0, textY = 0;
- if (!isButtonLabel) {
+ if (textSize == NULL) {
if (borderSize > 0) {
if (_vm->getVersion() <= 3)
height++;
@@ -956,7 +969,8 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
if (textShadow > 0)
textX--;
} else {
- y += 2;
+ x++;
+ y += 3;
}
switch (textCast->textAlign) {
@@ -973,11 +987,11 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
Graphics::ManagedSurface textWithFeatures(width + (borderSize * 2) + boxShadow + textShadow, height + borderSize + boxShadow + textShadow);
textWithFeatures.fillRect(Common::Rect(textWithFeatures.w, textWithFeatures.h), 0xff);
- if (!isButtonLabel && boxShadow > 0) {
+ if (textSize == NULL && boxShadow > 0) {
textWithFeatures.fillRect(Common::Rect(boxShadow, boxShadow, textWithFeatures.w + boxShadow, textWithFeatures.h), 0);
}
- if (!isButtonLabel && borderSize != kSizeNone) {
+ if (textSize == NULL && borderSize != kSizeNone) {
for (int bb = 0; bb < borderSize; bb++) {
Common::Rect borderRect(bb, bb, textWithFeatures.w - bb - boxShadow - textShadow, textWithFeatures.h - bb - boxShadow - textShadow);
textWithFeatures.fillRect(borderRect, 0xff);
diff --git a/engines/director/frame.h b/engines/director/frame.h
index f822a83fdb..3799c2043c 100644
--- a/engines/director/frame.h
+++ b/engines/director/frame.h
@@ -125,7 +125,7 @@ private:
void playSoundChannel();
void renderSprites(Graphics::ManagedSurface &surface, bool renderTrail);
void renderText(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 castId);
- void renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, bool isButtonLabel);
+ void renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Common::SeekableSubReadStreamEndian *textStream, Common::Rect *textSize);
void renderShape(Graphics::ManagedSurface &surface, uint16 spriteId);
void renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 textId);
void readPaletteInfo(Common::SeekableSubReadStreamEndian &stream);