//-----------------------------------------------------------------------------
// Frame-based update
//-----------------------------------------------------------------------------
void CVehicleFlatbedControlPanel::OnTick()
{
	BaseClass::OnTick();

	C_BaseObject *pObj = GetOwningObject();
	if (!pObj)
		return;

	Assert( dynamic_cast<C_VehicleFlatbed*>(pObj) );
	C_VehicleFlatbed *pRam = static_cast<C_VehicleFlatbed*>(pObj);

	char buf[256];
	// Update the currently manned player label
	if ( pRam->GetDriverPlayer() )
	{
		Q_snprintf( buf, sizeof( buf ), "Driven by %s", pRam->GetDriverPlayer()->GetPlayerName() );
		m_pDriverLabel->SetText( buf );
		m_pDriverLabel->SetVisible( true );
	}
	else
	{
		m_pDriverLabel->SetVisible( false );
	}

	int nPassengerCount = pRam->GetPassengerCount();
	int nMaxPassengerCount = pRam->GetMaxPassengerCount();

	Q_snprintf( buf, sizeof( buf ), "Passengers %d/%d", nPassengerCount >= 1 ? nPassengerCount - 1 : 0, nMaxPassengerCount - 1 );
	m_pPassengerLabel->SetText( buf );

	// Update the get in button
	if ( pRam->IsPlayerInVehicle( C_BaseTFPlayer::GetLocalPlayer() ) ) 
	{
		m_pOccupyButton->SetEnabled( false );
		return;
	}

	if ( pRam->GetOwner() == C_BaseTFPlayer::GetLocalPlayer() )
	{
		if (nPassengerCount == nMaxPassengerCount)
		{
			// Owners can boot other players to get in
			C_BaseTFPlayer *pPlayer = static_cast<C_BaseTFPlayer*>(pRam->GetPassenger( VEHICLE_ROLE_DRIVER ));
			Q_snprintf( buf, sizeof( buf ), "Get In (Ejecting %s)", pPlayer->GetPlayerName() );
			m_pDriverLabel->SetText( buf );
			m_pOccupyButton->SetEnabled( true );
		}
		else
		{
			m_pOccupyButton->SetText( "Get In" );
			m_pOccupyButton->SetEnabled( true );
		}
	}
	else
	{
		m_pOccupyButton->SetText( "Get In" );
		m_pOccupyButton->SetEnabled( pRam->GetPassengerCount() < pRam->GetMaxPassengerCount() );
	}
}
void CPortalStatsDisplayScreen::UpdateTextFields( C_PropPortalStatsDisplay *pPropPortalStatsDisplay )
{
	bool bIsTime = pPropPortalStatsDisplay->IsTime();
	float fNumPlayer = pPropPortalStatsDisplay->GetNumPlayerDisplay();
	float fNumGoal = pPropPortalStatsDisplay->GetNumGoalDisplay();

	// Figure out colors

	Color *( pColors[ 3 ] ) = { &m_cUnknown, &m_cFail, &m_cPass };

	int iColor = pPropPortalStatsDisplay->GetGoalSuccess() + 1;

	m_pNumPlayerLabel->SetFgColor( ( fNumPlayer != 0.0f ) ? ( *pColors[ iColor ] ) : ( m_cInvisible ) );
	m_pNumGoalLabel->SetFgColor( ( pPropPortalStatsDisplay->GetGoalVisible() ) ? ( *pColors[ iColor ] ) : ( m_cInvisible ) );

	// Fill in labels

	CFmtStr str;

	if ( !bIsTime )
	{
		str.sprintf( "%.0f", fNumPlayer );
		m_pNumPlayerLabel->SetText( str );

		str.sprintf( "%.0f", fNumGoal );
		m_pNumGoalLabel->SetText( str );
	}
	else
	{
		// break seconds into mnutes and seconds
		int iMinutes = static_cast<int>( fNumPlayer / 60.0f );
		int iHours = iMinutes / 60;
		iMinutes %= 60;
		int iSeconds = static_cast<int>( fNumPlayer ) % 60;
		MakeTimeString( str, iHours, iMinutes, iSeconds );
		m_pNumPlayerLabel->SetText( str );

		// break seconds into mnutes and seconds
		iMinutes = static_cast<int>( fNumGoal / 60.0f );
		iHours = iMinutes / 60;
		iMinutes %= 60;
		iSeconds = static_cast<int>( fNumGoal ) % 60;
		MakeTimeString( str, iHours, iMinutes, iSeconds );
		m_pNumGoalLabel->SetText( str );
	}

	// Draw cheated label when needed
	m_pCheatedLabel->SetVisible( pPropPortalStatsDisplay->HasCheated() );
}
//-----------------------------------------------------------------------------
// Frame-based update
//-----------------------------------------------------------------------------
void CTeleportCountdownScreen::OnTick()
{
	BaseClass::OnTick();

	// Find the active info teleporter countdown
	C_InfoTeleporterCountdown *pActiveCountdown = NULL;
	for ( int i = g_InfoTeleporterCountdownList.Head(); i != g_InfoTeleporterCountdownList.InvalidIndex();
		i = g_InfoTeleporterCountdownList.Next(i) )
	{
		if ( g_InfoTeleporterCountdownList[i]->m_bCountdownStarted )
		{
			pActiveCountdown = g_InfoTeleporterCountdownList[i];
			break;
		}
	}

	if ( !GetEntity() || !pActiveCountdown )
	{
		m_pTimeRemainingTitleLabel->SetVisible( false );
		m_pTimeRemainingLabel->SetVisible( false );
		m_pMalfunctionLabel->SetVisible( false );

		return;
	}

	// Make the appropriate labels visible
	bool bMalfunction = pActiveCountdown->m_bDisabled;
	m_pTimeRemainingTitleLabel->SetVisible( !bMalfunction );
	m_pTimeRemainingLabel->SetVisible( !bMalfunction );

	// This will make it flash
	m_pMalfunctionLabel->SetVisible( bMalfunction && (((int)(gpGlobals->curtime) & 0x1) == 0x1) );

	// Update the time remaining
	if ( !bMalfunction )
	{
		char buf[32];
		if (m_pTimeRemainingLabel)
		{
			float dt = gpGlobals->curtime - pActiveCountdown->m_flStartTime;
			if ( dt < 0.0f )
			{
				dt = 0.0f;
			}

			int nTimeRemaining = (int)(pActiveCountdown->m_flTimeRemaining - dt + 0.5f); 
			if ( nTimeRemaining < 0 )
			{
				nTimeRemaining = 0;
			}

			Q_snprintf( buf, sizeof( buf ), "%d", nTimeRemaining );
			m_pTimeRemainingLabel->SetText( buf );
		}
	}
}
Ejemplo n.º 4
0
//==============================================
// CHudFlags's Paint
// errr... paints the panel
//==============================================
void CHudCTFFlags::Paint()
{
	int m_iFlagCount = g_CtfFlags.Count();

	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();

	if( !pPlayer )
		return;


	//char text[512];
	int i;// = 0;
	int x_offset = 0;
	//int y_offset = 5;
	Color ColourWhite( 255, 255, 255, 255 );

	i = 0;
	while (i < MAX_FLAGS)
	{
		m_pLabelFlag[i]->SetVisible(false);
		i++;
	}
	
	//x_offset = ( (ScreenWidth() / 2) - (m_iFlagCount * 74) ); //Always lean to the left from the center. -HairyPotter
	x_offset = 0;

	for( i = 0; i < m_iFlagCount; i++ )
	{

		x_offset += 68;

		float fTimeToCap = gpGlobals->curtime;
		//switch( g_Flags[i]->m_iLastTeam )
		switch( g_CtfFlags[i]->GetTeamNumber() )
		{
		case TEAM_UNASSIGNED:
			switch( g_CtfFlags[i]->m_iForTeam )
			{
			case 0:
				m_pIconBlank->DrawSelf( x_offset, 0, ColourWhite );
				break;
			case 1: //This flag is picked up by the brits... so it's actually the american flag.
				m_pIconBlue->DrawSelf( x_offset, 0, ColourWhite );
				break;
			case 2: //This flag is picked up by the americans... so it's actually the british flag.
				m_pIconRed->DrawSelf( x_offset, 0, ColourWhite );
				break;
			}
			break;
		case TEAM_AMERICANS:
			m_pIconBlue->DrawSelf( x_offset, 0, ColourWhite );
			break;
		case TEAM_BRITISH:
			m_pIconRed->DrawSelf( x_offset, 0, ColourWhite );
			break;
		}

		if ( g_CtfFlags[i]->m_bIsCarried )
		{
			int r=0,g=0,b=0;
			
			//Start at blue.
			r = 0;
			g = 0;
			b = 255;
			//End up at red.
			r += 255 * (sin(fTimeToCap*4) + 1)/2;
			//g -= 100 * (sin(gpGlobals->curtime*4) + 1)/2;
			b -= 255 * (sin(fTimeToCap*4) + 1)/2;

			m_pLabelFlag[i]->SetText( "Taken" );
			m_pLabelFlag[i]->SizeToContents();
			//m_pLabelFlag[i]->SetVisible( true );

			//center on icon
			int w,h;
			m_pLabelFlag[i]->GetSize( w, h );
			m_pLabelFlag[i]->SetPos( (x_offset + 32) - w/2, 32 - h/2 );

			m_pLabelFlag[i]->SetFgColor( Color(r,g,b,255) );
			m_pLabelFlag[i]->SetVisible(true);
		}

		if ( g_CtfFlags[i]->GetMoveParent() && g_CtfFlags[i]->GetMoveParent() == pPlayer )
		{
			int ystart = GetTall() - 140; //Place this just above the LMS indicator.
			int w,h;

			m_pLabelCarrier->SetText( g_pVGuiLocalize->Find("#CTF"));
			m_pLabelCarrier->SizeToContents();
			m_pLabelCarrier->GetSize( w, h );
			m_pLabelCarrier->SetPos( 5, ystart - 1.3*h);
			m_pLabelCarrier->SetFgColor( ColourWhite );
			m_pLabelCarrier->SetVisible( true );
			//Msg("You are carrying a flag! \n");
		}
		else 
			m_pLabelCarrier->SetVisible( false );
	}
}