Merge lp:~alocritani/widelands/census_text_colors into lp:widelands

Proposed by Angelo Locritani
Status: Merged
Merged at revision: 6229
Proposed branch: lp:~alocritani/widelands/census_text_colors
Merge into: lp:widelands
Diff against target: 124 lines (+43/-4)
5 files modified
src/graphic/font_handler.cc (+19/-0)
src/graphic/font_handler.h (+7/-0)
src/logic/building.cc (+3/-3)
src/wui/interactive_base.cc (+12/-1)
src/wui/interactive_base.h (+2/-0)
To merge this branch: bzr merge lp:~alocritani/widelands/census_text_colors
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+93696@code.launchpad.net

Description of the change

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.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/graphic/font_handler.cc'
2--- src/graphic/font_handler.cc 2011-11-30 21:38:37 +0000
3+++ src/graphic/font_handler.cc 2012-02-18 16:05:25 +0000
4@@ -203,6 +203,25 @@
5 }
6
7 /**
8+ * Draw unwrapped, single-line text (i.e. no line breaks) with a gray shadow.
9+ */
10+void Font_Handler::draw_text_shadow
11+ (RenderTarget & dst,
12+ const TextStyle & style,
13+ Point dstpoint,
14+ const std::string & text,
15+ Align align,
16+ uint32_t caret)
17+{
18+
19+ TextStyle gray_style = style;
20+ gray_style.fg = RGBColor (0, 0, 0);
21+
22+ draw_text (dst, gray_style, dstpoint - Point(1, 1), text, align, caret);
23+ draw_text (dst, style, dstpoint, text, align, caret);
24+}
25+
26+/**
27 * Draw unwrapped, un-aligned single-line text at the given point, and return the width of the text.
28 */
29 uint32_t Font_Handler::draw_text_raw
30
31=== modified file 'src/graphic/font_handler.h'
32--- src/graphic/font_handler.h 2011-11-30 21:38:37 +0000
33+++ src/graphic/font_handler.h 2012-02-18 16:05:25 +0000
34@@ -54,6 +54,13 @@
35 const std::string & text,
36 Align align = Align_CenterLeft,
37 uint32_t caret = std::numeric_limits<uint32_t>::max());
38+ void draw_text_shadow
39+ (RenderTarget &,
40+ const TextStyle &,
41+ Point dstpoint,
42+ const std::string & text,
43+ Align align = Align_CenterLeft,
44+ uint32_t caret = std::numeric_limits<uint32_t>::max());
45 uint32_t draw_text_raw(RenderTarget &, const TextStyle &, Point dstpoint, const std::string & text);
46 void draw_multiline
47 (RenderTarget &,
48
49=== modified file 'src/logic/building.cc'
50--- src/logic/building.cc 2012-01-11 19:40:19 +0000
51+++ src/logic/building.cc 2012-02-18 16:05:25 +0000
52@@ -752,9 +752,9 @@
53
54 if (dpyflags & Interactive_Base::dfShowCensus) {
55 // TODO make more here
56- UI::g_fh->draw_text
57+ UI::g_fh->draw_text_shadow
58 (dst, UI::TextStyle::ui_small(),
59- pos - Point(0, 45),
60+ pos - Point(0, 48),
61 info_string(igbase.building_census_format()),
62 UI::Align_Center);
63 }
64@@ -765,7 +765,7 @@
65 (!iplayer->player().see_all() &&
66 iplayer->player().is_hostile(*get_owner()))
67 return;
68- UI::g_fh->draw_text
69+ UI::g_fh->draw_text_shadow
70 (dst, UI::TextStyle::ui_small(),
71 pos - Point(0, 35),
72 info_string(igbase.building_statistics_format()),
73
74=== modified file 'src/wui/interactive_base.cc'
75--- src/wui/interactive_base.cc 2012-01-10 21:40:17 +0000
76+++ src/wui/interactive_base.cc 2012-02-18 16:05:25 +0000
77@@ -90,8 +90,10 @@
78 m_buildroad (0),
79 m_road_build_player (0),
80 m_toolbar (this, 0, 0, UI::Box::Horizontal),
81+ m_label_speed_shadow
82+ (this, get_w() - 1, 0, std::string(), UI::Align_TopRight),
83 m_label_speed
84- (this, get_w(), 0, std::string(), UI::Align_TopRight)
85+ (this, get_w(), 1, std::string(), UI::Align_TopRight)
86 {
87 m_toolbar.set_layout_toplevel(true);
88 m->quicknavigation->set_setview
89@@ -125,6 +127,11 @@
90 m_sel.pic = g_gr->get_picture(PicMod_Game, "pics/fsel.png");
91
92 m_label_speed.set_visible(false);
93+ m_label_speed_shadow.set_visible(false);
94+
95+ UI::TextStyle style_shadow = m_label_speed.get_textstyle();
96+ style_shadow.fg = RGBColor(0, 0, 0);
97+ m_label_speed_shadow.set_textstyle(style_shadow);
98
99 setDefaultCommand (boost::bind(&Interactive_Base::cmdLua, this, _1));
100 addCommand
101@@ -299,6 +306,10 @@
102 m_label_speed.set_visible(true);
103 } else
104 m_label_speed.set_visible(false);
105+
106+ m_label_speed_shadow.set_text(m_label_speed.get_text());
107+ m_label_speed_shadow.set_visible(m_label_speed.is_visible());
108+
109 }
110
111
112
113=== modified file 'src/wui/interactive_base.h'
114--- src/wui/interactive_base.h 2011-11-30 21:38:37 +0000
115+++ src/wui/interactive_base.h 2012-02-18 16:05:25 +0000
116@@ -180,7 +180,9 @@
117 void cmdLua(std::vector<std::string> const & args);
118 void update_speedlabel();
119
120+ UI::Textarea m_label_speed_shadow;
121 UI::Textarea m_label_speed;
122+
123 UI::UniqueWindow::Registry m_debugconsole;
124 };
125

Subscribers

People subscribed via source and target branches

to status/vote changes: