#include "cbase.h" #include "PlayersWaitingPanel.h" #include "vgui/isurface.h" #include #include #include "c_asw_game_resource.h" #include "c_playerresource.h" // memdbgon must be the last include file in a .cpp file!!! #include PlayersWaitingPanel::PlayersWaitingPanel(vgui::Panel *parent, const char *panelName) : vgui::Panel(parent, panelName) { m_pTitle = new vgui::Label(this, "Title", "#asw_commanders"); for (int i=0;iSetBounds(padding, padding, title_wide, row_height); int name_wide = title_wide * 0.6f; int ready_wide = title_wide * 0.4f; for (int i=0;iSetBounds(padding, (i+1) * (row_height) + padding, name_wide, row_height); m_pPlayerReadyLabel[i]->SetBounds(padding + name_wide, (i+1) * (row_height) + padding, ready_wide, row_height); } } void PlayersWaitingPanel::ApplySchemeSettings(vgui::IScheme *pScheme) { BaseClass::ApplySchemeSettings(pScheme); SetPaintBackgroundEnabled(true); SetPaintBackgroundType(0); SetBgColor(Color(0,0,0,128)); vgui::HFont DefaultFont = pScheme->GetFont( "Default", IsProportional() ); m_pTitle->SetFont(DefaultFont); m_pTitle->SetFgColor(Color(255,255,255,255)); for (int i=0;iSetFont(DefaultFont); m_pPlayerReadyLabel[i]->SetFgColor(pScheme->GetColor("LightBlue", Color(128,128,128,255))); m_pPlayerNameLabel[i]->SetFont(DefaultFont); m_pPlayerNameLabel[i]->SetFgColor(pScheme->GetColor("LightBlue", Color(128,128,128,255))); } } void PlayersWaitingPanel::OnThink() { C_ASW_Game_Resource* pGameResource = ASWGameResource(); if (!pGameResource) return; // set labels and ready status from players int iNumPlayersInGame = 0; for ( int j = 1; j <= gpGlobals->maxClients; j++ ) { if ( g_PR->IsConnected( j ) ) { m_pPlayerNameLabel[iNumPlayersInGame]->SetText(g_PR->GetPlayerName(j)); bool bReady = pGameResource->IsPlayerReady(j); if (bReady) m_pPlayerReadyLabel[iNumPlayersInGame]->SetText("#asw_campaign_ready"); else m_pPlayerReadyLabel[iNumPlayersInGame]->SetText("#asw_campaign_waiting"); iNumPlayersInGame++; } } // hide further panels in for (int j=iNumPlayersInGame;jSetText(""); m_pPlayerReadyLabel[j]->SetText(""); } }