diff options
author | Filippos Karapetis | 2015-06-18 12:24:53 +0300 |
---|---|---|
committer | Filippos Karapetis | 2015-06-18 12:24:53 +0300 |
commit | 5ece075b582418b38f194c1f39a06c8c7343aeeb (patch) | |
tree | 7c465ad800cfa8c227ac33cb5d25f0559c112354 /engines | |
parent | 6cd17ca9dd3b94da81869c147e82c496243204b1 (diff) | |
download | scummvm-rg350-5ece075b582418b38f194c1f39a06c8c7343aeeb.tar.gz scummvm-rg350-5ece075b582418b38f194c1f39a06c8c7343aeeb.tar.bz2 scummvm-rg350-5ece075b582418b38f194c1f39a06c8c7343aeeb.zip |
SHERLOCK: RT: Reduce code duplication when writing fancy strings
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/surface.cpp | 12 | ||||
-rw-r--r-- | engines/sherlock/surface.h | 1 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_map.cpp | 30 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_tooltip.cpp | 30 |
4 files changed, 19 insertions, 54 deletions
diff --git a/engines/sherlock/surface.cpp b/engines/sherlock/surface.cpp index 48045beacd..79711b44d7 100644 --- a/engines/sherlock/surface.cpp +++ b/engines/sherlock/surface.cpp @@ -280,6 +280,18 @@ void Surface::writeString(const Common::String &str, const Common::Point &pt, by Fonts::writeString(this, str, pt, overrideColor); } +void Surface::writeFancyString(const Common::String &str, const Common::Point &pt, byte overrideColor1, byte overrideColor2) { + writeString(str, Common::Point(pt.x, pt.y), overrideColor1); + writeString(str, Common::Point(pt.x + 1, pt.y), overrideColor1); + writeString(str, Common::Point(pt.x + 2, pt.y), overrideColor1); + writeString(str, Common::Point(pt.x, pt.y + 1), overrideColor1); + writeString(str, Common::Point(pt.x + 2, pt.y + 1), overrideColor1); + writeString(str, Common::Point(pt.x, pt.y + 2), overrideColor1); + writeString(str, Common::Point(pt.x + 1, pt.y + 2), overrideColor1); + writeString(str, Common::Point(pt.x + 2, pt.y + 2), overrideColor1); + writeString(str, Common::Point(pt.x + 1, pt.y + 1), overrideColor2); +} + void Surface::maskArea(const ImageFrame &src, const Common::Point &pt, int scrollX) { // TODO error("TODO: maskArea"); diff --git a/engines/sherlock/surface.h b/engines/sherlock/surface.h index 150796ef9a..adda03dcc6 100644 --- a/engines/sherlock/surface.h +++ b/engines/sherlock/surface.h @@ -168,6 +168,7 @@ public: * Draws the given string into the back buffer using the images stored in _font */ virtual void writeString(const Common::String &str, const Common::Point &pt, byte overrideColor); + void writeFancyString(const Common::String &str, const Common::Point &pt, byte overrideColor1, byte overrideColor2); inline uint16 w() const { return _surface.w; } inline uint16 h() const { return _surface.h; } diff --git a/engines/sherlock/tattoo/tattoo_map.cpp b/engines/sherlock/tattoo/tattoo_map.cpp index 72834285cf..3be97c8b84 100644 --- a/engines/sherlock/tattoo/tattoo_map.cpp +++ b/engines/sherlock/tattoo/tattoo_map.cpp @@ -396,15 +396,7 @@ void TattooMap::checkMapNames(bool slamIt) { _textBuffer->fillRect(Common::Rect(0, 0, width, height), TRANSPARENCY); if (space == nullptr) { // The whole text can be drawn on a single line - _textBuffer->writeString(desc, Common::Point(0, 0), BLACK); - _textBuffer->writeString(desc, Common::Point(1, 0), BLACK); - _textBuffer->writeString(desc, Common::Point(2, 0), BLACK); - _textBuffer->writeString(desc, Common::Point(0, 1), BLACK); - _textBuffer->writeString(desc, Common::Point(2, 1), BLACK); - _textBuffer->writeString(desc, Common::Point(0, 2), BLACK); - _textBuffer->writeString(desc, Common::Point(1, 2), BLACK); - _textBuffer->writeString(desc, Common::Point(2, 2), BLACK); - _textBuffer->writeString(desc, Common::Point(1, 1), MAP_NAME_COLOR); + _textBuffer->writeFancyString(desc, Common::Point(0, 0), BLACK, MAP_NAME_COLOR); } else { // The text needs to be split up over two lines Common::String line1(desc.c_str(), space); @@ -412,28 +404,12 @@ void TattooMap::checkMapNames(bool slamIt) { // Draw the first line int xp = (width - screen.stringWidth(desc)) / 2; - _textBuffer->writeString(line1, Common::Point(xp + 0, 0), BLACK); - _textBuffer->writeString(line1, Common::Point(xp + 1, 0), BLACK); - _textBuffer->writeString(line1, Common::Point(xp + 2, 0), BLACK); - _textBuffer->writeString(line1, Common::Point(xp + 0, 1), BLACK); - _textBuffer->writeString(line1, Common::Point(xp + 2, 1), BLACK); - _textBuffer->writeString(line1, Common::Point(xp + 0, 2), BLACK); - _textBuffer->writeString(line1, Common::Point(xp + 1, 2), BLACK); - _textBuffer->writeString(line1, Common::Point(xp + 2, 2), BLACK); - _textBuffer->writeString(line1, Common::Point(xp + 1, 1), MAP_NAME_COLOR); + _textBuffer->writeFancyString(line1, Common::Point(xp, 0), BLACK, MAP_NAME_COLOR); int yp = screen.stringHeight(line2); xp = (width - screen.stringWidth(line2)) / 2; // CHECKME: Shouldn't we use yp for drawing line2? - _textBuffer->writeString(line2, Common::Point(xp + 0, yp), BLACK); - _textBuffer->writeString(line2, Common::Point(xp + 1, yp), BLACK); - _textBuffer->writeString(line2, Common::Point(xp + 2, yp), BLACK); - _textBuffer->writeString(line2, Common::Point(xp + 0, yp + 1), BLACK); - _textBuffer->writeString(line2, Common::Point(xp + 2, yp + 1), BLACK); - _textBuffer->writeString(line2, Common::Point(xp + 0, yp + 2), BLACK); - _textBuffer->writeString(line2, Common::Point(xp + 1, yp + 2), BLACK); - _textBuffer->writeString(line2, Common::Point(xp + 2, yp + 2), BLACK); - _textBuffer->writeString(line2, Common::Point(xp + 1, yp + 1), MAP_NAME_COLOR); + _textBuffer->writeFancyString(line2, Common::Point(xp, yp), BLACK, MAP_NAME_COLOR); } // Set the text display position diff --git a/engines/sherlock/tattoo/widget_tooltip.cpp b/engines/sherlock/tattoo/widget_tooltip.cpp index ee4b3cee2a..7d513b7af7 100644 --- a/engines/sherlock/tattoo/widget_tooltip.cpp +++ b/engines/sherlock/tattoo/widget_tooltip.cpp @@ -116,40 +116,16 @@ void WidgetTooltip::execute() { if (line2.empty()) { // Only a single line - _surface.writeString(str, Common::Point(0, 0), BLACK); - _surface.writeString(str, Common::Point(1, 0), BLACK); - _surface.writeString(str, Common::Point(2, 0), BLACK); - _surface.writeString(str, Common::Point(0, 1), BLACK); - _surface.writeString(str, Common::Point(2, 1), BLACK); - _surface.writeString(str, Common::Point(0, 2), BLACK); - _surface.writeString(str, Common::Point(1, 2), BLACK); - _surface.writeString(str, Common::Point(2, 2), BLACK); - _surface.writeString(str, Common::Point(1, 1), INFO_TOP); + _surface.writeFancyString(str, Common::Point(0, 0), BLACK, INFO_TOP); } else { // Two lines to display int xp, yp; xp = (width - screen.stringWidth(line1) - 2) / 2; - _surface.writeString(line1, Common::Point(xp, 0), BLACK); - _surface.writeString(line1, Common::Point(xp + 1, 0), BLACK); - _surface.writeString(line1, Common::Point(xp + 2, 0), BLACK); - _surface.writeString(line1, Common::Point(xp, 1), BLACK); - _surface.writeString(line1, Common::Point(xp + 2, 1), BLACK); - _surface.writeString(line1, Common::Point(xp, 2), BLACK); - _surface.writeString(line1, Common::Point(xp + 1, 2), BLACK); - _surface.writeString(line1, Common::Point(xp + 2, 2), BLACK); - _surface.writeString(line1, Common::Point(xp + 1, 1), INFO_TOP); + _surface.writeFancyString(line1, Common::Point(xp, 0), BLACK, INFO_TOP); xp = (width - screen.stringWidth(line2) - 2) / 2; yp = screen.stringHeight(line1) + 2; - _surface.writeString(line2, Common::Point(xp, yp), BLACK); - _surface.writeString(line2, Common::Point(xp + 1, yp), BLACK); - _surface.writeString(line2, Common::Point(xp + 2, yp), BLACK); - _surface.writeString(line2, Common::Point(xp, yp + 1), BLACK); - _surface.writeString(line2, Common::Point(xp + 2, yp + 1), BLACK); - _surface.writeString(line2, Common::Point(xp, yp + 2), BLACK); - _surface.writeString(line2, Common::Point(xp + 1, yp + 2), BLACK); - _surface.writeString(line2, Common::Point(xp + 2, yp + 2), BLACK); - _surface.writeString(line2, Common::Point(xp + 1, yp + 1), INFO_TOP); + _surface.writeFancyString(line2, Common::Point(xp, yp), BLACK, INFO_TOP); } // Set the initial display position for the tooltip text |