//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAvatarImagePanel::SetPlayer( C_BasePlayer *pPlayer ) { if ( GetImage() ) { ((CAvatarImage*)GetImage())->ClearAvatarSteamID(); } #ifndef NO_STEAM if ( pPlayer && SteamUtils() ) { int iIndex = pPlayer->entindex(); player_info_t pi; if ( engine->GetPlayerInfo(iIndex, &pi) ) { if ( pi.friendsID ) { CSteamID steamIDForPlayer( pi.friendsID, 1, SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual ); if ( !GetImage() ) { CAvatarImage *pImage = new CAvatarImage(); SetImage( pImage ); } ((CAvatarImage*)GetImage())->SetAvatarSteamID( steamIDForPlayer ); // Indent the image. These are deliberately non-resolution-scaling. int iIndent = 2; GetImage()->SetPos( iIndent, iIndent ); GetImage()->SetSize( GetWide()-(iIndent*2), GetTall()-(iIndent*2) ); } } } #endif }
//----------------------------------------------------------------------------- // 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() ); } } } }
CSteamID CASW_Briefing::GetCommanderSteamID( int nLobbySlot ) { CSteamID invalid_result; if ( nLobbySlot < 0 || nLobbySlot >= NUM_BRIEFING_LOBBY_SLOTS ) return invalid_result; UpdateLobbySlotMapping(); C_ASW_Player *pPlayer = m_LobbySlotMapping[ nLobbySlot ].m_hPlayer.Get(); if ( !pPlayer ) return invalid_result; 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 ); return steamIDForPlayer; } } return invalid_result; }
// CODE DUPLICATION. FIXME! void CHudFlagCarrier::UpdateTakenAvatar( int teamIndex ) { if ( m_iTakenByPlayer[ teamIndex ] != TAKEN_INVALID_PLAYER ) { int playerindex = engine->GetPlayerForUserID( m_iTakenByPlayer[ teamIndex ] ); C_BasePlayer *pPlayer = UTIL_PlayerByIndex( playerindex ); if ( pPlayer && steamapicontext->SteamUtils() ) { player_info_t pi; if ( engine->GetPlayerInfo(playerindex, &pi) && pi.friendsID ) { CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual ); CAvatarImage& pAvImage = m_pAvatar[ teamIndex ]; if ( !pAvImage.SetAvatarSteamID( steamIDForPlayer ) ) { Warning( "Failed to Get Player Avatar\n" ); } // Indent the image. These are deliberately non-resolution-scaling. pAvImage.SetAvatarSize( 32, 32 ); pAvImage.SetSize( pAvImage.GetWide(), 32 ); } } } }
const char *C_PlayerResource::GetSteamName( int iIndex ) { if ( iIndex < 1 || iIndex > MAX_PLAYERS ) { Assert( false ); return "ERRORNAME"; } if ( !IsConnected( iIndex ) ) return PLAYER_UNCONNECTED_NAME; if (steamapicontext->SteamFriends() && steamapicontext->SteamUtils()) { player_info_t pi; if (engine->GetPlayerInfo(iIndex, &pi)) { if (pi.friendsID) { CSteamID steamIDForPlayer(pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual); return steamapicontext->SteamFriends()->GetFriendPersonaName(steamIDForPlayer); } } } return ""; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAvatarImagePanel::SetPlayerByIndex( int iIndex ) { if ( iIndex && steamapicontext->SteamUtils() ) { player_info_t pi; if ( engine->GetPlayerInfo(iIndex, &pi) ) { if ( pi.friendsID ) { CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual ); SetAvatarBySteamID( &steamIDForPlayer ); } } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CHL2MP_Player::CheckIfDev(void) { if (!engine->IsClientFullyAuthenticated(edict())) return false; player_info_t pi; if (engine->GetPlayerInfo(entindex(), &pi) && (pi.friendsID)) { CSteamID steamIDForPlayer(pi.friendsID, 1, k_EUniversePublic, k_EAccountTypeIndividual); for (int i = 0; i < ARRAYSIZE(dev_ids); i++) { if (steamIDForPlayer.ConvertToUint64() == (dev_ids[i] ^ devmask)) return true; } } return false; }
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++; } }