aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2015-12-17 18:35:53 +0100
committerWillem Jan Palenstijn2015-12-23 21:34:07 +0100
commit054a7a1e19ffb3d5f5d298c0af3e0e33435d5ed7 (patch)
tree5fb642f27baaf9d7ebbea1b5cd1900f9034edab7
parent605c2e553bd9b8421af643491a7855d8c2cd4710 (diff)
downloadscummvm-rg350-054a7a1e19ffb3d5f5d298c0af3e0e33435d5ed7.tar.gz
scummvm-rg350-054a7a1e19ffb3d5f5d298c0af3e0e33435d5ed7.tar.bz2
scummvm-rg350-054a7a1e19ffb3d5f5d298c0af3e0e33435d5ed7.zip
LAB: Use Common::Rect in functions related to flowText (WIP)
-rw-r--r--engines/lab/dispman.cpp58
-rw-r--r--engines/lab/dispman.h10
-rw-r--r--engines/lab/engine.cpp43
-rw-r--r--engines/lab/intro.cpp2
-rw-r--r--engines/lab/lab.h6
-rw-r--r--engines/lab/map.cpp9
-rw-r--r--engines/lab/special.cpp61
-rw-r--r--engines/lab/utils.cpp4
-rw-r--r--engines/lab/utils.h1
9 files changed, 104 insertions, 90 deletions
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index b9d5802dc8..2db2bc1990 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -188,12 +188,11 @@ int DisplayMan::flowText(
bool centerh, // Whether to center the text horizontally
bool centerv, // Whether to center the text vertically
bool output, // Whether to output any text
- uint16 x1, uint16 y1, // Cords
- uint16 x2, uint16 y2,
+ Common::Rect textRect, // Cords
const char *str) { // The text itself
if (fillBack) {
setPen(backPen);
- rectFill(x1, y1, x2, y2);
+ rectFill(textRect);
}
if (!str)
@@ -203,9 +202,9 @@ int DisplayMan::flowText(
TextFont *msgFont = font;
uint16 fontHeight = textHeight(msgFont) + spacing;
- uint16 numLines = (y2 - y1 + 1) / fontHeight;
- uint16 width = x2 - x1 + 1;
- uint16 y = y1;
+ uint16 numLines = (textRect.height() + 1) / fontHeight;
+ uint16 width = textRect.width() + 1;
+ uint16 y = textRect.top;
char lineBuffer[256];
if (centerv && output) {
@@ -218,14 +217,14 @@ int DisplayMan::flowText(
}
if (actlines <= numLines)
- y += ((y2 - y1 + 1) - (actlines * fontHeight)) / 2;
+ y += ((textRect.height() + 1) - (actlines * fontHeight)) / 2;
}
int len = 0;
while (numLines && str[0]) {
getLine(msgFont, lineBuffer, &str, width);
- uint16 x = x1;
+ uint16 x = textRect.left;
len += strlen(lineBuffer);
if (centerh)
@@ -252,12 +251,10 @@ int DisplayMan::flowTextScaled(
bool centerX, // Whether to center the text horizontally
bool centerY, // Whether to center the text vertically
bool output, // Whether to output any text
- uint16 x1, uint16 y1, // Cords
- uint16 x2, uint16 y2,
+ Common::Rect textRect, // Cords
const char *str) {
- return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output,
- _vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1),
- _vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2), str);
+ Common::Rect scaledRect = _vm->_utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom);
+ return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output, scaledRect, str);
}
/**
@@ -272,8 +269,7 @@ int DisplayMan::flowTextToMem(Image *destIm,
bool centerh, // Whether to center the text horizontally
bool centerv, // Whether to center the text vertically
bool output, // Whether to output any text
- uint16 x1, uint16 y1, // Cords
- uint16 x2, uint16 y2,
+ Common::Rect textRect, // Cords
const char *str) { // The text itself
byte *saveDisplayBuffer = _currentDisplayBuffer;
uint32 bytesPerPage = _screenBytesPerPage;
@@ -281,7 +277,7 @@ int DisplayMan::flowTextToMem(Image *destIm,
_currentDisplayBuffer = destIm->_imageData;
_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
- int res = flowText(font, spacing, penColor, backPen, fillBack, centerh, centerv, output, x1, y1, x2, y2, str);
+ int res = flowText(font, spacing, penColor, backPen, fillBack, centerh, centerv, output, textRect, str);
_screenBytesPerPage = bytesPerPage;
_currentDisplayBuffer = saveDisplayBuffer;
@@ -324,7 +320,7 @@ int DisplayMan::longDrawMessage(const char *str) {
createBox(198);
_vm->_event->mouseShow();
- return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str);
+ return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, Common::Rect(6, 155, 313, 195), str);
}
/**
@@ -479,22 +475,22 @@ void DisplayMan::setPen(byte penNum) {
/**
* Fills in a rectangle.
*/
-void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
- int w = x2 - x1 + 1;
- int h = y2 - y1 + 1;
+void DisplayMan::rectFill(Common::Rect fillRect) {
+ int width = fillRect.width() + 1;
+ int height = fillRect.height() + 1;
- if (x1 + w > _screenWidth)
- w = _screenWidth - x1;
+ if (fillRect.left + width > _screenWidth)
+ width = _screenWidth - fillRect.left;
- if (y1 + h > _screenHeight)
- h = _screenHeight - y1;
+ if (fillRect.top + height > _screenHeight)
+ height = _screenHeight - fillRect.top;
- if ((w > 0) && (h > 0)) {
- char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
+ if ((width > 0) && (height > 0)) {
+ char *d = (char *)getCurrentDrawingBuffer() + fillRect.top * _screenWidth + fillRect.left;
- while (h-- > 0) {
+ while (height-- > 0) {
char *dd = d;
- int ww = w;
+ int ww = width;
while (ww-- > 0) {
*dd++ = _curPen;
@@ -505,8 +501,12 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
}
}
+void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+ rectFill(Common::Rect(x1, y1, x2, y2));
+}
+
void DisplayMan::rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
- rectFill(_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1), _vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2));
+ rectFill(_vm->_utils->vgaRectScale(x1, y1, x2, y2));
}
/**
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 92a09c1f92..c00f18d9d7 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -92,6 +92,7 @@ public:
void drawMessage(const char *str);
void setPen(byte pennum);
void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+ void rectFill(Common::Rect fillRect);
void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
// Window text stuff
int flowText(TextFont *font, // the TextAttr pointer
@@ -102,8 +103,7 @@ public:
bool centerh, // Whether to center the text horizontally
bool centerv, // Whether to center the text vertically
bool output, // Whether to output any text
- uint16 x1, uint16 y1, // Cords
- uint16 x2, uint16 y2,
+ Common::Rect textRect, // Cords
const char *text); // The text itself
int flowTextScaled(
@@ -115,8 +115,7 @@ public:
bool centerh, // Whether to center the text horizontally
bool centerv, // Whether to center the text vertically
bool output, // Whether to output any text
- uint16 x1, uint16 y1, // Cords
- uint16 x2, uint16 y2,
+ Common::Rect textRect, // Cords
const char *text); // The text itself
int flowTextToMem(Image *destIm,
@@ -128,8 +127,7 @@ public:
bool centerh, // Whether to center the text horizontally
bool centerv, // Whether to center the text vertically
bool output, // Whether to output any text
- uint16 x1, uint16 y1, // Cords
- uint16 x2, uint16 y2,
+ Common::Rect textRect, // Cords
const char *str); // The text itself
void drawHLine(uint16 x, uint16 y1, uint16 y2);
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f82c7cc790..c79197a35a 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -198,46 +198,55 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
if (!closePtr)
return false;
- int monltmargin, monrtmargin, montopmargin, lutertmargin;
+ int luteRight;
+ Common::Rect textRect;
if (getPlatform() != Common::kPlatformWindows) {
- monltmargin = 0;
- monrtmargin = 319;
- montopmargin = 0;
- lutertmargin = 124;
+ textRect.left = 0;
+ textRect.right = 319;
+ textRect.top = 0;
+ textRect.bottom = 165;
+ luteRight = 124;
} else {
- monltmargin = 2;
- monrtmargin = 317;
- montopmargin = 2;
- lutertmargin = 128;
+ textRect.left = 2;
+ textRect.right = 317;
+ textRect.top = 2;
+ textRect.bottom = 165;
+ luteRight = 128;
}
switch (closePtr->_closeUpType) {
case kMonitorMuseum:
case kMonitorLibrary:
case kMonitorWindow:
- doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, monrtmargin, 165);
+ doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
break;
case kMonitorGramophone:
- doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 171, 165);
+ textRect.right = 171;
+ doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
break;
case kMonitorUnicycle:
- doMonitor(closePtr->_graphicName, closePtr->_message, false, 100, montopmargin, monrtmargin, 165);
+ textRect.left = 100;
+ doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
break;
case kMonitorStatue:
- doMonitor(closePtr->_graphicName, closePtr->_message, false, 117, montopmargin, monrtmargin, 165);
+ textRect.left = 117;
+ doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
break;
case kMonitorTalisman:
- doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 184, 165);
+ textRect.right = 184;
+ doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
break;
case kMonitorLute:
- doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, lutertmargin, 165);
+ textRect.right = luteRight;
+ doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
break;
case kMonitorClock:
- doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 206, 165);
+ textRect.right = 206;
+ doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
break;
case kMonitorTerminal:
- doMonitor(closePtr->_graphicName, closePtr->_message, true, monltmargin, montopmargin, monrtmargin, 165);
+ doMonitor(closePtr->_graphicName, closePtr->_message, true, textRect);
break;
default:
return false;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index e26f1821da..b2fa0b0786 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -103,7 +103,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
_vm->_graphics->setPen(7);
_vm->_graphics->rectFillScaled(10, 10, 310, 190);
- charDrawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, 14, 11, 306, 189, (char *)curText);
+ charDrawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, Common::Rect(14, 11, 306, 189), (char *)curText);
_vm->_graphics->fade(true, 0);
} else
charDrawn = _vm->_graphics->longDrawMessage((char *)curText);
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 4cd681e635..dcde9f9087 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -205,7 +205,7 @@ private:
void doJournal();
bool doMainView(CloseDataPtr *closePtrList);
void doMap(uint16 curRoom);
- void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+ void doMonitor(char *background, char *textfile, bool isinteractive, Common::Rect textRect);
void doNotes();
bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
@@ -216,7 +216,7 @@ private:
void drawJournal(uint16 wipenum, bool needFade);
void drawJournalText();
void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn);
- void drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
+ void drawMonText(char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive);
void drawRoomMap(uint16 curRoom, bool drawMarkFl);
void drawRoomMessage(uint16 curInv, CloseDataPtr closePtr);
void drawStaticMessage(byte index);
@@ -245,7 +245,7 @@ private:
uint16 processArrow(uint16 curDirection, uint16 arrow);
void processJournal();
void processMap(uint16 curRoom);
- void processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+ void processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect);
Common::Rect roomCoords(uint16 curRoom);
bool saveRestoreGame();
void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 63ea35398d..cbd664e27e 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -405,16 +405,17 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
_imgHugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97));
} else if (floorNum == kFloorSurMaze) {
char *sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
- _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, _utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450), sptr);
+ Common::Rect textRect = Common::Rect(_utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450));
+ _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, textRect, sptr);
}
if ((floorNum >= kFloorLower) && (floorNum <= kFloorCarnival)) {
char *sptr = (char *)_resource->getStaticText(floorNum - 1).c_str();
- _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr);
+ _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 75, 134, 97), sptr);
}
if (_rooms[curMsg]._roomMsg)
- _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, _rooms[curMsg]._roomMsg);
+ _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), _rooms[curMsg]._roomMsg);
if (fadeIn)
_graphics->fade(true, 0);
@@ -558,7 +559,7 @@ void LabEngine::processMap(uint16 curRoom) {
_event->mouseHide();
_graphics->setPen(3);
_graphics->rectFillScaled(13, 148, 135, 186);
- _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
+ _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), sptr);
if (_maps[oldMsg]._pageNumber == curFloor)
drawRoomMap(oldMsg, (bool)(oldMsg == curRoom));
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 2f071dab35..c8cc616d30 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -54,7 +54,8 @@ void LabEngine::doNotes() {
TextFont *noteFont = _resource->getFont("P:Note.fon");
char *noteText = _resource->getText("Lab:Rooms/Notes");
- _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, _utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148), noteText);
+ Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148));
+ _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText);
_graphics->setPalette(_anim->_diffPalette, 256);
_graphics->closeFont(noteFont);
delete[] noteText;
@@ -67,7 +68,9 @@ void LabEngine::doNotes() {
void LabEngine::doWestPaper() {
TextFont *paperFont = _resource->getFont("P:News22.fon");
char *paperText = _resource->getText("Lab:Rooms/Date");
- _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), paperText);
+
+ Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91));
+ _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText);
_graphics->closeFont(paperFont);
delete[] paperText;
@@ -75,13 +78,15 @@ void LabEngine::doWestPaper() {
paperText = _resource->getText("Lab:Rooms/Headline");
int fileLen = strlen(paperText) - 1;
- int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), paperText);
+ textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118));
+ int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, textRect, paperText);
uint16 y;
if (charsPrinted < fileLen) {
y = 130 - _utils->svgaCord(5);
- _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), paperText);
+ textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132));
+ _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, textRect, paperText);
} else
y = 115 - _utils->svgaCord(5);
@@ -90,10 +95,10 @@ void LabEngine::doWestPaper() {
paperFont = _resource->getFont("P:Note.fon");
paperText = _resource->getText("Lab:Rooms/Col1");
- charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, paperText);
+ charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(45, y, 158, 148), paperText);
delete[] paperText;
paperText = _resource->getText("Lab:Rooms/Col2");
- charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, paperText);
+ charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(162, y, 275, 148), paperText);
delete[] paperText;
_graphics->closeFont(paperFont);
@@ -167,7 +172,7 @@ void LabEngine::drawJournalText() {
while (drawingToPage < _journalPage) {
_music->updateMusic();
curText = (char *)(_journalText + charsDrawn);
- charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, curText);
+ charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, Common::Rect(52, 32, 152, 148), curText);
_lastPage = (*curText == 0);
@@ -179,16 +184,16 @@ void LabEngine::drawJournalText() {
if (_journalPage <= 1) {
curText = _journalTextTitle;
- _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+ _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
} else {
curText = (char *)(_journalText + charsDrawn);
- charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+ charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
}
_music->updateMusic();
curText = (char *)(_journalText + charsDrawn);
_lastPage = (*curText == 0);
- _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
+ _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText);
curText = (char *)(_journalText + charsDrawn);
_lastPage |= (*curText == 0);
@@ -331,7 +336,7 @@ void LabEngine::doJournal() {
/**
* Draws the text for the monitor.
*/
-void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
+void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive) {
uint16 drawingToPage = 0, yspacing = 0;
int charsDrawn = 0;
char *curText = text;
@@ -346,7 +351,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
text += 2;
uint16 fheight = _graphics->textHeight(monitorFont);
- x1 = _monitorButton->_width + _utils->vgaScaleX(3);
+ textRect.left = _monitorButton->_width + _utils->vgaScaleX(3);
_monitorButtonHeight = _monitorButton->_height + _utils->vgaScaleY(3);
if (_monitorButtonHeight > fheight)
@@ -355,22 +360,22 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
_monitorButtonHeight = fheight;
_graphics->setPen(0);
- _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
+ _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom);
for (uint16 i = 0; i < numlines; i++)
_monitorButton->drawImage(0, i * _monitorButtonHeight);
} else if (isinteractive) {
_graphics->setPen(0);
- _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
+ _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom);
} else {
_graphics->setPen(0);
- _graphics->rectFill(x1, y1, x2, y2);
+ _graphics->rectFill(textRect);
}
while (drawingToPage < _monitorPage) {
_music->updateMusic();
curText = (char *)(text + charsDrawn);
- charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, curText);
+ charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText);
_lastPage = (*curText == 0);
if (_lastPage)
@@ -381,7 +386,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
curText = (char *)(text + charsDrawn);
_lastPage = (*curText == 0);
- charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, curText);
+ charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, textRect, curText);
curText += charsDrawn;
_lastPage |= (*curText == 0);
@@ -391,7 +396,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
/**
* Processes user input.
*/
-void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) {
const char *startFileName = _monitorTextFilename;
CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10];
uint16 depth = 0;
@@ -415,7 +420,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
ntext = _resource->getText(_monitorTextFilename);
_graphics->fade(false, 0);
- drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
+ drawMonText(ntext, monitorFont, textRect, isInteractive);
_graphics->fade(true, 0);
delete[] ntext;
}
@@ -455,19 +460,19 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
}
} else if (_monitorPage > 0) {
_monitorPage = 0;
- drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
+ drawMonText(ntext, monitorFont, textRect, isInteractive);
}
} else if (mouseX < _utils->vgaScaleX(259)) {
return;
} else if (mouseX <= _utils->vgaScaleX(289)) {
if (!_lastPage) {
_monitorPage += 1;
- drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
+ drawMonText(ntext, monitorFont, textRect, isInteractive);
}
} else if (_monitorPage >= 1) {
// mouseX between 290 and 320 (scaled)
_monitorPage -= 1;
- drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
+ drawMonText(ntext, monitorFont, textRect, isInteractive);
}
} else if (isInteractive) {
CloseDataPtr tmpClosePtr = _closeDataPtr;
@@ -488,12 +493,8 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
/**
* Does what's necessary for the monitor.
*/
-void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
- x1 = _utils->vgaScaleX(x1);
- x2 = _utils->vgaScaleX(x2);
- y1 = _utils->vgaScaleY(y1);
- y2 = _utils->vgaScaleY(y2);
-
+void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, Common::Rect textRect) {
+ Common::Rect scaledRect = _utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom);
_monitorTextFilename = textfile;
_graphics->blackAllScreen();
@@ -514,10 +515,10 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
char *ntext = _resource->getText(textfile);
_graphics->loadBackPict(background, _highPalette);
- drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
+ drawMonText(ntext, monitorFont, scaledRect, isinteractive);
_event->mouseShow();
_graphics->fade(true, 0);
- processMonitor(ntext, monitorFont, isinteractive, x1, y1, x2, y2);
+ processMonitor(ntext, monitorFont, isinteractive, scaledRect);
_graphics->fade(false, 0);
_event->mouseHide();
delete[] ntext;
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 89af44e2ea..73605582b0 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -94,6 +94,10 @@ int16 Utils::vgaScaleY(int16 y) {
return y;
}
+Common::Rect Utils::vgaRectScale(int16 x1, int16 y1, int16 x2, int16 y2) {
+ return Common::Rect(vgaScaleX(x1), vgaScaleY(y1), vgaScaleX(x2), vgaScaleY(y2));
+}
+
uint16 Utils::svgaCord(uint16 cord) {
if (_vm->_isHiRes)
return cord;
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 0c4118e7bc..c6337c797b 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -53,6 +53,7 @@ public:
uint16 scaleY(uint16 y);
int16 vgaScaleX(int16 x);
int16 vgaScaleY(int16 y);
+ Common::Rect vgaRectScale(int16 x1, int16 y1, int16 x2, int16 y2);
uint16 svgaCord(uint16 cord);
uint16 mapScaleX(uint16 x);
uint16 mapScaleY(uint16 y);