//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: // // $NoKeywords: $ //=============================================================================// #include "cbase.h" #include "dodteammenu.h" #include #include "hud.h" // for gEngfuncs #include "c_dod_player.h" #include "dod_gamerules.h" #include #include #include #include "c_dod_team.h" #include "IGameUIFuncs.h" // for key bindings extern IGameUIFuncs *gameuifuncs; // for key binding details using namespace vgui; //----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- CDODTeamMenu::CDODTeamMenu(IViewPort *pViewPort) : CTeamMenu(pViewPort) { m_pBackground = SETUP_PANEL( new CDODMenuBackground( this ) ); m_pPanel = new EditablePanel( this, "TeamImagePanel" );// team image panel m_pFirstButton = NULL; LoadControlSettings("Resource/UI/TeamMenu.res"); // reload this to catch DODButtons vgui::ivgui()->AddTickSignal( GetVPanel() ); m_iActiveTeam = TEAM_UNASSIGNED; m_iLastPlayerCount = -1; } //----------------------------------------------------------------------------- // Purpose: Destructor //----------------------------------------------------------------------------- CDODTeamMenu::~CDODTeamMenu() { } void CDODTeamMenu::ShowPanel(bool bShow) { if ( bShow ) { engine->CheckPoint( "TeamMenu" ); //MATTTODO what is this? m_iTeamMenuKey = gameuifuncs->GetButtonCodeForBind( "changeteam" ); } BaseClass::ShowPanel( bShow ); } //----------------------------------------------------------------------------- // Purpose: Make the first buttons page get displayed when the menu becomes visible //----------------------------------------------------------------------------- void CDODTeamMenu::SetVisible( bool state ) { BaseClass::SetVisible( state ); for( int i = 0; i< GetChildCount(); i++ ) // get all the buy buttons to performlayout { CDODMouseOverButton *button = dynamic_cast *>(GetChild(i)); if ( button ) { if( button == m_pFirstButton && state == true ) button->ShowPage(); else button->HidePage(); button->InvalidateLayout(); } } if ( state ) { Panel *pAutoButton = FindChildByName( "autobutton" ); if ( pAutoButton ) { pAutoButton->RequestFocus(); } } } void CDODTeamMenu::OnTick( void ) { C_DODTeam *pAllies = dynamic_cast( GetGlobalTeam(TEAM_ALLIES) ); C_DODTeam *pAxis = dynamic_cast( GetGlobalTeam(TEAM_AXIS) ); if ( !pAllies || !pAxis ) return; static int iLastAlliesCount = -1; static int iLastAxisCount = -1; int iNumAllies = pAllies->Get_Number_Players(); int iNumAxis = pAxis->Get_Number_Players(); if ( iNumAllies != iLastAlliesCount ) { iLastAlliesCount = iNumAllies; wchar_t wbuf[128]; if ( iNumAllies == 1 ) { g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), g_pVGuiLocalize->Find("#teammenu_numAllies_1"), 0 ); } else { wchar_t wnum[6]; _snwprintf( wnum, ARRAYSIZE(wnum), L"%d", iNumAllies ); g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), g_pVGuiLocalize->Find("#teammenu_numAllies"), 1, wnum ); } Label *pLabel = dynamic_cast