//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDoDHudMGHeatIcon::ApplySchemeSettings( vgui::IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	m_clrActive = pScheme->GetColor( "HudMGHeatIcon.Active", GetFgColor() );
	m_clrActiveLow = pScheme->GetColor( "HudMGHeatIcon.ActiveLow", GetFgColor() );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDHudAmmo::ApplySchemeSettings( vgui::IScheme *pScheme )
{
    BaseClass::ApplySchemeSettings( pScheme );

    m_clrTextColor = pScheme->GetColor( "HudAmmoCount", GetFgColor() );
    m_clrTextXColor = pScheme->GetColor( "HudPanelBorder", GetFgColor() );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDoDHudMGHeatProgressBar::ApplySchemeSettings( vgui::IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	m_clrActive = pScheme->GetColor( "HudMGHeatBar.Active", GetFgColor() );
	m_clrActiveLow = pScheme->GetColor( "HudMGHeatBar.ActiveLow", GetFgColor() );
	m_clrInactive = pScheme->GetColor( "HudMGHeatBar.InActive", GetFgColor() );
	m_clrInactiveLow = pScheme->GetColor( "HudMGHeatBar.InActiveLow", GetFgColor() );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDoDHudHealthBar::ApplySchemeSettings( vgui::IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	m_clrHealthHigh = pScheme->GetColor( "HudHealthGreen", GetFgColor() );
	m_clrHealthMed = pScheme->GetColor( "HudHealthYellow", GetFgColor() );
	m_clrHealthLow = pScheme->GetColor( "HudHealthRed", GetFgColor() );
	m_clrBackground = pScheme->GetColor( "HudHealthBG", GetBgColor() );
	m_clrBorder = pScheme->GetColor( "HudHealthBorder", GetBgColor() );
}
Beispiel #5
0
void ColorCmd::Write (ostream& out) {
    Command::Write(out);
    Catalog* catalog = unidraw->GetCatalog();

    catalog->WriteColor(GetFgColor(), out);
    catalog->WriteColor(GetBgColor(), out);
}
//-----------------------------------------------------------------------------
// Purpose: Updates the label color each frame
//-----------------------------------------------------------------------------
void CHudLessonPanel::OnThink()
{
	m_pLabel->SetFgColor(GetFgColor());
	for (int i = 0; i < m_Labels.Count(); i++)
	{
		m_Labels[i]->SetFgColor(GetFgColor());
	}

	// If our label size isn't at the extreme's, we're sliding open / closed
	// This is a hack to get around InvalideLayout() not getting called when
	// m_flLabelSizePercentage is changed via a HudAnimation.
	if ( m_flLabelSizePercentage != 0.0 && m_flLabelSizePercentage != 1.0 || m_bLastLabelUpdateHack )
	{
		m_bLastLabelUpdateHack = (m_flLabelSizePercentage != 0.0 && m_flLabelSizePercentage != 1.0);
		InvalidateLayout();
	}
}
ProtectedMethod void CGUICommunity::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings( pScheme );

	SetFgColor( pScheme->GetColor("Modfg", GetFgColor()) );
	SetBgColor( Color(0, 0, 0, 0) );
	SetBorder( pScheme->GetBorder( "FrameBorder" ) );
}
void CGUIReportBug::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings( pScheme );

	SetFgColor( pScheme->GetColor( "Modfg", GetFgColor() ) );
	SetBgColor( Color( 0, 0, 0, 0 ) );
	SetBorder( pScheme->GetBorder( "FrameBorder" ) );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudControlPointIcons::ApplySchemeSettings( IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	m_hTextFont = pScheme->GetFont( "ChatFont" );

	m_clrBackground = pScheme->GetColor( "HudPanelBackground", GetFgColor() );
	m_clrBorder = pScheme->GetColor( "HudPanelBorder", GetBgColor() );
}
void CHudLessonPanel::ApplySchemeSettings( vgui::IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	SetFgColor( GetFgColor() );
	m_hFont = pScheme->GetFont( "HudHintTextLarge", true );
	m_pLabel->SetBgColor( Color( 0, 0, 0, 150 ) );
	m_pLabel->SetPaintBackgroundType( 2 );
	m_pLabel->SetSize( 0, GetTall() );		// Start tiny, it'll grow.
}
bool CHudSideHintPanel::SetHintText( wchar_t *text )
{
	// clear the existing text
	for (int i = 0; i < m_Labels.Count(); i++)
	{
		m_Labels[i]->MarkForDeletion();
	}
	m_Labels.RemoveAll();

	wchar_t *p = text;

	while ( p )
	{
		wchar_t *line = p;
		wchar_t *end = wcschr( p, L'\n' );
		int linelengthbytes = 0;
		if ( end )
		{
			//*end = 0;	//eek
			p = end+1;
			linelengthbytes = ( end - line ) * 2;
		}
		else
		{
			p = NULL;
		}

		// replace any key references with bound keys
		wchar_t buf[512];
		if (linelengthbytes)
			UTIL_ReplaceKeyBindings( line, linelengthbytes, buf, sizeof( buf ) );
		else
		{
			if (!p)
				UTIL_ReplaceKeyBindings( line, linelengthbytes, buf, sizeof( buf ) );
			else
				buf[0] = '\0';
		}

		// put it in a label
		vgui::Label *label = vgui::SETUP_PANEL(new vgui::Label(this, NULL, buf));
		label->SetFont( m_hFont );
		label->SetPaintBackgroundEnabled( false );
		label->SetPaintBorderEnabled( false );
		label->SizeToContents();
		label->SetContentAlignment( vgui::Label::a_west );
		label->SetFgColor( GetFgColor() );
		m_Labels.AddToTail( vgui::SETUP_PANEL(label) );
	}

	InvalidateLayout( true );

	return true;
}
Beispiel #12
0
void CHudChatFilterPanel::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	LoadControlSettings( "resource/UI/ChatFilters.res" );

	BaseClass::ApplySchemeSettings( pScheme );

	Color cColor = pScheme->GetColor( "DullWhite", GetBgColor() );
	SetBgColor( Color ( cColor.r(), cColor.g(), cColor.b(), CHAT_HISTORY_ALPHA ) );

	SetFgColor( pScheme->GetColor( "Blank", GetFgColor() ) );
}
ProtectedMethod void CWebWindow::ApplySchemeSettings( vgui::IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	SetFgColor( pScheme->GetColor("Modfg", GetFgColor()) );
	SetBgColor( Color(0, 0, 0, 0) );
	SetBorder( pScheme->GetBorder( "FrameBorder" ) );

	m_pHTMLMessage = dynamic_cast< vgui::HTML * > ( FindChildByName("HTMLMessage") );
	AssertMsg( m_pHTMLMessage, "HTML Widget" );
}
Beispiel #14
0
	virtual void ApplySchemeSettings(IScheme *pScheme)
	{
		// set up the scheme settings
		Button::ApplySchemeSettings(pScheme);

		_textColor = GetSchemeColor("PropertySheet.SelectedTextColor", GetFgColor(), pScheme);
		_dimTextColor = GetSchemeColor("PropertySheet.TextColor", GetFgColor(), pScheme);
		m_pActiveBorder = pScheme->GetBorder("TabActiveBorder");
		m_pNormalBorder = pScheme->GetBorder("TabBorder");

		if ( m_pImage )
		{
			ClearImages();
			m_pImage->SetImage(scheme()->GetImage(m_pszImageName, false));
			AddImage( m_pImage->GetImage(), 2 );
			int w, h;
			m_pImage->GetSize( w, h );
			w += m_pContextLabel ? 10 : 0;
			if ( m_pContextLabel )
			{
				m_pImage->SetPos( 10, 0 );
			}
			SetSize( w + 4, h + 2 );
		}
		else
		{
			int wide, tall;
			int contentWide, contentTall;
			GetSize(wide, tall);
			GetContentSize(contentWide, contentTall);

			wide = max(m_bMaxTabWidth, contentWide + 10);  // 10 = 5 pixels margin on each side
			wide += m_pContextLabel ? 10 : 0;
			SetSize(wide, tall);
		}

		if ( m_pContextLabel )
		{
			SetTextInset( 12, 0 );
		}
	}
