diff options
author | Eric Fry | 2018-04-27 21:56:56 +1000 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
commit | 43ba5f6327c21e60c9c73b2f2f93e71dbde7bf08 (patch) | |
tree | dff47d532fc513df5086d9a4b27d87d4c55b7c77 /engines/illusions | |
parent | a36cd2e39fce85e5cc1024322767284ba9b8e3b4 (diff) | |
download | scummvm-rg350-43ba5f6327c21e60c9c73b2f2f93e71dbde7bf08.tar.gz scummvm-rg350-43ba5f6327c21e60c9c73b2f2f93e71dbde7bf08.tar.bz2 scummvm-rg350-43ba5f6327c21e60c9c73b2f2f93e71dbde7bf08.zip |
ILLUSIONS: Fill in background for text in menus
Diffstat (limited to 'engines/illusions')
-rw-r--r-- | engines/illusions/resources/fontresource.cpp | 9 | ||||
-rw-r--r-- | engines/illusions/resources/fontresource.h | 1 | ||||
-rw-r--r-- | engines/illusions/textdrawer.cpp | 12 |
3 files changed, 19 insertions, 3 deletions
diff --git a/engines/illusions/resources/fontresource.cpp b/engines/illusions/resources/fontresource.cpp index 29aaf9bf65..4c89708fbc 100644 --- a/engines/illusions/resources/fontresource.cpp +++ b/engines/illusions/resources/fontresource.cpp @@ -110,6 +110,15 @@ CharInfo *FontResource::getCharInfo(uint16 c) { return 0; } +const Common::Rect FontResource::calculateRectForText(uint16 *text, uint textLength) { + int16 width = 0; + for (uint i = 0; i < textLength && *text; i++) { + width += getCharInfo(*text)->_width; + text++; + } + return Common::Rect(width, getCharHeight() + getLineIncr()); +} + // FontInstance FontInstance::FontInstance(IllusionsEngine *vm) : _vm(vm) { diff --git a/engines/illusions/resources/fontresource.h b/engines/illusions/resources/fontresource.h index 6204c9df8b..1a433a2e51 100644 --- a/engines/illusions/resources/fontresource.h +++ b/engines/illusions/resources/fontresource.h @@ -67,6 +67,7 @@ public: int16 getColorIndex() const { return _colorIndex; } int16 getCharHeight() const { return _charHeight; } int16 getLineIncr() const { return _lineIncr; } + const Common::Rect calculateRectForText(uint16 *text, uint textLength); public: uint32 _totalSize; int16 _charHeight; diff --git a/engines/illusions/textdrawer.cpp b/engines/illusions/textdrawer.cpp index b1c9658ee2..a5679b0440 100644 --- a/engines/illusions/textdrawer.cpp +++ b/engines/illusions/textdrawer.cpp @@ -42,7 +42,6 @@ bool TextDrawer::wrapText(FontResource *font, uint16 *text, WidthHeight *dimensi } void TextDrawer::drawText(Screen *screen, Graphics::Surface *surface, uint16 backgroundColor, uint16 borderColor) { - // TODO Fill box, draw borders and shadow if flags are set uint16 x = 0; uint16 y = 0; @@ -62,8 +61,15 @@ void TextDrawer::drawText(Screen *screen, Graphics::Surface *surface, uint16 bac for (Common::Array<TextLine>::iterator it = _textLines.begin(); it != _textLines.end(); ++it) { const TextLine &textLine = *it; - if (textLine._text) + if (textLine._text) { screen->drawText(_font, surface, textLine._x + x, textLine._y + y, textLine._text, textLine._length); + if (_textFlags & TEXT_FLAG_BORDER_DECORATION) { + Common::Rect textRect = _font->calculateRectForText(textLine._text, textLine._length); + // Fill in remainder of text line with background color. + surface->fillRect(Common::Rect(textLine._x + x + textRect.right, textLine._y + y, + surface->w - 4, textLine._y + y + textRect.bottom), backgroundColor); + } + } #if 0 for (int16 linePos = 0; linePos < textLine._length; ++linePos) { const uint16 c = textLine._text[linePos]; @@ -73,7 +79,7 @@ void TextDrawer::drawText(Screen *screen, Graphics::Surface *surface, uint16 bac #endif } } - + bool TextDrawer::wrapTextIntern(int16 x, int16 y, int16 maxWidth, int16 maxHeight, uint16 *&outTextPtr) { bool lineBreak = false; |