widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #00652
[Merge] lp:~alocritani/widelands/census_text_colors into lp:widelands
Angelo Locritani has proposed merging lp:~alocritani/widelands/census_text_colors into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #927110 in widelands: "font color not adapted to map color"
https://bugs.launchpad.net/widelands/+bug/927110
For more details, see:
https://code.launchpad.net/~alocritani/widelands/census_text_colors/+merge/93696
I've added a black shadow behind yellow text (census, statistics and speed label). No idea if a better way other than mine exists.
Tested and readability seems a bit increased.
--
https://code.launchpad.net/~alocritani/widelands/census_text_colors/+merge/93696
Your team Widelands Developers is requested to review the proposed merge of lp:~alocritani/widelands/census_text_colors into lp:widelands.
=== modified file 'src/graphic/font_handler.cc'
--- src/graphic/font_handler.cc 2011-11-30 21:38:37 +0000
+++ src/graphic/font_handler.cc 2012-02-18 16:05:25 +0000
@@ -203,6 +203,25 @@
}
/**
+ * Draw unwrapped, single-line text (i.e. no line breaks) with a gray shadow.
+ */
+void Font_Handler::draw_text_shadow
+ (RenderTarget & dst,
+ const TextStyle & style,
+ Point dstpoint,
+ const std::string & text,
+ Align align,
+ uint32_t caret)
+{
+
+ TextStyle gray_style = style;
+ gray_style.fg = RGBColor (0, 0, 0);
+
+ draw_text (dst, gray_style, dstpoint - Point(1, 1), text, align, caret);
+ draw_text (dst, style, dstpoint, text, align, caret);
+}
+
+/**
* Draw unwrapped, un-aligned single-line text at the given point, and return the width of the text.
*/
uint32_t Font_Handler::draw_text_raw
=== modified file 'src/graphic/font_handler.h'
--- src/graphic/font_handler.h 2011-11-30 21:38:37 +0000
+++ src/graphic/font_handler.h 2012-02-18 16:05:25 +0000
@@ -54,6 +54,13 @@
const std::string & text,
Align align = Align_CenterLeft,
uint32_t caret = std::numeric_limits<uint32_t>::max());
+ void draw_text_shadow
+ (RenderTarget &,
+ const TextStyle &,
+ Point dstpoint,
+ const std::string & text,
+ Align align = Align_CenterLeft,
+ uint32_t caret = std::numeric_limits<uint32_t>::max());
uint32_t draw_text_raw(RenderTarget &, const TextStyle &, Point dstpoint, const std::string & text);
void draw_multiline
(RenderTarget &,
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc 2012-01-11 19:40:19 +0000
+++ src/logic/building.cc 2012-02-18 16:05:25 +0000
@@ -752,9 +752,9 @@
if (dpyflags & Interactive_Base::dfShowCensus) {
// TODO make more here
- UI::g_fh->draw_text
+ UI::g_fh->draw_text_shadow
(dst, UI::TextStyle::ui_small(),
- pos - Point(0, 45),
+ pos - Point(0, 48),
info_string(igbase.building_census_format()),
UI::Align_Center);
}
@@ -765,7 +765,7 @@
(!iplayer->player().see_all() &&
iplayer->player().is_hostile(*get_owner()))
return;
- UI::g_fh->draw_text
+ UI::g_fh->draw_text_shadow
(dst, UI::TextStyle::ui_small(),
pos - Point(0, 35),
info_string(igbase.building_statistics_format()),
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2012-01-10 21:40:17 +0000
+++ src/wui/interactive_base.cc 2012-02-18 16:05:25 +0000
@@ -90,8 +90,10 @@
m_buildroad (0),
m_road_build_player (0),
m_toolbar (this, 0, 0, UI::Box::Horizontal),
+ m_label_speed_shadow
+ (this, get_w() - 1, 0, std::string(), UI::Align_TopRight),
m_label_speed
- (this, get_w(), 0, std::string(), UI::Align_TopRight)
+ (this, get_w(), 1, std::string(), UI::Align_TopRight)
{
m_toolbar.set_layout_toplevel(true);
m->quicknavigation->set_setview
@@ -125,6 +127,11 @@
m_sel.pic = g_gr->get_picture(PicMod_Game, "pics/fsel.png");
m_label_speed.set_visible(false);
+ m_label_speed_shadow.set_visible(false);
+
+ UI::TextStyle style_shadow = m_label_speed.get_textstyle();
+ style_shadow.fg = RGBColor(0, 0, 0);
+ m_label_speed_shadow.set_textstyle(style_shadow);
setDefaultCommand (boost::bind(&Interactive_Base::cmdLua, this, _1));
addCommand
@@ -299,6 +306,10 @@
m_label_speed.set_visible(true);
} else
m_label_speed.set_visible(false);
+
+ m_label_speed_shadow.set_text(m_label_speed.get_text());
+ m_label_speed_shadow.set_visible(m_label_speed.is_visible());
+
}
=== modified file 'src/wui/interactive_base.h'
--- src/wui/interactive_base.h 2011-11-30 21:38:37 +0000
+++ src/wui/interactive_base.h 2012-02-18 16:05:25 +0000
@@ -180,7 +180,9 @@
void cmdLua(std::vector<std::string> const & args);
void update_speedlabel();
+ UI::Textarea m_label_speed_shadow;
UI::Textarea m_label_speed;
+
UI::UniqueWindow::Registry m_debugconsole;
};
Follow ups