//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointIcon::UpdateImage( void )
{
	int iOwner = ObjectiveResource()->GetOwningTeam( m_iCPIndex );

	if ( m_pBaseImage )
	{
		int iOwnerIcon = ObjectiveResource()->GetCPCurrentOwnerIcon( m_iCPIndex, iOwner );
		const char *szMatName = GetMaterialNameFromIndex( iOwnerIcon );

		if ( IsPointLocked() )
		{
			m_pBaseImage->SetImage( VarArgs("..\\%s_locked", szMatName ) );
		}
		else
		{
			m_pBaseImage->SetImage( VarArgs("..\\%s", szMatName ) );
		}
	}

	if ( m_pOverlayImage )
	{
		int iOverlayIcon = ObjectiveResource()->GetOverlayForTeam( m_iCPIndex, iOwner );
		if ( iOverlayIcon )
		{
			const char *szMatName = GetMaterialNameFromIndex( iOverlayIcon );
			m_pOverlayImage->SetImage( VarArgs("..\\%s", szMatName ) );
			m_pOverlayImage->SetVisible( true );
		}
		else
		{
			m_pOverlayImage->SetVisible( false );
		}
	}

	// Whenever a successful cap occurs, flash the cap point
	if ( m_pCapPulseImage )
	{
		if ( m_iPrevCappers != 0 && iOwner == m_iPrevCappers )
		{
			m_iPrevCappers = 0;

			if ( ShouldDraw() )
			{
				m_pCapPulseImage->SetVisible( true );
				m_pCapPulseImage->StartPulse( gpGlobals->curtime, GetWide() );
			}
			m_pBaseImage->StartPulsing( FINISHCAPANIM_SWOOP_LENGTH, 0.5, false );
		}
		
	}
}
Exemplo n.º 2
0
void C_VGuiScreen::OnDataChanged( DataUpdateType_t type )
{
	BaseClass::OnDataChanged( type );

	if ((type == DATA_UPDATE_CREATED) || (m_nPanelName != m_nOldPanelName))
	{
		CreateVguiScreen( PanelName() );
		m_nButtonState = 0;
	}

	// Set up the overlay material
	if (m_nOldOverlayMaterial != m_nOverlayMaterial)
	{
		m_OverlayMaterial.Shutdown();

		const char *pMaterialName = GetMaterialNameFromIndex(m_nOverlayMaterial);
		if (pMaterialName)
		{
			m_OverlayMaterial.Init( pMaterialName, TEXTURE_GROUP_VGUI );
		}
		else
		{
			m_OverlayMaterial.Init( m_WriteZMaterial );
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose:
// Input  : *pParticleMgr -
//			*pArgs -
//-----------------------------------------------------------------------------
void C_EntityParticleTrail::Start( )
{
    if( ParticleMgr()->AddEffect( &m_ParticleEffect, this ) == false )
        return;

    const char *pMaterialName = GetMaterialNameFromIndex( m_iMaterialName );
    if ( !pMaterialName )
        return;

    m_hMaterial	= ParticleMgr()->GetPMaterial( pMaterialName );
    m_teParticleSpawn.Init( 150 );
}
//-----------------------------------------------------------------------------
// Purpose: Draw the team's base icon at either end of the icon panel
//-----------------------------------------------------------------------------
bool CHudControlPointIcons::PaintTeamBaseIcon( int index, float flXPos, float flYPos, float flIconSize )
{
	float uv1 = 0.0f;
	float uv2 = 1.0f;

	// Find out which team owns the far left
	for ( int i = 0; i < MAX_TEAMS; i++ )
	{
		if ( ObjectiveResource()->GetBaseControlPointForTeam(i) == index )
		{
			int iTeamBaseIcon = ObjectiveResource()->GetBaseIconForTeam(i);
			if ( iTeamBaseIcon )
			{
				// Draw the Team's Base texture
				const char *szMatName = GetMaterialNameFromIndex( iTeamBaseIcon );

				vgui::surface()->DrawSetTextureFile( m_iTeamBaseTextures[i], szMatName, true, false );

				Vector2D uv11( uv1, uv1 );
				Vector2D uv21( uv2, uv1 );
				Vector2D uv22( uv2, uv2 );
				Vector2D uv12( uv1, uv2 );

				vgui::Vertex_t vert[4];	
				vert[0].Init( Vector2D( flXPos,					flYPos              ), uv11 );
				vert[1].Init( Vector2D( flXPos + flIconSize,	flYPos              ), uv21 );
				vert[2].Init( Vector2D( flXPos + flIconSize,	flYPos + flIconSize ), uv22 );				
				vert[3].Init( Vector2D( flXPos,					flYPos + flIconSize ), uv12 );

				vgui::surface()->DrawSetColor( Color(255,255,255,255) );	
				vgui::surface()->DrawTexturedPolygon( 4, vert );

				return true;
			}
		}
	}

	return false;
}