From 4b3e671de564b447eae23bfcdb3ce365ba5dd9a0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 12:27:56 +0200 Subject: LAB: Merge flowTextToMem() inside flowText() --- engines/lab/dispman.cpp | 27 +++++++++++---------------- engines/lab/dispman.h | 19 +------------------ engines/lab/special.cpp | 6 +++--- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp index ead60f7a91..b6ffbf8b2e 100644 --- a/engines/lab/dispman.cpp +++ b/engines/lab/dispman.cpp @@ -146,7 +146,16 @@ Common::String DisplayMan::getLine(TextFont *tf, const char **mainBuffer, uint16 } int DisplayMan::flowText(TextFont *font, int16 spacing, byte penColor, byte backPen, - bool fillBack, bool centerh, bool centerv, bool output, Common::Rect textRect, const char *str) { + bool fillBack, bool centerh, bool centerv, bool output, Common::Rect textRect, const char *str, Image *targetImage) { + + byte *saveDisplayBuffer = _currentDisplayBuffer; + uint32 bytesPerPage = _screenBytesPerPage; + + if (targetImage) { + _currentDisplayBuffer = targetImage->_imageData; + _screenBytesPerPage = (uint32)targetImage->_width * (int32)targetImage->_height; + } + if (fillBack) rectFill(textRect, backPen); @@ -192,24 +201,10 @@ int DisplayMan::flowText(TextFont *font, int16 spacing, byte penColor, byte back len--; - return len; -} - -int DisplayMan::flowTextToMem(Image *destIm, TextFont *font, int16 spacing, byte penColor, - byte backPen, bool fillBack, bool centerh, bool centerv, bool output, Common::Rect textRect, - const char *str) { - byte *saveDisplayBuffer = _currentDisplayBuffer; - uint32 bytesPerPage = _screenBytesPerPage; - - _currentDisplayBuffer = destIm->_imageData; - _screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height; - - int res = flowText(font, spacing, penColor, backPen, fillBack, centerh, centerv, output, textRect, str); - _screenBytesPerPage = bytesPerPage; _currentDisplayBuffer = saveDisplayBuffer; - return res; + return len; } void DisplayMan::createBox(uint16 y2) { diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h index cbad419382..3b41505e2f 100644 --- a/engines/lab/dispman.h +++ b/engines/lab/dispman.h @@ -177,24 +177,7 @@ public: * @param text The text itself */ int flowText(TextFont *font, int16 spacing, byte penColor, byte backPen, bool fillBack, - bool centerh, bool centerv, bool output, Common::Rect textRect, const char *text); - - /** - * Calls flowText, but flows it to memory. Same restrictions as flowText. - * @param destIm Destination buffer - * @param font Pointer on the font used - * @param penColor Pen number to use for text - * @param backPen Background color - * @param fillBack Whether to fill the background - * @param centerh Whether to center the text horizontally - * @param centerv Whether to center the text vertically - * @param output Whether to output any text - * @param textRect Coords - * @param text The text itself - */ - int flowTextToMem(Image *destIm, TextFont *font, int16 spacing, byte penColor, byte backPen, - bool fillBack, bool centerh, bool centerv, bool output, Common::Rect textRect, - const char *text); + bool centerh, bool centerv, bool output, Common::Rect textRect, const char *text, Image *targetImage = nullptr); /** * Draws a vertical line. diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 301ed59065..be371c6e3c 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -168,16 +168,16 @@ void LabEngine::drawJournalText() { if (_journalPage <= 1) { curText = _journalTextTitle.c_str(); - _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText); + _graphics->flowText(_journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage); } else { curText = _journalText.c_str() + charsDrawn; - charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText); + charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage); } updateMusicAndEvents(); curText = _journalText.c_str() + charsDrawn; _lastPage = (*curText == 0); - _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText); + _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText, _journalBackImage); } void LabEngine::turnPage(bool fromLeft) { -- cgit v1.2.3