diff -ur ScummVM-cvs20021120/scummvm/scumm/smush/frenderer.cpp ScummVM-cvs20021120+hack/scummvm/scumm/smush/frenderer.cpp
old
|
new
|
|
306 | 306 | } |
307 | 307 | |
308 | 308 | bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const { |
| 309 | int32 max_substr_width = 0; |
309 | 310 | debug(9, "FontRenderer::drawStringWrapCentered(%s, %d, %d)", str, x, y); |
310 | 311 | assert(strchr(str, '\n') == 0); |
311 | 312 | char * * words = split(str, ' '); |
… |
… |
|
324 | 325 | int32 space_width = charWidth(' '); |
325 | 326 | |
326 | 327 | i = 0; |
| 328 | width = MIN(width, size.getX()); |
327 | 329 | while(i < nb_sub) { |
328 | 330 | int32 substr_width = sizes[i]; |
329 | 331 | char * substr = new char[1000]; |
330 | 332 | strcpy(substr, words[i]); |
331 | 333 | int32 j = i + 1; |
332 | 334 | |
333 | | while(j < nb_sub && (substr_width + space_width + sizes[j]) < size.getX()) { |
| 335 | while(j < nb_sub && (substr_width + space_width + sizes[j]) < width) { |
334 | 336 | substr_width += sizes[j++] + space_width; |
335 | 337 | } |
336 | 338 | |
… |
… |
|
341 | 343 | |
342 | 344 | substrings[nb_subs] = substr; |
343 | 345 | substr_widths[nb_subs++] = substr_width; |
| 346 | max_substr_width = MAX(substr_width, max_substr_width); |
344 | 347 | i = j; |
345 | 348 | height += stringHeight(substr); |
346 | 349 | } |
… |
… |
|
355 | 358 | y = size.getY() - height; |
356 | 359 | } |
357 | 360 | |
| 361 | if(x - max_substr_width / 2 < 0) { |
| 362 | x = max_substr_width / 2; |
| 363 | } else if (x + max_substr_width / 2 >= size.getX()) { |
| 364 | x = size.getX() - 1 - max_substr_width / 2; |
| 365 | } |
| 366 | |
358 | 367 | for(i = 0; i < nb_subs; i++) { |
359 | 368 | int32 substr_width = substr_widths[i]; |
360 | 369 | drawSubstring((const byte *)substrings[i], buffer, size, x - substr_width / 2, y); |