Skip to content

Commit

Permalink
hud_redraw: remove int iMinX
Browse files Browse the repository at this point in the history
  • Loading branch information
Elinsrc committed Nov 28, 2024
1 parent 3434900 commit 553487b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cl_dll/ui/hud/ammohistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int HistoryResource::DrawAmmoHistory( float flTime )
SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
}

gHUD.DrawHudNumberStringReverse( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
gHUD.DrawHudNumberStringReverse( xpos - 10, ypos, rgAmmoHistory[i].iCount, r, g, b );
}
else if( rgAmmoHistory[i].type == HISTSLOT_WEAP )
{
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/ui/hud/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,9 @@ class CHud
int DrawHudNumber( int x, int y, int iNumber, int r, int g, int b );
int DrawHudNumberCentered( int x, int y, int iNumber, int r, int g, int b );
int DrawHudString( int x, int y, const char *szString, int r, int g, int b );
int DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b );
int DrawHudStringReverse( int xpos, int ypos, const char *szString, int r, int g, int b );
int DrawHudNumberString( int xpos, int ypos, int iNumber, int r, int g, int b );
int DrawHudNumberStringReverse( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b );
int DrawHudNumberStringReverse( int xpos, int ypos, int iNumber, int r, int g, int b );
int GetNumWidth( int iNumber, int iFlags );
int DrawHudStringLen( const char *szIt );
int GetHudStringWidth(const char* string);
Expand Down
9 changes: 4 additions & 5 deletions cl_dll/ui/hud/hud_redraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ int CHud::DrawHudNumberString( int xpos, int ypos, int iNumber, int r, int g, in
return DrawHudString( xpos, ypos, szString, r, g, b );
}

int CHud::DrawHudNumberStringReverse( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
int CHud::DrawHudNumberStringReverse( int xpos, int ypos, int iNumber, int r, int g, int b )
{
char szString[32];
sprintf( szString, "%d", iNumber );
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
return DrawHudStringReverse( xpos, ypos, szString, r, g, b );
}


Expand All @@ -338,13 +338,12 @@ int CHud::DrawHudNumberStringFixed( int xpos, int ypos, int iNumber, int r, int
}

// draws a string from right to left (right-aligned)
int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b )
int CHud::DrawHudStringReverse( int xpos, int ypos, const char *szString, int r, int g, int b )
{
// find the end of the string
for( const char *szIt = szString; *szIt != 0; szIt++ )
xpos -= gHUD.m_scrinfo.charWidths[(unsigned char)*szIt];
if( xpos < iMinX )
xpos = iMinX;

DrawHudString( xpos, ypos, szString, r, g, b );
return xpos;
}
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/ui/hud/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ int CHudMenu::Draw( float flTime )
if ( menu_ralign )
{
// IMPORTANT: Right-to-left rendered text does not parse escape tokens!
menu_x = gHUD.DrawHudStringReverse( menu_x, y, 0, menubuf, menu_r, menu_g, menu_b );
menu_x = gHUD.DrawHudStringReverse( menu_x, y, menubuf, menu_r, menu_g, menu_b );
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions cl_dll/ui/hud/scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int CHudScoreboard::Draw( float fTime )

char player_count[256];
sprintf(player_count, "%d/%d", get_player_count(), gEngfuncs.GetMaxClients());
gHUD.DrawHudStringReverse( COUNT_PLAYERS_POS + xpos_rel, info_pos, 0, player_count, 255, 140, 0 );
gHUD.DrawHudStringReverse( COUNT_PLAYERS_POS + xpos_rel, info_pos, player_count, 255, 140, 0 );

if( !gHUD.m_Teamplay )
{
Expand All @@ -185,10 +185,10 @@ int CHudScoreboard::Draw( float fTime )
else
gHUD.DrawHudString( xpos, ypos, CHudTextMessage::BufferedLocaliseTextString("#TEAMS"), 255, 140, 0 );

gHUD.DrawHudStringReverse( KILLS_RANGE_MAX + xpos_rel, ypos, 0, CHudTextMessage::BufferedLocaliseTextString("#SCORE"), 255, 140, 0 );
gHUD.DrawHudStringReverse( KILLS_RANGE_MAX + xpos_rel, ypos, CHudTextMessage::BufferedLocaliseTextString("#SCORE"), 255, 140, 0 );
gHUD.DrawHudString( DIVIDER_POS + xpos_rel, ypos, "/", 255, 140, 0 );
gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, CHudTextMessage::BufferedLocaliseTextString("#DEATHS"), 255, 140, 0 );
gHUD.DrawHudStringReverse( PING_RANGE_MAX + xpos_rel + 15, ypos, 0, CHudTextMessage::BufferedLocaliseTextString("#LATENCY"), 255, 140, 0 );
gHUD.DrawHudStringReverse( PING_RANGE_MAX + xpos_rel + 15, ypos, CHudTextMessage::BufferedLocaliseTextString("#LATENCY"), 255, 140, 0 );

list_slot += 1.2f;
ypos = ROW_TOP + ROW_RANGE_MIN + ( list_slot * ROW_GAP );
Expand Down Expand Up @@ -312,7 +312,7 @@ int CHudScoreboard::Draw( float fTime )

// draw kills (right to left)
xpos = KILLS_RANGE_MAX + xpos_rel;
gHUD.DrawHudNumberStringReverse( xpos, ypos, 0, team_info->frags, r, g, b );
gHUD.DrawHudNumberStringReverse( xpos, ypos, team_info->frags, r, g, b );

// draw divider
xpos = DIVIDER_POS + xpos_rel;
Expand All @@ -328,7 +328,7 @@ int CHudScoreboard::Draw( float fTime )
sprintf( buf, "%d/%d", team_info->ping, team_info->packetloss );
xpos = ( ( PING_RANGE_MAX - PING_RANGE_MIN ) / 2) + PING_RANGE_MIN + xpos_rel + 40;
UnpackRGB( r, g, b, gHUD.m_iDefaultHUDColor );
gHUD.DrawHudStringReverse( xpos, ypos, 0, buf, r, g, b );
gHUD.DrawHudStringReverse( xpos, ypos, buf, r, g, b );

team_info->already_drawn = TRUE; // set the already_drawn to be TRUE, so this team won't get drawn again
list_slot++;
Expand Down Expand Up @@ -448,7 +448,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,

// draw kills (right to left)
xpos = KILLS_RANGE_MAX + xpos_rel;
gHUD.DrawHudNumberStringReverse( xpos, ypos, 0, g_PlayerExtraInfo[best_player].frags, r, g, b );
gHUD.DrawHudNumberStringReverse( xpos, ypos, g_PlayerExtraInfo[best_player].frags, r, g, b );

// draw divider
xpos = DIVIDER_POS + xpos_rel;
Expand All @@ -462,7 +462,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
static char buf[64];
sprintf( buf, "%d/%d", g_PlayerInfoList[best_player].ping, g_PlayerInfoList[best_player].packetloss );
xpos = ( ( PING_RANGE_MAX - PING_RANGE_MIN ) / 2 ) + PING_RANGE_MIN + xpos_rel + 40;
gHUD.DrawHudStringReverse( xpos, ypos, 0, buf, r, g, b );
gHUD.DrawHudStringReverse( xpos, ypos, buf, r, g, b );

pl_info->name = NULL; // set the name to be NULL, so this client won't get drawn again
list_slot++;
Expand Down

0 comments on commit 553487b

Please sign in to comment.