Browse Source

Merge pull request #51 from nekonomicon/scoreboard

Do not show long nicknames on low resolution.
caseclosed
Alibek Omarov 7 years ago committed by GitHub
parent
commit
022e868af1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 65
      cl_dll/scoreboard.cpp

65
cl_dll/scoreboard.cpp

@ -92,17 +92,18 @@ We have a minimum width of 1-320 - we could have the field widths scale with it?
// X positions // X positions
// relative to the side of the scoreboard // relative to the side of the scoreboard
#define NAME_RANGE_MIN -65 #define NAME_RANGE_MIN 20
#define NAME_RANGE_MAX 180 #define NAME_RANGE_MAX 145
#define KILLS_RANGE_MIN 165 #define NAME_RANGE_MODIFIER 120
#define KILLS_RANGE_MAX 205 #define KILLS_RANGE_MIN 130
#define DIVIDER_POS 215 #define KILLS_RANGE_MAX 170
#define DEATHS_RANGE_MIN 220 #define DIVIDER_POS 180
#define DEATHS_RANGE_MAX 245 #define DEATHS_RANGE_MIN 185
#define PING_RANGE_MIN 280 #define DEATHS_RANGE_MAX 210
#define PING_RANGE_MAX 330 #define PING_RANGE_MIN 245
#define PL_RANGE_MIN 350 #define PING_RANGE_MAX 295
#define PL_RANGE_MAX 410 #define PL_RANGE_MIN 315
#define PL_RANGE_MAX 375
int SCOREBOARD_WIDTH = 320; int SCOREBOARD_WIDTH = 320;
@ -128,11 +129,11 @@ int CHudScoreboard::Draw( float fTime )
if( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) if( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) )
{ {
can_show_packetloss = 1; can_show_packetloss = 1;
SCOREBOARD_WIDTH = 400; SCOREBOARD_WIDTH = ( ScreenWidth >= 520 ) ? ( 400 - NAME_RANGE_MODIFIER ) : 400;
} }
else else
{ {
SCOREBOARD_WIDTH = 320; SCOREBOARD_WIDTH = ( ScreenWidth >= 440 ) ? ( 320 - NAME_RANGE_MODIFIER ) : 320;
} }
// just sort the list on the fly // just sort the list on the fly
@ -145,7 +146,14 @@ int CHudScoreboard::Draw( float fTime )
int xpos = NAME_RANGE_MIN + xpos_rel; int xpos = NAME_RANGE_MIN + xpos_rel;
FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX;
FAR_RIGHT += 125; FAR_RIGHT += 5;
if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) )
{
xpos -= NAME_RANGE_MODIFIER;
FAR_RIGHT += NAME_RANGE_MODIFIER;
}
if( cl_scoreboard_bg && cl_scoreboard_bg->value ) if( cl_scoreboard_bg && cl_scoreboard_bg->value )
gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX );
if( !gHUD.m_Teamplay ) if( !gHUD.m_Teamplay )
@ -165,7 +173,7 @@ int CHudScoreboard::Draw( float fTime )
list_slot += 1.2; list_slot += 1.2;
ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP ); ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP );
xpos = NAME_RANGE_MIN + xpos_rel; // xpos = NAME_RANGE_MIN + xpos_rel;
FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255 ); // draw the seperator line FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255 ); // draw the seperator line
list_slot += 0.8; list_slot += 0.8;
@ -266,12 +274,18 @@ int CHudScoreboard::Draw( float fTime )
break; break;
xpos = NAME_RANGE_MIN + xpos_rel; xpos = NAME_RANGE_MIN + xpos_rel;
if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) )
{
xpos -= NAME_RANGE_MODIFIER;
}
int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish
if( team_info->ownteam ) // if it is their team, draw the background different color if( team_info->ownteam ) // if it is their team, draw the background different color
{ {
// overlay the background in blue, then draw the score text over it // overlay the background in blue, then draw the score text over it
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 );
} }
// draw their name (left to right) // draw their name (left to right)
@ -340,7 +354,12 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
} }
FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX;
FAR_RIGHT += 125; FAR_RIGHT += 5;
if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) )
{
FAR_RIGHT += NAME_RANGE_MODIFIER;
}
// draw the players, in order, and restricted to team if set // draw the players, in order, and restricted to team if set
while( 1 ) while( 1 )
@ -380,6 +399,12 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
break; break;
int xpos = NAME_RANGE_MIN + xpos_rel; int xpos = NAME_RANGE_MIN + xpos_rel;
if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) )
{
xpos -= NAME_RANGE_MODIFIER;
}
int r = 255, g = 255, b = 255; int r = 255, g = 255, b = 255;
float *colors = GetClientColor( best_player ); float *colors = GetClientColor( best_player );
r *= colors[0], g *= colors[1], b *= colors[2]; r *= colors[0], g *= colors[1], b *= colors[2];
@ -388,18 +413,18 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
if( pl_info->thisplayer ) if( pl_info->thisplayer )
{ {
// green is the suicide color? i wish this could do grey... // green is the suicide color? i wish this could do grey...
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 ); FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 );
} }
else else
{ {
// Highlight the killers name - overlay the background in red, then draw the score text over it // Highlight the killers name - overlay the background in red, then draw the score text over it
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) ); FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) );
} }
} }
else if( pl_info->thisplayer ) // if it is their name, draw it a different color else if( pl_info->thisplayer ) // if it is their name, draw it a different color
{ {
// overlay the background in blue, then draw the score text over it // overlay the background in blue, then draw the score text over it
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 );
} }
// draw their name (left to right) // draw their name (left to right)

Loading…
Cancel
Save