diff options
author | Darkvater <Darkvater@openttd.org> | 2007-03-05 00:45:56 +0000 |
---|---|---|
committer | Darkvater <Darkvater@openttd.org> | 2007-03-05 00:45:56 +0000 |
commit | 2ff94ab0004f6274a79ccf1f88090dd7d69073c6 (patch) | |
tree | 347173f94845f2ed93206df1d8a324c41c93e2bd /src/texteff.cpp | |
parent | ca4c8562474608ac15b79198230fd30b020de36c (diff) | |
download | openttd-2ff94ab0004f6274a79ccf1f88090dd7d69073c6.tar.xz |
(svn r9012) -Fix/Feature (UTF8): When cutting strings into multiple lines also take into consideration whitespace characters of more than 1 byte length (eg IDEOGRAPHIC SPACE, IsWhitespace() function). When trimming such strings, account for multiple-byte long sequences so use *Utf8PrevChar(v) = '\0'.
-Codechange: Add a function Utf8TrimString() that properly trims a string to an UTF8 encoding seperation instead of somewhere in the wild (and use it in the chat area)
Diffstat (limited to 'src/texteff.cpp')
-rw-r--r-- | src/texteff.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/texteff.cpp b/src/texteff.cpp index 54c456364..ff2cf1b49 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -17,7 +17,7 @@ #include "date.h" enum { - MAX_TEXTMESSAGE_LENGTH = 150, + MAX_TEXTMESSAGE_LENGTH = 200, MAX_TEXT_MESSAGES = 30, MAX_CHAT_MESSAGES = 10, MAX_ANIMATED_TILES = 256, @@ -82,6 +82,9 @@ void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ... vsnprintf(buf, lengthof(buf), message, va); va_end(va); + + Utf8TrimString(buf, MAX_TEXTMESSAGE_LENGTH); + /* Force linebreaks for strings that are too long */ lines = GB(FormatStringLinebreaks(buf, _textmsg_box.width - 8), 0, 16) + 1; if (lines >= MAX_CHAT_MESSAGES) return; |