summaryrefslogtreecommitdiff
path: root/src/ui/ui_shared.c
diff options
context:
space:
mode:
authorTony J. White <tjw@tjw.org>2009-10-03 11:45:48 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:19 +0000
commitd6a0337fb1d80010eb0bb19623d52beef49eeee6 (patch)
tree169696862fadce29ceb728f41df95504d70c3670 /src/ui/ui_shared.c
parentc2f8f9a7f6a4cc3d0ca32a07e46a0803c2304095 (diff)
* add variable width to emoticons support. In addition to being a
.tga in the /emoticons/ dir of fs_game, emoticon file names need to end with "_{WIDTH}x1.tga". For example, /emoticons/dretch_1x1.tga (square) or /emoticons/rifle_2x1.tga (double-wide)
Diffstat (limited to 'src/ui/ui_shared.c')
-rw-r--r--src/ui/ui_shared.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c
index f2fe9b28..850ac52f 100644
--- a/src/ui/ui_shared.c
+++ b/src/ui/ui_shared.c
@@ -1834,7 +1834,8 @@ void Script_playLooped( itemDef_t *item, char **args )
}
}
-static qboolean UI_Text_Emoticon( const char *s, qboolean *escaped, int *length, qhandle_t *h )
+static qboolean UI_Text_Emoticon( const char *s, qboolean *escaped,
+ int *length, qhandle_t *h, int *width )
{
char name[ MAX_EMOTICON_NAME_LEN ] = {""};
const char *p = s;
@@ -1867,6 +1868,8 @@ static qboolean UI_Text_Emoticon( const char *s, qboolean *escaped, int *length,
}
if( h )
*h = DC->Assets.emoticonShaders[ j ];
+ if( width )
+ *width = DC->Assets.emoticonWidths[ j ];
*length = i + 2;
return qtrue;
}
@@ -1891,7 +1894,7 @@ float UI_Text_Width( const char *text, float scale, int limit )
fontInfo_t *font = &DC->Assets.textFont;
int emoticonLen;
qboolean emoticonEscaped;
- float emoticonWidth;
+ float emoticonW;
int emoticons = 0;
if( scale <= DC->getCVarValue( "ui_smallFont" ) )
@@ -1900,7 +1903,7 @@ float UI_Text_Width( const char *text, float scale, int limit )
font = &DC->Assets.bigFont;
useScale = scale * font->glyphScale;
- emoticonWidth = UI_Text_Height( "[", scale, 0 ) * DC->aspectScale;
+ emoticonW = UI_Text_Height( "[", scale, 0 ) * DC->aspectScale;
out = 0;
if( text )
@@ -1921,7 +1924,7 @@ float UI_Text_Width( const char *text, float scale, int limit )
s += 2;
continue;
}
- else if ( UI_Text_Emoticon( s, &emoticonEscaped, &emoticonLen, NULL ) )
+ else if ( UI_Text_Emoticon( s, &emoticonEscaped, &emoticonLen, NULL, NULL ) )
{
if( emoticonEscaped )
{
@@ -1940,7 +1943,7 @@ float UI_Text_Width( const char *text, float scale, int limit )
}
}
- return ( out * useScale ) + ( emoticons * emoticonWidth );
+ return ( out * useScale ) + ( emoticons * emoticonW );
}
float UI_Text_Height( const char *text, float scale, int limit )
@@ -2038,6 +2041,7 @@ void UI_Text_Paint_Limit( float *maxX, float x, float y, float scale,
qhandle_t emoticonHandle = 0;
float emoticonH, emoticonW;
qboolean emoticonEscaped;
+ int emoticonWidth;
emoticonH = UI_Text_Height( "[", scale, 0 );
emoticonW = emoticonH * DC->aspectScale;
@@ -2085,7 +2089,8 @@ void UI_Text_Paint_Limit( float *maxX, float x, float y, float scale,
s += 2;
continue;
}
- else if( UI_Text_Emoticon( s, &emoticonEscaped, &emoticonLen, &emoticonHandle ) )
+ else if( UI_Text_Emoticon( s, &emoticonEscaped, &emoticonLen,
+ &emoticonHandle, &emoticonWidth ) )
{
if( emoticonEscaped )
{
@@ -2095,9 +2100,10 @@ void UI_Text_Paint_Limit( float *maxX, float x, float y, float scale,
{
s += emoticonLen;
DC->setColor( NULL );
- DC->drawHandlePic( x, y - yadj, emoticonW, emoticonH, emoticonHandle );
+ DC->drawHandlePic( x, y - yadj, ( emoticonW * emoticonWidth ),
+ emoticonH, emoticonHandle );
DC->setColor( newColor );
- x += emoticonW;
+ x += ( emoticonW * emoticonWidth );
continue;
}
}
@@ -2139,6 +2145,7 @@ void UI_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex
qhandle_t emoticonHandle = 0;
float emoticonH, emoticonW;
qboolean emoticonEscaped;
+ int emoticonWidth;
if( scale <= DC->getCVarValue( "ui_smallFont" ) )
font = &DC->Assets.smallFont;
@@ -2179,7 +2186,8 @@ void UI_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex
s += 2;
continue;
}
- else if( UI_Text_Emoticon( s, &emoticonEscaped, &emoticonLen, &emoticonHandle ) )
+ else if( UI_Text_Emoticon( s, &emoticonEscaped, &emoticonLen,
+ &emoticonHandle, &emoticonWidth ) )
{
if( emoticonEscaped )
{
@@ -2188,9 +2196,10 @@ void UI_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex
else
{
DC->setColor( NULL );
- DC->drawHandlePic( x, y - yadj, emoticonW, emoticonH, emoticonHandle );
+ DC->drawHandlePic( x, y - yadj, ( emoticonW * emoticonWidth ),
+ emoticonH, emoticonHandle );
DC->setColor( newColor );
- x += emoticonW;
+ x += ( emoticonW * emoticonWidth );
s += emoticonLen;
continue;
}
@@ -4611,7 +4620,7 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width )
c[ 1 ] = q[ 1 ];
q += 2;
}
- while( UI_Text_Emoticon( q, &emoticonEscaped, &emoticonLen, NULL ) )
+ while( UI_Text_Emoticon( q, &emoticonEscaped, &emoticonLen, NULL, NULL ) )
{
if( emoticonEscaped )
q++;
@@ -4631,7 +4640,7 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width )
c[ 1 ] = q[ 1 ];
q += 2;
}
- while( UI_Text_Emoticon( q, &emoticonEscaped, &emoticonLen, NULL ) )
+ while( UI_Text_Emoticon( q, &emoticonEscaped, &emoticonLen, NULL, NULL ) )
{
if( emoticonEscaped )
q++;