summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_draw.c445
-rw-r--r--src/cgame/cg_local.h6
-rw-r--r--src/cgame/cg_main.c25
-rw-r--r--src/cgame/cg_scanner.c8
-rw-r--r--src/cgame/cg_weapons.c37
5 files changed, 99 insertions, 422 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index ec50146e..56d25c9c 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -28,8 +28,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_local.h"
#include "../ui/ui_shared.h"
-// used for scoreboard
-extern displayContextDef_t cgDC;
menuDef_t *menuScoreboard = NULL;
int drawTeamOverlayModificationCount = -1;
@@ -37,107 +35,6 @@ int drawTeamOverlayModificationCount = -1;
int sortedTeamPlayers[ TEAM_MAXOVERLAY ];
int numSortedTeamPlayers;
-//TA UI
-float CG_Text_Width( const char *text, float scale, int limit )
-{
- int count,len;
- float out;
- glyphInfo_t *glyph;
- float useScale;
- const char *s = text;
- fontInfo_t *font = &cgDC.Assets.textFont;
-
- if( scale <= cg_smallFont.value )
- font = &cgDC.Assets.smallFont;
- else if( scale > cg_bigFont.value )
- font = &cgDC.Assets.bigFont;
-
- useScale = scale * font->glyphScale;
- out = 0;
-
- if( text )
- {
- len = strlen( text );
- if( limit > 0 && len > limit )
- len = limit;
-
- count = 0;
- while( s && *s && count < len )
- {
- if( Q_IsColorString( s ) )
- {
- s += 2;
- continue;
- }
- else
- {
- glyph = &font->glyphs[ (int)*s ];
- out += glyph->xSkip;
- s++;
- count++;
- }
- }
- }
-
- return out * useScale;
-}
-
-float CG_Text_Height( const char *text, float scale, int limit )
-{
- int len, count;
- float max;
- glyphInfo_t *glyph;
- float useScale;
- const char *s = text;
- fontInfo_t *font = &cgDC.Assets.textFont;
-
- if( scale <= cg_smallFont.value )
- font = &cgDC.Assets.smallFont;
- else if( scale > cg_bigFont.value )
- font = &cgDC.Assets.bigFont;
-
- useScale = scale * font->glyphScale;
- max = 0;
-
- if( text )
- {
- len = strlen( text );
- if( limit > 0 && len > limit )
- len = limit;
-
- count = 0;
- while( s && *s && count < len )
- {
- if( Q_IsColorString( s ) )
- {
- s += 2;
- continue;
- }
- else
- {
- glyph = &font->glyphs[ (int)*s ];
- if( max < glyph->height )
- max = glyph->height;
-
- s++;
- count++;
- }
- }
- }
-
- return max * useScale;
-}
-
-float CG_Text_EmWidth( float scale )
-{
- return CG_Text_Width( "M", scale, 0 );
-}
-
-float CG_Text_EmHeight( float scale )
-{
- return CG_Text_Height( "M", scale, 0 );
-}
-
static void CG_AlignText( rectDef_t *rect, const char *text, float scale,
float w, float h,
int align, int valign,
@@ -147,22 +44,22 @@ static void CG_AlignText( rectDef_t *rect, const char *text, float scale,
if( scale > 0.0f )
{
- w = CG_Text_Width( text, scale, 0 );
- h = CG_Text_Height( text, scale, 0 );
+ w = UI_Text_Width( text, scale, 0 );
+ h = UI_Text_Height( text, scale, 0 );
}
switch( align )
{
default:
- case ITEM_ALIGN_LEFT:
+ case ALIGN_LEFT:
tx = 0.0f;
break;
- case ITEM_ALIGN_RIGHT:
+ case ALIGN_RIGHT:
tx = rect->w - w;
break;
- case ITEM_ALIGN_CENTER:
+ case ALIGN_CENTER:
tx = ( rect->w - w ) / 2.0f;
break;
}
@@ -170,15 +67,15 @@ static void CG_AlignText( rectDef_t *rect, const char *text, float scale,
switch( valign )
{
default:
- case ITEM_VALIGN_BOTTOM:
+ case VALIGN_BOTTOM:
ty = rect->h;
break;
- case ITEM_VALIGN_TOP:
+ case VALIGN_TOP:
ty = h;
break;
- case ITEM_VALIGN_CENTER:
+ case VALIGN_CENTER:
ty = h + ( ( rect->h - h ) / 2.0f );
break;
}
@@ -190,156 +87,6 @@ static void CG_AlignText( rectDef_t *rect, const char *text, float scale,
*y = rect->y + ty;
}
-void CG_Text_PaintChar( float x, float y, float width, float height, float scale,
- float s, float t, float s2, float t2, qhandle_t hShader )
-{
- float w, h;
- w = width * scale;
- h = height * scale;
- CG_AdjustFrom640( &x, &y, &w, &h );
- trap_R_DrawStretchPic( x, y, w, h, s, t, s2, t2, hShader );
-}
-
-void CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *text,
- float adjust, int limit, int style )
-{
- int len, count;
- vec4_t newColor;
- glyphInfo_t *glyph;
- float useScale;
- fontInfo_t *font = &cgDC.Assets.textFont;
-
- if( scale <= cg_smallFont.value )
- font = &cgDC.Assets.smallFont;
- else if( scale > cg_bigFont.value )
- font = &cgDC.Assets.bigFont;
-
- useScale = scale * font->glyphScale;
- if( text )
- {
-
- const char *s = text;
-
- trap_R_SetColor( color );
- memcpy( &newColor[ 0 ], &color[ 0 ], sizeof( vec4_t ) );
- len = strlen( text );
-
- if( limit > 0 && len > limit )
- len = limit;
-
- count = 0;
- while( s && *s && count < len )
- {
- glyph = &font->glyphs[ (int)*s ];
-
- if( Q_IsColorString( s ) )
- {
- memcpy( newColor, g_color_table[ ColorIndex( *( s + 1 ) ) ], sizeof( newColor ) );
- newColor[ 3 ] = color[ 3 ];
- trap_R_SetColor( newColor );
- s += 2;
- continue;
- }
- else
- {
- float yadj = useScale * glyph->top;
- if( style == ITEM_TEXTSTYLE_SHADOWED ||
- style == ITEM_TEXTSTYLE_SHADOWEDMORE )
- {
- int ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2;
- colorBlack[ 3 ] = newColor[ 3 ];
- trap_R_SetColor( colorBlack );
- CG_Text_PaintChar( x + ofs, y - yadj + ofs,
- glyph->imageWidth,
- glyph->imageHeight,
- useScale,
- glyph->s,
- glyph->t,
- glyph->s2,
- glyph->t2,
- glyph->glyph );
-
- colorBlack[ 3 ] = 1.0;
- trap_R_SetColor( newColor );
- }
- else if( style == ITEM_TEXTSTYLE_NEON )
- {
- vec4_t glow, outer, inner, white;
-
- glow[ 0 ] = newColor[ 0 ] * 0.5;
- glow[ 1 ] = newColor[ 1 ] * 0.5;
- glow[ 2 ] = newColor[ 2 ] * 0.5;
- glow[ 3 ] = newColor[ 3 ] * 0.2;
-
- outer[ 0 ] = newColor[ 0 ];
- outer[ 1 ] = newColor[ 1 ];
- outer[ 2 ] = newColor[ 2 ];
- outer[ 3 ] = newColor[ 3 ];
-
- inner[ 0 ] = newColor[ 0 ] * 1.5 > 1.0f ? 1.0f : newColor[ 0 ] * 1.5;
- inner[ 1 ] = newColor[ 1 ] * 1.5 > 1.0f ? 1.0f : newColor[ 1 ] * 1.5;
- inner[ 2 ] = newColor[ 2 ] * 1.5 > 1.0f ? 1.0f : newColor[ 2 ] * 1.5;
- inner[ 3 ] = newColor[ 3 ];
-
- white[ 0 ] = white[ 1 ] = white[ 2 ] = white[ 3 ] = 1.0f;
-
- trap_R_SetColor( glow );
- CG_Text_PaintChar( x - 3, y - yadj - 3,
- glyph->imageWidth + 6,
- glyph->imageHeight + 6,
- useScale,
- glyph->s,
- glyph->t,
- glyph->s2,
- glyph->t2,
- glyph->glyph );
-
- trap_R_SetColor( outer );
- CG_Text_PaintChar( x - 1, y - yadj - 1,
- glyph->imageWidth + 2,
- glyph->imageHeight + 2,
- useScale,
- glyph->s,
- glyph->t,
- glyph->s2,
- glyph->t2,
- glyph->glyph );
-
- trap_R_SetColor( inner );
- CG_Text_PaintChar( x - 0.5, y - yadj - 0.5,
- glyph->imageWidth + 1,
- glyph->imageHeight + 1,
- useScale,
- glyph->s,
- glyph->t,
- glyph->s2,
- glyph->t2,
- glyph->glyph );
-
- trap_R_SetColor( white );
- }
-
-
- CG_Text_PaintChar( x, y - yadj,
- glyph->imageWidth,
- glyph->imageHeight,
- useScale,
- glyph->s,
- glyph->t,
- glyph->s2,
- glyph->t2,
- glyph->glyph );
-
- x += ( glyph->xSkip * useScale ) + adjust;
- s++;
- count++;
- }
- }
-
- trap_R_SetColor( NULL );
- }
-}
-
/*
==============
CG_DrawFieldPadded
@@ -358,7 +105,7 @@ static void CG_DrawFieldPadded( int x, int y, int width, int cw, int ch, int val
charWidth = CHAR_WIDTH;
if( !( charHeight = ch ) )
- charWidth = CHAR_HEIGHT;
+ charHeight = CHAR_HEIGHT;
if( width < 1 )
return;
@@ -395,7 +142,7 @@ static void CG_DrawFieldPadded( int x, int y, int width, int cw, int ch, int val
orgL = l;
- x += 2;
+ x += ( 2.0f * cgDC.aspectScale );
ptr = num;
while( *ptr && l )
@@ -438,7 +185,7 @@ void CG_DrawField( float x, float y, int width, float cw, float ch, int value )
charWidth = CHAR_WIDTH;
if( !( charHeight = ch ) )
- charWidth = CHAR_HEIGHT;
+ charHeight = CHAR_HEIGHT;
if( width < 1 )
return;
@@ -473,7 +220,7 @@ void CG_DrawField( float x, float y, int width, float cw, float ch, int value )
if( l > width )
l = width;
- x += 2 + charWidth * ( width - l );
+ x += ( 2.0f * cgDC.aspectScale ) + charWidth * ( width - l );
ptr = num;
while( *ptr && l )
@@ -516,7 +263,7 @@ static void CG_DrawProgressBar( rectDef_t *rect, vec4_t color, float scale,
trap_R_SetColor( color );
//draw rim and bar
- if( align == ITEM_ALIGN_RIGHT )
+ if( align == ALIGN_RIGHT )
{
CG_DrawPic( rect->x, rect->y, rimWidth, rect->h, cgs.media.whiteShader );
CG_DrawPic( rect->x + rimWidth, rect->y,
@@ -542,9 +289,9 @@ static void CG_DrawProgressBar( rectDef_t *rect, vec4_t color, float scale,
if( scale > 0.0 )
{
Com_sprintf( textBuffer, sizeof( textBuffer ), "%d%%", (int)( progress * 100 ) );
- CG_AlignText( rect, textBuffer, scale, 0.0f, 0.0f, textalign, ITEM_VALIGN_CENTER, &tx, &ty );
+ CG_AlignText( rect, textBuffer, scale, 0.0f, 0.0f, textalign, VALIGN_CENTER, &tx, &ty );
- CG_Text_Paint( tx, ty, scale, color, textBuffer, 0, 0, textStyle );
+ UI_Text_Paint( tx, ty, scale, color, textBuffer, 0, 0, textStyle );
}
}
@@ -1172,10 +919,10 @@ static void CG_DrawProgressLabel( rectDef_t *rect, float text_x, float text_y, v
CG_AlignText( rect, s, scale, 0.0f, 0.0f, textalign, textvalign, &tx, &ty );
if( fraction < 1.0f )
- CG_Text_Paint( text_x + tx, text_y + ty, scale, white,
+ UI_Text_Paint( text_x + tx, text_y + ty, scale, white,
s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
else
- CG_Text_Paint( text_x + tx, text_y + ty, scale, color,
+ UI_Text_Paint( text_x + tx, text_y + ty, scale, color,
s, 0, 0, ITEM_TEXTSTYLE_NEON );
}
@@ -1392,82 +1139,12 @@ static void CG_DrawKiller( rectDef_t *rect, float scale, vec4_t color,
if( cg.killerName[ 0 ] )
{
int x = rect->x + rect->w / 2;
- CG_Text_Paint( x - CG_Text_Width( CG_GetKillerText( ), scale, 0 ) / 2,
+ UI_Text_Paint( x - UI_Text_Width( CG_GetKillerText( ), scale, 0 ) / 2,
rect->y + rect->h, scale, color, CG_GetKillerText( ), 0, 0, textStyle );
}
}
-static void CG_Text_Paint_Limit( float *maxX, float x, float y, float scale,
- vec4_t color, const char* text, float adjust, int limit )
-{
- int len, count;
- vec4_t newColor;
- glyphInfo_t *glyph;
-
- if( text )
- {
- const char *s = text;
- float max = *maxX;
- float useScale;
- fontInfo_t *font = &cgDC.Assets.textFont;
-
- if( scale <= cg_smallFont.value )
- font = &cgDC.Assets.smallFont;
- else if( scale > cg_bigFont.value )
- font = &cgDC.Assets.bigFont;
-
- useScale = scale * font->glyphScale;
- trap_R_SetColor( color );
- len = strlen( text );
-
- if( limit > 0 && len > limit )
- len = limit;
-
- count = 0;
-
- while( s && *s && count < len )
- {
- glyph = &font->glyphs[ (int)*s ];
-
- if( Q_IsColorString( s ) )
- {
- memcpy( newColor, g_color_table[ ColorIndex( *(s+1) ) ], sizeof( newColor ) );
- newColor[ 3 ] = color[ 3 ];
- trap_R_SetColor( newColor );
- s += 2;
- continue;
- }
- else
- {
- float yadj = useScale * glyph->top;
-
- if( CG_Text_Width( s, useScale, 1 ) + x > max )
- {
- *maxX = 0;
- break;
- }
-
- CG_Text_PaintChar( x, y - yadj,
- glyph->imageWidth,
- glyph->imageHeight,
- useScale,
- glyph->s,
- glyph->t,
- glyph->s2,
- glyph->t2,
- glyph->glyph );
- x += ( glyph->xSkip * useScale ) + adjust;
- *maxX = x;
- count++;
- s++;
- }
- }
-
- trap_R_SetColor( NULL );
- }
-}
-
static void CG_DrawTeamSpectators( rectDef_t *rect, float scale, int textvalign, vec4_t color, qhandle_t shader )
{
float y;
@@ -1503,7 +1180,7 @@ static void CG_DrawTeamSpectators( rectDef_t *rect, float scale, int textvalign,
cg.spectatorOffset += 2;
else
{
- cg.spectatorPaintX += CG_Text_Width( &cg.spectatorList[ cg.spectatorOffset ], scale, 1 ) - 1;
+ cg.spectatorPaintX += UI_Text_Width( &cg.spectatorList[ cg.spectatorOffset ], scale, 1 ) - 1;
cg.spectatorOffset++;
}
}
@@ -1529,16 +1206,16 @@ static void CG_DrawTeamSpectators( rectDef_t *rect, float scale, int textvalign,
}
maxX = rect->x + rect->w - 2;
- CG_AlignText( rect, NULL, 0.0f, 0.0f, CG_Text_EmHeight( scale ),
- ITEM_ALIGN_LEFT, textvalign, NULL, &y );
+ CG_AlignText( rect, NULL, 0.0f, 0.0f, UI_Text_EmHeight( scale ),
+ ALIGN_LEFT, textvalign, NULL, &y );
- CG_Text_Paint_Limit( &maxX, cg.spectatorPaintX, y, scale, color,
+ UI_Text_Paint_Limit( &maxX, cg.spectatorPaintX, y, scale, color,
&cg.spectatorList[ cg.spectatorOffset ], 0, 0 );
if( cg.spectatorPaintX2 >= 0 )
{
float maxX2 = rect->x + rect->w - 2;
- CG_Text_Paint_Limit( &maxX2, cg.spectatorPaintX2, y, scale,
+ UI_Text_Paint_Limit( &maxX2, cg.spectatorPaintX2, y, scale,
color, cg.spectatorList, 0, cg.spectatorOffset );
}
@@ -1590,17 +1267,17 @@ static void CG_DrawTeamLabel( rectDef_t *rect, pTeam_t team, float text_x, float
switch( textalign )
{
default:
- case ITEM_ALIGN_LEFT:
+ case ALIGN_LEFT:
s = va( "%s %s", t, stage );
break;
- case ITEM_ALIGN_RIGHT:
+ case ALIGN_RIGHT:
s = va( "%s %s", stage, t );
break;
}
CG_AlignText( rect, s, scale, 0.0f, 0.0f, textalign, textvalign, &tx, &ty );
- CG_Text_Paint( text_x + tx, text_y + ty, scale, color, s, 0, 0, textStyle );
+ UI_Text_Paint( text_x + tx, text_y + ty, scale, color, s, 0, 0, textStyle );
}
/*
@@ -1650,7 +1327,7 @@ static void CG_DrawStageReport( rectDef_t *rect, float text_x, float text_y,
CG_AlignText( rect, s, scale, 0.0f, 0.0f, textalign, textvalign, &tx, &ty );
- CG_Text_Paint( text_x + tx, text_y + ty, scale, color, s, 0, 0, textStyle );
+ UI_Text_Paint( text_x + tx, text_y + ty, scale, color, s, 0, 0, textStyle );
}
/*
@@ -1702,10 +1379,10 @@ static void CG_DrawFPS( rectDef_t *rect, float text_x, float text_y,
fps = 1000 * FPS_FRAMES / total;
s = va( "%d", fps );
- w = CG_Text_Width( "0", scale, 0 );
- h = CG_Text_Height( "0", scale, 0 );
+ w = UI_Text_Width( "0", scale, 0 );
+ h = UI_Text_Height( "0", scale, 0 );
strLength = CG_DrawStrlen( s );
- totalWidth = CG_Text_Width( FPS_STRING, scale, 0 ) + w * strLength;
+ totalWidth = UI_Text_Width( FPS_STRING, scale, 0 ) + w * strLength;
CG_AlignText( rect, s, 0.0f, totalWidth, h, textalign, textvalign, &tx, &ty );
@@ -1718,10 +1395,10 @@ static void CG_DrawFPS( rectDef_t *rect, float text_x, float text_y,
c[ 0 ] = s[ i ];
c[ 1 ] = '\0';
- CG_Text_Paint( text_x + tx + i * w, text_y + ty, scale, color, c, 0, 0, textStyle );
+ UI_Text_Paint( text_x + tx + i * w, text_y + ty, scale, color, c, 0, 0, textStyle );
}
- CG_Text_Paint( text_x + tx + i * w, text_y + ty, scale, color, FPS_STRING, 0, 0, textStyle );
+ UI_Text_Paint( text_x + tx + i * w, text_y + ty, scale, color, FPS_STRING, 0, 0, textStyle );
}
else
{
@@ -1811,8 +1488,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 = CG_Text_Width( "0", scale, 0 );
- h = CG_Text_Height( "0", scale, 0 );
+ w = UI_Text_Width( "0", scale, 0 );
+ h = UI_Text_Height( "0", scale, 0 );
strLength = CG_DrawStrlen( s );
totalWidth = w * strLength;
@@ -1825,7 +1502,7 @@ static void CG_DrawTimer( rectDef_t *rect, float text_x, float text_y,
c[ 0 ] = s[ i ];
c[ 1 ] = '\0';
- CG_Text_Paint( text_x + tx + i * w, text_y + ty, scale, color, c, 0, 0, textStyle );
+ UI_Text_Paint( text_x + tx + i * w, text_y + ty, scale, color, c, 0, 0, textStyle );
}
}
@@ -1872,8 +1549,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 = CG_Text_Width( "0", scale, 0 );
- h = CG_Text_Height( "0", scale, 0 );
+ w = UI_Text_Width( "0", scale, 0 );
+ h = UI_Text_Height( "0", scale, 0 );
strLength = CG_DrawStrlen( s );
totalWidth = w * strLength;
@@ -1886,7 +1563,7 @@ static void CG_DrawClock( rectDef_t *rect, float text_x, float text_y,
c[ 0 ] = s[ i ];
c[ 1 ] = '\0';
- CG_Text_Paint( text_x + tx + i * w, text_y + ty, scale, color, c, 0, 0, textStyle );
+ UI_Text_Paint( text_x + tx + i * w, text_y + ty, scale, color, c, 0, 0, textStyle );
}
}
@@ -1910,7 +1587,7 @@ static void CG_DrawSnapshot( rectDef_t *rect, float text_x, float text_y,
CG_AlignText( rect, s, scale, 0.0f, 0.0f, textalign, textvalign, &tx, &ty );
- CG_Text_Paint( text_x + tx, text_y + ty, scale, color, s, 0, 0, textStyle );
+ UI_Text_Paint( text_x + tx, text_y + ty, scale, color, s, 0, 0, textStyle );
}
/*
@@ -2021,8 +1698,8 @@ static void CG_DrawDisconnect( void )
// also add text in center of screen
s = "Connection Interrupted";
- w = CG_Text_Width( s, 0.7f, 0 );
- CG_Text_Paint( 320 - w / 2, 100, 0.7f, color, s, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
+ w = UI_Text_Width( s, 0.7f, 0 );
+ UI_Text_Paint( 320 - w / 2, 100, 0.7f, color, s, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
// blink the icon
if( ( cg.time >> 9 ) & 1 )
@@ -2175,18 +1852,18 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y,
trap_R_SetColor( NULL );
if( cg_nopredict.integer || cg_synchronousClients.integer )
- CG_Text_Paint( ax, ay, 0.5, white, "snc", 0, 0, ITEM_TEXTSTYLE_NORMAL );
+ UI_Text_Paint( ax, ay, 0.5, white, "snc", 0, 0, ITEM_TEXTSTYLE_NORMAL );
else
{
char *s;
s = va( "%d", cg.ping );
- ax = rect->x + ( rect->w / 2.0f ) - ( CG_Text_Width( s, scale, 0 ) / 2.0f ) + text_x;
- ay = rect->y + ( rect->h / 2.0f ) + ( CG_Text_Height( s, scale, 0 ) / 2.0f ) + text_y;
+ ax = rect->x + ( rect->w / 2.0f ) - ( UI_Text_Width( s, scale, 0 ) / 2.0f ) + text_x;
+ ay = rect->y + ( rect->h / 2.0f ) + ( UI_Text_Height( s, scale, 0 ) / 2.0f ) + text_y;
Vector4Copy( textColor, adjustedColor );
adjustedColor[ 3 ] = 0.5f;
- CG_Text_Paint( ax, ay, scale, adjustedColor, s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
+ UI_Text_Paint( ax, ay, scale, adjustedColor, s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
}
CG_DrawDisconnect( );
@@ -2311,6 +1988,8 @@ static void CG_DrawCrosshair( void )
w = h = wi->crossHairSize;
+ w *= cgDC.aspectScale;
+
x = cg_crosshairX.integer;
y = cg_crosshairY.integer;
CG_AdjustFrom640( &x, &y, &w, &h );
@@ -2397,9 +2076,9 @@ static void CG_DrawCrosshairNames( rectDef_t *rect, float scale, int textStyle )
}
name = cgs.clientinfo[ cg.crosshairClientNum ].name;
- w = CG_Text_Width( name, scale, 0 );
+ w = UI_Text_Width( name, scale, 0 );
x = rect->x + rect->w / 2;
- CG_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
+ UI_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
trap_R_SetColor( NULL );
}
@@ -2842,10 +2521,10 @@ static void CG_DrawCenterString( void )
linebuffer[ l ] = 0;
- w = CG_Text_Width( linebuffer, 0.5, 0 );
- h = CG_Text_Height( linebuffer, 0.5, 0 );
+ w = UI_Text_Width( linebuffer, 0.5, 0 );
+ h = UI_Text_Height( linebuffer, 0.5, 0 );
x = ( SCREEN_WIDTH - w ) / 2;
- CG_Text_Paint( x, y + h, 0.5, color, linebuffer, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE );
+ UI_Text_Paint( x, y + h, 0.5, color, linebuffer, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE );
y += h + 6;
while( *start && ( *start != '\n' ) )
@@ -2898,7 +2577,7 @@ static void CG_DrawVote( void )
Q_strncpyz( nokey, CG_KeyBinding( "vote no" ), sizeof( nokey ) );
s = va( "VOTE(%i): \"%s\" [%s]Yes:%i [%s]No:%i", sec, cgs.voteString,
yeskey, cgs.voteYes, nokey, cgs.voteNo );
- CG_Text_Paint( 8, 340, 0.3f, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
+ UI_Text_Paint( 8, 340, 0.3f, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
}
/*
@@ -2942,7 +2621,7 @@ static void CG_DrawTeamVote( void )
yeskey, cgs.teamVoteYes[cs_offset],
nokey, cgs.teamVoteNo[ cs_offset ] );
- CG_Text_Paint( 8, 360, 0.3f, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
+ UI_Text_Paint( 8, 360, 0.3f, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
}
@@ -3031,8 +2710,8 @@ static qboolean CG_DrawFollow( void )
strcpy( buffer, FOLLOWING_STRING );
strcat( buffer, cgs.clientinfo[ cg.snap->ps.clientNum ].name );
- w = CG_Text_Width( buffer, 0.7f, 0 );
- CG_Text_Paint( 320 - w / 2, 400, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
+ w = UI_Text_Width( buffer, 0.7f, 0 );
+ UI_Text_Paint( 320 - w / 2, 400, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
return qtrue;
}
@@ -3059,8 +2738,8 @@ static qboolean CG_DrawQueue( void )
Com_sprintf( buffer, MAX_STRING_CHARS, "You are in position %d of the spawn queue.",
cg.snap->ps.persistant[ PERS_QUEUEPOS ] + 1 );
- w = CG_Text_Width( buffer, 0.7f, 0 );
- CG_Text_Paint( 320 - w / 2, 360, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
+ w = UI_Text_Width( buffer, 0.7f, 0 );
+ UI_Text_Paint( 320 - w / 2, 360, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
if( cg.snap->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
{
@@ -3079,8 +2758,8 @@ static qboolean CG_DrawQueue( void )
cgs.numHumanSpawns );
}
- w = CG_Text_Width( buffer, 0.7f, 0 );
- CG_Text_Paint( 320 - w / 2, 400, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
+ w = UI_Text_Width( buffer, 0.7f, 0 );
+ UI_Text_Paint( 320 - w / 2, 400, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
return qtrue;
}
@@ -3121,8 +2800,8 @@ static void CG_Draw2D( void )
if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR )
{
- w = CG_Text_Width( SPECTATOR_STRING, 0.7f, 0 );
- CG_Text_Paint( 320 - w / 2, 440, 0.7f, color, SPECTATOR_STRING, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
+ w = UI_Text_Width( SPECTATOR_STRING, 0.7f, 0 );
+ UI_Text_Paint( 320 - w / 2, 440, 0.7f, color, SPECTATOR_STRING, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
}
else
menu = Menus_FindByName( BG_FindHudNameForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] ) );
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 012a29ed..f70afc85 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1375,6 +1375,7 @@ typedef struct
extern cgs_t cgs;
extern cg_t cg;
extern centity_t cg_entities[ MAX_GENTITIES ];
+extern displayContextDef_t cgDC;
extern weaponInfo_t cg_weapons[ 32 ];
extern upgradeInfo_t cg_upgrades[ 32 ];
@@ -1589,11 +1590,6 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x,
int align, int textalign, int textvalign, float special,
float scale, vec4_t color,
qhandle_t shader, int textStyle );
-void CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style );
-float CG_Text_Width( const char *text, float scale, int limit );
-float CG_Text_Height( const char *text, float scale, int limit );
-float CG_Text_EmWidth( float scale );
-float CG_Text_EmHeight( float scale );
float CG_GetValue(int ownerDraw);
void CG_RunMenuScript(char **args);
void CG_SetPrintString( int type, const char *p );
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 618762e3..b3452371 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -1594,7 +1594,7 @@ static float CG_Cvar_Get( const char *cvar )
void CG_Text_PaintWithCursor( float x, float y, float scale, vec4_t color, const char *text,
int cursorPos, char cursor, int limit, int style )
{
- CG_Text_Paint( x, y, scale, color, text, 0, limit, style );
+ UI_Text_Paint( x, y, scale, color, text, 0, limit, style );
}
static int CG_OwnerDrawWidth( int ownerDraw, float scale )
@@ -1602,7 +1602,7 @@ static int CG_OwnerDrawWidth( int ownerDraw, float scale )
switch( ownerDraw )
{
case CG_KILLER:
- return CG_Text_Width( CG_GetKillerText( ), scale, 0 );
+ return UI_Text_Width( CG_GetKillerText( ), scale, 0 );
break;
}
@@ -1646,15 +1646,15 @@ void CG_LoadHudMenu( void )
char buff[ 1024 ];
const char *hudSet;
+ cgDC.aspectScale = ( ( 640.0f * cgs.glconfig.vidHeight ) /
+ ( 480.0f * cgs.glconfig.vidWidth ) );
+ cgDC.xscale = cgs.glconfig.vidWidth / 640.0f;
+ cgDC.yscale = cgs.glconfig.vidHeight / 480.0f;
+
cgDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip;
cgDC.setColor = &trap_R_SetColor;
cgDC.drawHandlePic = &CG_DrawPic;
cgDC.drawStretchPic = &trap_R_DrawStretchPic;
- cgDC.drawText = &CG_Text_Paint;
- cgDC.textWidth = &CG_Text_Width;
- cgDC.textHeight = &CG_Text_Height;
- cgDC.textEmWidth = &CG_Text_EmWidth;
- cgDC.textEmHeight = &CG_Text_EmHeight;
cgDC.registerModel = &trap_R_RegisterModel;
cgDC.modelBounds = &trap_R_ModelBounds;
cgDC.fillRect = &CG_FillRect;
@@ -1673,7 +1673,6 @@ void CG_LoadHudMenu( void )
cgDC.setCVar = trap_Cvar_Set;
cgDC.getCVarString = trap_Cvar_VariableStringBuffer;
cgDC.getCVarValue = CG_Cvar_Get;
- cgDC.drawTextWithCursor = &CG_Text_PaintWithCursor;
cgDC.setOverstrikeMode = &trap_Key_SetOverstrikeMode;
cgDC.getOverstrikeMode = &trap_Key_GetOverstrikeMode;
cgDC.startLocalSound = &trap_S_StartLocalSound;
@@ -1748,6 +1747,11 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum )
cgs.processedSnapshotNum = serverMessageNum;
cgs.serverCommandSequence = serverCommandSequence;
+ // get the rendering configuration from the client system
+ trap_GetGlconfig( &cgs.glconfig );
+ cgs.screenXScale = cgs.glconfig.vidWidth / 640.0f;
+ cgs.screenYScale = cgs.glconfig.vidHeight / 480.0f;
+
// load a few needed things before we do any screen updates
cgs.media.whiteShader = trap_R_RegisterShader( "white" );
cgs.media.charsetShader = trap_R_RegisterShader( "gfx/2d/bigchars" );
@@ -1775,11 +1779,6 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum )
// old servers
- // get the rendering configuration from the client system
- trap_GetGlconfig( &cgs.glconfig );
- cgs.screenXScale = cgs.glconfig.vidWidth / 640.0;
- cgs.screenYScale = cgs.glconfig.vidHeight / 480.0;
-
// get the gamestate from the client system
trap_GetGameState( &cgs.gameState );
diff --git a/src/cgame/cg_scanner.c b/src/cgame/cg_scanner.c
index f9175ede..067ca7fb 100644
--- a/src/cgame/cg_scanner.c
+++ b/src/cgame/cg_scanner.c
@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "cg_local.h"
-static entityPos_t entityPositions;
+static entityPos_t entityPositions;
#define HUMAN_SCANNER_UPDATE_PERIOD 700
@@ -104,8 +104,8 @@ void CG_UpdateEntityPositions( void )
}
}
-#define STALKWIDTH 2.0f
-#define BLIPX 16.0f
+#define STALKWIDTH (2.0f * cgDC.aspectScale)
+#define BLIPX (16.0f * cgDC.aspectScale)
#define BLIPY 8.0f
#define FAR_ALPHA 0.8f
#define NEAR_ALPHA 1.2f
@@ -162,7 +162,7 @@ static void CG_DrawBlips( rectDef_t *rect, vec3_t origin, vec4_t colour )
trap_R_SetColor( NULL );
}
-#define BLIPX2 24.0f
+#define BLIPX2 (24.0f * cgDC.aspectScale)
#define BLIPY2 24.0f
/*
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index 613cddb2..fc8dc058 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -1140,11 +1140,12 @@ CG_DrawItemSelect
void CG_DrawItemSelect( rectDef_t *rect, vec4_t color )
{
int i;
- int x = rect->x;
- int y = rect->y;
- int width = rect->w;
- int height = rect->h;
- int iconsize;
+ float x = rect->x;
+ float y = rect->y;
+ float width = rect->w;
+ float height = rect->h;
+ float iconWidth;
+ float iconHeight;
int items[ 64 ];
int numItems = 0, selectedItem = 0;
int length;
@@ -1177,14 +1178,16 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color )
if( height > width )
{
vertical = qtrue;
- iconsize = width;
- length = height / width;
+ iconWidth = width * cgDC.aspectScale;
+ iconHeight = width;
+ length = height / ( width * cgDC.aspectScale );
}
else if( height <= width )
{
vertical = qfalse;
- iconsize = height;
- length = width / height;
+ iconWidth = height * cgDC.aspectScale;
+ iconHeight = height;
+ length = width / ( height * cgDC.aspectScale );
}
selectWindow = length / 2;
@@ -1248,17 +1251,17 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color )
trap_R_SetColor( color );
if( items[ item ] <= 32 )
- CG_DrawPic( x, y, iconsize, iconsize, cg_weapons[ items[ item ] ].weaponIcon );
+ CG_DrawPic( x, y, iconWidth, iconHeight, cg_weapons[ items[ item ] ].weaponIcon );
else if( items[ item ] > 32 )
- CG_DrawPic( x, y, iconsize, iconsize, cg_upgrades[ items[ item ] - 32 ].upgradeIcon );
+ CG_DrawPic( x, y, iconWidth, iconHeight, cg_upgrades[ items[ item ] - 32 ].upgradeIcon );
trap_R_SetColor( NULL );
}
if( vertical )
- y += iconsize;
+ y += iconHeight;
else
- x += iconsize;
+ x += iconWidth;
}
}
@@ -1288,9 +1291,9 @@ void CG_DrawItemSelectText( rectDef_t *rect, float scale, int textStyle )
{
if( ( name = cg_weapons[ cg.weaponSelect ].humanName ) )
{
- w = CG_Text_Width( name, scale, 0 );
+ w = UI_Text_Width( name, scale, 0 );
x = rect->x + rect->w / 2;
- CG_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
+ UI_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
}
}
}
@@ -1301,9 +1304,9 @@ void CG_DrawItemSelectText( rectDef_t *rect, float scale, int textStyle )
{
if( ( name = cg_upgrades[ cg.weaponSelect - 32 ].humanName ) )
{
- w = CG_Text_Width( name, scale, 0 );
+ w = UI_Text_Width( name, scale, 0 );
x = rect->x + rect->w / 2;
- CG_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
+ UI_Text_Paint( x - w / 2, rect->y + rect->h, scale, color, name, 0, 0, textStyle );
}
}
}