aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics/text32.cpp
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2016-03-20 16:53:58 +0100
committerColin Snover2016-06-21 08:14:12 -0500
commitab864ba3666b39586c54467137a2b26d246ba430 (patch)
treeab5fbac13293ace4913f76acf929f6843bfb6a3a /engines/sci/graphics/text32.cpp
parenta613a27b44eae68650eb9150ea146dff9befea28 (diff)
downloadscummvm-rg350-ab864ba3666b39586c54467137a2b26d246ba430.tar.gz
scummvm-rg350-ab864ba3666b39586c54467137a2b26d246ba430.tar.bz2
scummvm-rg350-ab864ba3666b39586c54467137a2b26d246ba430.zip
SCI32: Implement kScrollWindow
These should be all the actually used subfunctions. Co-authored-by: Colin Snover <github.com@zetafleet.com>
Diffstat (limited to 'engines/sci/graphics/text32.cpp')
-rw-r--r--engines/sci/graphics/text32.cpp70
1 files changed, 68 insertions, 2 deletions
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index f38a95de5b..d3b5bf5396 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -237,8 +237,10 @@ void GfxText32::drawTextBox() {
int16 textRectWidth = _textRect.width();
_drawPosition.y = _textRect.top;
uint charIndex = 0;
- if (getLongest(&charIndex, textRectWidth) == 0) {
- error("DrawTextBox GetLongest=0");
+ if (g_sci->getGameId() != GID_PHANTASMAGORIA) {
+ if (getLongest(&charIndex, textRectWidth) == 0) {
+ error("DrawTextBox GetLongest=0");
+ }
}
charIndex = 0;
@@ -651,5 +653,69 @@ int16 GfxText32::getTextCount(const Common::String &text, const uint index, cons
return getTextCount(text, index, textRect, doScaling);
}
+void GfxText32::scrollLine(const Common::String &lineText, int numLines, uint8 color, TextAlign align, GuiResourceId fontId, ScrollDirection dir) {
+ BitmapResource bmr(_bitmap);
+ byte *pixels = bmr.getPixels();
+
+ int h = _font->getHeight();
+
+ if (dir == kScrollUp) {
+ // Scroll existing text down
+ for (int i = 0; i < (numLines - 1) * h; ++i) {
+ int y = _textRect.top + numLines * h - i - 1;
+ memcpy(pixels + y * _width + _textRect.left,
+ pixels + (y - h) * _width + _textRect.left,
+ _textRect.width());
+ }
+ } else {
+ // Scroll existing text up
+ for (int i = 0; i < (numLines - 1) * h; ++i) {
+ int y = _textRect.top + i;
+ memcpy(pixels + y * _width + _textRect.left,
+ pixels + (y + h) * _width + _textRect.left,
+ _textRect.width());
+ }
+ }
+
+ Common::Rect lineRect = _textRect;
+
+ if (dir == kScrollUp) {
+ lineRect.bottom = lineRect.top + h;
+ } else {
+ // It is unclear to me what the purpose of this bottom++ is.
+ // It does not seem to be the usual inc/exc issue.
+ lineRect.top += (numLines - 1) * h;
+ lineRect.bottom++;
+ }
+
+ erase(lineRect, false);
+
+ _drawPosition.x = _textRect.left;
+ _drawPosition.y = _textRect.top;
+ if (dir == kScrollDown) {
+ _drawPosition.y += (numLines - 1) * h;
+ }
+
+ _foreColor = color;
+ _alignment = align;
+ //int fc = _foreColor;
+
+ setFont(fontId);
+
+ _text = lineText;
+ int16 textWidth = getTextWidth(0, lineText.size());
+
+ if (_alignment == kTextAlignCenter) {
+ _drawPosition.x += (_textRect.width() - textWidth) / 2;
+ } else if (_alignment == kTextAlignRight) {
+ _drawPosition.x += _textRect.width() - textWidth;
+ }
+
+ //_foreColor = fc;
+ //setFont(fontId);
+
+ drawText(0, lineText.size());
+}
+
} // End of namespace Sci