diff options
author | John Ellis <johne@verizon.net> | 2010-07-10 17:58:48 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:17:39 +0000 |
commit | 5f31f8a51af0839e7eeea065a78e84b701919f56 (patch) | |
tree | cf1c99af208db32327c58fc08455658b990c2232 /src/ui | |
parent | 3c7eb9def5ab4455044d5a94e3332d36681303de (diff) |
* Fix text width result and line wrap when encountering INDENT_MARKER
* Fix line wrapping when encountering emoticons
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/ui_shared.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c index 7b6db434..4f579e4a 100644 --- a/src/ui/ui_shared.c +++ b/src/ui/ui_shared.c @@ -1999,6 +1999,7 @@ float UI_Text_Width( const char *text, float scale, int limit ) if( *s == INDENT_MARKER ) { s++; + count++; continue; } @@ -4308,20 +4309,6 @@ static void SkipWhiteSpace( const char **text, char *lastColor ) } } -static void SkipEmoticons( const char **text ) -{ - int emoticonLen; - qboolean emoticonEscaped; - - while( UI_Text_IsEmoticon( *text, &emoticonEscaped, &emoticonLen, NULL, NULL ) ) - { - if( emoticonEscaped ) - (*text)++; - else - (*text) += emoticonLen; - } -} - const char *Item_Text_Wrap( const char *text, float scale, float width ) { static char out[ 8192 ] = ""; @@ -4351,6 +4338,8 @@ const char *Item_Text_Wrap( const char *text, float scale, float width ) while( testLength == 0 || UI_Text_Width( p, scale, testLength ) < testWidth ) { + int emoticonLen; + qboolean emoticonEscaped; qboolean previousCharIsSpace = qfalse; // Remaining string is too short to wrap @@ -4364,18 +4353,25 @@ const char *Item_Text_Wrap( const char *text, float scale, float width ) for( q = p, i = 0; i < testLength; i++ ) { SkipColorCodes( &q, c ); - SkipEmoticons( &q ); previousCharIsSpace = isspace( *q ); q++; } + if( UI_Text_IsEmoticon( q, &emoticonEscaped, &emoticonLen, NULL, NULL ) ) + { + testLength += emoticonLen; + continue; + } + if( testLength > 0 && *q == INDENT_MARKER ) + { indentWidth = UI_Text_Width( p, scale, testLength ); + eol = p; + } // Some color escapes might still be present SkipColorCodes( &q, c ); - SkipEmoticons( &q ); // Manual line break if( *q == '\n' ) |