From: Christoph Sommer Date: Sat, 22 Apr 2006 14:32:20 +0000 (+0000) Subject: Fixed textscroller's problem with blank lines X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2536976bee590a6028443c6fe6032ca00450866f;p=supertux.git Fixed textscroller's problem with blank lines SVN-Revision: 3382 --- diff --git a/src/textscroller.cpp b/src/textscroller.cpp index 85b7c085c..0f0a5c154 100644 --- a/src/textscroller.cpp +++ b/src/textscroller.cpp @@ -263,7 +263,14 @@ InfoBoxLine::split(const std::string& text, int line_length) std::string::size_type l; char format_char = '#'; while(i < text.size()) { + // take care of empty lines - represent them as blank lines of normal text + if (text[i] == '\n') { + lines.push_back(new InfoBoxLine('\t', "")); + i++; + continue; + } + // extract the format_char format_char = text[i]; i++; if (i >= text.size()) break; @@ -301,7 +308,6 @@ void InfoBoxLine::draw(DrawingContext& context, const Vector& position, int layer) { switch (lineType) { - case SPACER: case IMAGE: context.draw_surface(image, Vector( (SCREEN_WIDTH - image->get_width()) / 2, position.y), layer); break; @@ -318,8 +324,6 @@ float InfoBoxLine::get_height() { switch (lineType) { - case SPACER: - return font->get_height() + ITEMS_SPACE; case IMAGE: return image->get_height() + ITEMS_SPACE; case NORMAL_LEFT: diff --git a/src/textscroller.hpp b/src/textscroller.hpp index c7803ea47..604af0894 100644 --- a/src/textscroller.hpp +++ b/src/textscroller.hpp @@ -37,7 +37,7 @@ class Surface; class InfoBoxLine { private: - enum LineType { NORMAL, NORMAL_LEFT, SMALL, HEADING, REFERENCE, IMAGE, SPACER}; + enum LineType { NORMAL, NORMAL_LEFT, SMALL, HEADING, REFERENCE, IMAGE}; LineType lineType; Font* font; std::string text;