//----------------------------------------------------------------------------- // Purpose: Compute the size of the panel based upon the commander's zoom level //----------------------------------------------------------------------------- void CEntityPanel::ComputeAndSetSize( void ) { m_flScale = 1.0; // Scale the image // Use different scales in tactical / normal if ( IsLocalPlayerInTactical() ) { CClientModeCommander *commander = ( CClientModeCommander * )ClientModeCommander(); Assert( commander ); float flZoom = commander->GetCommanderOverlayPanel()->GetZoom(); // Scale our size m_flScale = 0.75 + (0.25 * (1.0 - flZoom)); // 1/2 size at max zoomed out, full size by half zoomed in } else if ( m_pBaseEntity ) { // Get distance to entity float flDistance = (m_pBaseEntity->GetRenderOrigin() - MainViewOrigin()).Length(); flDistance *= 2; m_flScale = 0.25 + MAX( 0, 2.0 - (flDistance / 2048) ); } // Update the size int w = m_iOrgWidth * m_flScale; int h = m_iOrgHeight * m_flScale; SetSize( w,h ); // Update the offsets too m_OffsetX = m_iOrgOffsetX * m_flScale; m_OffsetY = m_iOrgOffsetY * m_flScale; }
void CGroundLine::Draw() { if ( !m_pMaterial || m_nPoints < 2 ) return; if ( !IsVisible() ) return; float flAlpha = m_Alpha; if( g_pClientMode == ClientModeCommander() ) { flAlpha = 1; // draw bright.. } CBeamSegDraw beamDraw; beamDraw.Start( m_nPoints, m_pMaterial ); for( unsigned int i=0; i < m_nPoints; i++ ) { float t = (float)i / (m_nPoints - 1); CBeamSeg seg; seg.m_vPos = m_Points[i]; VectorLerp( m_vStartColor, m_vEndColor, t, seg.m_vColor ); seg.m_flTexCoord = 0; seg.m_flWidth = m_LineWidth; seg.m_flAlpha = m_Alpha; beamDraw.NextSeg( &seg ); } beamDraw.End(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CEntityPanel::ComputeParent( void ) { vgui::VPANEL parent = NULL; if ( IsLocalPlayerInTactical() || !m_bShowInNormal ) { CClientModeCommander *commander = ( CClientModeCommander * )ClientModeCommander(); Assert( commander ); parent = commander->GetCommanderOverlayPanel()->GetVPanel(); } else { parent = enginevgui->GetPanel( PANEL_CLIENTDLL ); } if ( !GetParent() || ( GetParent()->GetVPanel() != parent ) ) { SetParent( parent ); } }
//----------------------------------------------------------------------------- // Should we draw?. //----------------------------------------------------------------------------- bool CEntityPanel::ShouldDraw() { return ( ( IsLocalPlayerInTactical() && ClientModeCommander()->ShouldDrawEntity( m_pBaseEntity ) ) || ( !IsLocalPlayerInTactical() && m_bShowInNormal) ); }