Пример #1
0
//-----------------------------------------------------------------------------
// Purpose:
// Input  : *panel -
//			fg -
//			bg -
//-----------------------------------------------------------------------------
void CHudPlayerOverlay::SetColorLevel( vgui::Panel *panel, Color& fg, Color& bg )
{
    float frac = GetAlphaFrac();

    if ( frac == 1.0f )
    {
        panel->SetFgColor( fg );
        panel->SetBgColor( bg );
        return;
    }

    Color foreground;
    Color background;

    foreground = fg;
    background = bg;

    int r, g, b, a;
    foreground.GetColor( r, g, b, a );
    foreground.SetColor( r, g, b, (int)( ( float )a * frac ) );

    panel->SetFgColor( foreground );

    background.GetColor( r, g, b, a );
    background.SetColor( r, g, b, (int)( ( float )a * frac ) );

    panel->SetBgColor( background );
}
Пример #2
0
void Visuals::DrawString(unsigned long font, int x, int y, Color color, unsigned long alignment, const char* msg, ...)
{

	va_list va_alist;
	char buf[1024];
	va_start(va_alist, msg);
	_vsnprintf(buf, sizeof(buf), msg, va_alist);
	va_end(va_alist);
	wchar_t wbuf[1024];
	MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256);

	int r = 255, g = 255, b = 255, a = 255;
	color.GetColor(r, g, b, a);

	int width, height;
	g_VGuiSurface->GetTextSize(font, wbuf, width, height);

	if (alignment & FONT_RIGHT)
		x -= width;
	if (alignment & FONT_CENTER)
		x -= width / 2;

	g_VGuiSurface->DrawSetTextFont(font);
	g_VGuiSurface->DrawSetTextColor(r, g, b, a);
	g_VGuiSurface->DrawSetTextPos(x, y - height / 2);
	g_VGuiSurface->DrawPrintText(wbuf, wcslen(wbuf));
}
Пример #3
0
SpewRetval_t NewSpew(SpewType_t Type, const char *What) {
	if (Removed || (!What || !ml_Lua)) {
		return SPEW_CONTINUE;
	}
	
	Color tempColor = GetSpewOutputColor();
	tempColor.GetColor(Red,Green,Blue,Alpha);
	
	ILuaObject* hook = ml_Lua->GetGlobal("hook");
		ILuaObject* hookCall = hook->GetMember("Call");
			ml_Lua->Push(hookCall);
			ml_Lua->Push("SimpleSpew");
			ml_Lua->PushNil();
			ml_Lua->PushLong(Type);
			ml_Lua->Push(What);
			ml_Lua->Push( GetSpewOutputGroup() );
			ml_Lua->PushLong( GetSpewOutputLevel() );
			ml_Lua->PushLong(Red);
			ml_Lua->PushLong(Green);
			ml_Lua->PushLong(Blue);
			ml_Lua->PushLong(Alpha);
			ml_Lua->Call(10,0);
		hookCall->UnReference();
	hook->UnReference();
	
	
	if (OldSpew) {
		return OldSpew(Type, What);
	} else {
		return (SpewRetval_t)0;
	}
}
Пример #4
0
void CHUDAutoAim::Paint()
{
	if( hud_draw_active_reticle.GetBool() )
	{
		int xCenter = m_vecPos.x;
		int yCenter = m_vecPos.y;

		int width, height;
		float xMod, yMod;

		vgui::surface()->DrawSetTexture( m_textureID_ActiveReticle );
		vgui::surface()->DrawSetColor( 255, 255, 255, m_alpha );
		vgui::surface()->DrawGetTextureSize( m_textureID_ActiveReticle, width, height );

		float uv1 = 0.5f / width, uv2 = 1.0f - uv1;

		vgui::Vertex_t vert[4];	

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

		xMod = width;
		yMod = height;

		xMod *= m_scale;
		yMod *= m_scale;

		xMod /= 2;
		yMod /= 2;

		vert[0].Init( Vector2D( xCenter + xMod, yCenter + yMod ), uv21 );
		vert[1].Init( Vector2D( xCenter - xMod, yCenter + yMod ), uv11 );
		vert[2].Init( Vector2D( xCenter - xMod, yCenter - yMod ), uv12 );
		vert[3].Init( Vector2D( xCenter + xMod, yCenter - yMod ), uv22 );
		vgui::surface()->DrawTexturedPolygon( 4, vert );
	}

	if( hud_draw_fixed_reticle.GetBool() )
	{
		CHudTexture *pIcon;

		pIcon = gHUD.GetIcon( "crosshair_xbox" );

		if ( pIcon != NULL )
		{
			float x, y;
			Vector screen;

			x = ScreenWidth()/2;
			y = ScreenHeight()/2;

			x -= pIcon->Width() / 2; 
			y -= pIcon->Height() / 2; 

			Color	clr;
			clr = gHUD.m_clrNormal;

			int r,g,b,a;

			clr.GetColor( r,g,b,a );

			C_BaseHLPlayer *pLocalPlayer = (C_BaseHLPlayer *)C_BasePlayer::GetLocalPlayer();
			if( pLocalPlayer && pLocalPlayer->m_HL2Local.m_hAutoAimTarget.Get() )
			{
				r = 250; 
				g = 138;
				b = 4;
			}

			clr.SetColor( r,g,b,m_alphaFixed);

			pIcon->DrawSelf( x, y, clr );
		}
	}
}