//-----------------------------------------------------------------------------
// Purpose: Draw an icon with the group of static icons. 
//-----------------------------------------------------------------------------
void CBindPanel::DrawBackgroundIcon()
{
	if ( m_bController || !m_pBackground )		// no background image with controller buttons
		return;

	int iconWide = m_iIconTall * m_fWidthScale * m_fScale;

	// Don't draw the icon if we're on 360 and have a binding to draw
	m_pBackground->DrawSelf( 0, 0,
							 iconWide, m_iIconTall * m_fScale,
							 GetFgColor() );
}
Beispiel #16
0
void BitmapGraphic::Write (ostream& out) {
    Catalog* catalog = unidraw->GetCatalog();

    catalog->WriteBgFilled(BgFilled(), out);
    catalog->WriteBrush(GetBrush(), out);
    catalog->WriteColor(GetFgColor(), out);
    catalog->WriteColor(GetBgColor(), out);
    catalog->WriteFont(GetFont(), out);
    catalog->WritePattern(GetPattern(), out);
    catalog->WriteTransformer(GetTransformer(), out);

    catalog->WriteString(_fg_name, out);
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBasePanel::PaintBackground( void )
{
	if ( !m_bTexturedBackground )
	{
		BaseClass::PaintBackground();
		return;
	}

	if ( m_nBackgroundMaterial == -1 )
	{
		m_nBackgroundMaterial = vgui::surface()->CreateNewTextureID();
		vgui::surface()->DrawSetTextureFile( m_nBackgroundMaterial, m_szBgTexture, true, true );
	}
	
	vgui::surface()->DrawSetColor( GetFgColor() );

	// Draw it with texture
	vgui::surface()->DrawSetTexture( m_nBackgroundMaterial );

	if ( m_bTiled && ( !m_nTextureSize[ 0 ] ) )
	{
		vgui::surface()->DrawGetTextureSize( m_nBackgroundMaterial, m_nTextureSize[ 0 ], m_nTextureSize[ 1 ] );
	}

	int wide, tall;
	GetSize( wide, tall );

	if ( m_bTiled && m_nTextureSize[ 0 ] && m_nTextureSize[ 1 ] )
	{
		int x = 0;
		int y = 0;

		while ( y < tall )
		{
			vgui::surface()->DrawTexturedRect( 0, 0, m_nTextureSize[ 0 ], m_nTextureSize[ 1 ] );

			x += m_nTextureSize[ 0 ];

			if ( x >= wide )
			{
				x = 0;
				y += m_nTextureSize[ 1 ];
			}
		}
	}
	else
	{
		vgui::surface()->DrawTexturedRect( 0, 0, wide, tall );
	}
}
Beispiel #18
0
void CBaseHudChat::Paint( void )
{
#ifndef _XBOX
	if ( m_nVisibleHeight == 0 )
		return;

	int w, h;
	GetSize( w, h );

	vgui::surface()->DrawSetColor( GetBgColor() );
	vgui::surface()->DrawFilledRect( 0, h - m_nVisibleHeight, w, h );

	vgui::surface()->DrawSetColor( GetFgColor() );
	vgui::surface()->DrawOutlinedRect( 0, h - m_nVisibleHeight, w, h );
#endif
}
Beispiel #19
0
void JSlidePiece::Render()
{
    m_Pos.y = m_pSlideGame->m_TopLine + m_Speed*(JAnimServer::s_pInstance->GetCurTime() - m_StartTime);

    if (IsVisible())
    {   
        DWORD color = GetFgColor();
        if (IsHovered()) color = GetHoverFgColor();

        Frame ext = GetExt();
        ext.x = m_Pos.x;
        ext.y = m_Pos.y;
        SetExt( ext );

        ext.w = g_pDrawServer->GetFrameW( GetSkinPackID(), GetSkinFrame() );
        ext.h = g_pDrawServer->GetFrameH( GetSkinPackID(), GetSkinFrame() );
       
        g_pDrawServer->DrawSprite( ext, GetSkinPackID(), GetSkinFrame(), color );
        g_pDrawServer->Flush();
    }
} // JSlidePiece::Render
Beispiel #20
0
void CBaseHudChatLine::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings(pScheme);

	m_hFont = pScheme->GetFont( "Default" );

#ifdef HL1_CLIENT_DLL
	SetBgColor( Color( 0, 0, 0, 0 ) );
	SetFgColor( Color( 0, 0, 0, 0 ) );

	SetBorder( NULL );
#else
	SetBgColor( Color( 0, 0, 0, 100 ) );
#endif


	m_hFontMarlett = pScheme->GetFont( "Marlett" );

	m_clrText = pScheme->GetColor( "FgColor", GetFgColor() );
	SetFont( m_hFont );
}
Beispiel #21
0
	virtual void PerformLayout()
	{
		TextImage *textImage = GetTextImage();
		if (m_bSelected)
		{
			VPANEL focus = input()->GetFocus();
			// if one of the children of the SectionedListPanel has focus, then 'we have focus' if we're selected
			if (HasFocus() || (focus && ipanel()->HasParent(focus, GetVParent())))
			{
				textImage->SetColor(m_ArmedFgColor2);
			}
			else
			{
				textImage->SetColor(m_FgColor2);
			}
		}
		else
		{
			textImage->SetColor(GetFgColor());					
		}
		BaseClass::PerformLayout();
		Repaint();
	}
