forked from icantstandpeople/potassium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCDrawManager.cpp
More file actions
136 lines (121 loc) · 5.82 KB
/
CDrawManager.cpp
File metadata and controls
136 lines (121 loc) · 5.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "CDrawManager.h"
//===================================================================================
CDrawManager gDrawManager;
#define ESP_HEIGHT 14
//===================================================================================
void CDrawManager::Initialize( )
{
if ( gInts.Surface == NULL )
return;
gInts.Engine->GetScreenSize( gScreenSize.iScreenWidth, gScreenSize.iScreenHeight );
m_Font = gInts.Surface->CreateFont( ); //This is better than Arial
gInts.Surface->SetFontGlyphSet( m_Font, "Tahoma", ESP_HEIGHT, 500, 0, 0, 0x200 );
}
//===================================================================================
Color CDrawManager::GetPlayerColor(CBaseEntity* pPlayer)
{
if (pPlayer->GetIndex() == gCvars.iAimbotIndex)
return Color::Green();
else if (!gCvars.PlayerMode[pPlayer->GetIndex()])
return Color(0, 255, 255, 255);
else if (gCvars.PlayerMode[pPlayer->GetIndex()] == 2)
return Color::Yellow();
else
{
switch (pPlayer->GetTeamNum())
{
case 2: //RED
return Color(255, 20, 20, 255);
case 3: //BLU
return Color(0, 153, 255, 255);
default:
return Color(0, 0, 0, 0);
}
}
return Color(0, 0, 0, 0); //no reason for this to be here, i just wanna look smart
}
//===================================================================================
void CDrawManager::DrawString( int x, int y, Color clrColor, const wchar_t *pszText)
{
if( pszText == NULL )
return;
gInts.Surface->DrawSetTextPos( x, y );
gInts.Surface->DrawSetTextFont( m_Font );
gInts.Surface->DrawSetTextColor( clrColor.r(), clrColor.g(), clrColor.b(), clrColor.a() );
gInts.Surface->DrawPrintText( pszText, wcslen( pszText ) );
}
//===================================================================================
void CDrawManager::DrawString( int x, int y, Color clrColor, const char *pszText, ... )
{
if( pszText == NULL )
return;
va_list va_alist;
char szBuffer[1024] = { '\0' };
wchar_t szString[1024] = { '\0' };
va_start( va_alist, pszText );
vsprintf_s( szBuffer, pszText, va_alist );
va_end( va_alist );
wsprintfW( szString, L"%S", szBuffer );
gInts.Surface->DrawSetTextPos( x, y );
gInts.Surface->DrawSetTextFont( m_Font );
gInts.Surface->DrawSetTextColor( clrColor.r(), clrColor.g(), clrColor.b(), clrColor.a() );
gInts.Surface->DrawPrintText( szString, wcslen( szString ) );
}
//===================================================================================
byte CDrawManager::GetESPHeight( )
{
return ESP_HEIGHT;
}
//===================================================================================
void CDrawManager::DrawLine(int x, int y, int x1, int y1, Color clrColor)
{
gInts.Surface->DrawSetColor(clrColor.r(), clrColor.g(), clrColor.b(), clrColor.a());
gInts.Surface->DrawLine(x, y, x1, y1);
}
//===================================================================================
void CDrawManager::DrawLineEx(int x, int y, int w, int h, Color clrColor)
{
gInts.Surface->DrawSetColor(clrColor.r(), clrColor.g(), clrColor.b(), clrColor.a());
gInts.Surface->DrawLine(x, y, x + w, y + h);
}
//===================================================================================
void CDrawManager::DrawRect( int x, int y, int w, int h, Color clrColor)
{
gInts.Surface->DrawSetColor( clrColor.r(), clrColor.g(), clrColor.b(), clrColor.a() );
gInts.Surface->DrawFilledRect( x, y, x + w, y + h );
}
//===================================================================================
void CDrawManager::OutlineRect( int x, int y, int w, int h, Color clrColor)
{
gInts.Surface->DrawSetColor( clrColor.r(), clrColor.g(), clrColor.b(), clrColor.a() );
gInts.Surface->DrawOutlinedRect( x, y, x + w, y + h );
}
//===================================================================================
void CDrawManager::DrawBox( Vector vOrigin, int r, int g, int b, int alpha, int box_width, int radius )
{
Vector vScreen;
if( !WorldToScreen( vOrigin, vScreen ) )
return;
int radius2 = radius<<1;
OutlineRect( vScreen.x - radius + box_width, vScreen.y - radius + box_width, radius2 - box_width, radius2 - box_width, Color::Black() );
OutlineRect( vScreen.x - radius - 1, vScreen.y - radius - 1, radius2 + ( box_width + 2 ), radius2 + ( box_width + 2 ), Color::Black() );
DrawRect( vScreen.x - radius + box_width, vScreen.y - radius, radius2 - box_width, box_width, Color( r, g, b, alpha ));
DrawRect( vScreen.x - radius, vScreen.y + radius, radius2, box_width, Color( r, g, b, alpha ));
DrawRect( vScreen.x - radius, vScreen.y - radius, box_width, radius2, Color( r, g, b, alpha ));
DrawRect( vScreen.x + radius, vScreen.y - radius, box_width, radius2 + box_width, Color( r, g, b, alpha ) );
}
//===================================================================================
bool CDrawManager::WorldToScreen( Vector &vOrigin, Vector &vScreen )
{
const matrix3x4& worldToScreen = gInts.Engine->WorldToScreenMatrix(); //Grab the world to screen matrix from CEngineClient::WorldToScreenMatrix
float w = worldToScreen[3][0] * vOrigin[0] + worldToScreen[3][1] * vOrigin[1] + worldToScreen[3][2] * vOrigin[2] + worldToScreen[3][3]; //Calculate the angle in compareson to the player's camera.
vScreen.z = 0; //Screen doesn't have a 3rd dimension.
if( w > 0.001 ) //If the object is within view.
{
float fl1DBw = 1 / w; //Divide 1 by the angle.
vScreen.x = (gScreenSize.iScreenWidth / 2) + ( 0.5 * ((worldToScreen[0][0] * vOrigin[0] + worldToScreen[0][1] * vOrigin[1] + worldToScreen[0][2] * vOrigin[2] + worldToScreen[0][3]) * fl1DBw) * gScreenSize.iScreenWidth + 0.5); //Get the X dimension and push it in to the Vector.
vScreen.y = (gScreenSize.iScreenHeight / 2) - ( 0.5 * ((worldToScreen[1][0] * vOrigin[0] + worldToScreen[1][1] * vOrigin[1] + worldToScreen[1][2] * vOrigin[2] + worldToScreen[1][3]) * fl1DBw) * gScreenSize.iScreenHeight + 0.5); //Get the Y dimension and push it in to the Vector.
return true;
}
return false;
}