X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftextscroller.cpp;h=5c8586758160f7bcae47435ad4a0d68f20b8c6cd;hb=198f758764fff064a47630b5d0f1e3d6aabe95a8;hp=74dc0678ea62bc0ff31c9b5a778bdd2ec5e00033;hpb=fea3446f05e1e7673607b835c269d3e8d1929ab3;p=supertux.git diff --git a/src/textscroller.cpp b/src/textscroller.cpp index 74dc0678e..5c8586758 100644 --- a/src/textscroller.cpp +++ b/src/textscroller.cpp @@ -230,25 +230,42 @@ Font* get_font_by_format_char(char format_char) { switch(format_char) { case ' ': - return white_small_text; + return small_font; + break; + case '-': + return big_font; break; case '\t': - return white_text; + case '*': + case '#': + case '!': + return normal_font; + break; + default: + return normal_font; + log_warning << "Unknown format_char: '" << format_char << "'" << std::endl; + break; + } +} + +Color get_color_by_format_char(char format_char) { + switch(format_char) + { + case ' ': + return TextScroller::small_color; break; case '-': - return white_big_text; + return TextScroller::heading_color; break; case '*': - return blue_text; - break; + return TextScroller::reference_color; + case '\t': case '#': - return white_text; - break; case '!': - return 0; + return TextScroller::normal_color; break; default: - return 0; + return Color(0,0,0); log_warning << "Unknown format_char: '" << format_char << "'" << std::endl; break; } @@ -283,10 +300,11 @@ InfoBoxLine::LineType get_linetype_by_format_char(char format_char) { } } -InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) : lineType(NORMAL), font(white_text), text(text), image(0) +InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) : lineType(NORMAL), font(normal_font), text(text), image(0) { font = get_font_by_format_char(format_char); lineType = get_linetype_by_format_char(format_char); + color = get_color_by_format_char(format_char); if (lineType == IMAGE) image = new Surface(text); } @@ -337,7 +355,6 @@ InfoBoxLine::split(const std::string& text, float width) lines.push_back(new InfoBoxLine(format_char, s2)); s = overflow; } while (s.length() > 0); - } return lines; @@ -352,10 +369,10 @@ InfoBoxLine::draw(DrawingContext& context, const Rect& bbox, int layer) context.draw_surface(image, Vector( (bbox.p1.x + bbox.p2.x - image->get_width()) / 2, position.y), layer); break; case NORMAL_LEFT: - context.draw_text(font, text, Vector(position.x, position.y), ALIGN_LEFT, layer); + context.draw_text(font, text, Vector(position.x, position.y), ALIGN_LEFT, layer, color); break; default: - context.draw_text(font, text, Vector((bbox.p1.x + bbox.p2.x) / 2, position.y), ALIGN_CENTER, layer); + context.draw_text(font, text, Vector((bbox.p1.x + bbox.p2.x) / 2, position.y), ALIGN_CENTER, layer, color); break; } }