Merge lp:~widelands-dev/widelands/bug657285 into lp:widelands
- bug657285
- Merge into trunk
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 6643 | ||||||||||||
Proposed branch: | lp:~widelands-dev/widelands/bug657285 | ||||||||||||
Merge into: | lp:widelands | ||||||||||||
Diff against target: |
611 lines (+143/-34) 20 files modified
src/editor/ui_menus/editor_main_menu_load_map.cc (+4/-1) src/editor/ui_menus/editor_main_menu_save_map.cc (+10/-3) src/editor/ui_menus/editor_player_menu.cc (+2/-1) src/graphic/font_handler.cc (+7/-3) src/graphic/render/gl_surface_texture.cc (+32/-3) src/graphic/rendertarget.cc (+9/-0) src/io/dedicated_log.cc (+2/-1) src/logic/bob.cc (+1/-1) src/network/internet_gaming.cc (+7/-1) src/ui_basic/panel.cc (+32/-10) src/ui_basic/panel.h (+3/-1) src/ui_basic/table.cc (+7/-2) src/ui_basic/window.cc (+9/-0) src/ui_basic/window.h (+1/-0) src/ui_fsmenu/editor_mapselect.cc (+4/-1) src/ui_fsmenu/launchMPG.cc (+3/-1) src/ui_fsmenu/mapselect.cc (+4/-1) src/wui/building_ui.cc (+0/-2) src/wui/mapview.cc (+0/-1) src/wui/multiplayersetupgroup.cc (+6/-1) |
||||||||||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug657285 | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
cghislai (community) | Abstain | ||
Review via email: mp+175551@code.launchpad.net |
Commit message
Description of the change
I corrected the bug by handling mousein events in the Window class.
I also fixed two things found along in the way:
1 text alignment was not honored in tables
2 texts containing false tag such as '<parent>' to go up one directory, threw exception with the new font handler.
For 2, the parser will consider unallowed tags as normal text. Another way could be to escape all these correctly, but the solution here should be safe for translated strings as well. A warning is printed if such tag is detected and an exception should still be thrown for typos, as the closing tag will be parsed.
cghislai (charlyghislain) wrote : | # |
SirVer (sirver) wrote : | # |
do not worry - you add code at a tremendous rate and WL has no test suite (well, only the Lua test suite which tests quite a bit of code actually. And the new rich text renderer). So regressions do happen.
I can have a look at the OpenGL ones too - it might be as trivial as clear() ing the surface before rendering onto it. Or maybe the width are wrongly reported or so.
I am not too sure about the solution you propose for the text renderer here. The problem I see is that legal tags could still be part of the filenames and look strange or even crash the game. The right solution seems to be to escape < and > when only the raw text is needed. The renderer supports \< and \> for that. Why did you not go for this?
Also pulling in #include "wui/mapview.h" into ui is not a good design. ui_basic is the buildingblocks of the ui and wui are the Widelands specific elements. Adding knowledge of a child class into this is code-smelly. Can you not reset the tooltip in panel if no one handles the mouse in?
cghislai (charlyghislain) wrote : | # |
You are right, I was quite in a hurry to correct those bugs and the solutions I proposed here weren't by far the optimal ones.
I saw that escaping <> characters were supported. I first went for that then for some reason thought it would be best to handle that at the source directly. I thought about translators that might introduce false tags. I didn't even think about filenames, but still, the syntax exception crash the game with current code.
Concerning the tooltip, I totally agree about the design issue. I will try your suggestion, but Im afraid the tooltip behaviour will change too much with it, as every element seems to be a panel, and that mousein events occur all the time with statistics turned on for instance. A cast to Window may solve this. The other solution I first tried was to handle this case separately in every wui window. While it worked as intended, I thought it would be one more thing to implement on every window, and I looked for a more general solution, again.
cghislai (charlyghislain) : | # |
SirVer (sirver) wrote : | # |
About the tooltips: I think it should be another event. So, when the UI decides that it would like to show a tooltip, it calls "OnTooltip" or so on the current panels (very similar to how mousein behaves) and each of them can report with "true" to set the tooltip or false to pass on to the next panel one further down. That should solve the issues with a pattern that we use all over the UI code.
cghislai (charlyghislain) wrote : | # |
Looks fine also using opengl now.
cghislai (charlyghislain) wrote : | # |
A few comments concerning the opengl stuff:
- When an empty string, such as "<rt><font=
- The repetition occured because the blit function scaled the texture space coord but still draw the whole rect passed in. I corrected that by ensuring the clipping rect is no larger than the texture in the Graphics blitrect function.
- I did experience the white backgrounds behaviour at some point during testing, but it seems that with these two fixes the problem is gone.
SirVer (sirver) wrote : | # |
I think the new solution is really nice. A rt::escape method would have been nice - but since there is more work to kill the old renderer and make the new one the only one this will come eventually.
Merged.
Preview Diff
1 | === modified file 'src/editor/ui_menus/editor_main_menu_load_map.cc' |
2 | --- src/editor/ui_menus/editor_main_menu_load_map.cc 2013-02-25 17:00:19 +0000 |
3 | +++ src/editor/ui_menus/editor_main_menu_load_map.cc 2013-07-19 13:51:29 +0000 |
4 | @@ -41,6 +41,7 @@ |
5 | #include "ui_basic/textarea.h" |
6 | |
7 | #include <cstdio> |
8 | +#include <boost/format.hpp> |
9 | |
10 | using Widelands::WL_Map_Loader; |
11 | |
12 | @@ -219,8 +220,10 @@ |
13 | #else |
14 | m_parentdir = m_curdir.substr(0, m_curdir.rfind('\\')); |
15 | #endif |
16 | + std::string parent_string = |
17 | + (boost::format("\\<%s\\>") % _("parent")).str(); |
18 | m_ls->add |
19 | - (_("<parent>"), |
20 | + (parent_string.c_str(), |
21 | m_parentdir.c_str(), |
22 | g_gr->images().get("pics/ls_dir.png")); |
23 | } |
24 | |
25 | === modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc' |
26 | --- src/editor/ui_menus/editor_main_menu_save_map.cc 2013-03-04 21:09:29 +0000 |
27 | +++ src/editor/ui_menus/editor_main_menu_save_map.cc 2013-07-19 13:51:29 +0000 |
28 | @@ -42,6 +42,7 @@ |
29 | #include "upcast.h" |
30 | |
31 | #include <boost/scoped_ptr.hpp> |
32 | +#include <boost/format.hpp> |
33 | |
34 | #include <cstdio> |
35 | #include <cstring> |
36 | @@ -254,9 +255,13 @@ |
37 | m_nrplayers->set_text(""); |
38 | m_size ->set_text(""); |
39 | if (g_fs->IsDirectory(name)) { |
40 | - m_descr ->set_text(_("<Directory>")); |
41 | + std::string dir_string = |
42 | + (boost::format("\\<%s\\>") % _("directory")).str(); |
43 | + m_descr ->set_text(dir_string); |
44 | } else { |
45 | - m_descr ->set_text(_("<Not a map file>")); |
46 | + std::string not_map_string = |
47 | + (boost::format("\\<%s\\>") % _("Not a map file")).str(); |
48 | + m_descr ->set_text(not_map_string); |
49 | } |
50 | |
51 | } |
52 | @@ -292,8 +297,10 @@ |
53 | #else |
54 | m_parentdir = m_curdir.substr(0, m_curdir.rfind('\\')); |
55 | #endif |
56 | + std::string parent_string = |
57 | + (boost::format("\\<%s\\>") % _("parent")).str(); |
58 | m_ls->add |
59 | - (_("<parent>"), |
60 | + (parent_string.c_str(), |
61 | m_parentdir.c_str(), |
62 | g_gr->images().get("pics/ls_dir.png")); |
63 | } |
64 | |
65 | === modified file 'src/editor/ui_menus/editor_player_menu.cc' |
66 | --- src/editor/ui_menus/editor_player_menu.cc 2013-07-09 06:00:11 +0000 |
67 | +++ src/editor/ui_menus/editor_player_menu.cc 2013-07-19 13:51:29 +0000 |
68 | @@ -34,6 +34,7 @@ |
69 | |
70 | #include "editor_player_menu.h" |
71 | |
72 | +#define UNDEFINED_TRIBE_NAME "<undefined>" |
73 | |
74 | Editor_Player_Menu::Editor_Player_Menu |
75 | (Editor_Interactive & parent, UI::UniqueWindow::Registry & registry) |
76 | @@ -158,7 +159,7 @@ |
77 | (boost::bind(&Editor_Player_Menu::player_tribe_clicked, boost::ref(*this), p - 1)); |
78 | posx += 140 + spacing; |
79 | } |
80 | - if (map.get_scenario_player_tribe(p) != "<undefined>") |
81 | + if (map.get_scenario_player_tribe(p) != UNDEFINED_TRIBE_NAME) |
82 | m_plr_set_tribes_buts[p - 1]->set_title |
83 | (map.get_scenario_player_tribe(p).c_str()); |
84 | else { |
85 | |
86 | === modified file 'src/graphic/font_handler.cc' |
87 | --- src/graphic/font_handler.cc 2013-07-14 11:17:29 +0000 |
88 | +++ src/graphic/font_handler.cc 2013-07-19 13:51:29 +0000 |
89 | @@ -22,6 +22,7 @@ |
90 | #include <list> |
91 | |
92 | #include <SDL_ttf.h> |
93 | +#include <boost/algorithm/string.hpp> |
94 | |
95 | #include "graphic.h" |
96 | #include "log.h" |
97 | @@ -212,15 +213,18 @@ |
98 | Align align, |
99 | uint32_t caret) |
100 | { |
101 | - const LineCacheEntry & lce = d->get_line(style, text); |
102 | + // Erase every backslash in front of brackets |
103 | + std::string copytext = boost::replace_all_copy(text, "\\<", "<"); |
104 | + boost::replace_all(copytext, "\\>", ">"); |
105 | + const LineCacheEntry & lce = d->get_line(style, copytext); |
106 | |
107 | UI::correct_for_align(align, lce.width + 2 * LINE_MARGIN, lce.height, &dstpoint); |
108 | |
109 | if (lce.image) |
110 | dst.blit(Point(dstpoint.x + LINE_MARGIN, dstpoint.y), lce.image); |
111 | |
112 | - if (caret <= text.size()) |
113 | - draw_caret(dst, style, dstpoint, text, caret); |
114 | + if (caret <= copytext.size()) |
115 | + draw_caret(dst, style, dstpoint, copytext, caret); |
116 | } |
117 | |
118 | /** |
119 | |
120 | === modified file 'src/graphic/render/gl_surface_texture.cc' |
121 | --- src/graphic/render/gl_surface_texture.cc 2013-07-14 10:58:00 +0000 |
122 | +++ src/graphic/render/gl_surface_texture.cc 2013-07-19 13:51:29 +0000 |
123 | @@ -62,6 +62,9 @@ |
124 | { |
125 | init(w, h); |
126 | |
127 | + if (m_w <= 0 || m_h <= 0) { |
128 | + return; |
129 | + } |
130 | glTexImage2D |
131 | (GL_TEXTURE_2D, 0, GL_RGBA, m_tex_w, m_tex_h, 0, GL_RGBA, |
132 | GL_UNSIGNED_BYTE, 0); |
133 | @@ -168,6 +171,9 @@ |
134 | handle_glerror(); |
135 | m_w = w; |
136 | m_h = h; |
137 | + if (m_w <= 0 || m_h <= 0) { |
138 | + return; |
139 | + } |
140 | |
141 | if (g_gr->caps().gl.tex_power_of_two) { |
142 | m_tex_w = next_power_of_two(w); |
143 | @@ -194,6 +200,9 @@ |
144 | } |
145 | |
146 | void GLSurfaceTexture::lock(LockMode mode) { |
147 | + if (m_w <= 0 || m_h <= 0) { |
148 | + return; |
149 | + } |
150 | assert(!m_pixels); |
151 | |
152 | m_pixels.reset(new uint8_t[m_tex_w * m_tex_h * 4]); |
153 | @@ -205,6 +214,9 @@ |
154 | } |
155 | |
156 | void GLSurfaceTexture::unlock(UnlockMode mode) { |
157 | + if (m_w <= 0 || m_h <= 0) { |
158 | + return; |
159 | + } |
160 | assert(m_pixels); |
161 | |
162 | if (mode == Unlock_Update) { |
163 | @@ -223,6 +235,9 @@ |
164 | |
165 | void GLSurfaceTexture::draw_rect(const Rect& rc, const RGBColor clr) |
166 | { |
167 | + if (m_w <= 0 || m_h <= 0) { |
168 | + return; |
169 | + } |
170 | setup_gl(); |
171 | GLSurface::draw_rect(rc, clr); |
172 | reset_gl(); |
173 | @@ -232,7 +247,11 @@ |
174 | /** |
175 | * Draws a filled rectangle |
176 | */ |
177 | -void GLSurfaceTexture::fill_rect(const Rect& rc, const RGBAColor clr) { |
178 | +void GLSurfaceTexture::fill_rect(const Rect& rc, const RGBAColor clr) |
179 | +{ |
180 | + if (m_w <= 0 || m_h <= 0) { |
181 | + return; |
182 | + } |
183 | setup_gl(); |
184 | GLSurface::fill_rect(rc, clr); |
185 | reset_gl(); |
186 | @@ -243,21 +262,31 @@ |
187 | */ |
188 | void GLSurfaceTexture::brighten_rect(const Rect& rc, const int32_t factor) |
189 | { |
190 | + if (m_w <= 0 || m_h <= 0) { |
191 | + return; |
192 | + } |
193 | setup_gl(); |
194 | GLSurface::brighten_rect(rc, factor); |
195 | reset_gl(); |
196 | } |
197 | |
198 | void GLSurfaceTexture::draw_line |
199 | - (int32_t x1, int32_t y1, int32_t x2, int32_t y2, const RGBColor& color, uint8_t gwidth) |
200 | + (int32_t x1, int32_t y1, int32_t x2, int32_t y2, const RGBColor& color, uint8_t gwidth) |
201 | { |
202 | + if (m_w <= 0 || m_h <= 0) { |
203 | + return; |
204 | + } |
205 | setup_gl(); |
206 | GLSurface::draw_line(x1, y1, x2, y2, color, gwidth); |
207 | reset_gl(); |
208 | } |
209 | |
210 | void GLSurfaceTexture::blit |
211 | - (const Point& dst, const Surface* src, const Rect& srcrc, Composite cm) { |
212 | + (const Point& dst, const Surface* src, const Rect& srcrc, Composite cm) |
213 | +{ |
214 | + if (m_w <= 0 || m_h <= 0) { |
215 | + return; |
216 | + } |
217 | setup_gl(); |
218 | GLSurface::blit(dst, src, srcrc, cm); |
219 | reset_gl(); |
220 | |
221 | === modified file 'src/graphic/rendertarget.cc' |
222 | --- src/graphic/rendertarget.cc 2013-04-22 20:15:00 +0000 |
223 | +++ src/graphic/rendertarget.cc 2013-07-19 13:51:29 +0000 |
224 | @@ -442,6 +442,15 @@ |
225 | srcrc.h = m_rect.h - dst.y; |
226 | } |
227 | |
228 | + // Also ensure srcrc is not bigger than src |
229 | + // so opengl blits correctly |
230 | + if (src->width() < srcrc.x + srcrc.w) { |
231 | + srcrc.w = src->width() - srcrc.x; |
232 | + } |
233 | + if (src->height() < srcrc.y + srcrc.h) { |
234 | + srcrc.h = src->height() - srcrc.y; |
235 | + } |
236 | + |
237 | dst += m_rect; |
238 | |
239 | m_surface->blit(dst, src->surface(), srcrc, cm); |
240 | |
241 | === modified file 'src/io/dedicated_log.cc' |
242 | --- src/io/dedicated_log.cc 2013-04-20 20:20:34 +0000 |
243 | +++ src/io/dedicated_log.cc 2013-07-19 13:51:29 +0000 |
244 | @@ -20,6 +20,7 @@ |
245 | #include "dedicated_log.h" |
246 | #include "filesystem/layered_filesystem.h" |
247 | #include "log.h" |
248 | +#include "i18n.h" |
249 | |
250 | #include <boost/format.hpp> |
251 | |
252 | @@ -50,7 +51,6 @@ |
253 | m_info_file_path(""), |
254 | m_log_file_path(""), |
255 | d_name(""), |
256 | -d_ip("<unkown>"), |
257 | d_motd(""), |
258 | d_start(""), |
259 | d_logins(0), |
260 | @@ -62,6 +62,7 @@ |
261 | time_t currenttime = time(0); |
262 | strftime(ts, sizeof(ts), "%a %Y/%m/%d, %H:%M:%S", localtime(¤ttime)); |
263 | d_start = ts; |
264 | + d_ip = (boost::format("\\<%s\\>") % _("unknown")).str(); |
265 | } |
266 | |
267 | |
268 | |
269 | === modified file 'src/logic/bob.cc' |
270 | --- src/logic/bob.cc 2013-07-14 10:38:26 +0000 |
271 | +++ src/logic/bob.cc 2013-07-19 13:51:29 +0000 |
272 | @@ -1017,7 +1017,7 @@ |
273 | molog("ActScheduled: %s\n", m_actscheduled ? "true" : "false"); |
274 | molog |
275 | ("Animation: %s\n", |
276 | - m_anim ? descr().get_animation_name(m_anim).c_str() : "<none>"); |
277 | + m_anim ? descr().get_animation_name(m_anim).c_str() : "\\<none\\>"); |
278 | |
279 | molog("AnimStart: %i\n", m_animstart); |
280 | molog("WalkingDir: %i\n", m_walking); |
281 | |
282 | === modified file 'src/network/internet_gaming.cc' |
283 | --- src/network/internet_gaming.cc 2013-07-16 13:26:14 +0000 |
284 | +++ src/network/internet_gaming.cc 2013-07-19 13:51:29 +0000 |
285 | @@ -799,8 +799,14 @@ |
286 | /// formates a chat message and adds it to the list of chat messages |
287 | void InternetGaming::formatAndAddChat(std::string from, std::string to, bool system, std::string msg) { |
288 | ChatMessage c; |
289 | + if (!system && from.empty()) { |
290 | + std::string unkown_string = |
291 | + (boost::format("\\<%s\\>") % _("unknown")).str(); |
292 | + c.sender = unkown_string; |
293 | + } else { |
294 | + c.sender = from; |
295 | + } |
296 | c.time = time(0); |
297 | - c.sender = !system && from.empty() ? _("<unknown>") : from; |
298 | c.playern = system ? -1 : to.size() ? 3 : 7; |
299 | c.msg = msg; |
300 | c.recipient = to; |
301 | |
302 | === modified file 'src/ui_basic/panel.cc' |
303 | --- src/ui_basic/panel.cc 2013-07-14 11:17:29 +0000 |
304 | +++ src/ui_basic/panel.cc 2013-07-19 13:51:29 +0000 |
305 | @@ -214,11 +214,7 @@ |
306 | s_default_cursor_click : |
307 | s_default_cursor); |
308 | |
309 | - if (Panel * lowest = _mousein) { |
310 | - while (Panel * const mousein = lowest->_mousein) |
311 | - lowest = mousein; |
312 | - draw_tooltip(rt, lowest->tooltip()); |
313 | - } |
314 | + forefather->do_tooltip(); |
315 | |
316 | g_gr->refresh(); |
317 | } |
318 | @@ -681,6 +677,18 @@ |
319 | } |
320 | |
321 | /** |
322 | + * Called whenever a tooltip could be drawn. |
323 | + * Return true if the tooltip has been drawn, |
324 | + * false otherwise. |
325 | + */ |
326 | +bool Panel::handle_tooltip() |
327 | +{ |
328 | + RenderTarget & rt = *g_gr->get_render_target(); |
329 | + return draw_tooltip(rt, tooltip()); |
330 | +} |
331 | + |
332 | + |
333 | +/** |
334 | * Called whenever the user presses a mouse button in the panel while pressing the alt-key. |
335 | * This function is called first on the parent panels. |
336 | * It should be only overwritten by the UI::Window class. |
337 | @@ -982,6 +990,7 @@ |
338 | return true; |
339 | return handle_mouserelease(btn, x, y); |
340 | } |
341 | + |
342 | bool Panel::do_mousemove |
343 | (Uint8 const state, |
344 | int32_t x, int32_t y, int32_t const xdiff, int32_t const ydiff) |
345 | @@ -991,15 +1000,20 @@ |
346 | |
347 | x -= _lborder; |
348 | y -= _tborder; |
349 | - if (_g_mousegrab != this) |
350 | + if (_g_mousegrab != this) { |
351 | for |
352 | (Panel * child = _fchild; |
353 | (child = child_at_mouse_cursor(x, y, child)); |
354 | child = child->_next) |
355 | + { |
356 | if |
357 | (child->do_mousemove |
358 | (state, x - child->_x, y - child->_y, xdiff, ydiff)) |
359 | + { |
360 | return true; |
361 | + } |
362 | + } |
363 | + } |
364 | return handle_mousemove(state, x, y, xdiff, ydiff); |
365 | } |
366 | |
367 | @@ -1020,6 +1034,13 @@ |
368 | return handle_key(down, code); |
369 | } |
370 | |
371 | +bool Panel::do_tooltip() |
372 | +{ |
373 | + if (_mousein && _mousein->do_tooltip()) { |
374 | + return true; |
375 | + } |
376 | + return handle_tooltip(); |
377 | +} |
378 | |
379 | /** |
380 | * \return \c true if the given key is currently pressed, or \c false otherwise |
381 | @@ -1130,12 +1151,12 @@ |
382 | } |
383 | |
384 | /** |
385 | - * Draw the tooltip. |
386 | + * Draw the tooltip. Return true on success |
387 | */ |
388 | -void Panel::draw_tooltip(RenderTarget & dst, const std::string & text) |
389 | +bool Panel::draw_tooltip(RenderTarget & dst, const std::string & text) |
390 | { |
391 | if (text.empty()) |
392 | - return; |
393 | + return false; |
394 | |
395 | std::string text_to_render = text; |
396 | if (!is_richtext(text_to_render)) { |
397 | @@ -1145,7 +1166,7 @@ |
398 | static const uint32_t TIP_WIDTH_MAX = 360; |
399 | const Image* rendered_text = g_fh1->render(text_to_render, TIP_WIDTH_MAX); |
400 | if (!rendered_text) |
401 | - return; |
402 | + return false; |
403 | |
404 | uint16_t tip_width = rendered_text->width() + 4; |
405 | uint16_t tip_height = rendered_text->height() + 4; |
406 | @@ -1163,6 +1184,7 @@ |
407 | dst.fill_rect(r, RGBColor(63, 52, 34)); |
408 | dst.draw_rect(r, RGBColor(0, 0, 0)); |
409 | dst.blit(r + Point(2, 2), rendered_text); |
410 | + return true; |
411 | } |
412 | |
413 | std::string Panel::ui_fn() { |
414 | |
415 | === modified file 'src/ui_basic/panel.h' |
416 | --- src/ui_basic/panel.h 2013-03-09 07:56:31 +0000 |
417 | +++ src/ui_basic/panel.h 2013-07-19 13:51:29 +0000 |
418 | @@ -189,6 +189,7 @@ |
419 | (Uint8 state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff); |
420 | virtual bool handle_key(bool down, SDL_keysym code); |
421 | virtual bool handle_alt_drag(int32_t x, int32_t y); |
422 | + virtual bool handle_tooltip(); |
423 | |
424 | /// \returns whether a certain given is currently down. |
425 | /// |
426 | @@ -242,7 +243,7 @@ |
427 | |
428 | static void play_click(); |
429 | |
430 | - static void draw_tooltip(RenderTarget &, const std::string & text); |
431 | + static bool draw_tooltip(RenderTarget &, const std::string & text); |
432 | |
433 | private: |
434 | void check_child_death(); |
435 | @@ -259,6 +260,7 @@ |
436 | bool do_mousemove |
437 | (const Uint8 state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff); |
438 | bool do_key(bool down, SDL_keysym code); |
439 | + bool do_tooltip(); |
440 | |
441 | static Panel * ui_trackmouse(int32_t & x, int32_t & y); |
442 | static void ui_mousepress (const Uint8 button, int32_t x, int32_t y); |
443 | |
444 | === modified file 'src/ui_basic/table.cc' |
445 | --- src/ui_basic/table.cc 2013-07-16 17:30:22 +0000 |
446 | +++ src/ui_basic/table.cc 2013-07-19 13:51:29 +0000 |
447 | @@ -294,10 +294,15 @@ |
448 | } |
449 | |
450 | const Image* entry_text_im = UI::g_fh1->render(as_uifont(entry_string, m_fontsize)); |
451 | + uint16_t text_width = entry_text_im->width(); |
452 | + if (alignment & Align_Right) { |
453 | + point.x += curw - picw; |
454 | + } else if (alignment & Align_HCenter) { |
455 | + point.x += (curw - picw) / 2; |
456 | + } |
457 | + UI::correct_for_align(alignment, text_width, entry_text_im->height(), &point); |
458 | // Crop to column width |
459 | - UI::correct_for_align(alignment, entry_text_im->width(), entry_text_im->height(), &point); |
460 | dst.blitrect(point, entry_text_im, Rect(0, 0, curw - picw, lineheight)); |
461 | - |
462 | curx += curw; |
463 | } |
464 | |
465 | |
466 | === modified file 'src/ui_basic/window.cc' |
467 | --- src/ui_basic/window.cc 2013-02-10 19:36:24 +0000 |
468 | +++ src/ui_basic/window.cc 2013-07-19 13:51:29 +0000 |
469 | @@ -486,6 +486,15 @@ |
470 | return true; |
471 | } |
472 | |
473 | +// Always consume the tooltip event to prevent tooltips from |
474 | +// our parent to be rendered |
475 | +bool Window::handle_tooltip() |
476 | +{ |
477 | + UI::Panel::handle_tooltip(); |
478 | + return true; |
479 | +} |
480 | + |
481 | + |
482 | void Window::restore() { |
483 | assert(_is_minimal); |
484 | _is_minimal = false; |
485 | |
486 | === modified file 'src/ui_basic/window.h' |
487 | --- src/ui_basic/window.h 2013-02-09 23:18:23 +0000 |
488 | +++ src/ui_basic/window.h 2013-07-19 13:51:29 +0000 |
489 | @@ -87,6 +87,7 @@ |
490 | bool handle_mousemove |
491 | (Uint8 state, int32_t mx, int32_t my, int32_t xdiff, int32_t ydiff); |
492 | bool handle_alt_drag (int32_t mx, int32_t my); |
493 | + bool handle_tooltip(); |
494 | |
495 | protected: |
496 | virtual void layout(); |
497 | |
498 | === modified file 'src/ui_fsmenu/editor_mapselect.cc' |
499 | --- src/ui_fsmenu/editor_mapselect.cc 2013-02-10 19:36:24 +0000 |
500 | +++ src/ui_fsmenu/editor_mapselect.cc 2013-07-19 13:51:29 +0000 |
501 | @@ -32,6 +32,7 @@ |
502 | #include "log.h" |
503 | |
504 | #include <cstdio> |
505 | +#include <boost/format.hpp> |
506 | |
507 | using Widelands::WL_Map_Loader; |
508 | |
509 | @@ -225,8 +226,10 @@ |
510 | #else |
511 | m_parentdir = m_curdir.substr(0, m_curdir.rfind('\\')); |
512 | #endif |
513 | + std::string parent_string = |
514 | + (boost::format("\\<%s\\>") % _("parent")).str(); |
515 | m_list.add |
516 | - (_("<parent>"), |
517 | + (parent_string.c_str(), |
518 | m_parentdir.c_str(), |
519 | g_gr->images().get("pics/ls_dir.png")); |
520 | } |
521 | |
522 | === modified file 'src/ui_fsmenu/launchMPG.cc' |
523 | --- src/ui_fsmenu/launchMPG.cc 2013-06-23 19:37:41 +0000 |
524 | +++ src/ui_fsmenu/launchMPG.cc 2013-07-19 13:51:29 +0000 |
525 | @@ -564,8 +564,10 @@ |
526 | snprintf(buf, sizeof(buf), _("Player %u"), i); |
527 | infotext += buf; |
528 | if (player_save_tribe[i - 1].empty()) { |
529 | + std::string closed_string = |
530 | + (boost::format("\\<%s\\>") % _("closed")).str(); |
531 | infotext += ":\n "; |
532 | - infotext += _("<closed>"); |
533 | + infotext += closed_string; |
534 | // Close the player |
535 | m_settings->setPlayerState(i - 1, PlayerSettings::stateClosed); |
536 | continue; // if tribe is empty, the player does not exist |
537 | |
538 | === modified file 'src/ui_fsmenu/mapselect.cc' |
539 | --- src/ui_fsmenu/mapselect.cc 2013-07-16 00:52:36 +0000 |
540 | +++ src/ui_fsmenu/mapselect.cc 2013-07-19 13:51:29 +0000 |
541 | @@ -17,6 +17,7 @@ |
542 | */ |
543 | |
544 | #include <cstdio> |
545 | +#include <boost/format.hpp> |
546 | |
547 | #include "i18n.h" |
548 | #include "wexception.h" |
549 | @@ -340,9 +341,11 @@ |
550 | m_table.add(m_maps_data.size() - 1); |
551 | |
552 | te.set_string(0, ""); |
553 | + std::string parent_string = |
554 | + (boost::format("\\<%s\\>") % _("parent")).str(); |
555 | te.set_picture |
556 | (1, g_gr->images().get("pics/ls_dir.png"), |
557 | - _("<parent>")); |
558 | + parent_string); |
559 | |
560 | ++ndirs; |
561 | } |
562 | |
563 | === modified file 'src/wui/building_ui.cc' |
564 | --- src/wui/building_ui.cc 2013-07-16 10:17:53 +0000 |
565 | +++ src/wui/building_ui.cc 2013-07-19 13:51:29 +0000 |
566 | @@ -32,8 +32,6 @@ |
567 | */ |
568 | void Building::show_options(Interactive_GameBase & igbase, bool avoid_fastclick) |
569 | { |
570 | - // Reset tooltip before opening the window |
571 | - igbase.set_tooltip(""); |
572 | if (m_optionswindow) { |
573 | if (m_optionswindow->is_minimal()) |
574 | m_optionswindow->restore(); |
575 | |
576 | === modified file 'src/wui/mapview.cc' |
577 | --- src/wui/mapview.cc 2013-07-12 17:32:38 +0000 |
578 | +++ src/wui/mapview.cc 2013-07-19 13:51:29 +0000 |
579 | @@ -113,7 +113,6 @@ |
580 | } |
581 | |
582 | m_complete_redraw_needed = false; |
583 | - draw_tooltip(dst, tooltip()); |
584 | } |
585 | |
586 | void Map_View::set_changeview(const Map_View::ChangeViewFn & fn) |
587 | |
588 | === modified file 'src/wui/multiplayersetupgroup.cc' |
589 | --- src/wui/multiplayersetupgroup.cc 2013-03-05 00:41:24 +0000 |
590 | +++ src/wui/multiplayersetupgroup.cc 2013-07-19 13:51:29 +0000 |
591 | @@ -35,6 +35,8 @@ |
592 | #include "ui_basic/scrollbar.h" |
593 | #include "ui_basic/textarea.h" |
594 | |
595 | +#include <boost/format.hpp> |
596 | + |
597 | struct MultiPlayerClientGroup : public UI::Box { |
598 | MultiPlayerClientGroup |
599 | (UI::Panel * const parent, uint8_t id, |
600 | @@ -99,7 +101,10 @@ |
601 | void refresh() { |
602 | UserSettings us = s->settings().users.at(m_id); |
603 | if (us.position == UserSettings::notConnected()) { |
604 | - name->set_text(_("<free>")); |
605 | + std::string free_i18n = _("free"); |
606 | + std::string free_text = |
607 | + (boost::format("\\<%s\\>") % free_i18n).str(); |
608 | + name->set_text(free_text); |
609 | if (type) |
610 | type->set_visible(false); |
611 | else |
I add I feel sorry for all regressions linked to my code. I will fixes them all asap. Those linked to opengl rendering may be tricky.