summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2010-12-10 22:28:49 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:17:49 +0000
commit28b3eefd702c149afc5dd56bc408803de06b7ce5 (patch)
treeaa5c566adb58b3ea6842eeea9c65a71b47b78a23
parent1ae8c55f4750424e85f564cbf2b00f016d1c1f11 (diff)
* Remove used limit parameter from UI_Text_[Width|Height]
-rw-r--r--src/cgame/cg_draw.c50
-rw-r--r--src/cgame/cg_main.c2
-rw-r--r--src/cgame/cg_weapons.c4
-rw-r--r--src/ui/ui_main.c6
-rw-r--r--src/ui/ui_shared.c57
-rw-r--r--src/ui/ui_shared.h4
6 files changed, 55 insertions, 68 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index eda0bf58..7169540d 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -39,8 +39,8 @@ static void CG_AlignText( rectDef_t *rect, const char *text, float scale,
if( scale > 0.0f )
{
- w = UI_Text_Width( text, scale, 0 );
- h = UI_Text_Height( text, scale, 0 );
+ w = UI_Text_Width( text, scale );
+ h = UI_Text_Height( text, scale );
}
switch( align )
@@ -1284,7 +1284,7 @@ static void CG_DrawKiller( rectDef_t *rect, float scale, vec4_t color,
if( cg.killerName[ 0 ] )
{
int x = rect->x + rect->w / 2;
- UI_Text_Paint( x - UI_Text_Width( CG_GetKillerText( ), scale, 0 ) / 2,
+ UI_Text_Paint( x - UI_Text_Width( CG_GetKillerText( ), scale ) / 2,
rect->y + rect->h, scale, color, CG_GetKillerText( ), 0, 0, textStyle );
}
}
@@ -1301,7 +1301,7 @@ static void CG_DrawTeamSpectators( rectDef_t *rect, float scale, int textvalign,
{
float y;
char *text = cg.spectatorList;
- float textWidth = UI_Text_Width( text, scale, 0 );
+ float textWidth = UI_Text_Width( text, scale );
CG_AlignText( rect, text, scale, 0.0f, 0.0f, ALIGN_LEFT, textvalign, NULL, &y );
@@ -1514,10 +1514,10 @@ static void CG_DrawFPS( rectDef_t *rect, float text_x, float text_y,
fps = 1000 * FPS_FRAMES / total;
s = va( "%d", fps );
- w = UI_Text_Width( "0", scale, 0 );
- h = UI_Text_Height( "0", scale, 0 );
+ w = UI_Text_Width( "0", scale );
+ h = UI_Text_Height( "0", scale );
strLength = CG_DrawStrlen( s );
- totalWidth = UI_Text_Width( FPS_STRING, scale, 0 ) + w * strLength;
+ totalWidth = UI_Text_Width( FPS_STRING, scale ) + w * strLength;
CG_AlignText( rect, s, 0.0f, totalWidth, h, textalign, textvalign, &tx, &ty );
@@ -1623,8 +1623,8 @@ static void CG_DrawTimer( rectDef_t *rect, float text_x, float text_y,
seconds -= tens * 10;
s = va( "%d:%d%d", mins, tens, seconds );
- w = UI_Text_Width( "0", scale, 0 );
- h = UI_Text_Height( "0", scale, 0 );
+ w = UI_Text_Width( "0", scale );
+ h = UI_Text_Height( "0", scale );
strLength = CG_DrawStrlen( s );
totalWidth = w * strLength;
@@ -1918,8 +1918,8 @@ static void CG_DrawClock( rectDef_t *rect, float text_x, float text_y,
s = va( "%d%s%02d%s", h, ( qt.tm_sec % 2 ) ? ":" : " ", qt.tm_min, pm );
}
- w = UI_Text_Width( "0", scale, 0 );
- h = UI_Text_Height( "0", scale, 0 );
+ w = UI_Text_Width( "0", scale );
+ h = UI_Text_Height( "0", scale );
strLength = CG_DrawStrlen( s );
totalWidth = w * strLength;
@@ -2067,7 +2067,7 @@ static void CG_DrawDisconnect( void )
// also add text in center of screen
s = "Connection Interrupted";
- w = UI_Text_Width( s, 0.7f, 0 );
+ w = UI_Text_Width( s, 0.7f );
UI_Text_Paint( 320 - w / 2, 100, 0.7f, color, s, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
// blink the icon
@@ -2225,9 +2225,9 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y,
else
ping = va( "%d", cg.ping );
ax = rect->x + ( rect->w / 2.0f ) -
- ( UI_Text_Width( ping, scale, 0 ) / 2.0f ) + text_x;
+ ( UI_Text_Width( ping, scale ) / 2.0f ) + text_x;
ay = rect->y + ( rect->h / 2.0f ) +
- ( UI_Text_Height( ping, scale, 0 ) / 2.0f ) + text_y;
+ ( UI_Text_Height( ping, scale ) / 2.0f ) + text_y;
Vector4Copy( textColor, adjustedColor );
adjustedColor[ 3 ] = 0.5f;
@@ -2366,8 +2366,8 @@ static void CG_DrawSpeedText( rectDef_t *rect, float text_x, float text_y,
Com_sprintf( speedstr, sizeof( speedstr ), "%d", (int)val );
UI_Text_Paint(
- rect->x + ( rect->w - UI_Text_Width( speedstr, scale, 0 ) ) / 2.0f,
- rect->y + ( rect->h + UI_Text_Height( speedstr, scale, 0 ) ) / 2.0f,
+ rect->x + ( rect->w - UI_Text_Width( speedstr, scale ) ) / 2.0f,
+ rect->y + ( rect->h + UI_Text_Height( speedstr, scale ) ) / 2.0f,
scale, color, speedstr, 0, 0, ITEM_TEXTSTYLE_NORMAL );
}
@@ -2611,7 +2611,7 @@ static void CG_DrawLocation( rectDef_t *rect, float scale, int textalign, vec4_t
location = CG_ConfigString( CS_LOCATIONS );
// need to skip horiz. align if it's too long, but valign must be run either way
- if( UI_Text_Width( location, scale, 0 ) < rect->w )
+ if( UI_Text_Width( location, scale ) < rect->w )
{
CG_AlignText( rect, location, scale, 0.0f, 0.0f, textalign, VALIGN_CENTER, &tx, &ty );
UI_Text_Paint( tx, ty, scale, color, location, 0, 0, ITEM_TEXTSTYLE_NORMAL );
@@ -2665,7 +2665,7 @@ static void CG_DrawCrosshairNames( rectDef_t *rect, float scale, int textStyle )
cgs.clientinfo[ cg.crosshairClientNum ].health );
}
- w = UI_Text_Width( name, scale, 0 );
+ w = UI_Text_Width( name, scale );
x = rect->x + rect->w / 2.0f;
UI_Text_Paint( x - w / 2.0f, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
trap_R_SetColor( NULL );
@@ -3122,8 +3122,8 @@ static void CG_DrawCenterString( void )
linebuffer[ l ] = 0;
- w = UI_Text_Width( linebuffer, 0.5, 0 );
- h = UI_Text_Height( linebuffer, 0.5, 0 );
+ w = UI_Text_Width( linebuffer, 0.5 );
+ h = UI_Text_Height( linebuffer, 0.5 );
x = ( SCREEN_WIDTH - w ) / 2;
UI_Text_Paint( x, y + h, 0.5, color, linebuffer, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE );
y += h + 6;
@@ -3316,7 +3316,7 @@ static qboolean CG_DrawQueue( void )
Com_sprintf( buffer, MAX_STRING_CHARS, "You are %d%s in the spawn queue",
position, ordinal );
- w = UI_Text_Width( buffer, 0.7f, 0 );
+ w = UI_Text_Width( buffer, 0.7f );
UI_Text_Paint( 320 - w / 2, 360, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
if( cg.snap->ps.persistant[ PERS_SPAWNS ] == 0 )
@@ -3327,7 +3327,7 @@ static qboolean CG_DrawQueue( void )
Com_sprintf( buffer, MAX_STRING_CHARS, "There are %d spawns remaining",
cg.snap->ps.persistant[ PERS_SPAWNS ] );
- w = UI_Text_Width( buffer, 0.7f, 0 );
+ w = UI_Text_Width( buffer, 0.7f );
UI_Text_Paint( 320 - w / 2, 400, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
return qtrue;
@@ -3355,13 +3355,13 @@ static void CG_DrawWarmup( void )
if( sec < 0 )
return;
- w = UI_Text_Width( text, size, 0 );
- h = UI_Text_Height( text, size, 0 );
+ w = UI_Text_Width( text, size );
+ h = UI_Text_Height( text, size );
UI_Text_Paint( 320 - w / 2, 200, size, colorWhite, text, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
Com_sprintf( text, sizeof( text ), "%s", sec ? va( "%d", sec ) : "FIGHT!" );
- w = UI_Text_Width( text, size, 0 );
+ w = UI_Text_Width( text, size );
UI_Text_Paint( 320 - w / 2, 200 + 1.5f * h, size, colorWhite, text, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
}
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 8044dca9..a296aade 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -1575,7 +1575,7 @@ static int CG_OwnerDrawWidth( int ownerDraw, float scale )
switch( ownerDraw )
{
case CG_KILLER:
- return UI_Text_Width( CG_GetKillerText( ), scale, 0 );
+ return UI_Text_Width( CG_GetKillerText( ), scale );
break;
}
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index a166bf94..16c2d578 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -1523,7 +1523,7 @@ void CG_DrawItemSelectText( rectDef_t *rect, float scale, int textStyle )
{
if( ( name = cg_weapons[ cg.weaponSelect ].humanName ) )
{
- w = UI_Text_Width( name, scale, 0 );
+ w = UI_Text_Width( name, scale );
x = rect->x + rect->w / 2;
UI_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
}
@@ -1536,7 +1536,7 @@ void CG_DrawItemSelectText( rectDef_t *rect, float scale, int textStyle )
{
if( ( name = cg_upgrades[ cg.weaponSelect - 32 ].humanName ) )
{
- w = UI_Text_Width( name, scale, 0 );
+ w = UI_Text_Width( name, scale );
x = rect->x + rect->w / 2;
UI_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
}
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index 158bebbd..2813c874 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -1863,7 +1863,7 @@ static int UI_OwnerDrawWidth( int ownerDraw, float scale )
}
if( s )
- return UI_Text_Width( s, scale, 0 );
+ return UI_Text_Width( s, scale );
return 0;
}
@@ -4317,7 +4317,7 @@ static void UI_PrintTime ( char *buf, int bufsize, int time )
// FIXME: move to ui_shared.c?
void Text_PaintCenter( float x, float y, float scale, vec4_t color, const char *text, float adjust )
{
- int len = UI_Text_Width( text, scale, 0 );
+ int len = UI_Text_Width( text, scale );
UI_Text_Paint( x - len / 2, y, scale, color, text, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE );
}
@@ -4345,7 +4345,7 @@ void Text_PaintCenter_AutoWrapped( float x, float y, float xmax, float ystep, fl
*s3 = '\0';
- width = UI_Text_Width( s1, scale, 0 );
+ width = UI_Text_Width( s1, scale );
*s3 = c_bcp;
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c
index 5666ed60..12b306f3 100644
--- a/src/ui/ui_shared.c
+++ b/src/ui/ui_shared.c
@@ -1977,7 +1977,7 @@ static ID_INLINE fontInfo_t *UI_FontForScale( float scale )
return &DC->Assets.textFont;
}
-float UI_Char_Width( const char **text, float scale, int *characters )
+float UI_Char_Width( const char **text, float scale )
{
glyphInfo_t *glyph;
float useScale;
@@ -1991,7 +1991,7 @@ float UI_Char_Width( const char **text, float scale, int *characters )
useScale = scale * font->glyphScale;
emoticonW = UI_EmoticonWidth( font, scale );
- if( text && *text && characters )
+ if( text && *text )
{
s = *text;
glyph = &font->glyphs[ (int)*s ];
@@ -2004,7 +2004,6 @@ float UI_Char_Width( const char **text, float scale, int *characters )
if( *s == INDENT_MARKER )
{
- (*characters)++;
*text = s + 1;
return 0.0f;
@@ -2017,14 +2016,12 @@ float UI_Char_Width( const char **text, float scale, int *characters )
s++;
else
{
- *characters += emoticonLen;
*text = s + emoticonLen;
return emoticonWidth * emoticonW;
}
}
- (*characters)++;
*text = s + 1;
return glyph->xSkip * DC->aspectScale * useScale;
@@ -2033,9 +2030,8 @@ float UI_Char_Width( const char **text, float scale, int *characters )
return 0.0f;
}
-float UI_Text_Width( const char *text, float scale, int limit )
+float UI_Text_Width( const char *text, float scale )
{
- int count;
float out;
const char *s = text;
float indentWidth = 0.0f;
@@ -2044,19 +2040,17 @@ float UI_Text_Width( const char *text, float scale, int limit )
if( text )
{
- count = 0;
indentWidth = UI_Parse_Indent( &s );
- while( *s && ( limit == 0 || count < limit ) )
- out += UI_Char_Width( &s, scale, &count );
+ while( *s )
+ out += UI_Char_Width( &s, scale );
}
return out + indentWidth;
}
-float UI_Text_Height( const char *text, float scale, int limit )
+float UI_Text_Height( const char *text, float scale )
{
- int len, count;
float max;
glyphInfo_t *glyph;
float useScale;
@@ -2068,14 +2062,7 @@ float UI_Text_Height( const char *text, float scale, int limit )
if( text )
{
- len = strlen( text );
-
- if( limit > 0 && len > limit )
- len = limit;
-
- count = 0;
-
- while( s && *s && count < len )
+ while( s && *s )
{
if( Q_IsColorString( s ) )
{
@@ -2090,7 +2077,6 @@ float UI_Text_Height( const char *text, float scale, int limit )
max = glyph->height;
s++;
- count++;
}
}
}
@@ -2100,12 +2086,12 @@ float UI_Text_Height( const char *text, float scale, int limit )
float UI_Text_EmWidth( float scale )
{
- return UI_Text_Width( "M", scale, 0 );
+ return UI_Text_Width( "M", scale );
}
float UI_Text_EmHeight( float scale )
{
- return UI_Text_Height( "M", scale, 0 );
+ return UI_Text_Height( "M", scale );
}
@@ -2221,9 +2207,11 @@ static void UI_Text_Paint_Generic( float x, float y, float scale, float gapAdjus
while( s && *s && count < len )
{
+ const char *t = s;
+ float charWidth = UI_Char_Width( &t, scale );
glyph = &font->glyphs[ (int)*s ];
- if( maxX && UI_Text_Width( s, scale, 1 ) + x > *maxX )
+ if( maxX && charWidth + x > *maxX )
{
*maxX = 0;
break;
@@ -3246,7 +3234,7 @@ static void Item_TextField_CalcPaintOffset( itemDef_t *item, char *buff )
if( buff[ item->cursorPos + 1 ] == '\0' )
{
- while( UI_Text_Width( &buff[ editPtr->paintOffset ], item->textscale, 0 ) <=
+ while( UI_Text_Width( &buff[ editPtr->paintOffset ], item->textscale ) <=
( editPtr->maxFieldWidth - EDIT_CURSOR_WIDTH ) && editPtr->paintOffset > 0 )
editPtr->paintOffset--;
}
@@ -3255,7 +3243,7 @@ static void Item_TextField_CalcPaintOffset( itemDef_t *item, char *buff )
// Shift paintOffset so that the cursor is visible
- while( UI_Text_Width( &buff[ editPtr->paintOffset ], item->textscale, 0 ) >
+ while( UI_Text_Width( &buff[ editPtr->paintOffset ], item->textscale ) >
( editPtr->maxFieldWidth - EDIT_CURSOR_WIDTH ) )
editPtr->paintOffset++;
}
@@ -4245,14 +4233,14 @@ void Item_SetTextExtents( itemDef_t *item, int *width, int *height, const char *
{
char buff[ MAX_CVAR_VALUE_STRING ];
DC->getCVarString( item->cvar, buff, sizeof( buff ) );
- originalWidth = UI_Text_Width( item->text, item->textscale, 0 ) +
- UI_Text_Width( buff, item->textscale, 0 );
+ originalWidth = UI_Text_Width( item->text, item->textscale ) +
+ UI_Text_Width( buff, item->textscale );
}
else
- originalWidth = UI_Text_Width( item->text, item->textscale, 0 );
+ originalWidth = UI_Text_Width( item->text, item->textscale );
- *width = UI_Text_Width( textPtr, item->textscale, 0 );
- *height = UI_Text_Height( textPtr, item->textscale, 0 );
+ *width = UI_Text_Width( textPtr, item->textscale );
+ *height = UI_Text_Height( textPtr, item->textscale );
item->textRect.w = *width;
item->textRect.h = *height;
@@ -4353,7 +4341,6 @@ const char *Item_Text_Wrap( const char *text, float scale, float width )
float textWidth = 0.0f;
const char *eol = p;
const char *q = p;
- int count = 0;
float testWidth = width - indentWidth;
SkipColorCodes( &q, c );
@@ -4388,7 +4375,7 @@ const char *Item_Text_Wrap( const char *text, float scale, float width )
if( !previousCharIsSpace && isspace( *q ) )
eol = q;
- textWidth += UI_Char_Width( &q, scale, &count );
+ textWidth += UI_Char_Width( &q, scale );
}
// No split has taken place, so just split mid-word
@@ -4814,7 +4801,7 @@ void Item_TextField_Paint( itemDef_t *item )
editPtr->paintOffset = 0;
// Shorten string to max viewable
- while( UI_Text_Width( buff + editPtr->paintOffset, item->textscale, 0 ) >
+ while( UI_Text_Width( buff + editPtr->paintOffset, item->textscale ) >
( editPtr->maxFieldWidth - cursorWidth ) && strlen( buff ) > 0 )
buff[ strlen( buff ) - 1 ] = '\0';
@@ -5506,7 +5493,7 @@ void Item_ListBoxRow_Paint( itemDef_t *item, int row, int renderPos, qboolean hi
{
float alignOffset = 0.0f, tw;
- tw = UI_Text_Width( text, item->textscale, 0 );
+ tw = UI_Text_Width( text, item->textscale );
switch( listPtr->columnInfo[ j ].align )
{
diff --git a/src/ui/ui_shared.h b/src/ui/ui_shared.h
index ab7336de..649d51f1 100644
--- a/src/ui/ui_shared.h
+++ b/src/ui/ui_shared.h
@@ -540,8 +540,8 @@ void UI_DrawTextBlock( rectDef_t *rect, float text_x, float text_y, vec4_t color
void UI_Text_Paint( float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style );
void UI_Text_Paint_Limit( float *maxX, float x, float y, float scale,
vec4_t color, const char* text, float adjust, int limit );
-float UI_Text_Width( const char *text, float scale, int limit );
-float UI_Text_Height( const char *text, float scale, int limit );
+float UI_Text_Width( const char *text, float scale );
+float UI_Text_Height( const char *text, float scale );
float UI_Text_EmWidth( float scale );
float UI_Text_EmHeight( float scale );
qboolean UI_Text_IsEmoticon( const char *s, qboolean *escaped, int *length, qhandle_t *h, int *width );