aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Hesse2012-06-30 01:46:24 +0200
committerSven Hesse2012-07-30 01:24:18 +0200
commit00fa997039525eeeacc34734e9a12e53f7b847dd (patch)
tree982fe2588bed0934e18cd04c57fb1f63755633c6
parentb5fa752b78c63bedcb53d38fb11244b7e99f9941 (diff)
downloadscummvm-rg350-00fa997039525eeeacc34734e9a12e53f7b847dd.tar.gz
scummvm-rg350-00fa997039525eeeacc34734e9a12e53f7b847dd.tar.bz2
scummvm-rg350-00fa997039525eeeacc34734e9a12e53f7b847dd.zip
GOB: Move drawString into Font
-rw-r--r--engines/gob/draw.cpp15
-rw-r--r--engines/gob/draw.h2
-rw-r--r--engines/gob/draw_fascin.cpp4
-rw-r--r--engines/gob/draw_playtoons.cpp4
-rw-r--r--engines/gob/draw_v2.cpp4
-rw-r--r--engines/gob/inter_v5.cpp10
-rw-r--r--engines/gob/minigames/geisha/penetration.cpp45
-rw-r--r--engines/gob/video.cpp17
-rw-r--r--engines/gob/video.h3
9 files changed, 49 insertions, 55 deletions
diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp
index 9253a0a242..3932987e0a 100644
--- a/engines/gob/draw.cpp
+++ b/engines/gob/draw.cpp
@@ -425,21 +425,6 @@ int Draw::stringLength(const char *str, uint16 fontIndex) {
return len;
}
-void Draw::drawString(const char *str, int16 x, int16 y, int16 color1, int16 color2,
- int16 transp, Surface &dest, const Font &font) {
-
- while (*str != '\0') {
- const int16 charRight = x + font.getCharWidth(*str);
- const int16 charBottom = y + font.getCharHeight();
-
- if ((charRight <= dest.getWidth()) && (charBottom <= dest.getHeight()))
- font.drawLetter(dest, *str, x, y, color1, color2, transp);
-
- x += font.getCharWidth(*str);
- str++;
- }
-}
-
void Draw::printTextCentered(int16 id, int16 left, int16 top, int16 right,
int16 bottom, const char *str, int16 fontIndex, int16 color) {
diff --git a/engines/gob/draw.h b/engines/gob/draw.h
index e7af1f9af3..b51c6466e0 100644
--- a/engines/gob/draw.h
+++ b/engines/gob/draw.h
@@ -194,8 +194,6 @@ public:
adjustCoords(adjust, (int16 *)coord1, (int16 *)coord2);
}
int stringLength(const char *str, uint16 fontIndex);
- void drawString(const char *str, int16 x, int16 y, int16 color1, int16 color2,
- int16 transp, Surface &dest, const Font &font);
void printTextCentered(int16 id, int16 left, int16 top, int16 right,
int16 bottom, const char *str, int16 fontIndex, int16 color);
void oPlaytoons_sub_F_1B( uint16 id, int16 left, int16 top, int16 right, int16 bottom, char *paramStr, int16 var3, int16 var4, int16 shortId);
diff --git a/engines/gob/draw_fascin.cpp b/engines/gob/draw_fascin.cpp
index 54cd52b660..12009d7ee5 100644
--- a/engines/gob/draw_fascin.cpp
+++ b/engines/gob/draw_fascin.cpp
@@ -222,8 +222,8 @@ void Draw_Fascination::spriteOperation(int16 operation) {
_destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency);
}
} else {
- drawString(_textToPrint, _destSpriteX, _destSpriteY, _frontColor,
- _backColor, _transparency, *_spritesArray[_destSurface], *font);
+ font->drawString(_textToPrint, _destSpriteX, _destSpriteY, _frontColor,
+ _backColor, _transparency, *_spritesArray[_destSurface]);
_destSpriteX += len * font->getCharWidth();
}
} else {
diff --git a/engines/gob/draw_playtoons.cpp b/engines/gob/draw_playtoons.cpp
index a443f81ccf..76e2ae591c 100644
--- a/engines/gob/draw_playtoons.cpp
+++ b/engines/gob/draw_playtoons.cpp
@@ -283,8 +283,8 @@ void Draw_Playtoons::spriteOperation(int16 operation) {
_destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency);
}
} else {
- drawString(_textToPrint, _destSpriteX, _destSpriteY, _frontColor,
- _backColor, _transparency, *_spritesArray[_destSurface], *font);
+ font->drawString(_textToPrint, _destSpriteX, _destSpriteY, _frontColor,
+ _backColor, _transparency, *_spritesArray[_destSurface]);
_destSpriteX += len * font->getCharWidth();
}
} else {
diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp
index b637ecbd2b..ac43c7b86a 100644
--- a/engines/gob/draw_v2.cpp
+++ b/engines/gob/draw_v2.cpp
@@ -831,8 +831,8 @@ void Draw_v2::spriteOperation(int16 operation) {
getColor(_backColor), _transparency);
}
} else {
- drawString(_textToPrint, _destSpriteX, _destSpriteY, getColor(_frontColor),
- getColor(_backColor), _transparency, *_spritesArray[_destSurface], *font);
+ font->drawString(_textToPrint, _destSpriteX, _destSpriteY, getColor(_frontColor),
+ getColor(_backColor), _transparency, *_spritesArray[_destSurface]);
_destSpriteX += len * font->getCharWidth();
}
} else {
diff --git a/engines/gob/inter_v5.cpp b/engines/gob/inter_v5.cpp
index c0e8978afd..24905b08d1 100644
--- a/engines/gob/inter_v5.cpp
+++ b/engines/gob/inter_v5.cpp
@@ -281,7 +281,7 @@ void Inter_v5::o5_getSystemCDSpeed(OpGobParams &params) {
Font *font;
if ((font = _vm->_draw->loadFont("SPEED.LET"))) {
- _vm->_draw->drawString("100 %", 402, 89, 112, 144, 0, *_vm->_draw->_backSurface, *font);
+ font->drawString("100 %", 402, 89, 112, 144, 0, *_vm->_draw->_backSurface);
_vm->_draw->forceBlit();
delete font;
@@ -293,7 +293,7 @@ void Inter_v5::o5_getSystemRAM(OpGobParams &params) {
Font *font;
if ((font = _vm->_draw->loadFont("SPEED.LET"))) {
- _vm->_draw->drawString("100 %", 402, 168, 112, 144, 0, *_vm->_draw->_backSurface, *font);
+ font->drawString("100 %", 402, 168, 112, 144, 0, *_vm->_draw->_backSurface);
_vm->_draw->forceBlit();
delete font;
@@ -305,7 +305,7 @@ void Inter_v5::o5_getSystemCPUSpeed(OpGobParams &params) {
Font *font;
if ((font = _vm->_draw->loadFont("SPEED.LET"))) {
- _vm->_draw->drawString("100 %", 402, 248, 112, 144, 0, *_vm->_draw->_backSurface, *font);
+ font->drawString("100 %", 402, 248, 112, 144, 0, *_vm->_draw->_backSurface);
_vm->_draw->forceBlit();
delete font;
@@ -317,7 +317,7 @@ void Inter_v5::o5_getSystemDrawSpeed(OpGobParams &params) {
Font *font;
if ((font = _vm->_draw->loadFont("SPEED.LET"))) {
- _vm->_draw->drawString("100 %", 402, 326, 112, 144, 0, *_vm->_draw->_backSurface, *font);
+ font->drawString("100 %", 402, 326, 112, 144, 0, *_vm->_draw->_backSurface);
_vm->_draw->forceBlit();
delete font;
@@ -329,7 +329,7 @@ void Inter_v5::o5_totalSystemSpecs(OpGobParams &params) {
Font *font;
if ((font = _vm->_draw->loadFont("SPEED.LET"))) {
- _vm->_draw->drawString("100 %", 402, 405, 112, 144, 0, *_vm->_draw->_backSurface, *font);
+ font->drawString("100 %", 402, 405, 112, 144, 0, *_vm->_draw->_backSurface);
_vm->_draw->forceBlit();
delete font;
diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp
index 05695e5dbb..c8c4f2bba7 100644
--- a/engines/gob/minigames/geisha/penetration.cpp
+++ b/engines/gob/minigames/geisha/penetration.cpp
@@ -778,29 +778,24 @@ void Penetration::drawFloorText() {
else if (_floor == 2)
floorString = strings[kString1stBasement];
+ Surface &surface = *_vm->_draw->_backSurface;
+
if (floorString)
- _vm->_draw->drawString(floorString, 10, 15, kColorFloorText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
+ font->drawString(floorString, 10, 15, kColorFloorText, kColorBlack, 1, surface);
if (_exits.size() > 0) {
int exitCount = kString2Exits;
if (_exits.size() == 1)
exitCount = kString1Exit;
- _vm->_draw->drawString(strings[kStringYouHave] , 10, 38, kColorExitText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
- _vm->_draw->drawString(strings[exitCount] , 10, 53, kColorExitText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
- _vm->_draw->drawString(strings[kStringToReach] , 10, 68, kColorExitText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
- _vm->_draw->drawString(strings[kStringUpperLevel1], 10, 84, kColorExitText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
- _vm->_draw->drawString(strings[kStringUpperLevel2], 10, 98, kColorExitText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
+ font->drawString(strings[kStringYouHave] , 10, 38, kColorExitText, kColorBlack, 1, surface);
+ font->drawString(strings[exitCount] , 10, 53, kColorExitText, kColorBlack, 1, surface);
+ font->drawString(strings[kStringToReach] , 10, 68, kColorExitText, kColorBlack, 1, surface);
+ font->drawString(strings[kStringUpperLevel1], 10, 84, kColorExitText, kColorBlack, 1, surface);
+ font->drawString(strings[kStringUpperLevel2], 10, 98, kColorExitText, kColorBlack, 1, surface);
} else
- _vm->_draw->drawString(strings[kStringNoExit], 10, 53, kColorExitText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
+ font->drawString(strings[kStringNoExit], 10, 53, kColorExitText, kColorBlack, 1, surface);
}
void Penetration::drawEndText() {
@@ -814,21 +809,17 @@ void Penetration::drawEndText() {
if (!font)
return;
+ Surface &surface = *_vm->_draw->_backSurface;
+
const char **strings = kStrings[getLanguage()];
- _vm->_draw->drawString(strings[kStringLevel0] , 11, 21, kColorExitText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
- _vm->_draw->drawString(strings[kStringPenetration], 11, 42, kColorExitText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
- _vm->_draw->drawString(strings[kStringSuccessful] , 11, 58, kColorExitText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
-
- _vm->_draw->drawString(strings[kStringDanger] , 11, 82, kColorFloorText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
- _vm->_draw->drawString(strings[kStringGynoides] , 11, 98, kColorFloorText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
- _vm->_draw->drawString(strings[kStringActivated], 11, 113, kColorFloorText, kColorBlack, 1,
- *_vm->_draw->_backSurface, *font);
+ font->drawString(strings[kStringLevel0] , 11, 21, kColorExitText, kColorBlack, 1, surface);
+ font->drawString(strings[kStringPenetration], 11, 42, kColorExitText, kColorBlack, 1, surface);
+ font->drawString(strings[kStringSuccessful] , 11, 58, kColorExitText, kColorBlack, 1, surface);
+
+ font->drawString(strings[kStringDanger] , 11, 82, kColorFloorText, kColorBlack, 1, surface);
+ font->drawString(strings[kStringGynoides] , 11, 98, kColorFloorText, kColorBlack, 1, surface);
+ font->drawString(strings[kStringActivated], 11, 113, kColorFloorText, kColorBlack, 1, surface);
_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, kTextAreaLeft, kTextAreaTop, kTextAreaRight, kTextAreaBigBottom);
_vm->_draw->blitInvalidated();
diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp
index f1f014cce0..8bcf14e040 100644
--- a/engines/gob/video.cpp
+++ b/engines/gob/video.cpp
@@ -134,6 +134,23 @@ void Font::drawLetter(Surface &surf, uint8 c, uint16 x, uint16 y,
}
}
+void Font::drawString(const Common::String &str, int16 x, int16 y, int16 color1, int16 color2,
+ bool transp, Surface &dest) const {
+
+ const char *s = str.c_str();
+
+ while (*s != '\0') {
+ const int16 charRight = x + getCharWidth(*s);
+ const int16 charBottom = y + getCharHeight();
+
+ if ((x >= 0) && (y >= 0) && (charRight <= dest.getWidth()) && (charBottom <= dest.getHeight()))
+ drawLetter(dest, *s, x, y, color1, color2, transp);
+
+ x += getCharWidth(*s);
+ s++;
+ }
+}
+
const byte *Font::getCharData(uint8 c) const {
if (_endItem == 0) {
warning("Font::getCharData(): _endItem == 0");
diff --git a/engines/gob/video.h b/engines/gob/video.h
index ecbb579c5f..a8c1480a6b 100644
--- a/engines/gob/video.h
+++ b/engines/gob/video.h
@@ -46,6 +46,9 @@ public:
void drawLetter(Surface &surf, uint8 c, uint16 x, uint16 y,
uint32 color1, uint32 color2, bool transp) const;
+ void drawString(const Common::String &str, int16 x, int16 y, int16 color1, int16 color2,
+ bool transp, Surface &dest) const;
+
private:
const byte *_dataPtr;
const byte *_data;