Пример #1
0
void StatsReport::SetPlayerNames( void )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	int nMarine = 0;

	C_ASW_Game_Resource *pGameResource = ASWGameResource();

	for ( int i = 0; i < pGameResource->GetMaxMarineResources() && nMarine < ASW_STATS_REPORT_MAX_PLAYERS; i++ )
	{
		CASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i );
		if ( pMR )
		{
			C_ASW_Player *pCommander = pMR->GetCommander();

			Color color = getColorPerIndex(pMR->GetCommanderIndex());

			if ( pPlayer != pCommander )
			{
				color[ 3 ] = 128;
			}

			m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetLineColor( color );
			m_pPlayerNames[ nMarine ]->SetFgColor( color );

			wchar_t wszMarineName[ 32 ];
			pMR->GetDisplayName( wszMarineName, sizeof( wszMarineName ) );

			m_pPlayerNames[ nMarine ]->SetText( wszMarineName );

			if ( gpGlobals->maxClients == 1 )
			{
				// Don't need these in singleplayer
				m_pAvatarImages[ nMarine ]->SetVisible( false );
				m_pReadyCheckImages[ nMarine ]->SetVisible( false );
			}
			else
			{
#if !defined(NO_STEAM)
				CSteamID steamID;

				if ( pCommander )
				{
					player_info_t pi;
					if ( engine->GetPlayerInfo( pCommander->entindex(), &pi ) )
					{
						if ( pi.friendsID )
						{
							CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual );
							steamID = steamIDForPlayer;
						}
					}
				}

				if ( steamID.IsValid() )
				{
					m_pAvatarImages[ nMarine ]->SetAvatarBySteamID( &steamID );

					int wide, tall;
					m_pAvatarImages[ nMarine ]->GetSize( wide, tall );

					CAvatarImage *pImage = static_cast< CAvatarImage* >( m_pAvatarImages[ nMarine ]->GetImage() );
					if ( pImage )
					{
						pImage->SetAvatarSize( wide, tall );
						pImage->SetPos( -AVATAR_INDENT_X, -AVATAR_INDENT_Y );
					}
				}
#endif
			}

			nMarine++;
		}
	}

	while ( nMarine < ASW_STATS_REPORT_MAX_PLAYERS )
	{
		m_pAvatarImages[ nMarine ]->SetVisible( false );
		m_pReadyCheckImages[ nMarine ]->SetVisible( false );
		nMarine++;
	}
}