Browse Source

Merge branch 'cl_scoreboard_bg' into theyhunger

theyhunger
Night Owl 8 years ago
parent
commit
0c4a0e174e
  1. 2
      cl_dll/MOTD.cpp
  2. 2
      cl_dll/cl_util.h
  3. 36
      cl_dll/hud_redraw.cpp
  4. 27
      cl_dll/scoreboard.cpp
  5. 4
      dlls/client.cpp

2
cl_dll/MOTD.cpp

@ -103,7 +103,7 @@ int CHudMOTD::Draw( float fTime ) @@ -103,7 +103,7 @@ int CHudMOTD::Draw( float fTime )
// find where to start drawing the line
if( ( ypos > ROW_RANGE_MIN ) && ( ypos + LINE_HEIGHT <= ypos_r + height ) )
gHUD.DrawHudString( xpos, ypos, xmax, ch, 255, 180, 0 );
DrawUtfString( xpos, ypos, xmax, ch, 255, 180, 0 );
ypos += LINE_HEIGHT;

2
cl_dll/cl_util.h

@ -115,6 +115,8 @@ inline void GetConsoleStringSize( const char *string, int *width, int *height ) @@ -115,6 +115,8 @@ inline void GetConsoleStringSize( const char *string, int *width, int *height )
gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height );
}
int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b );
inline int ConsoleStringLen( const char *string )
{
int _width = 0, _height = 0;

36
cl_dll/hud_redraw.cpp

@ -93,6 +93,13 @@ int CHud::Redraw( float flTime, int intermission ) @@ -93,6 +93,13 @@ int CHud::Redraw( float flTime, int intermission )
if( m_flTimeDelta < 0 )
m_flTimeDelta = 0;
if( !m_iIntermission && intermission )
{
// Take a screenshot if the client's got the cvar set
if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
m_flShotTime = flTime + 1.0; // Take a screenshot in a second
}
if( m_flShotTime && m_flShotTime < flTime )
{
gEngfuncs.pfnClientCmd( "snapshot\n" );
@ -226,6 +233,35 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g @@ -226,6 +233,35 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g
return xpos;
}
int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b )
{
// xash3d: reset unicode state
gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 );
// draw the string until we hit the null character or a newline character
for( ; *szIt != 0 && *szIt != '\n'; szIt++ )
{
int w = gHUD.m_scrinfo.charWidths['M'];
if( xpos + w > iMaxX )
return xpos;
if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') )
{
szIt++;
r = colors[*szIt - '0'][0];
g = colors[*szIt - '0'][1];
b = colors[*szIt - '0'][2];
if( !*(++szIt) )
return xpos;
}
int c = (unsigned int)(unsigned char)*szIt;
xpos += gEngfuncs.pfnVGUI2DrawCharacterAdditive( xpos, ypos, c, r, g, b, 0 );
}
return xpos;
}
int CHud::DrawHudStringLen( char *szIt )
{
int l = 0;

27
cl_dll/scoreboard.cpp

@ -26,6 +26,7 @@ @@ -26,6 +26,7 @@
#include <string.h>
#include <stdio.h>
cvar_t *cl_scoreboard_bg;
cvar_t *cl_showpacketloss;
hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine
extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll
@ -59,6 +60,7 @@ int CHudScoreboard::Init( void ) @@ -59,6 +60,7 @@ int CHudScoreboard::Init( void )
InitHUDData();
cl_scoreboard_bg = CVAR_CREATE( "cl_scoreboard_bg", "1", FCVAR_ARCHIVE );
cl_showpacketloss = CVAR_CREATE( "cl_showpacketloss", "0", FCVAR_ARCHIVE );
return 1;
@ -144,20 +146,21 @@ int CHudScoreboard::Draw( float fTime ) @@ -144,20 +146,21 @@ int CHudScoreboard::Draw( float fTime )
FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX;
FAR_RIGHT += 5;
if( cl_scoreboard_bg && cl_scoreboard_bg->value )
gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX );
if( !gHUD.m_Teamplay )
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 );
DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 );
else
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 );
DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 );
gHUD.DrawHudStringReverse( KILLS_RANGE_MAX + xpos_rel, ypos, 0, "kills", 255, 140, 0 );
gHUD.DrawHudString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", 255, 140, 0 );
gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 );
gHUD.DrawHudString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 );
DrawUtfString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", 255, 140, 0 );
DrawUtfString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 );
DrawUtfString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 );
if( can_show_packetloss )
{
gHUD.DrawHudString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 );
DrawUtfString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 );
}
list_slot += 1.2;
@ -272,7 +275,7 @@ int CHudScoreboard::Draw( float fTime ) @@ -272,7 +275,7 @@ int CHudScoreboard::Draw( float fTime )
}
// draw their name (left to right)
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b );
DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b );
// draw kills (right to left)
xpos = KILLS_RANGE_MAX + xpos_rel;
@ -280,7 +283,7 @@ int CHudScoreboard::Draw( float fTime ) @@ -280,7 +283,7 @@ int CHudScoreboard::Draw( float fTime )
// draw divider
xpos = DIVIDER_POS + xpos_rel;
gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b );
DrawUtfString( xpos, ypos, xpos + 20, "/", r, g, b );
// draw deaths
xpos = DEATHS_RANGE_MAX + xpos_rel;
@ -300,7 +303,7 @@ int CHudScoreboard::Draw( float fTime ) @@ -300,7 +303,7 @@ int CHudScoreboard::Draw( float fTime )
xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2) + PL_RANGE_MIN + xpos_rel + 25;
sprintf( buf, " %d", team_info->packetloss );
gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b );
DrawUtfString( xpos, ypos, xpos+50, buf, r, g, b );
}
team_info->already_drawn = TRUE; // set the already_drawn to be TRUE, so this team won't get drawn again
@ -400,7 +403,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, @@ -400,7 +403,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
}
// draw their name (left to right)
gHUD.DrawHudString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, pl_info->name, r, g, b );
DrawUtfString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, pl_info->name, r, g, b );
// draw kills (right to left)
xpos = KILLS_RANGE_MAX + xpos_rel;
@ -408,7 +411,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, @@ -408,7 +411,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
// draw divider
xpos = DIVIDER_POS + xpos_rel;
gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b );
DrawUtfString( xpos, ypos, xpos + 20, "/", r, g, b );
// draw deaths
xpos = DEATHS_RANGE_MAX + xpos_rel;
@ -435,7 +438,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, @@ -435,7 +438,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2 ) + PL_RANGE_MIN + xpos_rel + 25;
gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b );
DrawUtfString( xpos, ypos, xpos+50, buf, r, g, b );
}
pl_info->name = NULL; // set the name to be NULL, so this client won't get drawn again

4
dlls/client.cpp

@ -466,10 +466,10 @@ void ClientCommand( edict_t *pEntity ) @@ -466,10 +466,10 @@ void ClientCommand( edict_t *pEntity )
edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer );
pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles );
}
/*else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) )
else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) )
{
// MenuSelect returns true only if the command is properly handled, so don't print a warning
}*/
}
else if( FStrEq( pcmd, "VModEnable" ) )
{
// clear 'Unknown command: VModEnable' in singleplayer

Loading…
Cancel
Save