equal
deleted
inserted
replaced
273 } |
273 } |
274 |
274 |
275 |
275 |
276 /** Truncate a given string to a maximum width if neccessary. |
276 /** Truncate a given string to a maximum width if neccessary. |
277 * If the string is truncated, add three dots ('...') to show this. |
277 * If the string is truncated, add three dots ('...') to show this. |
278 * @param *dest string that is checked and possibly truncated |
278 * @param *str string that is checked and possibly truncated |
279 * @param maxw maximum width in pixels of the string |
279 * @param maxw maximum width in pixels of the string |
280 * @return new width of (truncated) string */ |
280 * @return new width of (truncated) string */ |
281 static int TruncateString(char *str, int maxw) |
281 static int TruncateString(char *str, int maxw) |
282 { |
282 { |
283 int w = 0; |
283 int w = 0; |
411 } |
411 } |
412 |
412 |
413 /** 'Correct' a string to a maximum length. Longer strings will be cut into |
413 /** 'Correct' a string to a maximum length. Longer strings will be cut into |
414 * additional lines at whitespace characters if possible. The string parameter |
414 * additional lines at whitespace characters if possible. The string parameter |
415 * is modified with terminating characters mid-string which are the |
415 * is modified with terminating characters mid-string which are the |
416 * placeholders for the newlines.<br/> |
416 * placeholders for the newlines. |
417 * The string WILL be truncated if there was no whitespace for the current |
417 * The string WILL be truncated if there was no whitespace for the current |
418 * line's maximum width. |
418 * line's maximum width. |
419 * |
419 * |
420 * @note To know if the the terminating '\0' is the string end or just a |
420 * @note To know if the terminating '\0' is the string end or just a |
421 * newline, the returned 'num' value should be consulted. The num'th '\0', |
421 * newline, the returned 'num' value should be consulted. The num'th '\0', |
422 * starting with index 0 is the real string end. |
422 * starting with index 0 is the real string end. |
423 * |
423 * |
424 * @param str string to check and correct for length restrictions |
424 * @param str string to check and correct for length restrictions |
425 * @param maxw the maximum width the string can have on one line |
425 * @param maxw the maximum width the string can have on one line |
485 |
485 |
486 /** Draw a given string with the centre around the given x coordinates |
486 /** Draw a given string with the centre around the given x coordinates |
487 * @param x Centre the string around this pixel width |
487 * @param x Centre the string around this pixel width |
488 * @param y Draw the string at this pixel height (first line's bottom) |
488 * @param y Draw the string at this pixel height (first line's bottom) |
489 * @param str String to draw |
489 * @param str String to draw |
490 * @param max Maximum width the string can have before it is wrapped */ |
490 * @param maxw Maximum width the string can have before it is wrapped */ |
491 void DrawStringMultiCenter(int x, int y, StringID str, int maxw) |
491 void DrawStringMultiCenter(int x, int y, StringID str, int maxw) |
492 { |
492 { |
493 char buffer[512]; |
493 char buffer[512]; |
494 uint32 tmp; |
494 uint32 tmp; |
495 int num, w, mt; |
495 int num, w, mt; |
624 } |
624 } |
625 |
625 |
626 /** Draw a string at the given coordinates with the given colour |
626 /** Draw a string at the given coordinates with the given colour |
627 * @param string the string to draw |
627 * @param string the string to draw |
628 * @param x offset from left side of the screen, if negative offset from the right side |
628 * @param x offset from left side of the screen, if negative offset from the right side |
629 * @param x offset from top side of the screen, if negative offset from the bottom |
629 * @param y offset from top side of the screen, if negative offset from the bottom |
630 * @param real_color colour of the string, see _string_colormap in |
630 * @param real_color colour of the string, see _string_colormap in |
631 * table/palettes.h or docs/ottd-colourtext-palette.png |
631 * table/palettes.h or docs/ottd-colourtext-palette.png |
632 * @return the x-coordinates where the drawing has finished. If nothing is drawn |
632 * @return the x-coordinates where the drawing has finished. If nothing is drawn |
633 * the originally passed x-coordinate is returned */ |
633 * the originally passed x-coordinate is returned */ |
634 int DoDrawString(const char *string, int x, int y, uint16 real_color) |
634 int DoDrawString(const char *string, int x, int y, uint16 real_color) |
650 |
650 |
651 if (color != 0xFF) { |
651 if (color != 0xFF) { |
652 switch_color:; |
652 switch_color:; |
653 if (real_color & IS_PALETTE_COLOR) { |
653 if (real_color & IS_PALETTE_COLOR) { |
654 _string_colorremap[1] = color; |
654 _string_colorremap[1] = color; |
655 _string_colorremap[2] = 215; |
655 _string_colorremap[2] = _use_dos_palette ? 1 : 215; |
656 } else { |
656 } else { |
657 _string_colorremap[1] = _string_colormap[color].text; |
657 uint palette = _use_dos_palette ? 1 : 0; |
658 _string_colorremap[2] = _string_colormap[color].shadow; |
658 _string_colorremap[1] = _string_colormap[palette][color].text; |
|
659 _string_colorremap[2] = _string_colormap[palette][color].shadow; |
659 } |
660 } |
660 _color_remap_ptr = _string_colorremap; |
661 _color_remap_ptr = _string_colorremap; |
661 } |
662 } |
662 } |
663 } |
663 |
664 |