diff options
author | Tim Angus <tim@ngus.net> | 2002-01-19 01:47:04 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2002-01-19 01:47:04 +0000 |
commit | d7f74fc7757a223eb740705d23a17e454b3726da (patch) | |
tree | 382ea6fefdf9506fa78f963491b8418d10fcfaca | |
parent | 88f875b5c2ce0eff085084535c6fa23f2b30470c (diff) |
TA Hud stuff mostly integrated
-rw-r--r-- | depend | 54 | ||||
-rw-r--r-- | src/cgame/cg_draw.c | 2324 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 12 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 670 | ||||
-rw-r--r-- | ui/menudef.h | 39 |
5 files changed, 1775 insertions, 1324 deletions
@@ -243,7 +243,10 @@ releasei386-glibc/cgame/cg_creep.o: ./src/cgame/cg_creep.c src/cgame/cg_local.h releasei386-glibc/cgame/cg_draw.o: ./src/cgame/cg_draw.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ - src/cgame/cg_public.h + src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \ + src/cgame/../ui/../game/q_shared.h \ + src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \ + src/cgame/../ui/../../ui/menudef.h releasei386-glibc/cgame/cg_drawtools.o: ./src/cgame/cg_drawtools.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ @@ -271,7 +274,10 @@ releasei386-glibc/cgame/cg_localents.o: ./src/cgame/cg_localents.c src/cgame/cg_ releasei386-glibc/cgame/cg_main.o: ./src/cgame/cg_main.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ - src/cgame/cg_public.h + src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \ + src/cgame/../ui/../game/q_shared.h \ + src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \ + src/cgame/../ui/../../ui/menudef.h releasei386-glibc/cgame/cg_marks.o: ./src/cgame/cg_marks.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ @@ -284,6 +290,13 @@ releasei386-glibc/cgame/cg_mp3decoder.o: ./src/cgame/cg_mp3decoder.c src/cgame/c src/cgame/cg_local.h src/cgame/../game/q_shared.h \ src/cgame/../game/surfaceflags.h src/cgame/tr_types.h \ src/cgame/../game/bg_public.h src/cgame/cg_public.h +releasei386-glibc/cgame/cg_newdraw.o: ./src/cgame/cg_newdraw.c src/cgame/cg_local.h \ + src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ + src/cgame/tr_types.h src/cgame/../game/bg_public.h \ + src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \ + src/cgame/../ui/../game/q_shared.h \ + src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \ + src/cgame/../ui/../../ui/menudef.h releasei386-glibc/cgame/cg_particles.o: ./src/cgame/cg_particles.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ @@ -351,7 +364,10 @@ debugi386-glibc/cgame/cg_creep.o: ./src/cgame/cg_creep.c src/cgame/cg_local.h \ debugi386-glibc/cgame/cg_draw.o: ./src/cgame/cg_draw.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ - src/cgame/cg_public.h + src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \ + src/cgame/../ui/../game/q_shared.h \ + src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \ + src/cgame/../ui/../../ui/menudef.h debugi386-glibc/cgame/cg_drawtools.o: ./src/cgame/cg_drawtools.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ @@ -379,7 +395,10 @@ debugi386-glibc/cgame/cg_localents.o: ./src/cgame/cg_localents.c src/cgame/cg_lo debugi386-glibc/cgame/cg_main.o: ./src/cgame/cg_main.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ - src/cgame/cg_public.h + src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \ + src/cgame/../ui/../game/q_shared.h \ + src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \ + src/cgame/../ui/../../ui/menudef.h debugi386-glibc/cgame/cg_marks.o: ./src/cgame/cg_marks.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ @@ -392,6 +411,13 @@ debugi386-glibc/cgame/cg_mp3decoder.o: ./src/cgame/cg_mp3decoder.c src/cgame/cg_ src/cgame/cg_local.h src/cgame/../game/q_shared.h \ src/cgame/../game/surfaceflags.h src/cgame/tr_types.h \ src/cgame/../game/bg_public.h src/cgame/cg_public.h +debugi386-glibc/cgame/cg_newdraw.o: ./src/cgame/cg_newdraw.c src/cgame/cg_local.h \ + src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ + src/cgame/tr_types.h src/cgame/../game/bg_public.h \ + src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \ + src/cgame/../ui/../game/q_shared.h \ + src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \ + src/cgame/../ui/../../ui/menudef.h debugi386-glibc/cgame/cg_particles.o: ./src/cgame/cg_particles.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ @@ -459,7 +485,10 @@ qvm/cgame/cg_creep.asm: ./src/cgame/cg_creep.c src/cgame/cg_local.h \ qvm/cgame/cg_draw.asm: ./src/cgame/cg_draw.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ - src/cgame/cg_public.h + src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \ + src/cgame/../ui/../game/q_shared.h \ + src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \ + src/cgame/../ui/../../ui/menudef.h qvm/cgame/cg_drawtools.asm: ./src/cgame/cg_drawtools.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ @@ -487,7 +516,10 @@ qvm/cgame/cg_localents.asm: ./src/cgame/cg_localents.c src/cgame/cg_local.h \ qvm/cgame/cg_main.asm: ./src/cgame/cg_main.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ - src/cgame/cg_public.h + src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \ + src/cgame/../ui/../game/q_shared.h \ + src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \ + src/cgame/../ui/../../ui/menudef.h qvm/cgame/cg_marks.asm: ./src/cgame/cg_marks.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ @@ -500,6 +532,13 @@ qvm/cgame/cg_mp3decoder.asm: ./src/cgame/cg_mp3decoder.c src/cgame/cg_mp3decoder src/cgame/cg_local.h src/cgame/../game/q_shared.h \ src/cgame/../game/surfaceflags.h src/cgame/tr_types.h \ src/cgame/../game/bg_public.h src/cgame/cg_public.h +qvm/cgame/cg_newdraw.asm: ./src/cgame/cg_newdraw.c src/cgame/cg_local.h \ + src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ + src/cgame/tr_types.h src/cgame/../game/bg_public.h \ + src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \ + src/cgame/../ui/../game/q_shared.h \ + src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \ + src/cgame/../ui/../../ui/menudef.h qvm/cgame/cg_particles.asm: ./src/cgame/cg_particles.c src/cgame/cg_local.h \ src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \ src/cgame/tr_types.h src/cgame/../game/bg_public.h \ @@ -577,7 +616,6 @@ releasei386-glibc/ui/ui_syscalls.o: ./src/ui/ui_syscalls.c src/ui/ui_local.h \ src/ui/../cgame/tr_types.h src/ui/ui_public.h src/ui/keycodes.h \ src/ui/../game/bg_public.h src/ui/ui_shared.h \ src/ui/../../ui/menudef.h -releasei386-glibc/ui/ui_util.o: ./src/ui/ui_util.c debugi386-glibc/ui/ui_atoms.o: ./src/ui/ui_atoms.c src/ui/ui_local.h \ src/ui/../game/q_shared.h src/ui/../game/surfaceflags.h \ src/ui/../cgame/tr_types.h src/ui/ui_public.h src/ui/keycodes.h \ @@ -607,7 +645,6 @@ debugi386-glibc/ui/ui_syscalls.o: ./src/ui/ui_syscalls.c src/ui/ui_local.h \ src/ui/../cgame/tr_types.h src/ui/ui_public.h src/ui/keycodes.h \ src/ui/../game/bg_public.h src/ui/ui_shared.h \ src/ui/../../ui/menudef.h -debugi386-glibc/ui/ui_util.o: ./src/ui/ui_util.c qvm/ui/ui_atoms.asm: ./src/ui/ui_atoms.c src/ui/ui_local.h \ src/ui/../game/q_shared.h src/ui/../game/surfaceflags.h \ src/ui/../cgame/tr_types.h src/ui/ui_public.h src/ui/keycodes.h \ @@ -637,4 +674,3 @@ qvm/ui/ui_syscalls.asm: ./src/ui/ui_syscalls.c src/ui/ui_local.h \ src/ui/../cgame/tr_types.h src/ui/ui_public.h src/ui/keycodes.h \ src/ui/../game/bg_public.h src/ui/ui_shared.h \ src/ui/../../ui/menudef.h -qvm/ui/ui_util.asm: ./src/ui/ui_util.c diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 069ea844..ec92e4cc 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -18,7 +18,14 @@ #include "cg_local.h" +#include "../ui/ui_shared.h" + +// used for scoreboard +extern displayContextDef_t cgDC; +menuDef_t *menuScoreboard = NULL; + int drawTeamOverlayModificationCount = -1; + int sortedTeamPlayers[TEAM_MAXOVERLAY]; int numSortedTeamPlayers; @@ -26,295 +33,728 @@ char systemChat[256]; char teamChat1[256]; char teamChat2[256]; -/* -============== -CG_DrawField - -Draws large numbers for status bar and powerups -============== -*/ -static void CG_DrawField (int x, int y, int width, int value) { - char num[16], *ptr; - int l; - int frame; - - if ( width < 1 ) { - return; +//TA UI +int CG_Text_Width( const char *text, float scale, int limit ) +{ + int count,len; + float out; + glyphInfo_t *glyph; + float useScale; +// FIXME: see ui_main.c, same problem +// const unsigned char *s = text; + 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 ]; + //TTimo: FIXME: getting nasty warnings without the cast, + //hopefully this doesn't break the VM build + out += glyph->xSkip; + s++; + count++; + } + } } + + return out * useScale; +} - // draw number string - if ( width > 5 ) { - width = 5; +int CG_Text_Height( const char *text, float scale, int limit ) +{ + int len, count; + float max; + glyphInfo_t *glyph; + float useScale; +// TTimo: FIXME +// const unsigned char *s = text; + 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 ]; + //TTimo: FIXME: getting nasty warnings without the cast, + //hopefully this doesn't break the VM build + if( max < glyph->height ) + max = glyph->height; + + s++; + count++; + } + } } + + return max * useScale; +} + +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 ); +} - switch ( width ) { - case 1: - value = value > 9 ? 9 : value; - value = value < 0 ? 0 : value; - break; - case 2: - value = value > 99 ? 99 : value; - value = value < -9 ? -9 : value; - break; - case 3: - value = value > 999 ? 999 : value; - value = value < -99 ? -99 : value; - break; - case 4: - value = value > 9999 ? 9999 : value; - value = value < -999 ? -999 : value; - break; +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 ) + { +// TTimo: FIXME +// const unsigned char *s = 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 ]; + //TTimo: FIXME: getting nasty warnings without the cast, + //hopefully this doesn't break the VM build + + 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 ); + } + + 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 ); } +} - Com_sprintf (num, sizeof(num), "%i", value); - l = strlen(num); - if (l > width) - l = width; - x += 2 + CHAR_WIDTH*(width - l); +//=============== TA: was cg_newdraw.c - ptr = num; - while (*ptr && l) - { - if (*ptr == '-') - frame = STAT_MINUS; - else - frame = *ptr -'0'; +void CG_InitTeamChat( ) +{ + memset( teamChat1, 0, sizeof( teamChat1 ) ); + memset( teamChat2, 0, sizeof( teamChat2 ) ); + memset( systemChat, 0, sizeof( systemChat ) ); +} - CG_DrawPic( x,y, CHAR_WIDTH, CHAR_HEIGHT, cgs.media.numberShaders[frame] ); - x += CHAR_WIDTH; - ptr++; - l--; +void CG_SetPrintString( int type, const char *p ) +{ + if( type == SYSTEM_PRINT ) + { + strcpy( systemChat, p ); + } + else + { + strcpy( teamChat2, teamChat1 ); + strcpy( teamChat1, p ); } } +static void CG_DrawPlayerAmmoValue( rectDef_t *rect, float scale, vec4_t color, + qhandle_t shader, int textStyle ) +{ + char num[ 16 ]; + int value; + centity_t *cent; + playerState_t *ps; -/* -================ -CG_Draw3DModel - -================ -*/ -void CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model, qhandle_t skin, vec3_t origin, vec3_t angles ) { - refdef_t refdef; - refEntity_t ent; + cent = &cg_entities[ cg.snap->ps.clientNum ]; + ps = &cg.snap->ps; - if ( !cg_draw3dIcons.integer || !cg_drawIcons.integer ) { - return; + if( cent->currentState.weapon ) + { + BG_unpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, &value, NULL, NULL ); + if( value > -1 ) + { + if( shader ) + { + trap_R_SetColor( color ); + CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); + trap_R_SetColor( NULL ); + } + else + { + Com_sprintf( num, sizeof( num ), "%d", value ); + value = CG_Text_Width( num, scale, 0 ); + CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, + scale, color, num, 0, 0, textStyle ); + } + } } +} - CG_AdjustFrom640( &x, &y, &w, &h ); +static void CG_DrawPlayerClipsValue( rectDef_t *rect, float scale, vec4_t color, + qhandle_t shader, int textStyle ) +{ + char num[ 16 ]; + int value; + centity_t *cent; + playerState_t *ps; + + cent = &cg_entities[ cg.snap->ps.clientNum ]; + ps = &cg.snap->ps; - memset( &refdef, 0, sizeof( refdef ) ); + if( cent->currentState.weapon ) + { + BG_unpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, NULL, &value, NULL ); + if( value > -1 ) + { + if( shader ) + { + trap_R_SetColor( color ); + CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); + trap_R_SetColor( NULL ); + } + else + { + Com_sprintf( num, sizeof( num ), "%d", value ); + value = CG_Text_Width( num, scale, 0 ); + CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, + scale, color, num, 0, 0, textStyle ); + } + } + } +} - memset( &ent, 0, sizeof( ent ) ); - AnglesToAxis( angles, ent.axis ); - VectorCopy( origin, ent.origin ); - ent.hModel = model; - ent.customSkin = skin; - ent.renderfx = RF_NOSHADOW; // no stencil shadows +static void CG_DrawPlayerHealth( rectDef_t *rect, float scale, vec4_t color, + qhandle_t shader, int textStyle ) +{ + playerState_t *ps; + int value; + char num[ 16 ]; - refdef.rdflags = RDF_NOWORLDMODEL; + ps = &cg.snap->ps; - AxisClear( refdef.viewaxis ); + value = ps->stats[ STAT_HEALTH ]; - refdef.fov_x = 30; - refdef.fov_y = 30; + if( shader ) + { + trap_R_SetColor( color ); + CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); + trap_R_SetColor( NULL ); + } + else + { + Com_sprintf( num, sizeof( num ), "%d", value ); + value = CG_Text_Width( num, scale, 0 ); + CG_Text_Paint( rect->x + ( rect->w - value ) / 2, rect->y + rect->h, + scale, color, num, 0, 0, textStyle ); + } +} - refdef.x = x; - refdef.y = y; - refdef.width = w; - refdef.height = h; +float CG_GetValue( int ownerDraw ) +{ + centity_t *cent; + clientInfo_t *ci; + playerState_t *ps; - refdef.time = cg.time; + cent = &cg_entities[ cg.snap->ps.clientNum ]; + ps = &cg.snap->ps; - trap_R_ClearScene(); - trap_R_AddRefEntityToScene( &ent ); - trap_R_RenderScene( &refdef ); + switch( ownerDraw ) + { + case CG_PLAYER_AMMO_VALUE: + if( cent->currentState.weapon ) + { + int value; + + BG_unpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, + &value, NULL, NULL ); + + return value; + } + break; + case CG_PLAYER_CLIPS_VALUE: + if( cent->currentState.weapon ) + { + int value; + + BG_unpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, + NULL, &value, NULL ); + + return value; + } + break; + case CG_PLAYER_HEALTH: + return ps->stats[ STAT_HEALTH ]; + break; + default: + break; + } + + return -1; } -/* -================ -CG_DrawHead +static void CG_DrawAreaSystemChat( rectDef_t *rect, float scale, vec4_t color, qhandle_t shader ) +{ + CG_Text_Paint( rect->x, rect->y + rect->h, scale, color, systemChat, 0, 0, 0 ); +} -Used for both the status bar and the scoreboard -================ -*/ -void CG_DrawHead( float x, float y, float w, float h, int clientNum, vec3_t headAngles ) { - clipHandle_t cm; - clientInfo_t *ci; - float len; - vec3_t origin; - vec3_t mins, maxs; - - ci = &cgs.clientinfo[ clientNum ]; - - if ( cg_draw3dIcons.integer ) { - cm = ci->headModel; - if ( !cm ) { - return; - } +static void CG_DrawAreaTeamChat( rectDef_t *rect, float scale, vec4_t color, qhandle_t shader ) +{ + CG_Text_Paint( rect->x, rect->y + rect->h, scale, color,teamChat1, 0, 0, 0 ); +} - // offset the origin y and z to center the head - trap_R_ModelBounds( cm, mins, maxs ); +static void CG_DrawAreaChat(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) +{ + CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, teamChat2, 0, 0, 0); +} - origin[2] = -0.5 * ( mins[2] + maxs[2] ); - origin[1] = 0.5 * ( mins[1] + maxs[1] ); +const char *CG_GetKillerText( ) +{ + const char *s = ""; + if( cg.killerName[ 0 ] ) + s = va( "Fragged by %s", cg.killerName ); - // calculate distance so the head nearly fills the box - // assume heads are taller than wide - len = 0.7 * ( maxs[2] - mins[2] ); - origin[0] = len / 0.268; // len / tan( fov/2 ) + return s; +} - // allow per-model tweaking - VectorAdd( origin, ci->headOffset, origin ); - CG_Draw3DModel( x, y, w, h, ci->headModel, ci->headSkin, origin, headAngles ); - } else if ( cg_drawIcons.integer ) { - CG_DrawPic( x, y, w, h, ci->modelIcon ); +static void CG_DrawKiller( rectDef_t *rect, float scale, vec4_t color, + qhandle_t shader, int textStyle ) +{ + // fragged by ... line + if( cg.killerName[ 0 ] ) + { + int x = rect->x + rect->w / 2; + CG_Text_Paint( x - CG_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 they are deferred, draw a cross out - if ( ci->deferred ) { - CG_DrawPic( x, y, w, h, cgs.media.deferShader ); + if( text ) + { +// TTimo: FIXME +// const unsigned char *s = text; // bk001206 - unsigned + 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 ]; + //TTimo: FIXME: getting nasty warnings without the cast, + //hopefully this doesn't break the VM build + + 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 ); } } -/* -================ -CG_DrawFlagModel +void CG_OwnerDraw( float x, float y, float w, float h, float text_x, + float text_y, int ownerDraw, int ownerDrawFlags, + int align, float special, float scale, vec4_t color, + qhandle_t shader, int textStyle ) +{ + rectDef_t rect; -Used for both the status bar and the scoreboard -================ -*/ -void CG_DrawFlagModel( float x, float y, float w, float h, int team, qboolean force2D ) { - qhandle_t cm; - float len; - vec3_t origin, angles; - vec3_t mins, maxs; - qhandle_t handle; + if( cg_drawStatus.integer == 0 ) + return; - if ( !force2D && cg_draw3dIcons.integer ) { + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; - VectorClear( angles ); + switch( ownerDraw ) + { + case CG_PLAYER_AMMO_VALUE: + CG_DrawPlayerAmmoValue(&rect, scale, color, shader, textStyle); + break; + case CG_PLAYER_CLIPS_VALUE: + CG_DrawPlayerClipsValue(&rect, scale, color, shader, textStyle); + break; + case CG_PLAYER_HEALTH: + CG_DrawPlayerHealth(&rect, scale, color, shader, textStyle); + break; + case CG_AREA_SYSTEMCHAT: + CG_DrawAreaSystemChat(&rect, scale, color, shader); + break; + case CG_AREA_TEAMCHAT: + CG_DrawAreaTeamChat(&rect, scale, color, shader); + break; + case CG_AREA_CHAT: + CG_DrawAreaChat(&rect, scale, color, shader); + break; + case CG_KILLER: + CG_DrawKiller(&rect, scale, color, shader, textStyle); + break; + default: + break; + } +} - cm = cgs.media.redFlagModel; +void CG_MouseEvent( int x, int y ) +{ + int n; - // offset the origin y and z to center the flag - trap_R_ModelBounds( cm, mins, maxs ); + if( ( cg.predictedPlayerState.pm_type == PM_NORMAL || + cg.predictedPlayerState.pm_type == PM_SPECTATOR ) && + cg.showScores == qfalse ) + { + trap_Key_SetCatcher( 0 ); + return; + } - origin[2] = -0.5 * ( mins[2] + maxs[2] ); - origin[1] = 0.5 * ( mins[1] + maxs[1] ); + cgs.cursorX += x; + if( cgs.cursorX < 0 ) + cgs.cursorX = 0; + else if( cgs.cursorX > 640 ) + cgs.cursorX = 640; - // calculate distance so the flag nearly fills the box - // assume heads are taller than wide - len = 0.5 * ( maxs[2] - mins[2] ); - origin[0] = len / 0.268; // len / tan( fov/2 ) + cgs.cursorY += y; + if( cgs.cursorY < 0 ) + cgs.cursorY = 0; + else if( cgs.cursorY > 480 ) + cgs.cursorY = 480; - angles[YAW] = 60 * sin( cg.time / 2000.0 );; + n = Display_CursorType( cgs.cursorX, cgs.cursorY ); + cgs.activeCursor = 0; + if( n == CURSOR_ARROW ) + cgs.activeCursor = cgs.media.selectCursor; + else if( n == CURSOR_SIZER ) + cgs.activeCursor = cgs.media.sizeCursor; - CG_Draw3DModel( x, y, w, h, - team == TEAM_HUMANS ? cgs.media.redFlagModel : cgs.media.blueFlagModel, - 0, origin, angles ); - } else if ( cg_drawIcons.integer ) { -/* gitem_t *item = BG_FindItemForPowerup( team == TEAM_HUMANS ? PW_REDFLAG : PW_BLUEFLAG ); + if( cgs.capturedItem ) + Display_MouseMove( cgs.capturedItem, x, y ); + else + Display_MouseMove( NULL, cgs.cursorX, cgs.cursorY ); +} - CG_DrawPic( x, y, w, h, cg_items[ ITEM_INDEX(item) ].icon );*/ - } +/* +================== +CG_HideTeamMenus +================== + +*/ +void CG_HideTeamMenu( ) +{ + Menus_CloseByName( "teamMenu" ); + Menus_CloseByName( "getMenu" ); } /* -================ -CG_DrawStatusBarHead +================== +CG_ShowTeamMenus +================== -================ */ -static void CG_DrawStatusBarHead( float x ) { - vec3_t angles; - float size, stretch; - float frac; +void CG_ShowTeamMenu( ) +{ + Menus_OpenByName("teamMenu"); +} - VectorClear( angles ); - if ( cg.damageTime && cg.time - cg.damageTime < DAMAGE_TIME ) { - frac = (float)(cg.time - cg.damageTime ) / DAMAGE_TIME; - size = ICON_SIZE * 1.25 * ( 1.5 - frac * 0.5 ); - stretch = size - ICON_SIZE * 1.25; - // kick in the direction of damage - x -= stretch * 0.5 + cg.damageX * stretch * 0.5; - cg.headStartYaw = 180 + cg.damageX * 45; +/* +================== +CG_EventHandling +================== + type 0 - no event handling + 1 - team menu + 2 - hud editor - cg.headEndYaw = 180 + 20 * cos( crandom()*M_PI ); - cg.headEndPitch = 5 * cos( crandom()*M_PI ); +*/ +void CG_EventHandling( int type ) +{ + cgs.eventHandling = type; + + if( type == CGAME_EVENT_NONE ) + { + CG_HideTeamMenu( ); + } + else if( type == CGAME_EVENT_TEAMMENU ) + { + //CG_ShowTeamMenu(); + } + else if( type == CGAME_EVENT_SCOREBOARD ) + { + + } +} - cg.headStartTime = cg.time; - cg.headEndTime = cg.time + 100 + random() * 2000; - } else { - if ( cg.time >= cg.headEndTime ) { - // select a new head angle - cg.headStartYaw = cg.headEndYaw; - cg.headStartPitch = cg.headEndPitch; - cg.headStartTime = cg.headEndTime; - cg.headEndTime = cg.time + 100 + random() * 2000; - cg.headEndYaw = 180 + 20 * cos( crandom()*M_PI ); - cg.headEndPitch = 5 * cos( crandom()*M_PI ); - } - size = ICON_SIZE * 1.25; +void CG_KeyEvent( int key, qboolean down ) +{ + if( !down) + return; + + if( cg.predictedPlayerState.pm_type == PM_NORMAL || + ( cg.predictedPlayerState.pm_type == PM_SPECTATOR && + cg.showScores == qfalse ) ) + { + CG_EventHandling( CGAME_EVENT_NONE ); + trap_Key_SetCatcher( 0 ); + return; } - // if the server was frozen for a while we may have a bad head start time - if ( cg.headStartTime > cg.time ) { - cg.headStartTime = cg.time; + Display_HandleKey( key, down, cgs.cursorX, cgs.cursorY ); + + if( cgs.capturedItem ) + { + cgs.capturedItem = NULL; } + else + { + if( key == K_MOUSE2 && down ) + cgs.capturedItem = Display_CaptureItem( cgs.cursorX, cgs.cursorY ); + } +} - frac = ( cg.time - cg.headStartTime ) / (float)( cg.headEndTime - cg.headStartTime ); - frac = frac * frac * ( 3 - 2 * frac ); - angles[YAW] = cg.headStartYaw + ( cg.headEndYaw - cg.headStartYaw ) * frac; - angles[PITCH] = cg.headStartPitch + ( cg.headEndPitch - cg.headStartPitch ) * frac; +int CG_ClientNumFromName( const char *p ) +{ + int i; + + for( i = 0; i < cgs.maxclients; i++ ) + { + if( cgs.clientinfo[ i ].infoValid && + Q_stricmp( cgs.clientinfo[ i ].name, p ) == 0 ) + return i; + } + + return -1; +} - CG_DrawHead( x, 480 - size, size, size, - cg.snap->ps.clientNum, angles ); +void CG_ShowResponseHead( ) +{ + Menus_OpenByName( "voiceMenu" ); + trap_Cvar_Set( "cl_conXOffset", "72" ); + cg.voiceTime = cg.time; } -/* -================ -CG_DrawStatusBarFlag +void CG_RunMenuScript( char **args ) +{ +} -================ -*/ -static void CG_DrawStatusBarFlag( float x, int team ) { - CG_DrawFlagModel( x, 480 - ICON_SIZE, ICON_SIZE, ICON_SIZE, team, qfalse ); + +void CG_GetTeamColor(vec4_t *color) +{ + (*color)[0] = (*color)[2] = 0.0f; + (*color)[1] = 0.17f; + (*color)[3] = 0.25f; } +//END TA UI /* -================ -CG_DrawTeamBackground +============== +CG_DrawField -================ +Draws large numbers for status bar and powerups +============== */ -void CG_DrawTeamBackground( int x, int y, int w, int h, float alpha, int team ) +static void CG_DrawField( int x, int y, int width, int value ) { - vec4_t hcolor; + char num[ 16 ], *ptr; + int l; + int frame; - hcolor[3] = alpha; - if ( team == TEAM_HUMANS ) { - hcolor[0] = 1.0f; - hcolor[1] = 0.0f; - hcolor[2] = 0.0f; - } else if ( team == TEAM_ALIENS ) { - hcolor[0] = 0.0f; - hcolor[1] = 0.0f; - hcolor[2] = 1.0f; - } else { - return; - } - trap_R_SetColor( hcolor ); - CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar ); - trap_R_SetColor( NULL ); + if( width < 1 ) + return; + + // draw number string + if( width > 5 ) + width = 5; + + switch( width ) + { + case 1: + value = value > 9 ? 9 : value; + value = value < 0 ? 0 : value; + break; + case 2: + value = value > 99 ? 99 : value; + value = value < -9 ? -9 : value; + break; + case 3: + value = value > 999 ? 999 : value; + value = value < -99 ? -99 : value; + break; + case 4: + value = value > 9999 ? 9999 : value; + value = value < -999 ? -999 : value; + break; + } + + Com_sprintf( num, sizeof( num ), "%d", value ); + l = strlen( num ); + + if ( l > width ) + l = width; + + x += 2 + CHAR_WIDTH * ( width - l ); + + ptr = num; + while( *ptr && l ) + { + if( *ptr == '-' ) + frame = STAT_MINUS; + else + frame = *ptr -'0'; + + CG_DrawPic( x,y, CHAR_WIDTH, CHAR_HEIGHT, cgs.media.numberShaders[ frame ] ); + x += CHAR_WIDTH; + ptr++; + l--; + } } /* @@ -326,49 +766,13 @@ CG_DrawLighting static void CG_DrawLighting( void ) { centity_t *cent; - int currentLum; - static int lum; - vec3_t point, direction; cent = &cg_entities[cg.snap->ps.clientNum]; - VectorCopy( cent->lerpOrigin, point ); - - AngleVectors( cg.refdefViewAngles, direction, NULL, NULL ); - - currentLum = CG_LightFromDirection( point, direction ); - //CG_Printf( "%d\n", lum ); - if( abs( lum - currentLum ) > 4 ) - lum = currentLum; - - switch( cg.snap->ps.stats[ STAT_PCLASS ] ) + if( cg.snap->ps.stats[ STAT_PCLASS ] == PCL_H_BASE ) { - default: -/* if( lum < 10 ) - CG_DrawPic( -4, -4, 648, 488, cgs.media.alienNav9 ); - else if( lum >= 10 && lum < 16 ) - CG_DrawPic( -4, -4, 648, 488, cgs.media.alienNav8 ); - else if( lum >= 16 && lum < 22 ) - CG_DrawPic( -4, -4, 648, 488, cgs.media.alienNav7 ); - else if( lum >= 22 && lum < 28 ) - CG_DrawPic( -4, -4, 648, 488, cgs.media.alienNav6 ); - else if( lum >= 28 && lum < 34 ) - CG_DrawPic( -4, -4, 648, 488, cgs.media.alienNav5 ); - else if( lum >= 34 && lum < 40 ) - CG_DrawPic( -4, -4, 648, 488, cgs.media.alienNav4 ); - else if( lum >= 40 && lum < 46 ) - CG_DrawPic( -4, -4, 648, 488, cgs.media.alienNav3 ); - else if( lum >= 46 && lum < 53 ) - CG_DrawPic( -4, -4, 648, 488, cgs.media.alienNav2 ); - else if( lum >= 53 ) - CG_DrawPic( -4, -4, 648, 488, cgs.media.alienNav1 );*/ - - break; - - case PCL_H_BASE: - if( BG_activated( UP_NVG, cg.snap->ps.stats ) ) - CG_DrawPic( 0, 0, 640, 480, cgs.media.humanNV ); - break; + if( BG_activated( UP_NVG, cg.snap->ps.stats ) ) + CG_DrawPic( 0, 0, 640, 480, cgs.media.humanNV ); } //fade to black if stamina is low @@ -389,7 +793,7 @@ CG_DrawStatusBar ================ */ -static void CG_DrawStatusBar( void ) { +/*static void CG_DrawStatusBar( void ) { int color; centity_t *cent; playerState_t *ps; @@ -416,7 +820,7 @@ static void CG_DrawStatusBar( void ) { cent = &cg_entities[cg.snap->ps.clientNum]; ps = &cg.snap->ps; - VectorClear( angles ); + VectorClear( angles );*/ //TA: stop drawing all these silly 3d models on the hud. Saves space and is more realistic. @@ -449,7 +853,7 @@ static void CG_DrawStatusBar( void ) { // // ammo // - if ( cent->currentState.weapon ) { +/* if ( cent->currentState.weapon ) { //TA: must mask off clips and maxClips if( !BG_FindInfinteAmmoForWeapon( cent->currentState.weapon ) ) BG_unpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, &ammo, &clips, &maxclips ); @@ -475,7 +879,7 @@ static void CG_DrawStatusBar( void ) { if( maxclips ) CG_DrawField( 20, 432, 1, clips ); - trap_R_SetColor( NULL ); + trap_R_SetColor( NULL );*/ // if we didn't draw a 3D icon, draw a 2D icon for ammo /*if ( !cg_draw3dIcons.integer && cg_drawIcons.integer ) { @@ -486,7 +890,7 @@ static void CG_DrawStatusBar( void ) { CG_DrawPic( CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, icon ); } }*/ - } +/* } } // @@ -589,13 +993,13 @@ static void CG_DrawStatusBar( void ) { value = (int)( (float)( (float)ps->stats[STAT_HEALTH] / ps->stats[STAT_MAX_HEALTH] ) * 100 ); - CG_DrawFadePic( 20, 0, 30, 440, fcolor, tcolor, value, cgs.media.alienHealth ); + CG_DrawFadePic( 20, 0, 30, 440, fcolor, tcolor, value, cgs.media.alienHealth );*/ /* value = (int)( (float)( (float)ps->stats[STAT_ARMOR] / ps->stats[STAT_MAX_HEALTH] ) * 100 ); if( value > 0 ) CG_DrawFadePic( 580, 0, 30, 440, fcolor, tcolor, value, cgs.media.alienHealth );*/ - } +/* } else { value = ps->stats[STAT_HEALTH]; @@ -614,7 +1018,7 @@ static void CG_DrawStatusBar( void ) { CG_DrawField ( 300, 432, 3, value); CG_ColorForHealth( hcolor ); trap_R_SetColor( hcolor ); - +*/ /* value = ps->stats[STAT_ARMOR]; if (value > 0 ) { @@ -626,9 +1030,9 @@ static void CG_DrawStatusBar( void ) { CG_DrawPic( 370 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, cgs.media.armorIcon ); } }*/ - } +/* } -} +}*/ /* =========================================================================================== @@ -639,59 +1043,12 @@ static void CG_DrawStatusBar( void ) { */ /* -================ -CG_DrawAttacker - -================ -*/ -static float CG_DrawAttacker( float y ) { - int t; - float size; - vec3_t angles; - const char *info; - const char *name; - int clientNum; - - if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) { - return y; - } - - if ( !cg.attackerTime ) { - return y; - } - - clientNum = cg.predictedPlayerState.persistant[PERS_ATTACKER]; - if ( clientNum < 0 || clientNum >= MAX_CLIENTS || clientNum == cg.snap->ps.clientNum ) { - return y; - } - - t = cg.time - cg.attackerTime; - if ( t > ATTACKER_HEAD_TIME ) { - cg.attackerTime = 0; - return y; - } - - size = ICON_SIZE * 1.25; - - angles[PITCH] = 0; - angles[YAW] = 180; - angles[ROLL] = 0; - CG_DrawHead( 640 - size, y, size, size, clientNum, angles ); - - info = CG_ConfigString( CS_PLAYERS + clientNum ); - name = Info_ValueForKey( info, "n" ); - y += size; - CG_DrawBigString( 640 - ( Q_PrintStrlen( name ) * BIGCHAR_WIDTH), y, name, 0.5 ); - - return y + BIGCHAR_HEIGHT + 2; -} - -/* ================== CG_DrawSnapshot ================== */ -static float CG_DrawSnapshot( float y ) { +static float CG_DrawSnapshot( float y ) +{ char *s; int w; @@ -710,39 +1067,43 @@ CG_DrawFPS ================== */ #define FPS_FRAMES 4 -static float CG_DrawFPS( float y ) { - char *s; - int w; - static int previousTimes[FPS_FRAMES]; +static float CG_DrawFPS( float y ) +{ + char *s; + int w; + static int previousTimes[ FPS_FRAMES ]; static int index; - int i, total; - int fps; - static int previous; - int t, frameTime; + int i, total; + int fps; + static int previous; + int t, frameTime; // don't use serverTime, because that will be drifting to // correct for internet lag changes, timescales, timedemos, etc - t = trap_Milliseconds(); + t = trap_Milliseconds( ); frameTime = t - previous; previous = t; - previousTimes[index % FPS_FRAMES] = frameTime; + previousTimes[ index % FPS_FRAMES ] = frameTime; index++; - if ( index > FPS_FRAMES ) { + + if( index > FPS_FRAMES ) + { // average multiple frames together to smooth changes out a bit total = 0; - for ( i = 0 ; i < FPS_FRAMES ; i++ ) { - total += previousTimes[i]; - } - if ( !total ) { + + for( i = 0 ; i < FPS_FRAMES ; i++ ) + total += previousTimes[ i ]; + + if( !total ) total = 1; - } + fps = 1000 * FPS_FRAMES / total; s = va( "%ifps", fps ); w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; - CG_DrawBigString( 635 - w, y + 2, s, 1.0F); + CG_DrawBigString( 635 - w, y + 2, s, 1.0F ); } return y + BIGCHAR_HEIGHT + 4; @@ -777,179 +1138,6 @@ static float CG_DrawTimer( float y ) { /* -================= -CG_DrawTeamOverlay -================= -*/ - -static float CG_DrawTeamOverlay( float y, qboolean right, qboolean upper ) { - int x, w, h, xx; - int i, j, len; - const char *p; - vec4_t hcolor; - int pwidth, lwidth; - int plyrs; - char st[16]; - clientInfo_t *ci; - gitem_t *item; - int ret_y, count; - - if ( !cg_drawTeamOverlay.integer ) { - return y; - } - - if ( cg.snap->ps.persistant[PERS_TEAM] != TEAM_HUMANS && - cg.snap->ps.persistant[PERS_TEAM] != TEAM_ALIENS ) { - return y; // Not on any team - } - - plyrs = 0; - - // max player name width - pwidth = 0; - count = (numSortedTeamPlayers > 8) ? 8 : numSortedTeamPlayers; - for (i = 0; i < count; i++) { - ci = cgs.clientinfo + sortedTeamPlayers[i]; - if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) { - plyrs++; - len = CG_DrawStrlen(ci->name); - if (len > pwidth) - pwidth = len; - } - } - - if (!plyrs) - return y; - - if (pwidth > TEAM_OVERLAY_MAXNAME_WIDTH) - pwidth = TEAM_OVERLAY_MAXNAME_WIDTH; - - // max location name width - lwidth = 0; - for (i = 1; i < MAX_LOCATIONS; i++) { - p = CG_ConfigString(CS_LOCATIONS + i); - if (p && *p) { - len = CG_DrawStrlen(p); - if (len > lwidth) - lwidth = len; - } - } - - if (lwidth > TEAM_OVERLAY_MAXLOCATION_WIDTH) - lwidth = TEAM_OVERLAY_MAXLOCATION_WIDTH; - - w = (pwidth + lwidth + 4 + 7) * TINYCHAR_WIDTH; - - if ( right ) - x = 640 - w; - else - x = 0; - - h = plyrs * TINYCHAR_HEIGHT; - - if ( upper ) { - ret_y = y + h; - } else { - y -= h; - ret_y = y; - } - - if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_HUMANS ) { - hcolor[0] = 1; - hcolor[1] = 0; - hcolor[2] = 0; - hcolor[3] = 0.33f; - } else { // if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_ALIENS ) - hcolor[0] = 0; - hcolor[1] = 0; - hcolor[2] = 1; - hcolor[3] = 0.33f; - } - trap_R_SetColor( hcolor ); - CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar ); - trap_R_SetColor( NULL ); - - for (i = 0; i < count; i++) { - ci = cgs.clientinfo + sortedTeamPlayers[i]; - if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) { - - hcolor[0] = hcolor[1] = hcolor[2] = hcolor[3] = 1.0; - - xx = x + TINYCHAR_WIDTH; - - CG_DrawStringExt( xx, y, - ci->name, hcolor, qfalse, qfalse, - TINYCHAR_WIDTH, TINYCHAR_HEIGHT, TEAM_OVERLAY_MAXNAME_WIDTH); - - if (lwidth) { - p = CG_ConfigString(CS_LOCATIONS + ci->location); - if (!p || !*p) - p = "unknown"; - len = CG_DrawStrlen(p); - if (len > lwidth) - len = lwidth; - -// xx = x + TINYCHAR_WIDTH * 2 + TINYCHAR_WIDTH * pwidth + -// ((lwidth/2 - len/2) * TINYCHAR_WIDTH); - xx = x + TINYCHAR_WIDTH * 2 + TINYCHAR_WIDTH * pwidth; - CG_DrawStringExt( xx, y, - p, hcolor, qfalse, qfalse, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, - TEAM_OVERLAY_MAXLOCATION_WIDTH); - } - - CG_GetColorForHealth( ci->health, ci->armor, hcolor ); - - Com_sprintf (st, sizeof(st), "%3i %3i", ci->health, ci->armor); - - xx = x + TINYCHAR_WIDTH * 3 + - TINYCHAR_WIDTH * pwidth + TINYCHAR_WIDTH * lwidth; - - CG_DrawStringExt( xx, y, - st, hcolor, qfalse, qfalse, - TINYCHAR_WIDTH, TINYCHAR_HEIGHT, 0 ); - - // draw weapon icon - xx += TINYCHAR_WIDTH * 3; - - if ( cg_weapons[ci->curWeapon].weaponIcon ) { - CG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, - cg_weapons[ci->curWeapon].weaponIcon ); - } else { - CG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, - cgs.media.deferShader ); - } - - // Draw powerup icons - if (right) { - xx = x; - } else { - xx = x + w - TINYCHAR_WIDTH; - } - /*for (j = 0; j < PW_NUM_POWERUPS; j++) { - if (ci->powerups & (1 << j)) { - gitem_t *item; - - item = BG_FindItemForPowerup( j ); - - CG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, - trap_R_RegisterShader( item->icon ) ); - if (right) { - xx -= TINYCHAR_WIDTH; - } else { - xx += TINYCHAR_WIDTH; - } - } - }*/ - - y += TINYCHAR_HEIGHT; - } - } - - return ret_y; -} - - -/* ===================== CG_DrawUpperRight @@ -960,9 +1148,6 @@ static void CG_DrawUpperRight( void ) { y = 0; - if ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 1 ) { - y = CG_DrawTeamOverlay( y, qtrue, qtrue ); - } if ( cg_drawSnapshot.integer ) { y = CG_DrawSnapshot( y ); } @@ -972,10 +1157,6 @@ static void CG_DrawUpperRight( void ) { if ( cg_drawTimer.integer ) { y = CG_DrawTimer( y ); } - if ( cg_drawAttacker.integer ) { - y = CG_DrawAttacker( y ); - } - } /* @@ -989,12 +1170,12 @@ static void CG_DrawUpperRight( void ) { /* ================= -CG_DrawPoints +CG_DrawBuildPoints Draw the small two score display ================= */ -static float CG_DrawPoints( float y ) +/*static float CG_DrawBuildPoints( float y ) { const char *s; int points, totalpoints, buildpoints; @@ -1043,486 +1224,10 @@ static float CG_DrawPoints( float y ) } return y1 - 8; -} - - -/* -================= -CG_DrawScores - -Draw the small two score display -================= -*/ -static float CG_DrawScores( float y ) { - const char *s; - int s1, s2, score; - int x, w; - int v; - vec4_t color; - float y1; - gitem_t *item; - - s1 = cgs.scores1; - s2 = cgs.scores2; - - y -= BIGCHAR_HEIGHT + 8; - - y1 = y; - - // draw from the right side to left - if ( cgs.gametype >= GT_TEAM ) { - x = 640; - - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 1.0f; - color[3] = 0.33f; - s = va( "%2i", s2 ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8; - x -= w; - CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color ); - if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_ALIENS ) { - CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader ); - } - CG_DrawBigString( x + 4, y, s, 1.0F); - - if ( cgs.gametype == GT_CTF ) { - // Display flag status - /*item = BG_FindItemForPowerup( PW_BLUEFLAG );*/ - - if (item) { - y1 = y - BIGCHAR_HEIGHT - 8; - if( cgs.blueflag >= 0 && cgs.blueflag <= 2 ) { - CG_DrawPic( x, y1-4, w, BIGCHAR_HEIGHT+8, cgs.media.blueFlagShader[cgs.blueflag] ); - } - } - } - - color[0] = 1.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.33f; - s = va( "%2i", s1 ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8; - x -= w; - CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color ); - if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_HUMANS ) { - CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader ); - } - CG_DrawBigString( x + 4, y, s, 1.0F); - - if ( cgs.gametype == GT_CTF ) { - // Display flag status - /*item = BG_FindItemForPowerup( PW_REDFLAG );*/ - - if (item) { - y1 = y - BIGCHAR_HEIGHT - 8; - if( cgs.redflag >= 0 && cgs.redflag <= 2 ) { - CG_DrawPic( x, y1-4, w, BIGCHAR_HEIGHT+8, cgs.media.redFlagShader[cgs.redflag] ); - } - } - } - - - if ( cgs.gametype >= GT_CTF ) { - v = cgs.capturelimit; - } else { - v = cgs.fraglimit; - } - if ( v ) { - s = va( "%2i", v ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8; - x -= w; - CG_DrawBigString( x + 4, y, s, 1.0F); - } - - } else { - qboolean spectator; - - x = 640; - score = cg.snap->ps.persistant[PERS_SCORE]; - spectator = ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) || - ( cg.snap->ps.stats[ STAT_STATE ] & SS_INFESTING ) || - ( cg.snap->ps.stats[ STAT_STATE ] & SS_HOVELING ); - - // always show your score in the second box if not in first place - if ( s1 != score ) { - s2 = score; - } - if ( s2 != SCORE_NOT_PRESENT ) { - s = va( "%2i", s2 ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8; - x -= w; - if ( !spectator && score == s2 && score != s1 ) { - color[0] = 1.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.33f; - CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color ); - CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader ); - } else { - color[0] = 0.5f; - color[1] = 0.5f; - color[2] = 0.5f; - color[3] = 0.33f; - CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color ); - } - CG_DrawBigString( x + 4, y, s, 1.0F); - } - - // first place - if ( s1 != SCORE_NOT_PRESENT ) { - s = va( "%2i", s1 ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8; - x -= w; - if ( !spectator && score == s1 ) { - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 1.0f; - color[3] = 0.33f; - CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color ); - CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader ); - } else { - color[0] = 0.5f; - color[1] = 0.5f; - color[2] = 0.5f; - color[3] = 0.33f; - CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color ); - } - CG_DrawBigString( x + 4, y, s, 1.0F); - } - - if ( cgs.fraglimit ) { - s = va( "%2i", cgs.fraglimit ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8; - x -= w; - CG_DrawBigString( x + 4, y, s, 1.0F); - } - - } - - return y1 - 8; -} - -/* -================ -CG_DrawPowerups -================ -*/ -static float CG_DrawPowerups( float y ) { - int sorted[MAX_POWERUPS]; - int sortedTime[MAX_POWERUPS]; - int i, j, k; - int active; - playerState_t *ps; - int t; - gitem_t *item; - int x; - int color; - float size; - float f; - static float colors[2][4] = { - { 0.2f, 1.0f, 0.2f, 1.0f }, - { 1.0f, 0.2f, 0.2f, 1.0f } - }; - - ps = &cg.snap->ps; - - if ( ps->stats[STAT_HEALTH] <= 0 ) { - return y; - } - - // sort the list by time remaining - active = 0; - for ( i = 0 ; i < MAX_POWERUPS ; i++ ) { - if ( !ps->powerups[ i ] ) { - continue; - } - t = ps->powerups[ i ] - cg.time; - // ZOID--don't draw if the power up has unlimited time (999 seconds) - // This is true of the CTF flags - if ( t < 0 || t > 999000) { - continue; - } - - // insert into the list - for ( j = 0 ; j < active ; j++ ) { - if ( sortedTime[j] >= t ) { - for ( k = active - 1 ; k >= j ; k-- ) { - sorted[k+1] = sorted[k]; - sortedTime[k+1] = sortedTime[k]; - } - break; - } - } - sorted[j] = i; - sortedTime[j] = t; - active++; - } - - // draw the icons and timers - x = 640 - ICON_SIZE - CHAR_WIDTH * 2; - for ( i = 0 ; i < active ; i++ ) { - /*item = BG_FindItemForPowerup( sorted[i] );*/ - - if (item) { - - color = 1; - - y -= ICON_SIZE; - - trap_R_SetColor( colors[color] ); - CG_DrawField( x, y, 2, sortedTime[ i ] / 1000 ); - - t = ps->powerups[ sorted[i] ]; - if ( t - cg.time >= POWERUP_BLINKS * POWERUP_BLINK_TIME ) { - trap_R_SetColor( NULL ); - } else { - vec4_t modulate; - - f = (float)( t - cg.time ) / POWERUP_BLINK_TIME; - f -= (int)f; - modulate[0] = modulate[1] = modulate[2] = modulate[3] = f; - trap_R_SetColor( modulate ); - } - - if ( cg.powerupActive == sorted[i] && - cg.time - cg.powerupTime < PULSE_TIME ) { - f = 1.0 - ( ( (float)cg.time - cg.powerupTime ) / PULSE_TIME ); - size = ICON_SIZE * ( 1.0 + ( PULSE_SCALE - 1.0 ) * f ); - } else { - size = ICON_SIZE; - } - - CG_DrawPic( 640 - size, y + ICON_SIZE / 2 - size / 2, - size, size, trap_R_RegisterShader( item->icon ) ); - } - } - trap_R_SetColor( NULL ); - - return y; -} - - -/* -===================== -CG_DrawLowerRight - -===================== -*/ -static void CG_DrawLowerRight( void ) { - float y; - - y = 480 - ICON_SIZE; - - if ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 2 ) { - y = CG_DrawTeamOverlay( y, qtrue, qfalse ); - } - - //y = CG_DrawScores( y ); - //y = CG_DrawPoints( y ); - y = CG_DrawPowerups( y ); -} - -/* -=================== -CG_DrawPickupItem -=================== -*/ -static int CG_DrawPickupItem( int y ) { - int value; - float *fadeColor; - - if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) { - return y; - } - - y -= ICON_SIZE; - - value = cg.itemPickup; - if ( value ) { - fadeColor = CG_FadeColor( cg.itemPickupTime, 3000 ); - if ( fadeColor ) { - /*CG_RegisterItemVisuals( value );*/ - trap_R_SetColor( fadeColor ); - CG_DrawPic( 8, y, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon ); - //TA: BG_FindHumanNameForWeapon is probably highly inappropriate here, but this will probably never get called - CG_DrawBigString( ICON_SIZE + 16, y + (ICON_SIZE/2 - BIGCHAR_HEIGHT/2), BG_FindHumanNameForWeapon( value ), fadeColor[0] ); - trap_R_SetColor( NULL ); - } - } - - return y; -} - -/* -===================== -CG_DrawLowerLeft - -===================== -*/ -static void CG_DrawLowerLeft( void ) { - float y; - - y = 480 - ICON_SIZE; - - if ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 3 ) { - y = CG_DrawTeamOverlay( y, qfalse, qfalse ); - } - - - y = CG_DrawPickupItem( y ); -} - - +}*/ //=========================================================================================== -/* -================= -CG_DrawTeamInfo -================= -*/ -static void CG_DrawTeamInfo( void ) { - int w, h; - int i, len; - vec4_t hcolor; - int chatHeight; - -#define CHATLOC_Y 420 // bottom end -#define CHATLOC_X 0 - - if (cg_teamChatHeight.integer < TEAMCHAT_HEIGHT) - chatHeight = cg_teamChatHeight.integer; - else - chatHeight = TEAMCHAT_HEIGHT; - if (chatHeight <= 0) - return; // disabled - - if (cgs.teamLastChatPos != cgs.teamChatPos) { - if (cg.time - cgs.teamChatMsgTimes[cgs.teamLastChatPos % chatHeight] > cg_teamChatTime.integer) { - cgs.teamLastChatPos++; - } - - h = (cgs.teamChatPos - cgs.teamLastChatPos) * TINYCHAR_HEIGHT; - - w = 0; - - for (i = cgs.teamLastChatPos; i < cgs.teamChatPos; i++) { - len = CG_DrawStrlen(cgs.teamChatMsgs[i % chatHeight]); - if (len > w) - w = len; - } - w *= TINYCHAR_WIDTH; - w += TINYCHAR_WIDTH * 2; - - if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_HUMANS ) { - hcolor[0] = 1.0f; - hcolor[1] = 0.0f; - hcolor[2] = 0.0f; - hcolor[3] = 0.33f; - } else if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_ALIENS ) { - hcolor[0] = 0.0f; - hcolor[1] = 0.0f; - hcolor[2] = 1.0f; - hcolor[3] = 0.33f; - } else { - hcolor[0] = 0.0f; - hcolor[1] = 1.0f; - hcolor[2] = 0.0f; - hcolor[3] = 0.33f; - } - - trap_R_SetColor( hcolor ); - CG_DrawPic( CHATLOC_X, CHATLOC_Y - h, 640, h, cgs.media.teamStatusBar ); - trap_R_SetColor( NULL ); - - hcolor[0] = hcolor[1] = hcolor[2] = 1.0f; - hcolor[3] = 1.0f; - - for (i = cgs.teamChatPos - 1; i >= cgs.teamLastChatPos; i--) { - CG_DrawStringExt( CHATLOC_X + TINYCHAR_WIDTH, - CHATLOC_Y - (cgs.teamChatPos - i)*TINYCHAR_HEIGHT, - cgs.teamChatMsgs[i % chatHeight], hcolor, qfalse, qfalse, - TINYCHAR_WIDTH, TINYCHAR_HEIGHT, 0 ); - } - } -} - -/* -=================== -CG_DrawHoldableItem -=================== -*/ -static void CG_DrawHoldableItem( void ) { - int value; - - //TA: not using q3 holdable item code - /*value = cg.snap->ps.stats[STAT_HOLDABLE_ITEM]; - if ( value ) { - CG_RegisterItemVisuals( value ); - CG_DrawPic( 640-ICON_SIZE, (SCREEN_HEIGHT-ICON_SIZE)/2, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon ); - }*/ - -} - - -/* -=================== -CG_DrawReward -=================== -*/ -static void CG_DrawReward( void ) { - float *color; - int i, count; - float x, y; - char buf[32]; - - if ( !cg_drawRewards.integer ) { - return; - } - color = CG_FadeColor( cg.rewardTime, REWARD_TIME ); - if ( !color ) { - if (cg.rewardStack > 0) { - for(i = 0; i < cg.rewardStack; i++) { - cg.rewardSound[i] = cg.rewardSound[i+1]; - cg.rewardShader[i] = cg.rewardShader[i+1]; - cg.rewardCount[i] = cg.rewardCount[i+1]; - } - cg.rewardTime = cg.time; - cg.rewardStack--; - color = CG_FadeColor( cg.rewardTime, REWARD_TIME ); - trap_S_StartLocalSound(cg.rewardSound[0], CHAN_ANNOUNCER); - } else { - return; - } - } - - trap_R_SetColor( color ); - - if ( cg.rewardCount[0] >= 10 ) { - y = 56; - x = 320 - ICON_SIZE/2; - CG_DrawPic( x, y, ICON_SIZE-4, ICON_SIZE-4, cg.rewardShader[0] ); - Com_sprintf(buf, sizeof(buf), "%d", cg.rewardCount[0]); - x = ( SCREEN_WIDTH - SMALLCHAR_WIDTH * CG_DrawStrlen( buf ) ) / 2; - CG_DrawStringExt( x, y+ICON_SIZE, buf, color, qfalse, qtrue, - SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0 ); - } - else { - - count = cg.rewardCount[0]; - - y = 56; - x = 320 - count * ICON_SIZE/2; - for ( i = 0 ; i < count ; i++ ) { - CG_DrawPic( x, y, ICON_SIZE-4, ICON_SIZE-4, cg.rewardShader[0] ); - x += ICON_SIZE; - } - } - trap_R_SetColor( NULL ); -} - /* =============================================================================== @@ -1534,12 +1239,12 @@ LAGOMETER #define LAG_SAMPLES 128 - -typedef struct { - int frameSamples[LAG_SAMPLES]; +typedef struct +{ + int frameSamples[ LAG_SAMPLES ]; int frameCount; - int snapshotFlags[LAG_SAMPLES]; - int snapshotSamples[LAG_SAMPLES]; + int snapshotFlags[ LAG_SAMPLES ]; + int snapshotSamples[ LAG_SAMPLES ]; int snapshotCount; } lagometer_t; @@ -1552,11 +1257,12 @@ CG_AddLagometerFrameInfo Adds the current interpolate / extrapolate bar for this frame ============== */ -void CG_AddLagometerFrameInfo( void ) { +void CG_AddLagometerFrameInfo( void ) +{ int offset; offset = cg.time - cg.latestSnapshotTime; - lagometer.frameSamples[ lagometer.frameCount & ( LAG_SAMPLES - 1) ] = offset; + lagometer.frameSamples[ lagometer.frameCount & ( LAG_SAMPLES - 1 ) ] = offset; lagometer.frameCount++; } @@ -1570,17 +1276,19 @@ the number of snapshots that were dropped before it. Pass NULL for a dropped packet. ============== */ -void CG_AddLagometerSnapshotInfo( snapshot_t *snap ) { +void CG_AddLagometerSnapshotInfo( snapshot_t *snap ) +{ // dropped packet - if ( !snap ) { - lagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = -1; + if( !snap ) + { + lagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1 ) ] = -1; lagometer.snapshotCount++; return; } // add this snapshot's info - lagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = snap->ping; - lagometer.snapshotFlags[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = snap->snapFlags; + lagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1 ) ] = snap->ping; + lagometer.snapshotFlags[ lagometer.snapshotCount & ( LAG_SAMPLES - 1 ) ] = snap->snapFlags; lagometer.snapshotCount++; } @@ -1591,38 +1299,37 @@ CG_DrawDisconnect Should we draw something differnet for long lag vs no packets? ============== */ -static void CG_DrawDisconnect( void ) { - float x, y; - int cmdNum; - usercmd_t cmd; - const char *s; - int w; +static void CG_DrawDisconnect( void ) +{ + float x, y; + int cmdNum; + usercmd_t cmd; + const char *s; + int w; // draw the phone jack if we are completely past our buffers - cmdNum = trap_GetCurrentCmdNumber() - CMD_BACKUP + 1; + cmdNum = trap_GetCurrentCmdNumber( ) - CMD_BACKUP + 1; trap_GetUserCmd( cmdNum, &cmd ); - if ( cmd.serverTime <= cg.snap->ps.commandTime - || cmd.serverTime > cg.time ) { // special check for map_restart + + // special check for map_restart + if( cmd.serverTime <= cg.snap->ps.commandTime || cmd.serverTime > cg.time ) return; - } // also add text in center of screen s = "Connection Interrupted"; w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; - CG_DrawBigString( 320 - w/2, 100, s, 1.0F); + CG_DrawBigString( 320 - w / 2, 100, s, 1.0F); // blink the icon - if ( ( cg.time >> 9 ) & 1 ) { + if( ( cg.time >> 9 ) & 1 ) return; - } x = 640 - 48; y = 480 - 48; - CG_DrawPic( x, y, 48, 48, trap_R_RegisterShader("gfx/2d/net.tga" ) ); + CG_DrawPic( x, y, 48, 48, trap_R_RegisterShader( "gfx/2d/net.tga" ) ); } - #define MAX_LAGOMETER_PING 900 #define MAX_LAGOMETER_RANGE 300 @@ -1631,15 +1338,17 @@ static void CG_DrawDisconnect( void ) { CG_DrawLagometer ============== */ -static void CG_DrawLagometer( void ) { +static void CG_DrawLagometer( void ) +{ int a, x, y, i; float v; float ax, ay, aw, ah, mid, range; int color; float vscale; - if ( !cg_lagometer.integer || cgs.localServer ) { - CG_DrawDisconnect(); + if( !cg_lagometer.integer || cgs.localServer ) + { + CG_DrawDisconnect( ); return; } @@ -1647,7 +1356,7 @@ static void CG_DrawLagometer( void ) { // draw the graph // x = 640 - 48; - y = 480 - 48; + y = 480 - 144; trap_R_SetColor( NULL ); CG_DrawPic( x, y, 48, 48, cgs.media.lagometerShader ); @@ -1665,28 +1374,37 @@ static void CG_DrawLagometer( void ) { vscale = range / MAX_LAGOMETER_RANGE; // draw the frame interpoalte / extrapolate graph - for ( a = 0 ; a < aw ; a++ ) { - i = ( lagometer.frameCount - 1 - a ) & (LAG_SAMPLES - 1); - v = lagometer.frameSamples[i]; + for( a = 0 ; a < aw ; a++ ) + { + i = ( lagometer.frameCount - 1 - a ) & ( LAG_SAMPLES - 1 ); + v = lagometer.frameSamples[ i ]; v *= vscale; - if ( v > 0 ) { - if ( color != 1 ) { + + if( v > 0 ) + { + if( color != 1 ) + { color = 1; - trap_R_SetColor( g_color_table[ColorIndex(COLOR_YELLOW)] ); + trap_R_SetColor( g_color_table[ ColorIndex( COLOR_YELLOW ) ] ); } - if ( v > range ) { + + if( v > range ) v = range; - } - trap_R_DrawStretchPic ( ax + aw - a, mid - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); - } else if ( v < 0 ) { - if ( color != 2 ) { + + trap_R_DrawStretchPic( ax + aw - a, mid - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); + } + else if( v < 0 ) + { + if( color != 2 ) + { color = 2; - trap_R_SetColor( g_color_table[ColorIndex(COLOR_BLUE)] ); + trap_R_SetColor( g_color_table[ ColorIndex( COLOR_BLUE ) ] ); } + v = -v; - if ( v > range ) { + if( v > range ) v = range; - } + trap_R_DrawStretchPic( ax + aw - a, mid, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); } } @@ -1695,40 +1413,54 @@ static void CG_DrawLagometer( void ) { range = ah / 2; vscale = range / MAX_LAGOMETER_PING; - for ( a = 0 ; a < aw ; a++ ) { - i = ( lagometer.snapshotCount - 1 - a ) & (LAG_SAMPLES - 1); - v = lagometer.snapshotSamples[i]; - if ( v > 0 ) { - if ( lagometer.snapshotFlags[i] & SNAPFLAG_RATE_DELAYED ) { - if ( color != 5 ) { + for( a = 0 ; a < aw ; a++ ) + { + i = ( lagometer.snapshotCount - 1 - a ) & ( LAG_SAMPLES - 1 ); + v = lagometer.snapshotSamples[ i ]; + + if( v > 0 ) + { + if( lagometer.snapshotFlags[ i ] & SNAPFLAG_RATE_DELAYED ) + { + if( color != 5 ) + { color = 5; // YELLOW for rate delay - trap_R_SetColor( g_color_table[ColorIndex(COLOR_YELLOW)] ); + trap_R_SetColor( g_color_table[ ColorIndex( COLOR_YELLOW ) ] ); } - } else { - if ( color != 3 ) { + } + else + { + if( color != 3 ) + { color = 3; - trap_R_SetColor( g_color_table[ColorIndex(COLOR_GREEN)] ); + + trap_R_SetColor( g_color_table[ ColorIndex( COLOR_GREEN ) ] ); } } + v = v * vscale; - if ( v > range ) { + + if( v > range ) v = range; - } + trap_R_DrawStretchPic( ax + aw - a, ay + ah - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); - } else if ( v < 0 ) { - if ( color != 4 ) { + } + else if( v < 0 ) + { + if( color != 4 ) + { color = 4; // RED for dropped snapshots - trap_R_SetColor( g_color_table[ColorIndex(COLOR_RED)] ); + trap_R_SetColor( g_color_table[ ColorIndex( COLOR_RED ) ] ); } + trap_R_DrawStretchPic( ax + aw - a, ay + ah - range, 1, range, 0, 0, 0, 0, cgs.media.whiteShader ); } } trap_R_SetColor( NULL ); - if ( cg_nopredict.integer || cg_synchronousClients.integer ) { + if( cg_nopredict.integer || cg_synchronousClients.integer ) CG_DrawBigString( ax, ay, "snc", 1.0 ); - } CG_DrawDisconnect(); } @@ -1752,10 +1484,11 @@ Called for important messages that should stay in the center of the screen for a few moments ============== */ -void CG_CenterPrint( const char *str, int y, int charWidth ) { +void CG_CenterPrint( const char *str, int y, int charWidth ) +{ char *s; - Q_strncpyz( cg.centerPrint, str, sizeof(cg.centerPrint) ); + Q_strncpyz( cg.centerPrint, str, sizeof( cg.centerPrint ) ); cg.centerPrintTime = cg.time; cg.centerPrintY = y; @@ -1764,9 +1497,11 @@ void CG_CenterPrint( const char *str, int y, int charWidth ) { // count the number of lines for centering cg.centerPrintLines = 1; s = cg.centerPrint; - while( *s ) { - if (*s == '\n') + while( *s ) + { + if( *s == '\n' ) cg.centerPrintLines++; + s++; } } @@ -1777,20 +1512,20 @@ void CG_CenterPrint( const char *str, int y, int charWidth ) { CG_DrawCenterString =================== */ -static void CG_DrawCenterString( void ) { +static void CG_DrawCenterString( void ) +{ char *start; int l; int x, y, w; + int h; float *color; - if ( !cg.centerPrintTime ) { + if( !cg.centerPrintTime ) return; - } color = CG_FadeColor( cg.centerPrintTime, 1000 * cg_centertime.value ); - if ( !color ) { + if( !color ) return; - } trap_R_SetColor( color ); @@ -1798,32 +1533,32 @@ static void CG_DrawCenterString( void ) { y = cg.centerPrintY - cg.centerPrintLines * BIGCHAR_HEIGHT / 2; - while ( 1 ) { - char linebuffer[1024]; + while( 1 ) + { + char linebuffer[ 1024 ]; - for ( l = 0; l < 50; l++ ) { - if ( !start[l] || start[l] == '\n' ) { + for( l = 0; l < 50; l++ ) + { + if( !start[ l ] || start[ l ] == '\n' ) break; - } - linebuffer[l] = start[l]; + + linebuffer[ l ] = start[ l ]; } - linebuffer[l] = 0; - - w = cg.centerPrintCharWidth * CG_DrawStrlen( linebuffer ); - - x = ( SCREEN_WIDTH - w ) / 2; - - CG_DrawStringExt( x, y, linebuffer, color, qfalse, qtrue, - cg.centerPrintCharWidth, (int)(cg.centerPrintCharWidth * 1.5), 0 ); + + linebuffer[ l ] = 0; - y += cg.centerPrintCharWidth * 1.5; + w = CG_Text_Width( linebuffer, 0.5, 0 ); + h = CG_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 ); + y += h + 6; - while ( *start && ( *start != '\n' ) ) { + while( *start && ( *start != '\n' ) ) start++; - } - if ( !*start ) { + + if( !*start ) break; - } + start++; } @@ -1846,41 +1581,42 @@ CROSSHAIR CG_DrawCrosshair ================= */ -static void CG_DrawCrosshair(void) { - float w, h; +static void CG_DrawCrosshair( void ) +{ + float w, h; qhandle_t hShader; - float f; - float x, y; - int ca; + float f; + float x, y; + int ca; - if ( !cg_drawCrosshair.integer ) { + if( !cg_drawCrosshair.integer ) return; - } if( ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) || ( cg.snap->ps.stats[ STAT_STATE ] & SS_INFESTING ) || ( cg.snap->ps.stats[ STAT_STATE ] & SS_HOVELING ) ) return; - if ( cg.renderingThirdPerson ) { + if( cg.renderingThirdPerson ) return; - } // set color based on health - if ( cg_crosshairHealth.integer ) { + if( cg_crosshairHealth.integer ) + { vec4_t hcolor; CG_ColorForHealth( hcolor ); trap_R_SetColor( hcolor ); - } else { - trap_R_SetColor( NULL ); } + else + trap_R_SetColor( NULL ); w = h = cg_crosshairSize.value; // pulse the size of the crosshair when picking up items f = cg.time - cg.itemPickupBlendTime; - if ( f > 0 && f < ITEM_BLOB_TIME ) { + if( f > 0 && f < ITEM_BLOB_TIME ) + { f /= ITEM_BLOB_TIME; w *= ( 1 + f ); h *= ( 1 + f ); @@ -1891,13 +1627,13 @@ static void CG_DrawCrosshair(void) { CG_AdjustFrom640( &x, &y, &w, &h ); ca = cg_drawCrosshair.integer; - if (ca < 0) { + if( ca < 0 ) ca = 0; - } + hShader = cgs.media.crosshairShader[ ca % NUM_CROSSHAIRS ]; - trap_R_DrawStretchPic( x + cg.refdef.x + 0.5 * (cg.refdef.width - w), - y + cg.refdef.y + 0.5 * (cg.refdef.height - h), + trap_R_DrawStretchPic( x + cg.refdef.x + 0.5 * ( cg.refdef.width - w ), + y + cg.refdef.y + 0.5 * ( cg.refdef.height - h ), w, h, 0, 0, 1, 1, hShader ); } @@ -1908,30 +1644,25 @@ static void CG_DrawCrosshair(void) { CG_ScanForCrosshairEntity ================= */ -static void CG_ScanForCrosshairEntity( void ) { +static void CG_ScanForCrosshairEntity( void ) +{ trace_t trace; vec3_t start, end; int content; VectorCopy( cg.refdef.vieworg, start ); - VectorMA( start, 131072, cg.refdef.viewaxis[0], end ); + VectorMA( start, 131072, cg.refdef.viewaxis[ 0 ], end ); CG_Trace( &trace, start, vec3_origin, vec3_origin, end, cg.snap->ps.clientNum, CONTENTS_SOLID|CONTENTS_BODY ); - if ( trace.entityNum >= MAX_CLIENTS ) { + + if( trace.entityNum >= MAX_CLIENTS ) return; - } // if the player is in fog, don't show it content = trap_CM_PointContents( trace.endpos, 0 ); - if ( content & CONTENTS_FOG ) { + if( content & CONTENTS_FOG ) return; - } - - // if the player is invisible, don't show it - /*if ( cg_entities[ trace.entityNum ].currentState.powerups & ( 1 << PW_INVIS ) ) { - return; - }*/ // update the fade timer cg.crosshairClientNum = trace.entityNum; @@ -1944,34 +1675,36 @@ static void CG_ScanForCrosshairEntity( void ) { CG_DrawCrosshairNames ===================== */ -static void CG_DrawCrosshairNames( void ) { +static void CG_DrawCrosshairNames( void ) +{ float *color; char *name; float w; - if ( !cg_drawCrosshair.integer ) { + if( !cg_drawCrosshair.integer ) return; - } - if ( !cg_drawCrosshairNames.integer ) { + + if( !cg_drawCrosshairNames.integer ) return; - } - if ( cg.renderingThirdPerson ) { + + if( cg.renderingThirdPerson ) return; - } // scan the known entities to see if the crosshair is sighted on one - CG_ScanForCrosshairEntity(); + CG_ScanForCrosshairEntity( ); // draw the name of the player being looked at color = CG_FadeColor( cg.crosshairClientTime, 1000 ); - if ( !color ) { + if( !color ) + { trap_R_SetColor( NULL ); return; } name = cgs.clientinfo[ cg.crosshairClientNum ].name; - w = CG_DrawStrlen( name ) * BIGCHAR_WIDTH; - CG_DrawBigString( 320 - w / 2, 170, name, color[3] * 0.5f ); + color[ 3 ] *= 0.5f; + w = CG_Text_Width( name, 0.3f, 0 ); + CG_Text_Paint( 320 - w / 2, 190, 0.3f, color, name, 0, 0, ITEM_TEXTSTYLE_SHADOWED ); trap_R_SetColor( NULL ); } @@ -1985,14 +1718,11 @@ static void CG_DrawCrosshairNames( void ) { CG_DrawSpectator ================= */ -static void CG_DrawSpectator(void) { - CG_DrawBigString(320 - 9 * 8, 440, "SPECTATOR", 1.0F); - if ( cgs.gametype == GT_TOURNAMENT ) { - CG_DrawBigString(320 - 15 * 8, 460, "waiting to play", 1.0F); - } - if ( cgs.gametype >= GT_TEAM ) { - CG_DrawBigString(320 - 39 * 8, 460, "press ESC and use the JOIN menu to play", 1.0F); - } +static void CG_DrawSpectator( void ) +{ + if( cg.snap->ps.stats[ STAT_STATE ] & SS_HOVELING || + cg.snap->ps.stats[ STAT_STATE ] & SS_INFESTING ) + CG_DrawBigString(320 - 9 * 8, 440, "SPECTATOR", 1.0F); } /* @@ -2000,26 +1730,30 @@ static void CG_DrawSpectator(void) { CG_DrawVote ================= */ -static void CG_DrawVote(void) { +static void CG_DrawVote( void ) +{ char *s; int sec; - if ( !cgs.voteTime ) { + if( !cgs.voteTime ) return; - } // play a talk beep whenever it is modified - if ( cgs.voteModified ) { + if( cgs.voteModified ) + { cgs.voteModified = qfalse; trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); } sec = ( VOTE_TIME - ( cg.time - cgs.voteTime ) ) / 1000; - if ( sec < 0 ) { + + if( sec < 0 ) sec = 0; - } - s = va("VOTE(%i):%s yes:%i no:%i", sec, cgs.voteString, cgs.voteYes, cgs.voteNo ); - CG_DrawSmallString( 0, 58, s, 1.0F ); + + s = va( "VOTE(%i):%s yes:%i no:%i", sec, cgs.voteString, cgs.voteYes, cgs.voteNo ); + CG_DrawSmallString( 0, 58, s, 1.0F ); + s = "or press ESC then click Vote"; + CG_DrawSmallString( 0, 58 + SMALLCHAR_HEIGHT + 2, s, 1.0F ); } /* @@ -2027,39 +1761,43 @@ static void CG_DrawVote(void) { CG_DrawTeamVote ================= */ -static void CG_DrawTeamVote(void) { +static void CG_DrawTeamVote( void ) +{ char *s; int sec, cs_offset; - if ( cgs.clientinfo->team == TEAM_HUMANS ) + if( cgs.clientinfo->team == TEAM_HUMANS ) cs_offset = 0; - else if ( cgs.clientinfo->team == TEAM_ALIENS ) + else if( cgs.clientinfo->team == TEAM_ALIENS ) cs_offset = 1; else return; - if ( !cgs.teamVoteTime[cs_offset] ) { + if( !cgs.teamVoteTime[ cs_offset ] ) return; - } // play a talk beep whenever it is modified - if ( cgs.teamVoteModified[cs_offset] ) { - cgs.teamVoteModified[cs_offset] = qfalse; + if ( cgs.teamVoteModified[ cs_offset ] ) + { + cgs.teamVoteModified[ cs_offset ] = qfalse; trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); } - sec = ( VOTE_TIME - ( cg.time - cgs.teamVoteTime[cs_offset] ) ) / 1000; - if ( sec < 0 ) { + sec = ( VOTE_TIME - ( cg.time - cgs.teamVoteTime[ cs_offset ] ) ) / 1000; + + if( sec < 0 ) sec = 0; - } - s = va("TEAMVOTE(%i):%s yes:%i no:%i", sec, cgs.teamVoteString[cs_offset], - cgs.teamVoteYes[cs_offset], cgs.teamVoteNo[cs_offset] ); + + s = va( "TEAMVOTE(%i):%s yes:%i no:%i", sec, cgs.teamVoteString[ cs_offset ], + cgs.teamVoteYes[cs_offset], cgs.teamVoteNo[ cs_offset ] ); + CG_DrawSmallString( 0, 90, s, 1.0F ); } -static qboolean CG_DrawScoreboard() { - return CG_DrawOldScoreboard(); +static qboolean CG_DrawScoreboard( ) +{ + return CG_DrawOldScoreboard( ); } /* @@ -2067,14 +1805,16 @@ static qboolean CG_DrawScoreboard() { CG_DrawIntermission ================= */ -static void CG_DrawIntermission( void ) { - if ( cgs.gametype == GT_SINGLE_PLAYER ) { - CG_DrawCenterString(); +static void CG_DrawIntermission( void ) +{ + if( cgs.gametype == GT_SINGLE_PLAYER ) + { + CG_DrawCenterString( ); return; } cg.scoreFadeTime = cg.time; - cg.scoreBoardShowing = CG_DrawScoreboard(); + cg.scoreBoardShowing = CG_DrawScoreboard( ); } /* @@ -2082,18 +1822,19 @@ static void CG_DrawIntermission( void ) { CG_DrawFollow ================= */ -static qboolean CG_DrawFollow( void ) { - float x; - vec4_t color; +static qboolean CG_DrawFollow( void ) +{ + float x; + vec4_t color; const char *name; - if ( !(cg.snap->ps.pm_flags & PMF_FOLLOW) ) { + if( !( cg.snap->ps.pm_flags & PMF_FOLLOW ) ) return qfalse; - } - color[0] = 1; - color[1] = 1; - color[2] = 1; - color[3] = 1; + + color[ 0 ] = 1; + color[ 1 ] = 1; + color[ 2 ] = 1; + color[ 3 ] = 1; CG_DrawBigString( 320 - 9 * 8, 24, "following", 1.0F ); @@ -2114,11 +1855,11 @@ static qboolean CG_DrawFollow( void ) { CG_DrawAmmoWarning ================= */ -static void CG_DrawAmmoWarning( void ) { +static void CG_DrawAmmoWarning( void ) +{ const char *s; int w; - //TA: hack if( cg.snap->ps.weapon == WP_NONE ) return; @@ -2134,7 +1875,7 @@ static void CG_DrawAmmoWarning( void ) { s = "LOW AMMO WARNING"; w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; - CG_DrawBigString(320 - w / 2, 64, s, 1.0F); + CG_DrawBigString( 320 - w / 2, 64, s, 1.0F ); } /* @@ -2142,7 +1883,8 @@ static void CG_DrawAmmoWarning( void ) { CG_DrawWarmup ================= */ -static void CG_DrawWarmup( void ) { +static void CG_DrawWarmup( void ) +{ int w; int sec; int i; @@ -2152,108 +1894,122 @@ static void CG_DrawWarmup( void ) { const char *s; sec = cg.warmup; - if ( !sec ) { + if( !sec ) return; - } - if ( sec < 0 ) { + if( sec < 0 ) + { s = "Waiting for players"; w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; - CG_DrawBigString(320 - w / 2, 24, s, 1.0F); + CG_DrawBigString( 320 - w / 2, 24, s, 1.0F ); cg.warmupCount = 0; return; } - if (cgs.gametype == GT_TOURNAMENT) { + if( cgs.gametype == GT_TOURNAMENT ) + { // find the two active players ci1 = NULL; ci2 = NULL; - for ( i = 0 ; i < cgs.maxclients ; i++ ) { - if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_FREE ) { - if ( !ci1 ) { - ci1 = &cgs.clientinfo[i]; - } else { - ci2 = &cgs.clientinfo[i]; - } + + for( i = 0 ; i < cgs.maxclients ; i++ ) + { + if( cgs.clientinfo[ i ].infoValid && cgs.clientinfo[ i ].team == TEAM_FREE ) + { + if( !ci1 ) + ci1 = &cgs.clientinfo[ i ]; + else + ci2 = &cgs.clientinfo[ i ]; } } - if ( ci1 && ci2 ) { + if( ci1 && ci2 ) + { s = va( "%s vs %s", ci1->name, ci2->name ); w = CG_DrawStrlen( s ); - if ( w > 640 / GIANT_WIDTH ) { + if( w > 640 / GIANT_WIDTH ) cw = 640 / w; - } else { + else cw = GIANT_WIDTH; - } - CG_DrawStringExt( 320 - w * cw/2, 20,s, colorWhite, - qfalse, qtrue, cw, (int)(cw * 1.5f), 0 ); + + CG_DrawStringExt( 320 - w * cw / 2, 20,s, colorWhite, + qfalse, qtrue, cw, (int)( cw * 1.5f ), 0 ); } - } else { - if ( cgs.gametype == GT_FFA ) { + } + else + { + if( cgs.gametype == GT_FFA ) s = "Free For All"; - } else if ( cgs.gametype == GT_TEAM ) { + else if ( cgs.gametype == GT_TEAM ) s = "Team Deathmatch"; - } else if ( cgs.gametype == GT_CTF ) { + else if ( cgs.gametype == GT_CTF ) s = "Capture the Flag"; - } else { + else s = ""; - } + w = CG_DrawStrlen( s ); - if ( w > 640 / GIANT_WIDTH ) { + if( w > 640 / GIANT_WIDTH ) cw = 640 / w; - } else { + else cw = GIANT_WIDTH; - } - CG_DrawStringExt( 320 - w * cw/2, 25,s, colorWhite, - qfalse, qtrue, cw, (int)(cw * 1.1f), 0 ); + + CG_DrawStringExt( 320 - w * cw / 2, 25,s, colorWhite, + qfalse, qtrue, cw, (int)( cw * 1.1f ), 0 ); } sec = ( sec - cg.time ) / 1000; - if ( sec < 0 ) { + if( sec < 0 ) + { cg.warmup = 0; sec = 0; } + s = va( "Starts in: %i", sec + 1 ); - if ( sec != cg.warmupCount ) { + + if( sec != cg.warmupCount ) + { cg.warmupCount = sec; - switch ( sec ) { + switch( sec ) + { + case 0: + trap_S_StartLocalSound( cgs.media.count1Sound, CHAN_ANNOUNCER ); + break; + case 1: + trap_S_StartLocalSound( cgs.media.count2Sound, CHAN_ANNOUNCER ); + break; + case 2: + trap_S_StartLocalSound( cgs.media.count3Sound, CHAN_ANNOUNCER ); + break; + default: + break; + } + } + + scale = 0.45f; + + switch( cg.warmupCount ) + { case 0: - trap_S_StartLocalSound( cgs.media.count1Sound, CHAN_ANNOUNCER ); + cw = 28; + scale = 0.54f; break; case 1: - trap_S_StartLocalSound( cgs.media.count2Sound, CHAN_ANNOUNCER ); + cw = 24; + scale = 0.51f; break; case 2: - trap_S_StartLocalSound( cgs.media.count3Sound, CHAN_ANNOUNCER ); + cw = 20; + scale = 0.48f; break; default: + cw = 16; + scale = 0.45f; break; - } - } - scale = 0.45f; - switch ( cg.warmupCount ) { - case 0: - cw = 28; - scale = 0.54f; - break; - case 1: - cw = 24; - scale = 0.51f; - break; - case 2: - cw = 20; - scale = 0.48f; - break; - default: - cw = 16; - scale = 0.45f; - break; } w = CG_DrawStrlen( s ); - CG_DrawStringExt( 320 - w * cw/2, 70, s, colorWhite, - qfalse, qtrue, cw, (int)(cw * 1.5), 0 ); + CG_DrawStringExt( 320 - w * cw / 2, 70, s, colorWhite, + qfalse, qtrue, cw, (int)( cw * 1.5 ), 0 ); } //================================================================================== @@ -2263,50 +2019,46 @@ static void CG_DrawWarmup( void ) { CG_Draw2D ================= */ -static void CG_Draw2D( void ) { +static void CG_Draw2D( void ) +{ // if we are taking a levelshot for the menu, don't draw anything - if ( cg.levelShot ) { + if( cg.levelShot ) return; - } - if ( cg_draw2D.integer == 0 ) { + if( cg_draw2D.integer == 0 ) return; - } - if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { - CG_DrawIntermission(); + if( cg.snap->ps.pm_type == PM_INTERMISSION ) + { + CG_DrawIntermission( ); return; } //TA: draw the lighting effects e.g. nvg - CG_DrawLighting(); + CG_DrawLighting( ); - if( ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) || - ( cg.snap->ps.stats[ STAT_STATE ] & SS_INFESTING ) || - ( cg.snap->ps.stats[ STAT_STATE ] & SS_HOVELING ) ) - { - CG_DrawSpectator(); - CG_DrawCrosshair(); - CG_DrawCrosshairNames(); - } - else + if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) + CG_DrawBigString(320 - 9 * 8, 440, "SPECTATOR", 1.0F); + else if( !( cg.snap->ps.stats[ STAT_STATE ] & SS_INFESTING ) && + !( cg.snap->ps.stats[ STAT_STATE ] & SS_HOVELING ) ) { // don't draw any status if dead or the scoreboard is being explicitly shown - if ( !cg.showScores && cg.snap->ps.stats[STAT_HEALTH] > 0 ) { - CG_DrawStatusBar(); + if( !cg.showScores && cg.snap->ps.stats[ STAT_HEALTH ] > 0 ) + { + if( cg_drawStatus.integer ) + { + Menu_PaintAll(); + /*CG_DrawTimedMenus();*/ + } + CG_DrawAmmoWarning(); CG_DrawCrosshair(); - CG_DrawCrosshairNames(); CG_DrawWeaponSelect(); - CG_DrawHoldableItem(); - CG_DrawReward(); - } - if ( cgs.gametype >= GT_TEAM ) { - CG_DrawTeamInfo(); + + if( BG_gotItem( UP_HELMET, cg.snap->ps.stats ) ) + CG_Scanner( ); } - if( BG_gotItem( UP_HELMET, cg.snap->ps.stats ) ) - CG_Scanner( ); } CG_DrawVote(); @@ -2316,23 +2068,19 @@ static void CG_Draw2D( void ) { CG_DrawUpperRight(); - CG_DrawLowerRight(); - - CG_DrawLowerLeft(); - - if ( !CG_DrawFollow() ) { + if( !CG_DrawFollow( ) ) CG_DrawWarmup(); - } // don't draw center string if scoreboard is up - cg.scoreBoardShowing = CG_DrawScoreboard(); - if ( !cg.scoreBoardShowing) { - CG_DrawCenterString(); - } + cg.scoreBoardShowing = CG_DrawScoreboard( ); + + if( !cg.scoreBoardShowing ) + CG_DrawCenterString( ); } -static void CG_DrawTourneyScoreboard() { +static void CG_DrawTourneyScoreboard( ) +{ CG_DrawOldTourneyScoreboard(); } @@ -2344,59 +2092,61 @@ CG_DrawActive Perform all drawing needed to completely fill the screen ===================== */ -void CG_DrawActive( stereoFrame_t stereoView ) { +void CG_DrawActive( stereoFrame_t stereoView ) +{ float separation; vec3_t baseOrg; // optionally draw the info screen instead - if ( !cg.snap ) { - CG_DrawInformation(); + if( !cg.snap ) + { + CG_DrawInformation( ); return; } // optionally draw the tournement scoreboard instead - if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR && - ( cg.snap->ps.pm_flags & PMF_SCOREBOARD ) ) { - CG_DrawTourneyScoreboard(); + if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR && + ( cg.snap->ps.pm_flags & PMF_SCOREBOARD ) ) + { + CG_DrawTourneyScoreboard( ); return; } - switch ( stereoView ) { - case STEREO_CENTER: - separation = 0; - break; - case STEREO_LEFT: - separation = -cg_stereoSeparation.value / 2; - break; - case STEREO_RIGHT: - separation = cg_stereoSeparation.value / 2; - break; - default: - separation = 0; - CG_Error( "CG_DrawActive: Undefined stereoView" ); + switch ( stereoView ) + { + case STEREO_CENTER: + separation = 0; + break; + case STEREO_LEFT: + separation = -cg_stereoSeparation.value / 2; + break; + case STEREO_RIGHT: + separation = cg_stereoSeparation.value / 2; + break; + default: + separation = 0; + CG_Error( "CG_DrawActive: Undefined stereoView" ); } - // clear around the rendered view if sized down - CG_TileClear(); + CG_TileClear( ); // offset vieworg appropriately if we're doing stereo separation VectorCopy( cg.refdef.vieworg, baseOrg ); - if ( separation != 0 ) { - VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg ); - } + + if( separation != 0 ) + VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[ 1 ], + cg.refdef.vieworg ); // draw 3D view trap_R_RenderScene( &cg.refdef ); // restore original viewpoint if running stereo - if ( separation != 0 ) { + if( separation != 0 ) VectorCopy( baseOrg, cg.refdef.vieworg ); - } // draw status bar and other floating elements - CG_Draw2D(); + CG_Draw2D( ); } - diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 5ffedbd6..e497fc83 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -24,6 +24,7 @@ // If you absolutely need something stored, it can either be kept // by the server in the server stored userinfos, or stashed in a cvar. +#define CG_FONT_THRESHOLD 0.1 #define POWERUP_BLINKS 5 @@ -1715,12 +1716,11 @@ int trap_Key_GetCatcher( void ); void trap_Key_SetCatcher( int catcher ); int trap_Key_GetKey( const char *binding ); -//TA: um... -//typedef enum { -// SYSTEM_PRINT, -// CHAT_PRINT, -// TEAMCHAT_PRINT -//}; +typedef enum { + SYSTEM_PRINT, + CHAT_PRINT, + TEAMCHAT_PRINT +} q3print_t; int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits); diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 0c65371b..384ef030 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -17,6 +17,10 @@ #include "cg_local.h" +#include "../ui/ui_shared.h" +// display context for new ui stuff +displayContextDef_t cgDC; + int forceModelModificationCount = -1; void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ); @@ -51,6 +55,8 @@ int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int a CG_KeyEvent(arg0, arg1); return 0; case CG_MOUSE_EVENT: + cgDC.cursorx = cgs.cursorX; + cgDC.cursory = cgs.cursorY; CG_MouseEvent(arg0, arg1); return 0; case CG_EVENT_HANDLING: @@ -974,6 +980,659 @@ void CG_StartMusic( void ) { trap_S_StartBackgroundTrack( parm1, parm2 ); } +//TA: FIXME: preliminary integration of CG TA UI stuff +// +// ============================== +// new hud stuff ( mission pack ) +// ============================== +// +char *CG_GetMenuBuffer(const char *filename) { + int len; + fileHandle_t f; + static char buf[MAX_MENUFILE]; + + len = trap_FS_FOpenFile( filename, &f, FS_READ ); + if ( !f ) { + trap_Print( va( S_COLOR_RED "menu file not found: %s, using default\n", filename ) ); + return NULL; + } + if ( len >= MAX_MENUFILE ) { + trap_Print( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", filename, len, MAX_MENUFILE ) ); + trap_FS_FCloseFile( f ); + return NULL; + } + + trap_FS_Read( buf, len, f ); + buf[len] = 0; + trap_FS_FCloseFile( f ); + + return buf; +} + +qboolean CG_Asset_Parse(int handle) { + pc_token_t token; + const char *tempStr; + + if (!trap_PC_ReadToken(handle, &token)) + return qfalse; + if (Q_stricmp(token.string, "{") != 0) { + return qfalse; + } + + while ( 1 ) { + if (!trap_PC_ReadToken(handle, &token)) + return qfalse; + + if (Q_stricmp(token.string, "}") == 0) { + return qtrue; + } + + // font + if (Q_stricmp(token.string, "font") == 0) { + int pointSize; + if (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle, &pointSize)) { + return qfalse; + } + cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.textFont); + continue; + } + + // smallFont + if (Q_stricmp(token.string, "smallFont") == 0) { + int pointSize; + if (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle, &pointSize)) { + return qfalse; + } + cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.smallFont); + continue; + } + + // font + if (Q_stricmp(token.string, "bigfont") == 0) { + int pointSize; + if (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle, &pointSize)) { + return qfalse; + } + cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.bigFont); + continue; + } + + // gradientbar + if (Q_stricmp(token.string, "gradientbar") == 0) { + if (!PC_String_Parse(handle, &tempStr)) { + return qfalse; + } + cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip(tempStr); + continue; + } + + // enterMenuSound + if (Q_stricmp(token.string, "menuEnterSound") == 0) { + if (!PC_String_Parse(handle, &tempStr)) { + return qfalse; + } + cgDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr, qfalse ); + continue; + } + + // exitMenuSound + if (Q_stricmp(token.string, "menuExitSound") == 0) { + if (!PC_String_Parse(handle, &tempStr)) { + return qfalse; + } + cgDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr, qfalse ); + continue; + } + + // itemFocusSound + if (Q_stricmp(token.string, "itemFocusSound") == 0) { + if (!PC_String_Parse(handle, &tempStr)) { + return qfalse; + } + cgDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr, qfalse ); + continue; + } + + // menuBuzzSound + if (Q_stricmp(token.string, "menuBuzzSound") == 0) { + if (!PC_String_Parse(handle, &tempStr)) { + return qfalse; + } + cgDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr, qfalse ); + continue; + } + + if (Q_stricmp(token.string, "cursor") == 0) { + if (!PC_String_Parse(handle, &cgDC.Assets.cursorStr)) { + return qfalse; + } + cgDC.Assets.cursor = trap_R_RegisterShaderNoMip( cgDC.Assets.cursorStr); + continue; + } + + if (Q_stricmp(token.string, "fadeClamp") == 0) { + if (!PC_Float_Parse(handle, &cgDC.Assets.fadeClamp)) { + return qfalse; + } + continue; + } + + if (Q_stricmp(token.string, "fadeCycle") == 0) { + if (!PC_Int_Parse(handle, &cgDC.Assets.fadeCycle)) { + return qfalse; + } + continue; + } + + if (Q_stricmp(token.string, "fadeAmount") == 0) { + if (!PC_Float_Parse(handle, &cgDC.Assets.fadeAmount)) { + return qfalse; + } + continue; + } + + if (Q_stricmp(token.string, "shadowX") == 0) { + if (!PC_Float_Parse(handle, &cgDC.Assets.shadowX)) { + return qfalse; + } + continue; + } + + if (Q_stricmp(token.string, "shadowY") == 0) { + if (!PC_Float_Parse(handle, &cgDC.Assets.shadowY)) { + return qfalse; + } + continue; + } + + if (Q_stricmp(token.string, "shadowColor") == 0) { + if (!PC_Color_Parse(handle, &cgDC.Assets.shadowColor)) { + return qfalse; + } + cgDC.Assets.shadowFadeClamp = cgDC.Assets.shadowColor[3]; + continue; + } + } + return qfalse; // bk001204 - why not? +} + +void CG_ParseMenu(const char *menuFile) { + pc_token_t token; + int handle; + + handle = trap_PC_LoadSource(menuFile); + if (!handle) + handle = trap_PC_LoadSource("ui/testhud.menu"); + if (!handle) + return; + + while ( 1 ) { + if (!trap_PC_ReadToken( handle, &token )) { + break; + } + + //if ( Q_stricmp( token, "{" ) ) { + // Com_Printf( "Missing { in menu file\n" ); + // break; + //} + + //if ( menuCount == MAX_MENUS ) { + // Com_Printf( "Too many menus!\n" ); + // break; + //} + + if ( token.string[0] == '}' ) { + break; + } + + if (Q_stricmp(token.string, "assetGlobalDef") == 0) { + if (CG_Asset_Parse(handle)) { + continue; + } else { + break; + } + } + + + if (Q_stricmp(token.string, "menudef") == 0) { + // start a new menu + Menu_New(handle); + } + } + trap_PC_FreeSource(handle); +} + +qboolean CG_Load_Menu(char **p) { + char *token; + + token = COM_ParseExt(p, qtrue); + + if (token[0] != '{') { + return qfalse; + } + + while ( 1 ) { + + token = COM_ParseExt(p, qtrue); + + if (Q_stricmp(token, "}") == 0) { + return qtrue; + } + + if ( !token || token[0] == 0 ) { + return qfalse; + } + + CG_ParseMenu(token); + } + return qfalse; +} + + + +void CG_LoadMenus(const char *menuFile) { + char *token; + char *p; + int len, start; + fileHandle_t f; + static char buf[MAX_MENUDEFFILE]; + + start = trap_Milliseconds(); + + len = trap_FS_FOpenFile( menuFile, &f, FS_READ ); + if ( !f ) { + trap_Error( va( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ) ); + len = trap_FS_FOpenFile( "ui/hud.txt", &f, FS_READ ); + if (!f) { + trap_Error( va( S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n", menuFile ) ); + } + } + + if ( len >= MAX_MENUDEFFILE ) { + trap_Error( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", menuFile, len, MAX_MENUDEFFILE ) ); + trap_FS_FCloseFile( f ); + return; + } + + trap_FS_Read( buf, len, f ); + buf[len] = 0; + trap_FS_FCloseFile( f ); + + COM_Compress(buf); + + Menu_Reset(); + + p = buf; + + while ( 1 ) { + token = COM_ParseExt( &p, qtrue ); + if( !token || token[0] == 0 || token[0] == '}') { + break; + } + + //if ( Q_stricmp( token, "{" ) ) { + // Com_Printf( "Missing { in menu file\n" ); + // break; + //} + + //if ( menuCount == MAX_MENUS ) { + // Com_Printf( "Too many menus!\n" ); + // break; + //} + + if ( Q_stricmp( token, "}" ) == 0 ) { + break; + } + + if (Q_stricmp(token, "loadmenu") == 0) { + if (CG_Load_Menu(&p)) { + continue; + } else { + break; + } + } + } + + Com_Printf("UI menu load time = %d milli seconds\n", trap_Milliseconds() - start); + +} + + + +static qboolean CG_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, int key) { + return qfalse; +} + + +static int CG_FeederCount(float feederID) { + int i, count; + count = 0; +/* if (feederID == FEEDER_REDTEAM_LIST) { + for (i = 0; i < cg.numScores; i++) { + if (cg.scores[i].team == TEAM_RED) { + count++; + } + } + } else if (feederID == FEEDER_BLUETEAM_LIST) { + for (i = 0; i < cg.numScores; i++) { + if (cg.scores[i].team == TEAM_BLUE) { + count++; + } + } + } else if (feederID == FEEDER_SCOREBOARD) { + return cg.numScores; + }*/ + return count; +} + + +void CG_SetScoreSelection(void *p) { + menuDef_t *menu = (menuDef_t*)p; + playerState_t *ps = &cg.snap->ps; + int i, red, blue; + red = blue = 0; +/* for (i = 0; i < cg.numScores; i++) { + if (cg.scores[i].team == TEAM_RED) { + red++; + } else if (cg.scores[i].team == TEAM_BLUE) { + blue++; + } + if (ps->clientNum == cg.scores[i].client) { + cg.selectedScore = i; + } + }*/ + + if (menu == NULL) { + // just interested in setting the selected score + return; + } + + if ( cgs.gametype >= GT_TEAM ) { + int feeder = FEEDER_REDTEAM_LIST; + i = red; +/* if (cg.scores[cg.selectedScore].team == TEAM_BLUE) { + feeder = FEEDER_BLUETEAM_LIST; + i = blue; + }*/ + Menu_SetFeederSelection(menu, feeder, i, NULL); + } else { + Menu_SetFeederSelection(menu, FEEDER_SCOREBOARD, cg.selectedScore, NULL); + } +} + +// FIXME: might need to cache this info +static clientInfo_t * CG_InfoFromScoreIndex(int index, int team, int *scoreIndex) { + int i, count; + if ( cgs.gametype >= GT_TEAM ) { + count = 0; + for (i = 0; i < cg.numScores; i++) { + if (cg.scores[i].team == team) { + if (count == index) { + *scoreIndex = i; + return &cgs.clientinfo[cg.scores[i].client]; + } + count++; + } + } + } + *scoreIndex = index; + return &cgs.clientinfo[ cg.scores[index].client ]; +} + +static const char *CG_FeederItemText(float feederID, int index, int column, qhandle_t *handle) { + gitem_t *item; + int scoreIndex = 0; + clientInfo_t *info = NULL; + int team = -1; + score_t *sp = NULL; + + *handle = -1; + + if (feederID == FEEDER_REDTEAM_LIST) { + /*team = TEAM_RED;*/ + } else if (feederID == FEEDER_BLUETEAM_LIST) { + /*team = TEAM_BLUE;*/ + } + + info = CG_InfoFromScoreIndex(index, team, &scoreIndex); + sp = &cg.scores[scoreIndex]; + + if (info && info->infoValid) { + switch (column) { + case 0: +/* if ( info->powerups & ( 1 << PW_NEUTRALFLAG ) ) { + item = BG_FindItemForPowerup( PW_NEUTRALFLAG ); + *handle = cg_items[ ITEM_INDEX(item) ].icon; + } else if ( info->powerups & ( 1 << PW_REDFLAG ) ) { + item = BG_FindItemForPowerup( PW_REDFLAG ); + *handle = cg_items[ ITEM_INDEX(item) ].icon; + } else if ( info->powerups & ( 1 << PW_BLUEFLAG ) ) { + item = BG_FindItemForPowerup( PW_BLUEFLAG ); + *handle = cg_items[ ITEM_INDEX(item) ].icon; + } else { + if ( info->botSkill > 0 && info->botSkill <= 5 ) { + *handle = cgs.media.botSkillShaders[ info->botSkill - 1 ]; + } else if ( info->handicap < 100 ) { + return va("%i", info->handicap ); + } + }*/ + break; + case 1: + if (team == -1) { + return ""; + } else { + /**handle = CG_StatusHandle(info->teamTask);*/ + } + break; + case 2: +/* if ( cg.snap->ps.stats[ STAT_CLIENTS_READY ] & ( 1 << sp->client ) ) { + return "Ready"; + } + if (team == -1) { + if (cgs.gametype == GT_TOURNAMENT) { + return va("%i/%i", info->wins, info->losses); + } else if (info->infoValid && info->team == TEAM_SPECTATOR ) { + return "Spectator"; + } else { + return ""; + } + } else { + if (info->teamLeader) { + return "Leader"; + } + }*/ + break; + case 3: + return info->name; + break; + case 4: + return va("%i", info->score); + break; + case 5: + return va("%4i", sp->time); + break; + case 6: + if ( sp->ping == -1 ) { + return "connecting"; + } + return va("%4i", sp->ping); + break; + } + } + + return ""; +} + +static qhandle_t CG_FeederItemImage(float feederID, int index) { + return 0; +} + +static void CG_FeederSelection(float feederID, int index) { +/* if ( cgs.gametype >= GT_TEAM ) { + int i, count; + int team = (feederID == FEEDER_REDTEAM_LIST) ? TEAM_RED : TEAM_BLUE; + count = 0; + for (i = 0; i < cg.numScores; i++) { + if (cg.scores[i].team == team) { + if (index == count) { + cg.selectedScore = i; + } + count++; + } + } + } else { + cg.selectedScore = index; + }*/ +} + +static float CG_Cvar_Get(const char *cvar) { + char buff[128]; + memset(buff, 0, sizeof(buff)); + trap_Cvar_VariableStringBuffer(cvar, buff, sizeof(buff)); + return atof(buff); +} + +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); +} + +static int CG_OwnerDrawWidth(int ownerDraw, float scale) { + switch (ownerDraw) { +/* case CG_GAME_TYPE: + return CG_Text_Width(CG_GameTypeString(), scale, 0);*/ +/* case CG_GAME_STATUS: + return CG_Text_Width(CG_GetGameStatusText(), scale, 0); + break;*/ + case CG_KILLER: + return CG_Text_Width(CG_GetKillerText(), scale, 0); + break; +/* case CG_RED_NAME: + return CG_Text_Width(cg_redTeamName.string, scale, 0); + break; + case CG_BLUE_NAME: + return CG_Text_Width(cg_blueTeamName.string, scale, 0); + break;*/ + + + } + return 0; +} + +static int CG_PlayCinematic(const char *name, float x, float y, float w, float h) { + return trap_CIN_PlayCinematic(name, x, y, w, h, CIN_loop); +} + +static void CG_StopCinematic(int handle) { + trap_CIN_StopCinematic(handle); +} + +static void CG_DrawCinematic(int handle, float x, float y, float w, float h) { + trap_CIN_SetExtents(handle, x, y, w, h); + trap_CIN_DrawCinematic(handle); +} + +static void CG_RunCinematicFrame(int handle) { + trap_CIN_RunCinematic(handle); +} + +/* +================= +CG_LoadHudMenu(); + +================= +*/ +void CG_LoadHudMenu() { + char buff[1024]; + const char *hudSet; + + 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.registerModel = &trap_R_RegisterModel; + cgDC.modelBounds = &trap_R_ModelBounds; + cgDC.fillRect = &CG_FillRect; + cgDC.drawRect = &CG_DrawRect; + cgDC.drawSides = &CG_DrawSides; + cgDC.drawTopBottom = &CG_DrawTopBottom; + cgDC.clearScene = &trap_R_ClearScene; + cgDC.addRefEntityToScene = &trap_R_AddRefEntityToScene; + cgDC.renderScene = &trap_R_RenderScene; + cgDC.registerFont = &trap_R_RegisterFont; + cgDC.ownerDrawItem = &CG_OwnerDraw; + cgDC.getValue = &CG_GetValue; + cgDC.ownerDrawVisible = NULL; //&CG_OwnerDrawVisible; + cgDC.runScript = &CG_RunMenuScript; + cgDC.getTeamColor = &CG_GetTeamColor; + 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; + cgDC.ownerDrawHandleKey = &CG_OwnerDrawHandleKey; + cgDC.feederCount = &CG_FeederCount; + cgDC.feederItemImage = &CG_FeederItemImage; + cgDC.feederItemText = &CG_FeederItemText; + cgDC.feederSelection = &CG_FeederSelection; + //cgDC.setBinding = &trap_Key_SetBinding; + //cgDC.getBindingBuf = &trap_Key_GetBindingBuf; + //cgDC.keynumToStringBuf = &trap_Key_KeynumToStringBuf; + //cgDC.executeText = &trap_Cmd_ExecuteText; + cgDC.Error = &Com_Error; + cgDC.Print = &Com_Printf; + cgDC.ownerDrawWidth = &CG_OwnerDrawWidth; + //cgDC.Pause = &CG_Pause; + cgDC.registerSound = &trap_S_RegisterSound; + cgDC.startBackgroundTrack = &trap_S_StartBackgroundTrack; + cgDC.stopBackgroundTrack = &trap_S_StopBackgroundTrack; + cgDC.playCinematic = &CG_PlayCinematic; + cgDC.stopCinematic = &CG_StopCinematic; + cgDC.drawCinematic = &CG_DrawCinematic; + cgDC.runCinematicFrame = &CG_RunCinematicFrame; + + Init_Display(&cgDC); + + Menu_Reset(); + + trap_Cvar_VariableStringBuffer("cg_hudFiles", buff, sizeof(buff)); + hudSet = buff; + if (hudSet[0] == '\0') { + hudSet = "ui/hud.txt"; + } + + CG_LoadMenus(hudSet); +} + +void CG_AssetCache() { + //if (Assets.textFont == NULL) { + // trap_R_RegisterFont("fonts/arial.ttf", 72, &Assets.textFont); + //} + //Assets.background = trap_R_RegisterShaderNoMip( ASSET_BACKGROUND ); + //Com_Printf("Menu Size: %i bytes\n", sizeof(Menus)); + cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR ); + cgDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE ); + cgDC.Assets.fxPic[0] = trap_R_RegisterShaderNoMip( ART_FX_RED ); + cgDC.Assets.fxPic[1] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW ); + cgDC.Assets.fxPic[2] = trap_R_RegisterShaderNoMip( ART_FX_GREEN ); + cgDC.Assets.fxPic[3] = trap_R_RegisterShaderNoMip( ART_FX_TEAL ); + cgDC.Assets.fxPic[4] = trap_R_RegisterShaderNoMip( ART_FX_BLUE ); + cgDC.Assets.fxPic[5] = trap_R_RegisterShaderNoMip( ART_FX_CYAN ); + cgDC.Assets.fxPic[6] = trap_R_RegisterShaderNoMip( ART_FX_WHITE ); + cgDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR ); + cgDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN ); + cgDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP ); + cgDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT ); + cgDC.Assets.scrollBarArrowRight = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT ); + cgDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB ); + cgDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR ); + cgDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB ); +} +//TA: FIXME: preliminary integration of CG TA UI stuff /* ================= @@ -990,7 +1649,6 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) { memset( &cgs, 0, sizeof( cgs ) ); memset( &cg, 0, sizeof( cg ) ); memset( cg_entities, 0, sizeof(cg_entities) ); - memset( cg_upgrades, 0, sizeof(cg_upgrades) ); memset( cg_items, 0, sizeof(cg_items) ); cg.clientNum = clientNum; @@ -1044,6 +1702,8 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) { trap_CM_LoadMap( cgs.mapname ); + String_Init(); + cg.loading = qtrue; // force players to load instead of defer CG_LoadingString( "sounds" ); @@ -1063,6 +1723,10 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) { CG_RegisterClients(); // if low on memory, some clients will be deferred + //TA: FIXME: TA UI + CG_AssetCache(); + CG_LoadHudMenu(); // load new hud stuff + cg.loading = qfalse; // future players will be deferred CG_InitLocalEntities(); @@ -1105,7 +1769,7 @@ CG_EventHandling 2 - hud editor */ -void CG_EventHandling(int type) { +/*void CG_EventHandling(int type) { } @@ -1115,4 +1779,4 @@ void CG_KeyEvent(int key, qboolean down) { void CG_MouseEvent(int x, int y) { } - +*/ diff --git a/ui/menudef.h b/ui/menudef.h index bedefc46..3049250f 100644 --- a/ui/menudef.h +++ b/ui/menudef.h @@ -123,26 +123,27 @@ // ideally these should be done outside of this file but // this makes it much easier for the macro expansion to // convert them for the designers ( from the .menu files ) -#define CG_OWNERDRAW_BASE 1 -#define CG_PLAYER_ARMOR_ICON 1 -#define CG_PLAYER_ARMOR_VALUE 2 -#define CG_PLAYER_HEAD 3 -#define CG_PLAYER_HEALTH 4 -#define CG_PLAYER_AMMO_ICON 5 -#define CG_PLAYER_AMMO_VALUE 6 -#define CG_SELECTEDPLAYER_HEAD 7 -#define CG_SELECTEDPLAYER_NAME 8 -#define CG_SELECTEDPLAYER_LOCATION 9 -#define CG_SELECTEDPLAYER_STATUS 10 -#define CG_SELECTEDPLAYER_WEAPON 11 -#define CG_SELECTEDPLAYER_POWERUP 12 +#define CG_OWNERDRAW_BASE 1 +#define CG_PLAYER_ARMOR_ICON 1 +#define CG_PLAYER_ARMOR_VALUE 2 +#define CG_PLAYER_HEAD 3 +#define CG_PLAYER_HEALTH 4 +#define CG_PLAYER_AMMO_ICON 5 +#define CG_PLAYER_AMMO_VALUE 6 +#define CG_PLAYER_CLIPS_VALUE 70 +#define CG_SELECTEDPLAYER_HEAD 7 +#define CG_SELECTEDPLAYER_NAME 8 +#define CG_SELECTEDPLAYER_LOCATION 9 +#define CG_SELECTEDPLAYER_STATUS 10 +#define CG_SELECTEDPLAYER_WEAPON 11 +#define CG_SELECTEDPLAYER_POWERUP 12 -#define CG_FLAGCARRIER_HEAD 13 -#define CG_FLAGCARRIER_NAME 14 -#define CG_FLAGCARRIER_LOCATION 15 -#define CG_FLAGCARRIER_STATUS 16 -#define CG_FLAGCARRIER_WEAPON 17 -#define CG_FLAGCARRIER_POWERUP 18 +#define CG_FLAGCARRIER_HEAD 13 +#define CG_FLAGCARRIER_NAME 14 +#define CG_FLAGCARRIER_LOCATION 15 +#define CG_FLAGCARRIER_STATUS 16 +#define CG_FLAGCARRIER_WEAPON 17 +#define CG_FLAGCARRIER_POWERUP 18 #define CG_PLAYER_ITEM 19 #define CG_PLAYER_SCORE 20 |