diff options
-rw-r--r-- | src/cgame/cg_draw.c | 826 | ||||
-rw-r--r-- | src/cgame/cg_event.c | 4 | ||||
-rw-r--r-- | src/cgame/cg_weapons.c | 14 | ||||
-rw-r--r-- | src/game/bg_misc.c | 1 | ||||
-rw-r--r-- | src/game/bg_public.h | 1 | ||||
-rw-r--r-- | src/game/g_cmds.c | 25 | ||||
-rw-r--r-- | ui/menudef.h | 6 |
7 files changed, 454 insertions, 423 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 25a62b85..74b5dc61 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -1030,309 +1030,6 @@ static void CG_DrawTeamSpectators( rectDef_t *rect, float scale, vec4_t color, q cg.spectatorPaintX2 = -1; } } -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; - - if( cg_drawStatus.integer == 0 ) - return; - - rect.x = x; - rect.y = y; - rect.w = w; - rect.h = h; - - switch( ownerDraw ) - { - case CG_PLAYER_CREDITS_VALUE: - CG_DrawPlayerCreditsValue( &rect, color ); - break; - case CG_PLAYER_BANK_VALUE: - CG_DrawPlayerBankValue( &rect, color ); - break; - case CG_PLAYER_STAMINA: - CG_DrawPlayerStamina( &rect ); - break; - case CG_PLAYER_AMMO_VALUE: - CG_DrawPlayerAmmoValue( &rect, color ); - break; - case CG_PLAYER_CLIPS_VALUE: - CG_DrawPlayerClipsValue( &rect, color ); - break; - case CG_PLAYER_HEALTH: - CG_DrawPlayerHealth( &rect, color ); - 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; - case CG_PLAYER_SELECT: - CG_DrawWeaponSelect( &rect ); - break; - case CG_PLAYER_SELECTTEXT: - CG_DrawWeaponSelectText( &rect, scale, textStyle ); - break; - case CG_SPECTATORS: - CG_DrawTeamSpectators( &rect, scale, color, shader ); - break; - - //loading screen - case CG_LOAD_LEVELSHOT: - CG_DrawLevelShot( &rect ); - break; - case CG_LOAD_MEDIA: - CG_DrawMediaProgress( &rect, color, scale, align, textStyle ); - break; - case CG_LOAD_MEDIA_LABEL: - CG_DrawMediaProgressLabel( &rect, text_x, text_y, color, scale, align ); - break; - case CG_LOAD_BUILDABLES: - CG_DrawBuildablesProgress( &rect, color, scale, align, textStyle ); - break; - case CG_LOAD_BUILDABLES_LABEL: - CG_DrawBuildablesProgressLabel( &rect, text_x, text_y, color, scale, align ); - break; - case CG_LOAD_CHARMODEL: - CG_DrawCharModelProgress( &rect, color, scale, align, textStyle ); - break; - case CG_LOAD_CHARMODEL_LABEL: - CG_DrawCharModelProgressLabel( &rect, text_x, text_y, color, scale, align ); - break; - case CG_LOAD_OVERALL: - CG_DrawOverallProgress( &rect, color, scale, align, textStyle ); - break; - case CG_LOAD_LEVELNAME: - CG_DrawLevelName( &rect, text_x, text_y, color, scale, align, textStyle ); - break; - case CG_LOAD_MOTD: - CG_DrawMOTD( &rect, text_x, text_y, color, scale, align, textStyle ); - break; - case CG_LOAD_HOSTNAME: - CG_DrawHostname( &rect, text_x, text_y, color, scale, align, textStyle ); - break; - default: - break; - } -} - -void CG_MouseEvent( int x, int y ) -{ - int n; - - if( ( cg.predictedPlayerState.pm_type == PM_NORMAL || - cg.predictedPlayerState.pm_type == PM_SPECTATOR ) && - cg.showScores == qfalse ) - { - trap_Key_SetCatcher( 0 ); - return; - } - - cgs.cursorX += x; - if( cgs.cursorX < 0 ) - cgs.cursorX = 0; - else if( cgs.cursorX > 640 ) - cgs.cursorX = 640; - - cgs.cursorY += y; - if( cgs.cursorY < 0 ) - cgs.cursorY = 0; - else if( cgs.cursorY > 480 ) - cgs.cursorY = 480; - - 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; - - if( cgs.capturedItem ) - Display_MouseMove( cgs.capturedItem, x, y ); - else - Display_MouseMove( NULL, cgs.cursorX, cgs.cursorY ); -} - -/* -================== -CG_HideTeamMenus -================== - -*/ -void CG_HideTeamMenu( ) -{ - Menus_CloseByName( "teamMenu" ); - Menus_CloseByName( "getMenu" ); -} - -/* -================== -CG_ShowTeamMenus -================== - -*/ -void CG_ShowTeamMenu( ) -{ - Menus_OpenByName("teamMenu"); -} - -/* -================== -CG_EventHandling -================== - type 0 - no event handling - 1 - team menu - 2 - hud editor - -*/ -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 ) - { - - } -} - - - -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; - } - - 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 ); - } -} - -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; -} - -void CG_ShowResponseHead( ) -{ - Menus_OpenByName( "voiceMenu" ); - trap_Cvar_Set( "cl_conXOffset", "72" ); - cg.voiceTime = cg.time; -} - -void CG_RunMenuScript( char **args ) -{ -} - - -void CG_GetTeamColor(vec4_t *color) -{ - (*color)[0] = (*color)[2] = 0.0f; - (*color)[1] = 0.17f; - (*color)[3] = 0.25f; -} -//END TA UI - - -/* -================ -CG_DrawLighting - -================ -*/ -static void CG_DrawLighting( void ) -{ - centity_t *cent; - - cent = &cg_entities[cg.snap->ps.clientNum]; - - if( cg.snap->ps.stats[ STAT_PCLASS ] == PCL_H_BASE ) - { - 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 - if( ( cg.snap->ps.stats[ STAT_STAMINA ] < -800 ) && - ( cg.snap->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) ) - { - vec4_t black = { 0, 0, 0, 0 }; - black[ 3 ] = 1.0 - ( (float)( cg.snap->ps.stats[ STAT_STAMINA ] + 1000 ) / 200.0f ); - trap_R_SetColor( black ); - CG_DrawPic( 0, 0, 640, 480, cgs.media.whiteShader ); - trap_R_SetColor( NULL ); - } -} - -/* -=========================================================================================== - - UPPER RIGHT CORNER - -=========================================================================================== -*/ - -/* -================== -CG_DrawSnapshot -================== -*/ -static float CG_DrawSnapshot( float y ) -{ - char *s; - int w; - - s = va( "time:%d snap:%d cmd:%d", cg.snap->serverTime, - cg.latestSnapshotNum, cgs.serverCommandSequence ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; - - CG_DrawBigString( 635 - w, y + 2, s, 1.0F); - - return y + BIGCHAR_HEIGHT + 4; -} /* ================== @@ -1341,10 +1038,12 @@ CG_DrawFPS */ //TA: personally i think this should be longer - it should really be a cvar #define FPS_FRAMES 40 -static float CG_DrawFPS( float y ) +#define FPS_STRING "fps" +static void CG_DrawFPS( rectDef_t *rect, float text_x, float text_y, + float scale, vec4_t color, int align, int textStyle ) { char *s; - int w; + int tx, w, totalWidth, strLength; static int previousTimes[ FPS_FRAMES ]; static int index; int i, total; @@ -1352,6 +1051,9 @@ static float CG_DrawFPS( float y ) static int previous; int t, frameTime; + if( !cg_drawFPS.integer ) + return; + // don't use serverTime, because that will be drifting to // correct for internet lag changes, timescales, timedemos, etc t = trap_Milliseconds( ); @@ -1374,27 +1076,60 @@ static float CG_DrawFPS( float y ) fps = 1000 * FPS_FRAMES / total; - s = va( "%dfps", fps ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; + s = va( "%d", fps ); + w = CG_Text_Width( "0", scale, 0 ); + strLength = CG_DrawStrlen( s ); + totalWidth = CG_Text_Width( FPS_STRING, scale, 0 ) + w * strLength; + + switch( align ) + { + case ITEM_ALIGN_LEFT: + tx = rect->x; + break; - CG_DrawBigString( 635 - w, y + 2, s, 1.0F ); - } + case ITEM_ALIGN_RIGHT: + tx = rect->x + rect->w - totalWidth; + break; + + case ITEM_ALIGN_CENTER: + tx = rect->x + ( rect->w / 2.0f ) - ( totalWidth / 2.0f ); + break; - return y + BIGCHAR_HEIGHT + 4; + default: + tx = 0.0f; + } + + for( i = 0; i < strLength; i++ ) + { + char c[ 2 ]; + + c[ 0 ] = s[ i ]; + c[ 1 ] = '\0'; + + CG_Text_Paint( text_x + tx + i * w, rect->y + text_y, scale, color, c, 0, 0, textStyle ); + } + + CG_Text_Paint( text_x + tx + i * w, rect->y + text_y, scale, color, FPS_STRING, 0, 0, textStyle ); + } } + /* ================= CG_DrawTimer ================= */ -static float CG_DrawTimer( float y ) +static void CG_DrawTimer( rectDef_t *rect, float text_x, float text_y, + float scale, vec4_t color, int align, int textStyle ) { char *s; - int w; + int i, tx, w, totalWidth, strLength; int mins, seconds, tens; int msec; + if( !cg_drawTimer.integer ) + return; + msec = cg.time - cgs.levelStartTime; seconds = msec / 1000; @@ -1404,105 +1139,77 @@ static float CG_DrawTimer( float y ) seconds -= tens * 10; s = va( "%d:%d%d", mins, tens, seconds ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; - - CG_DrawBigString( 635 - w, y + 2, s, 1.0F); - - return y + BIGCHAR_HEIGHT + 4; -} + w = CG_Text_Width( "0", scale, 0 ); + strLength = CG_DrawStrlen( s ); + totalWidth = w * strLength; + + switch( align ) + { + case ITEM_ALIGN_LEFT: + tx = rect->x; + break; + case ITEM_ALIGN_RIGHT: + tx = rect->x + rect->w - totalWidth; + break; -/* -===================== -CG_DrawUpperRight + case ITEM_ALIGN_CENTER: + tx = rect->x + ( rect->w / 2.0f ) - ( totalWidth / 2.0f ); + break; -===================== -*/ -static void CG_DrawUpperRight( void ) -{ - float y; + default: + tx = 0.0f; + } - y = 0; + for( i = 0; i < strLength; i++ ) + { + char c[ 2 ]; - if( cg_drawSnapshot.integer ) - y = CG_DrawSnapshot( y ); - - if( cg_drawFPS.integer ) - y = CG_DrawFPS( y ); - - if( cg_drawTimer.integer ) - y = CG_DrawTimer( y ); + c[ 0 ] = s[ i ]; + c[ 1 ] = '\0'; + + CG_Text_Paint( text_x + tx + i * w, rect->y + text_y, scale, color, c, 0, 0, textStyle ); + } } /* -=========================================================================================== - - LOWER RIGHT CORNER - -=========================================================================================== -*/ - - -/* -================= -CG_DrawBuildPoints - -Draw the small two score display -================= +================== +CG_DrawSnapshot +================== */ -/*static float CG_DrawBuildPoints( float y ) +static void CG_DrawSnapshot( rectDef_t *rect, float text_x, float text_y, + float scale, vec4_t color, int align, int textStyle ) { - const char *s; - int points, totalpoints, buildpoints; - int team; - int x, w; - float y1; - qboolean spectator; - - y -= BIGCHAR_HEIGHT + 8; - - y1 = y; - - - x = 640; - points = cg.snap->ps.persistant[PERS_POINTS]; - totalpoints = cg.snap->ps.persistant[PERS_TOTALPOINTS]; + char *s; + int w, tx; - team = cg.snap->ps.stats[ STAT_PTEAM ]; + if( !cg_drawSnapshot.integer ) + return; - if( team == PTE_ALIENS ) - buildpoints = cgs.alienBuildPoints; - else if( team == PTE_HUMANS ) - buildpoints = cgs.humanBuildPoints; - - spectator = ( team == PTE_NONE ); - - if( !spectator ) + s = va( "time:%d snap:%d cmd:%d", cg.snap->serverTime, + cg.latestSnapshotNum, cgs.serverCommandSequence ); + w = CG_Text_Width( s, scale, 0 ); + + switch( align ) { - s = va( "%2i", points ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8; - x -= w; - - CG_DrawBigString( x + 2, y, s, 1.0F ); - - s = va( "%2i", totalpoints ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8; - x -= w; + case ITEM_ALIGN_LEFT: + tx = rect->x; + break; - CG_DrawBigString( x + 2, y, s, 1.0F ); + case ITEM_ALIGN_RIGHT: + tx = rect->x + rect->w - w; + break; - s = va( "%2i", buildpoints ); - w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8; - x -= w; + case ITEM_ALIGN_CENTER: + tx = rect->x + ( rect->w / 2.0f ) - ( w / 2.0f ); + break; - CG_DrawBigString( x + 2, y, s, 1.0F ); + default: + tx = 0.0f; } - return y1 - 8; -}*/ - -//=========================================================================================== - + CG_Text_Paint( text_x + tx, rect->y + text_y, scale, color, s, 0, 0, textStyle ); +} /* =============================================================================== @@ -1581,6 +1288,7 @@ static void CG_DrawDisconnect( void ) usercmd_t cmd; const char *s; int w; + vec4_t color = { 1.0f, 1.0f, 1.0f, 1.0f }; // draw the phone jack if we are completely past our buffers cmdNum = trap_GetCurrentCmdNumber( ) - CMD_BACKUP + 1; @@ -1592,8 +1300,8 @@ static void CG_DrawDisconnect( void ) // 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); + w = CG_Text_Width( s, 0.7f, 0 ); + CG_Text_Paint( 320 - w / 2, 100, 0.7f, color, s, 0, 0, ITEM_TEXTSTYLE_SHADOWED ); // blink the icon if( ( cg.time >> 9 ) & 1 ) @@ -1613,7 +1321,7 @@ static void CG_DrawDisconnect( void ) CG_DrawLagometer ============== */ -static void CG_DrawLagometer( void ) +static void CG_DrawLagometer( rectDef_t *rect, qhandle_t shader ) { int a, x, y, i; float v; @@ -1621,7 +1329,7 @@ static void CG_DrawLagometer( void ) int color; float vscale; - if( !cg_lagometer.integer || cgs.localServer ) + if( !cg_lagometer.integer ) { CG_DrawDisconnect( ); return; @@ -1630,16 +1338,14 @@ static void CG_DrawLagometer( void ) // // draw the graph // - x = 640 - 48; - y = 480 - 144; + ax = x = rect->x; + ay = y = rect->y; + aw = rect->w; + ah = rect->h; trap_R_SetColor( NULL ); - CG_DrawPic( x, y, 48, 48, cgs.media.lagometerShader ); + CG_DrawPic( x, y, rect->w, rect->h, shader ); - ax = x; - ay = y; - aw = 48; - ah = 48; CG_AdjustFrom640( &ax, &ay, &aw, &ah ); color = -1; @@ -1741,6 +1447,306 @@ static void CG_DrawLagometer( void ) } +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; + + if( cg_drawStatus.integer == 0 ) + return; + + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + + switch( ownerDraw ) + { + case CG_PLAYER_CREDITS_VALUE: + CG_DrawPlayerCreditsValue( &rect, color ); + break; + case CG_PLAYER_BANK_VALUE: + CG_DrawPlayerBankValue( &rect, color ); + break; + case CG_PLAYER_STAMINA: + CG_DrawPlayerStamina( &rect ); + break; + case CG_PLAYER_AMMO_VALUE: + CG_DrawPlayerAmmoValue( &rect, color ); + break; + case CG_PLAYER_CLIPS_VALUE: + CG_DrawPlayerClipsValue( &rect, color ); + break; + case CG_PLAYER_HEALTH: + CG_DrawPlayerHealth( &rect, color ); + 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; + case CG_PLAYER_SELECT: + CG_DrawWeaponSelect( &rect ); + break; + case CG_PLAYER_SELECTTEXT: + CG_DrawWeaponSelectText( &rect, scale, textStyle ); + break; + case CG_SPECTATORS: + CG_DrawTeamSpectators( &rect, scale, color, shader ); + break; + + //loading screen + case CG_LOAD_LEVELSHOT: + CG_DrawLevelShot( &rect ); + break; + case CG_LOAD_MEDIA: + CG_DrawMediaProgress( &rect, color, scale, align, textStyle ); + break; + case CG_LOAD_MEDIA_LABEL: + CG_DrawMediaProgressLabel( &rect, text_x, text_y, color, scale, align ); + break; + case CG_LOAD_BUILDABLES: + CG_DrawBuildablesProgress( &rect, color, scale, align, textStyle ); + break; + case CG_LOAD_BUILDABLES_LABEL: + CG_DrawBuildablesProgressLabel( &rect, text_x, text_y, color, scale, align ); + break; + case CG_LOAD_CHARMODEL: + CG_DrawCharModelProgress( &rect, color, scale, align, textStyle ); + break; + case CG_LOAD_CHARMODEL_LABEL: + CG_DrawCharModelProgressLabel( &rect, text_x, text_y, color, scale, align ); + break; + case CG_LOAD_OVERALL: + CG_DrawOverallProgress( &rect, color, scale, align, textStyle ); + break; + case CG_LOAD_LEVELNAME: + CG_DrawLevelName( &rect, text_x, text_y, color, scale, align, textStyle ); + break; + case CG_LOAD_MOTD: + CG_DrawMOTD( &rect, text_x, text_y, color, scale, align, textStyle ); + break; + case CG_LOAD_HOSTNAME: + CG_DrawHostname( &rect, text_x, text_y, color, scale, align, textStyle ); + break; + + case CG_FPS: + CG_DrawFPS( &rect, text_x, text_y, scale, color, align, textStyle ); + break; + case CG_TIMER: + CG_DrawTimer( &rect, text_x, text_y, scale, color, align, textStyle ); + break; + case CG_SNAPSHOT: + CG_DrawSnapshot( &rect, text_x, text_y, scale, color, align, textStyle ); + break; + case CG_LAGOMETER: + CG_DrawLagometer( &rect, shader ); + break; + + default: + break; + } +} + +void CG_MouseEvent( int x, int y ) +{ + int n; + + if( ( cg.predictedPlayerState.pm_type == PM_NORMAL || + cg.predictedPlayerState.pm_type == PM_SPECTATOR ) && + cg.showScores == qfalse ) + { + trap_Key_SetCatcher( 0 ); + return; + } + + cgs.cursorX += x; + if( cgs.cursorX < 0 ) + cgs.cursorX = 0; + else if( cgs.cursorX > 640 ) + cgs.cursorX = 640; + + cgs.cursorY += y; + if( cgs.cursorY < 0 ) + cgs.cursorY = 0; + else if( cgs.cursorY > 480 ) + cgs.cursorY = 480; + + 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; + + if( cgs.capturedItem ) + Display_MouseMove( cgs.capturedItem, x, y ); + else + Display_MouseMove( NULL, cgs.cursorX, cgs.cursorY ); +} + +/* +================== +CG_HideTeamMenus +================== + +*/ +void CG_HideTeamMenu( ) +{ + Menus_CloseByName( "teamMenu" ); + Menus_CloseByName( "getMenu" ); +} + +/* +================== +CG_ShowTeamMenus +================== + +*/ +void CG_ShowTeamMenu( ) +{ + Menus_OpenByName("teamMenu"); +} + +/* +================== +CG_EventHandling +================== + type 0 - no event handling + 1 - team menu + 2 - hud editor + +*/ +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 ) + { + + } +} + + + +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; + } + + 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 ); + } +} + +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; +} + +void CG_ShowResponseHead( ) +{ + Menus_OpenByName( "voiceMenu" ); + trap_Cvar_Set( "cl_conXOffset", "72" ); + cg.voiceTime = cg.time; +} + +void CG_RunMenuScript( char **args ) +{ +} + + +void CG_GetTeamColor(vec4_t *color) +{ + (*color)[0] = (*color)[2] = 0.0f; + (*color)[1] = 0.17f; + (*color)[3] = 0.25f; +} +//END TA UI + + +/* +================ +CG_DrawLighting + +================ +*/ +static void CG_DrawLighting( void ) +{ + centity_t *cent; + + cent = &cg_entities[cg.snap->ps.clientNum]; + + if( cg.snap->ps.stats[ STAT_PCLASS ] == PCL_H_BASE ) + { + 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 + if( ( cg.snap->ps.stats[ STAT_STAMINA ] < -800 ) && + ( cg.snap->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) ) + { + vec4_t black = { 0, 0, 0, 0 }; + black[ 3 ] = 1.0 - ( (float)( cg.snap->ps.stats[ STAT_STAMINA ] + 1000 ) / 200.0f ); + trap_R_SetColor( black ); + CG_DrawPic( 0, 0, 640, 480, cgs.media.whiteShader ); + trap_R_SetColor( NULL ); + } +} + +/* +=========================================================================================== + + LOWER RIGHT CORNER + +=========================================================================================== +*/ + + /* =============================================================================== @@ -2366,8 +2372,8 @@ static void CG_Draw2D( void ) BG_FindHudNameForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] ) ), qtrue ); } - CG_DrawAmmoWarning(); - CG_DrawCrosshair(); + CG_DrawAmmoWarning( ); + CG_DrawCrosshair( ); if( BG_gotItem( UP_HELMET, cg.snap->ps.stats ) ) CG_Scanner( ); @@ -2377,12 +2383,8 @@ static void CG_Draw2D( void ) } } - CG_DrawVote(); - CG_DrawTeamVote(); - - CG_DrawLagometer(); - - CG_DrawUpperRight(); + CG_DrawVote( ); + CG_DrawTeamVote( ); if( !CG_DrawFollow( ) ) CG_DrawWarmup(); diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c index 3cab52cd..4ae78987 100644 --- a/src/cgame/cg_event.c +++ b/src/cgame/cg_event.c @@ -806,6 +806,10 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) DEBUGNAME("EV_CHANGE_WEAPON"); trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.selectSound ); break; + case EV_NEXT_WEAPON: + DEBUGNAME("EV_NEXT_WEAPON"); + CG_NextWeapon_f( ); + break; case EV_FIRE_WEAPON: DEBUGNAME("EV_FIRE_WEAPON"); CG_FireWeapon( cent ); diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index cc5e745b..d8441016 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -1552,14 +1552,6 @@ void CG_DrawWeaponSelect( rectDef_t *rect ) else x += iconsize; } - - /*//TA: yuck! :) - if( y == 10 ) - { - trap_R_SetColor( NULL ); - return; - }*/ - } @@ -1583,7 +1575,8 @@ void CG_DrawWeaponSelectText( rectDef_t *rect, float scale, int textStyle ) // draw the selected name if( cg.weaponSelect <= 32 ) { - if( cg_weapons[ cg.weaponSelect ].registered ) + if( cg_weapons[ cg.weaponSelect ].registered && + BG_gotWeapon( cg.weaponSelect, cg.snap->ps.stats ) ) { if( name = cg_weapons[ cg.weaponSelect ].humanName ) { @@ -1595,7 +1588,8 @@ void CG_DrawWeaponSelectText( rectDef_t *rect, float scale, int textStyle ) } else if( cg.weaponSelect > 32 ) { - if( cg_upgrades[ cg.weaponSelect - 32 ].registered ) + if( cg_upgrades[ cg.weaponSelect - 32 ].registered && + BG_gotItem( cg.weaponSelect - 32, cg.snap->ps.stats ) ) { if( name = cg_upgrades[ cg.weaponSelect - 32 ].humanName ) { diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index c6a46353..3f60271b 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -3368,6 +3368,7 @@ char *eventnames[] = { "EV_NOAMMO", "EV_CHANGE_WEAPON", + "EV_NEXT_WEAPON", "EV_FIRE_WEAPON", "EV_FIRE_WEAPON2", "EV_FIRE_WEAPONBOTH", diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 7e8483de..2d59fe82 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -504,6 +504,7 @@ typedef enum { EV_NOAMMO, EV_CHANGE_WEAPON, + EV_NEXT_WEAPON, EV_FIRE_WEAPON, EV_FIRE_WEAPON2, EV_FIRE_WEAPONBOTH, diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 66e0f16a..331326ae 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1851,9 +1851,21 @@ void Cmd_Buy_f( gentity_t *ent ) int i; gentity_t *mcuEntity; qboolean nearMCU = qfalse; - int weapon, upgrade; + int weapon, upgrade, numItems = 0; int quan, clips, maxClips; + for( i = UP_NONE; i < UP_NUM_UPGRADES; i++ ) + { + if( BG_gotItem( i, ent->client->ps.stats ) ) + numItems++; + } + + for( i = WP_NONE; i < WP_NUM_WEAPONS; i++ ) + { + if( BG_gotWeapon( i, ent->client->ps.stats ) ) + numItems++; + } + trap_Argv( 1, s, sizeof( s ) ); //aliens don't buy stuff @@ -2029,6 +2041,9 @@ void Cmd_Buy_f( gentity_t *ent ) trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) ); } + //if the buyer previously had no items at all, force a new selection + if( numItems == 0 ) + G_AddEvent( ent, EV_NEXT_WEAPON, 0 ); } @@ -2086,6 +2101,10 @@ void Cmd_Sell_f( gentity_t *ent ) //add to funds ent->client->ps.persistant[ PERS_CREDIT ] += BG_FindPriceForWeapon( weapon ); } + + //if we have this weapon selected, force a new selection + if( weapon == ent->client->ps.weapon ) + G_AddEvent( ent, EV_NEXT_WEAPON, 0 ); } else if( upgrade != UP_NONE ) { @@ -2097,6 +2116,10 @@ void Cmd_Sell_f( gentity_t *ent ) //add to funds ent->client->ps.persistant[ PERS_CREDIT ] += BG_FindPriceForUpgrade( upgrade ); } + + //if we have this upgrade selected, force a new selection + if( upgrade == ent->client->pers.cmd.weapon - 32 ) + G_AddEvent( ent, EV_NEXT_WEAPON, 0 ); } else { diff --git a/ui/menudef.h b/ui/menudef.h index 1e56651e..45a44825 100644 --- a/ui/menudef.h +++ b/ui/menudef.h @@ -220,6 +220,12 @@ #define CG_LOAD_MOTD 85 #define CG_LOAD_HOSTNAME 86 +#define CG_FPS 87 +#define CG_TIMER 88 +#define CG_SNAPSHOT 89 +#define CG_LAGOMETER 90 + + #define UI_OWNERDRAW_BASE 200 #define UI_HANDICAP 200 |