From: Ingo Ruhnke Date: Tue, 26 Aug 2008 14:07:00 +0000 (+0000) Subject: qmax patch to fix bug #0000389 - colors in infoblocks X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=198f758764fff064a47630b5d0f1e3d6aabe95a8;p=supertux.git qmax patch to fix bug #0000389 - colors in infoblocks SVN-Revision: 5747 --- diff --git a/src/colorscheme.cpp b/src/colorscheme.cpp index 5673e0018..4f62e94e5 100644 --- a/src/colorscheme.cpp +++ b/src/colorscheme.cpp @@ -51,4 +51,10 @@ namespace WorldMapNS { Color teleporter_message_color(0.5,1.0,0.5); }} +namespace TextScroller { + Color small_color(1.0,1.0,1.0); + Color heading_color(1.0,1.0,0.6); + Color reference_color(0.2,0.6,1.0); + Color normal_color(1.0,1.0,1.0); +} diff --git a/src/textscroller.cpp b/src/textscroller.cpp index d4c4ad728..5c8586758 100644 --- a/src/textscroller.cpp +++ b/src/textscroller.cpp @@ -232,23 +232,40 @@ Font* get_font_by_format_char(char format_char) { case ' ': return small_font; break; - case '\t': - return normal_font; - break; case '-': return big_font; break; + case '\t': case '*': - return normal_font; // blue_text - break; 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 TextScroller::heading_color; + break; + case '*': + return TextScroller::reference_color; + case '\t': + case '#': 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; } @@ -287,6 +304,7 @@ InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) : lineType(N { 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); } @@ -351,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, Color(1,1,1)); + 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,Color(1,1,1)); + context.draw_text(font, text, Vector((bbox.p1.x + bbox.p2.x) / 2, position.y), ALIGN_CENTER, layer, color); break; } } diff --git a/src/textscroller.hpp b/src/textscroller.hpp index b232b1895..ede1e6bbf 100644 --- a/src/textscroller.hpp +++ b/src/textscroller.hpp @@ -29,6 +29,7 @@ #include "screen.hpp" #include "math/vector.hpp" #include "math/rect.hpp" +#include "video/color.hpp" class DrawingContext; class Surface; @@ -53,6 +54,7 @@ public: private: InfoBoxLine::LineType lineType; Font* font; + Color color; std::string text; Surface* image; }; @@ -92,6 +94,10 @@ public: void draw(DrawingContext& context); void update(float elapsed_time); + static Color small_color; + static Color heading_color; + static Color reference_color; + static Color normal_color; private: float defaultspeed; float speed;