Beispiel #22
0
void CBaseHudChatInputLine::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings(pScheme);
	
	// FIXME:  Outline
	vgui::HFont hFont = pScheme->GetFont( "Trebuchet18" );

	m_pPrompt->SetFont( hFont );
	m_pInput->SetFont( hFont );

	SetPaintBackgroundEnabled( false );
	m_pPrompt->SetPaintBackgroundEnabled( false );
	m_pPrompt->SetContentAlignment( vgui::Label::a_west );
	m_pPrompt->SetTextInset( 2, 0 );

#ifdef HL1_CLIENT_DLL
	m_pInput->SetBgColor( Color( 255, 255, 255, 0 ) );
#else
	m_pInput->SetFgColor( GetFgColor() );
	m_pInput->SetBgColor( GetBgColor() );
#endif

}
Beispiel #23
0
void ScanLinePanel::Paint()
{
	vgui::surface()->DrawSetColor(GetFgColor());
	if (m_bDouble)
	{
		vgui::surface()->DrawSetTexture(m_nDoubleScanLine);	
	}
	else
	{
		vgui::surface()->DrawSetTexture(m_nSingleScanLine);	
	}
	int w, t;
	GetSize(w, t);
	float u = float(w) / 4.0f;
	float v = float(t) / 4.0f;
	vgui::Vertex_t points[4] = 
	{ 
	vgui::Vertex_t( Vector2D(0, 0), Vector2D(0,0) ), 
	vgui::Vertex_t( Vector2D(w, 0), Vector2D(u,0) ), 
	vgui::Vertex_t( Vector2D(w, t), Vector2D(u,v) ), 
	vgui::Vertex_t( Vector2D(0, t), Vector2D(0,v) ) 
	}; 
	vgui::surface()->DrawTexturedPolygon( 4, points );
}
Beispiel #24
0
Command* ColorCmd::Copy () {
    Command* copy = new ColorCmd(CopyControlInfo(), GetFgColor(),GetBgColor());
    InitCopy(copy);
    return copy;
}
Beispiel #25
0
void JButton::Render()
{
    Frame ext = GetExt();
    uint32_t clr = GetFgColor();
    int skinFrame = m_NormalFrame;

    if (IsBlendAdd())
    {
        g_pDrawServer->SetAdditive( true );
    }

    if (m_bPressed && m_PressedFrame != -1)
    {
        skinFrame = m_PressedFrame;
    }

    if (!IsEnabled())
    {
        if (m_DisabledFrame != -1)
        {
            skinFrame = m_DisabledFrame;
        }
        //clr = m_DisableFgColor;
    }

    if (IsHovered())
    {
        clr = GetHoverFgColor();
        if (m_HoverFrame != -1)
        {
            skinFrame = m_HoverFrame;
        }
    }

    g_pDrawServer->Flush();
    if (GetSkinPackID() >= 0)
    {
        g_pDrawServer->DrawSprite( ext, GetSkinPackID(), skinFrame, GetBgColor() );
    }
    g_pDrawServer->SetLinFilter( IsFilterFont() );
    g_pDrawServer->Flush();

    const char* text = GetText();
    if (text && text[0] != 0)
    {
        //  draw button text
        ext.w = g_pDrawServer->GetTextWidth( GetFontID(), text, GetFontHeight() );
        ext.h = GetFontHeight();
        ext = ApplyAlignment( ext, GetExt(), XAlign_Center, YAlign_Center );
        if (m_ShadowColor != 0)
        {
            g_pDrawServer->DrawString( ext.x + m_ShadowShiftX, ext.y + m_ShadowShiftY,
                GetFontID(), GetText(), m_ShadowColor, GetFontHeight() );
            g_pDrawServer->Flush();
        }
        g_pDrawServer->DrawString( ext.x, ext.y, GetFontID(), GetText(), clr, GetFontHeight() );
    }
    else if (m_GlyphID >= 0)
    {
        //  draw button glyph
        ext.w = g_pDrawServer->GetFrameW( m_GlyphID, m_GlyphFrame );
        ext.h = g_pDrawServer->GetFrameH( m_GlyphID, m_GlyphFrame );
        ext = ApplyAlignment( ext, GetExt(), XAlign_Center, YAlign_Center );
        g_pDrawServer->DrawSprite( ext.x, ext.y, m_GlyphID, m_GlyphFrame, GetFgColor() );
    }
    g_pDrawServer->Flush();

    if (IsBlendAdd())
    {
        g_pDrawServer->SetAdditive( false );
    }
} // JButton::Render
Beispiel #26
0
void JBlotPiece::Render()
{
    DWORD color = GetFgColor();
    float scale;
    if (m_bSelected) scale = m_Scale; else scale = 1.0f;

    //Moving the piece to m_MovePos
    if (m_bMoving)
    {
        Frame ext   = GetExt();
        float t     = JAnimServer::s_pInstance->GetCurTime() - m_StartMoveTime; 
        if (t >= 1.0f)
        {
            t = 1.0f;
            m_bMoving = false;
        }
        else if (t <= 0.0f) 
        {
            t = 0.0f;
        }
        Vec2 cur_pos( ext.x , ext.y );
        Vec2 pos    = cur_pos + t * (m_MovePos - cur_pos);
        ext.x       = pos.x;
        ext.y       = pos.y;
        SetExt( ext );
    }

    if (IsHovered()||m_bSelected) 
    {
        color = GetHoverFgColor();
    }

    Frame ext = GetLocalExt();
    Vec2 pos( ext.x, ext.y );
    float dist = pos.dist( m_HomePos );
    float c_SnapBias = 10.0f;
    if (dist < c_SnapBias)
    {
        m_bAtHome = true; 
    }
    else 
    {
        m_bAtHome = false;
    }

    ext = GetExt();
    ext.w = scale*g_pDrawServer->GetFrameW( GetSkinPackID(), GetSkinFrame() );
    ext.h = scale*g_pDrawServer->GetFrameH( GetSkinPackID(), GetSkinFrame() );
    
    if (m_bRipple)
    {
        //Start Rippling
        s_pThis = this;
        g_pDrawServer->Flush();
        g_pDrawServer->SetVertexCB( RippleCallback );
        g_pDrawServer->DrawSprite( ext, GetSkinPackID(), GetSkinFrame(), color );
        g_pDrawServer->Flush();
        g_pDrawServer->SetVertexCB( NULL );
        s_pThis = NULL;
        //Stop Rippling
    } else
    {
        //Simple drawing
        g_pDrawServer->DrawSprite( ext, GetSkinPackID(), GetSkinFrame(), color );
        g_pDrawServer->Flush();
    }

    JAnmContext& ctx = JAnimation::PushContext();

    ctx.m_Pos.x = ext.x;
    ctx.m_Pos.y = ext.y;
} // JBlotPiece::Render
//-----------------------------------------------------------------------------
// Purpose: Update and draw the frame
//-----------------------------------------------------------------------------
void VideoPlayerPanel::Paint( void )
{
	BaseClass::Paint();

	// Get our dimensions
	int xpos = 0;
	int ypos = 0;
	vgui::ipanel()->GetAbsPos( GetVPanel(), xpos, ypos );
//	GetPanelPos( xpos, ypos );
	int width = GetWide();
	int height = GetTall();

	
	// Are we playing the video?  Do we even have a video?
	if ( !m_VideoLoaded || !m_VideoPlaying )
	{
		vgui::surface()->DrawSetColor(  0, 0, 0, 255 );
		vgui::surface()->DrawFilledRect( 0, 0, width, height );
		return;		
	}
	
	if ( m_VideoMaterial == NULL )
		return;

	if ( m_VideoMaterial->Update() == false )
	{
		StopVideo();
		return;
	}

	// Black out the letterbox ares if we have them
	if ( m_letterBox != 0 )
	{
		vgui::surface()->DrawSetColor(  0, 0, 0, 255 );
		
		if ( m_letterBox == 1 )		// bars on top, bottom
		{
			int excess = ( height - m_nPlaybackHeight );
			int top = excess /2;
			int bot = excess - top;
		
			vgui::surface()->DrawFilledRect( 0, 0, width, top );
			vgui::surface()->DrawFilledRect( 0, height - bot, width, height );
		}
		
		if ( m_letterBox == 2 )		// bars on left, right
		{
			int excess = ( width - m_nPlaybackWidth );
			int left = excess /2;
			int right = excess - left;
		
			vgui::surface()->DrawFilledRect( 0, 0, left, height );
			vgui::surface()->DrawFilledRect( width-right, 0, width, height );
		}
	}

	// Draw the polys to draw this out
	CMatRenderContextPtr pRenderContext( materials );
	
	pRenderContext->MatrixMode( MATERIAL_VIEW );
	pRenderContext->PushMatrix();
	pRenderContext->LoadIdentity();

	pRenderContext->MatrixMode( MATERIAL_PROJECTION );
	pRenderContext->PushMatrix();
	pRenderContext->LoadIdentity();

	pRenderContext->Bind( m_pMaterial, NULL );

	CMeshBuilder meshBuilder;
	IMesh* pMesh = pRenderContext->GetDynamicMesh( true );
	meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );

	float flLeftX = xpos;
	float flRightX = xpos + ( m_nPlaybackWidth-1 );

	float flTopY = ypos;
	float flBottomY = ypos + ( m_nPlaybackHeight-1 );

	// Map our UVs to cut out just the portion of the video we're interested in
	float flLeftU = 0.0f;
	float flTopV = 0.0f;

	// We need to subtract off a pixel to make sure we don't bleed
	float flRightU = m_flU - ( 1.0f / (float) m_nPlaybackWidth );
	float flBottomV = m_flV - ( 1.0f / (float) m_nPlaybackHeight );

	// Get the current viewport size
	int vx, vy, vw, vh;
	pRenderContext->GetViewport( vx, vy, vw, vh );

	// map from screen pixel coords to -1..1
	flRightX = FLerp( -1, 1, 0, vw, flRightX );
	flLeftX = FLerp( -1, 1, 0, vw, flLeftX );
	flTopY = FLerp( 1, -1, 0, vh ,flTopY );
	flBottomY = FLerp( 1, -1, 0, vh, flBottomY );

	float alpha = ((float)GetFgColor()[3]/255.0f);

	for ( int corner=0; corner<4; corner++ )
	{
		bool bLeft = (corner==0) || (corner==3);
		meshBuilder.Position3f( (bLeft) ? flLeftX : flRightX, (corner & 2) ? flBottomY : flTopY, 0.0f );
		meshBuilder.Normal3f( 0.0f, 0.0f, 1.0f );
		meshBuilder.TexCoord2f( 0, (bLeft) ? flLeftU : flRightU, (corner & 2) ? flBottomV : flTopV );
		meshBuilder.TangentS3f( 0.0f, 1.0f, 0.0f );
		meshBuilder.TangentT3f( 1.0f, 0.0f, 0.0f );
		meshBuilder.Color4f( 1.0f, 1.0f, 1.0f, alpha );
		meshBuilder.AdvanceVertex();
	}
	
	meshBuilder.End();
	pMesh->Draw();

	pRenderContext->MatrixMode( MATERIAL_VIEW );
	pRenderContext->PopMatrix();

	pRenderContext->MatrixMode( MATERIAL_PROJECTION );
	pRenderContext->PopMatrix();
	
}
//-----------------------------------------------------------------------------
// Purpose: Update and draw the frame
//-----------------------------------------------------------------------------
void VideoPanel::Paint( void )
{
	BaseClass::Paint();

	// No video to play, so do nothing
	if ( m_BIKHandle == BIKHANDLE_INVALID || m_bPlaying == false )
	{
		return;
	}

	// Update our frame
	if ( bik->Update( m_BIKHandle ) == false )
	{
		if ( m_bRepeat )
		{
			Play();
		}
		else
		{
			OnClose();
		}
	}

	// Sit in the "center"
	int xpos, ypos;
	GetPanelPos( xpos, ypos );

	// Black out the background (we could omit drawing under the video surface, but this is straight-forward)
	if ( m_bBlackBackground )
	{
		vgui::surface()->DrawSetColor(  0, 0, 0, 255 );
		vgui::surface()->DrawFilledRect( 0, 0, GetWide(), GetTall() );
	}

	// Draw the polys to draw this out
	CMatRenderContextPtr pRenderContext( materials );
	
	pRenderContext->MatrixMode( MATERIAL_VIEW );
	pRenderContext->PushMatrix();
	pRenderContext->LoadIdentity();

	pRenderContext->MatrixMode( MATERIAL_PROJECTION );
	pRenderContext->PushMatrix();
	pRenderContext->LoadIdentity();

	pRenderContext->Bind( m_pMaterial, NULL );

	CMeshBuilder meshBuilder;
	IMesh* pMesh = pRenderContext->GetDynamicMesh( true );
	meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );

	float flLeftX = xpos;
	float flRightX = xpos + (m_nPlaybackWidth-1);

	float flTopY = ypos;
	float flBottomY = ypos + (m_nPlaybackHeight-1);

	// Map our UVs to cut out just the portion of the video we're interested in
	float flLeftU = 0.0f;
	float flTopV = 0.0f;

	// We need to subtract off a pixel to make sure we don't bleed
	float flRightU = m_flU - ( 1.0f / (float) m_nPlaybackWidth );
	float flBottomV = m_flV - ( 1.0f / (float) m_nPlaybackHeight );

	// Get the current viewport size
	int vx, vy, vw, vh;
	pRenderContext->GetViewport( vx, vy, vw, vh );

	// map from screen pixel coords to -1..1
	flRightX = FLerp( -1, 1, 0, vw, flRightX );
	flLeftX = FLerp( -1, 1, 0, vw, flLeftX );
	flTopY = FLerp( 1, -1, 0, vh ,flTopY );
	flBottomY = FLerp( 1, -1, 0, vh, flBottomY );

	float alpha = ((float)GetFgColor()[3]/255.0f);

	for ( int corner=0; corner<4; corner++ )
	{
		bool bLeft = (corner==0) || (corner==3);
		meshBuilder.Position3f( (bLeft) ? flLeftX : flRightX, (corner & 2) ? flBottomY : flTopY, 0.0f );
		meshBuilder.Normal3f( 0.0f, 0.0f, 1.0f );
		meshBuilder.TexCoord2f( 0, (bLeft) ? flLeftU : flRightU, (corner & 2) ? flBottomV : flTopV );
		meshBuilder.TangentS3f( 0.0f, 1.0f, 0.0f );
		meshBuilder.TangentT3f( 1.0f, 0.0f, 0.0f );
		meshBuilder.Color4f( 1.0f, 1.0f, 1.0f, alpha );
		meshBuilder.AdvanceVertex();
	}
	
	meshBuilder.End();
	pMesh->Draw();

	pRenderContext->MatrixMode( MATERIAL_VIEW );
	pRenderContext->PopMatrix();

	pRenderContext->MatrixMode( MATERIAL_PROJECTION );
	pRenderContext->PopMatrix();
}
Beispiel #29
0
void JObjectTree::RenderNode( JObject* pObject, const Frame& ext, bool bExpanded ) const
{
    static int spID = g_pDrawServer->GetSpriteID( "button" );
    int frameID = 11;
    int nCh = pObject->GetNChildren();
    if (nCh > 0)
    {
        frameID = 12;
        float connectW = 4.0f;
        if (bExpanded)
        {
            frameID = 14;
            Frame rcLine;
            rcLine.x = ext.r() - 2.0f;
            rcLine.h = float( nCh - 1 )*m_NodeHeight;
            rcLine.w = 2.0f;
            rcLine.y = ext.y - rcLine.h*0.5f + m_NodeHeight*0.5f;
            g_pDrawServer->DrawRect( rcLine, m_ConnectColor );
            connectW = 10.0f;
        }

        Frame rcConnect;
        rcConnect.x = ext.r() - 10.0f;
        rcConnect.h = 8.0f;
        rcConnect.w = connectW;
        rcConnect.y = ext.y + 3.0f;
        g_pDrawServer->DrawRect( rcConnect, m_ConnectColor );
    }

    Vec2 mousePos;
    g_pWindowServer->GetMousePos( mousePos );
    bool bHovered = ext.PtIn( mousePos.x, mousePos.y );

    DWORD bgColor = GetBgColor();
    DWORD fgColor = GetFgColor();

    if (bHovered)
    {
        bgColor = GetHoverBgColor();
        fgColor = GetHoverFgColor();
    }

    g_pDrawServer->DrawSprite( ext.x, ext.y, spID, frameID, bgColor );
    if (m_pSelected == pObject)
    {
        g_pDrawServer->DrawSprite( ext.x, ext.y, spID, 13, fgColor );
    }
    g_pDrawServer->Flush();
    float strW = g_pDrawServer->GetTextWidth(  GetFontID(), pObject->GetName() );
    Frame vp;
    Frame clipExt( ext );
    clipExt.w -= 10.0f;
    bool bClip = (strW > clipExt.w);
    if (bClip)
    {
        vp = g_pRenderServer->GetViewport();
        g_pRenderServer->SetViewport( clipExt );
    }
    g_pDrawServer->DrawString( ext.x + m_NodeCaptionPos.x, ext.y + m_NodeCaptionPos.y,
                               GetFontID(), pObject->GetName(), GetFgColor() );
    g_pDrawServer->Flush();
    if (bClip)
    {
        g_pRenderServer->SetViewport( vp );
    }
} // JObjectTree::RenderNode