//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAvatarImagePanel::SetPlayer( C_BasePlayer *pPlayer ) { if ( GetImage() ) { ((CAvatarImage*)GetImage())->ClearAvatarSteamID(); } if ( pPlayer && steamapicontext->SteamUtils() ) { int iIndex = pPlayer->entindex(); player_info_t pi; if ( engine->GetPlayerInfo(iIndex, &pi) ) { if ( pi.friendsID ) { CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual ); if ( !GetImage() ) { CAvatarImage *pImage = new CAvatarImage(); SetImage( pImage ); } CAvatarImage *pAvImage = ((CAvatarImage*)GetImage()); pAvImage->SetAvatarSteamID( steamIDForPlayer ); // Indent the image. These are deliberately non-resolution-scaling. pAvImage->SetAvatarSize( 32, 32 ); // Deliberately non scaling SetSize( pAvImage->GetWide(), GetTall() ); } } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFDeathMatchScoreBoardDialog::UpdatePlayerAvatar(int playerIndex, KeyValues *kv) { // Update their avatar if (kv && ShowAvatars() && steamapicontext->SteamFriends() && steamapicontext->SteamUtils()) { player_info_t pi; if (engine->GetPlayerInfo(playerIndex, &pi)) { if (pi.friendsID) { CSteamID steamIDForPlayer(pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual); // See if we already have that avatar in our list int iMapIndex = m_mapAvatarsToImageList.Find(steamIDForPlayer); int iImageIndex; if (iMapIndex == m_mapAvatarsToImageList.InvalidIndex()) { CAvatarImage *pImage = new CAvatarImage(); pImage->SetAvatarSteamID(steamIDForPlayer); pImage->SetAvatarSize(32, 32); // Deliberately non scaling pImage->SetDrawFriend(false); iImageIndex = m_pImageList->AddImage(pImage); m_mapAvatarsToImageList.Insert(steamIDForPlayer, iImageIndex); } else { iImageIndex = m_mapAvatarsToImageList[iMapIndex]; } kv->SetInt("avatar", iImageIndex); } } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CClientScoreBoardDialog::UpdatePlayerAvatar( int playerIndex, KeyValues *kv ) { // Update their avatar if ( kv && ShowAvatars() && steamapicontext->SteamFriends() && steamapicontext->SteamUtils() ) { player_info_t pi; if ( engine->GetPlayerInfo( playerIndex, &pi ) ) { if ( pi.friendsID ) { CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual ); // See if the avatar's changed int iAvatar = steamapicontext->SteamFriends()->GetFriendAvatar( steamIDForPlayer, k_EAvatarSize32x32 ); if ( m_iImageAvatars[playerIndex] != iAvatar ) { m_iImageAvatars[playerIndex] = iAvatar; // Now see if we already have that avatar in our list int iIndex = m_mapAvatarsToImageList.Find( iAvatar ); if ( iIndex == m_mapAvatarsToImageList.InvalidIndex() ) { CAvatarImage *pImage = new CAvatarImage(); pImage->SetAvatarSteamID( steamIDForPlayer ); pImage->SetAvatarSize( 32, 32 ); // Deliberately non scaling int iImageIndex = m_pImageList->AddImage( pImage ); m_mapAvatarsToImageList.Insert( iAvatar, iImageIndex ); } } int iIndex = m_mapAvatarsToImageList.Find( iAvatar ); if ( iIndex != m_mapAvatarsToImageList.InvalidIndex() ) { kv->SetInt( "avatar", m_mapAvatarsToImageList[iIndex] ); CAvatarImage *pAvIm = (CAvatarImage *)m_pImageList->GetImage( m_mapAvatarsToImageList[iIndex] ); pAvIm->UpdateFriendStatus(); } } } } }
void StatsReport::PerformLayout() { BaseClass::PerformLayout(); int padding = YRES( 6 ); int paddingSmall = YRES( 2 ); int nCategoryButtonX, nCategoryButtonY, nCategoryButtonW, nCategoryButtonH; nCategoryButtonY = m_pCategoryButtons[ 0 ]->GetTall(); m_pCategoryButtons[ 0 ]->SizeToContents(); m_pCategoryButtons[ 0 ]->SetTall( nCategoryButtonY ); m_pCategoryButtons[ 0 ]->GetBounds( nCategoryButtonX, nCategoryButtonY, nCategoryButtonW, nCategoryButtonH ); nCategoryButtonX += nCategoryButtonW + padding; // align stat lines in a vertical list one after the other for ( int i = 1; i < ASW_STATS_REPORT_CATEGORIES; i++ ) { m_pCategoryButtons[ i ]->SetPos( nCategoryButtonX, nCategoryButtonY ); m_pCategoryButtons[ i ]->SizeToContents(); m_pCategoryButtons[ i ]->SetTall( nCategoryButtonH ); nCategoryButtonW = m_pCategoryButtons[ i ]->GetWide(); nCategoryButtonX += nCategoryButtonW + padding; } // Check box int nPlayerBoundsW, nPlayerBoundsH; int nReadyCheckImageX, nReadyCheckImageY, nReadyCheckImageYOffset, nReadyCheckImageW, nReadyCheckImageH; m_pPlayerNamesPosition->GetBounds( nReadyCheckImageX, nReadyCheckImageY, nPlayerBoundsW, nPlayerBoundsH ); m_fPlayerNamePosY[ 0 ] = nReadyCheckImageY; nReadyCheckImageW = m_pReadyCheckImages[ 0 ]->GetTall(); nReadyCheckImageH = m_pReadyCheckImages[ 0 ]->GetTall(); nReadyCheckImageYOffset = nPlayerBoundsH / 2 - nReadyCheckImageH / 2; for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; i++ ) { m_pReadyCheckImages[ i ]->SetPos( nReadyCheckImageX, nReadyCheckImageY + nReadyCheckImageYOffset ); m_pReadyCheckImages[ i ]->SetSize( nReadyCheckImageW, nReadyCheckImageH ); m_fPlayerNamePosY[ i ] = nReadyCheckImageY; nReadyCheckImageY += nPlayerBoundsH + paddingSmall; } nPlayerBoundsW -= nReadyCheckImageW + paddingSmall; // Avatar int nAvatarImageX, nAvatarImageYOffset, nAvatarImageW, nAvatarImageH; nAvatarImageX = nReadyCheckImageX + nReadyCheckImageW + padding; nAvatarImageW = m_pAvatarImages[ 0 ]->GetWide(); nAvatarImageH = m_pAvatarImages[ 0 ]->GetTall(); nAvatarImageYOffset = nPlayerBoundsH / 2 - nAvatarImageH / 2; for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; i++ ) { m_pAvatarImages[ i ]->SetPos( nAvatarImageX, m_fPlayerNamePosY[ i ] + nAvatarImageYOffset ); m_pAvatarImages[ i ]->SetSize( nAvatarImageW, nAvatarImageH ); CAvatarImage *pImage = static_cast< CAvatarImage* >( m_pAvatarImages[ i ]->GetImage() ); if ( pImage ) { pImage->SetAvatarSize( nAvatarImageW, nAvatarImageH ); } } nPlayerBoundsW -= nAvatarImageW + paddingSmall; // Player name int nPlayerNameX; nPlayerNameX = nAvatarImageX + nAvatarImageW + paddingSmall; for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; i++ ) { m_pPlayerNames[ i ]->SetPos( nPlayerNameX, m_fPlayerNamePosY[ i ] ); m_pPlayerNames[ i ]->SetSize( nPlayerBoundsW, nPlayerBoundsH ); } SetStatCategory( 1 ); }
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++; } }