|
28 | 28 | #include <string.h> |
29 | 29 | #include <stdio.h> |
30 | 30 | #include "draw_util.h" |
| 31 | +#include "vgui_parser.h" |
| 32 | +#include <ctype.h> |
31 | 33 |
|
32 | 34 | hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine |
33 | 35 | extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll |
@@ -180,16 +182,17 @@ int CHudScoreboard :: DrawScoreboard( float fTime ) |
180 | 182 | int ypos = ystart + (list_slot * ROW_GAP) + 5; |
181 | 183 |
|
182 | 184 | if( gHUD.m_szServerName[0] ) |
183 | | - snprintf( ServerName, 80, "%s SERVER: %s", (char*)(gHUD.m_Teamplay ? "TEAMS" : "PLAYERS"), gHUD.m_szServerName ); |
| 185 | + // snprintf( ServerName, 80, "%s", (char*)(gHUD.m_Teamplay ? "TEAMS" : "PLAYERS"), gHUD.m_szServerName ); |
| 186 | + strncpy( ServerName, gHUD.m_szServerName, 80 ); |
184 | 187 | else |
185 | 188 | strncpy( ServerName, gHUD.m_Teamplay ? "TEAMS" : "PLAYERS", 80 ); |
186 | 189 |
|
187 | 190 | DrawUtils::DrawHudString( NAME_POS_START(), ypos, NAME_POS_END(), ServerName, 255, 140, 0 ); |
188 | | - DrawUtils::DrawHudStringReverse( HP_POS_END(), ypos, 0, "HP", 255, 140, 0 ); |
189 | | - DrawUtils::DrawHudString( MONEY_POS_START(), ypos, MONEY_POS_END(), "MONEY", 255, 140, 0 ); |
190 | | - DrawUtils::DrawHudStringReverse( KILLS_POS_END(), ypos, KILLS_POS_START(), "KILLS", 255, 140, 0 ); |
191 | | - DrawUtils::DrawHudString( DEATHS_POS_START(), ypos, DEATHS_POS_END(), "DEATHS", 255, 140, 0 ); |
192 | | - DrawUtils::DrawHudStringReverse( PING_POS_END(), ypos, PING_POS_START(), "PING", 255, 140, 0 ); |
| 191 | + DrawUtils::DrawHudStringReverse( HP_POS_END(), ypos, 0, Localize( "#Cstrike_HEALTH" ), 255, 140, 0 ); |
| 192 | + DrawUtils::DrawHudString( MONEY_POS_START(), ypos, MONEY_POS_END(), Localize( "#Cstrike_ACCOUNT" ), 255, 140, 0 ); |
| 193 | + DrawUtils::DrawHudStringReverse( KILLS_POS_END(), ypos, KILLS_POS_START(), Localize( "#PlayerScore" ), 255, 140, 0 ); |
| 194 | + DrawUtils::DrawHudString( DEATHS_POS_START(), ypos, DEATHS_POS_END(), Localize( "#PlayerDeath" ), 255, 140, 0 ); |
| 195 | + DrawUtils::DrawHudStringReverse( PING_POS_END(), ypos, PING_POS_START(), Localize( "#PlayerPing" ), 255, 140, 0 ); |
193 | 196 |
|
194 | 197 | list_slot += 2; |
195 | 198 | ypos = ystart + (list_slot * ROW_GAP); |
@@ -314,20 +317,43 @@ int CHudScoreboard :: DrawTeams( float list_slot ) |
314 | 317 | int r, g, b; |
315 | 318 | char teamName[64]; |
316 | 319 |
|
| 320 | + char numPlayers[16]; |
| 321 | + sprintf( numPlayers, "%d", team_info->players ); |
| 322 | + |
| 323 | + char fmtString[32]; |
| 324 | + strncpy( fmtString, Localize( team_info->players == 1 ? "#Cstrike_ScoreBoard_Player" : "#Cstrike_ScoreBoard_Players" ), sizeof( fmtString ) ); |
| 325 | + |
| 326 | + if ( !strcmp( fmtString, team_info->players == 1 ? "Cstrike_ScoreBoard_Player" : "Cstrike_ScoreBoard_Players" ) ) |
| 327 | + strncpy( fmtString, team_info->players == 1 ? "%s - %s player" : "%s - %s players", sizeof( fmtString ) ); |
| 328 | + else |
| 329 | + for ( size_t i = 0; i < strlen( fmtString ) - 2; i++ ) |
| 330 | + { |
| 331 | + if ( fmtString[i] == '%' && fmtString[i + 1] == 's' && isdigit( fmtString[i + 2] ) ) |
| 332 | + { |
| 333 | + char *first = &fmtString[i + 2]; |
| 334 | + char *second = &fmtString[i + 3]; |
| 335 | + |
| 336 | + size_t len = strlen( second ); |
| 337 | + |
| 338 | + memmove( first, second, strlen( second ) ); |
| 339 | + first[len] = '\0'; |
| 340 | + } |
| 341 | + } |
| 342 | + |
317 | 343 | GetTeamColor( r, g, b, team_info->teamnumber ); |
318 | | - switch( team_info->teamnumber ) |
| 344 | + switch ( team_info->teamnumber ) |
319 | 345 | { |
320 | 346 | case TEAM_TERRORIST: |
321 | | - snprintf(teamName, sizeof(teamName), "Terrorists - %i players", team_info->players); |
322 | | - DrawUtils::DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), team_info->frags, r, g, b ); |
| 347 | + snprintf( teamName, sizeof( teamName ), fmtString, Localize( "#Cstrike_ScoreBoard_Ter" ), numPlayers ); |
| 348 | + DrawUtils::DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), team_info->frags, r, g, b ); |
323 | 349 | break; |
324 | 350 | case TEAM_CT: |
325 | | - snprintf(teamName, sizeof(teamName), "Counter-Terrorists - %i players", team_info->players); |
326 | | - DrawUtils::DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), team_info->frags, r, g, b ); |
| 351 | + snprintf( teamName, sizeof( teamName ), fmtString, Localize( "#Cstrike_ScoreBoard_CT" ), numPlayers ); |
| 352 | + DrawUtils::DrawHudNumberString( KILLS_POS_END(), ypos, KILLS_POS_START(), team_info->frags, r, g, b ); |
327 | 353 | break; |
328 | 354 | case TEAM_SPECTATOR: |
329 | 355 | case TEAM_UNASSIGNED: |
330 | | - strncpy( teamName, "Spectators", sizeof(teamName) ); |
| 356 | + strncpy( teamName, Localize( "#Spectators" ), sizeof( teamName ) ); |
331 | 357 | break; |
332 | 358 | } |
333 | 359 |
|
@@ -410,11 +436,13 @@ int CHudScoreboard :: DrawPlayers( float list_slot, int nameoffset, const char * |
410 | 436 | { |
411 | 437 | // draw bomb( if player have the bomb ) |
412 | 438 | if( g_PlayerExtraInfo[best_player].dead ) |
413 | | - DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), "Dead", r, g, b ); |
| 439 | + DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), Localize( "#Cstrike_DEAD" ), r, g, b ); |
414 | 440 | else if( g_PlayerExtraInfo[best_player].has_c4 ) |
415 | | - DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), "Bomb", r, g, b ); |
| 441 | + DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), Localize( "#Cstrike_BOMB" ), r, g, b ); |
416 | 442 | else if( g_PlayerExtraInfo[best_player].vip ) |
417 | | - DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), "VIP", r, g, b ); |
| 443 | + DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), Localize( "#Cstrike_VIP" ), r, g, b ); |
| 444 | + else if (g_PlayerExtraInfo[best_player].has_defuse_kit ) |
| 445 | + DrawUtils::DrawHudString( ATTRIB_POS_START(), ypos, ATTRIB_POS_END(), Localize( "#Cstrike_DEFUSE_KIT" ), r, g, b ); |
418 | 446 | } |
419 | 447 | } |
420 | 448 | else |
|
0 commit comments