-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDraw.cpp
151 lines (131 loc) · 4.33 KB
/
Draw.cpp
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include "precompiled.h"
#include "Draw.h"
#include "CustomFont.h"
// Font List
HFont ESPFONT;
HFont ESPNumberFont;
HFont WeaponIcon;
// Textures
IMaterial* visible_tex;
IMaterial* hidden_tex;
IMaterial* visible_flat;
IMaterial* hidden_flat;
void SetupTextures()
{
}
void SetupFonts()
{
// TODO : ENCRYPT
// Setup Fonts allowing custom fonts for text
Interfaces::Surface->SetFontGlyphSet(ESPFONT = Interfaces::Surface->Create_Font(), "Tahoma", 12, FW_EXTRABOLD, NULL, NULL, FONTFLAG_OUTLINE);
Interfaces::Surface->SetFontGlyphSet(ESPNumberFont = Interfaces::Surface->Create_Font(), "Tahoma", 13, FW_LIGHT, NULL, NULL, FONTFLAG_OUTLINE | FONTFLAG_DROPSHADOW);
Interfaces::Surface->SetFontGlyphSet(WeaponIcon = Interfaces::Surface->Create_Font(), "Arial", 18, 300, 0, 0, 0x210);
}
void DrawFilledRect(int x, int y, int w, int h, Color col)
{
int r = 255, g = 255, b = 255, a = 255;
col.GetColor(r, g, b, a);
Interfaces::Surface->DrawSetColor(r, g, b, a);
Interfaces::Surface->DrawFilledRect(x, y, x + w, y + h);
}
void DrawLine(int x0, int y0, int x1, int y1, Color col)
{
Interfaces::Surface->DrawSetColor(col);
Interfaces::Surface->DrawLine(x0, y0, x1, y1);
}
void DrawRect(int x, int y, int w, int h, Color col)
{
Interfaces::Surface->DrawSetColor(col);
Interfaces::Surface->DrawRect(x, y, x + w, y + h);
}
void DrawOutlinedRect(int x, int y, int w, int h, Color col)
{
Interfaces::Surface->DrawSetColor(col);
Interfaces::Surface->DrawOutlinedRect(x, y, x + w, y + h);
}
void DrawPixel(int x, int y, Color col)
{
Interfaces::Surface->DrawSetColor(col);
Interfaces::Surface->DrawRect(x, y, x + 1, y + 1);
}
void GetTextSize(unsigned long& Font, int& w, int& h, const char* strText, ...)
{
char buf[1024];
wchar_t wbuf[1024];
va_list vlist;
va_start(vlist, strText);
vsprintf(buf, strText, vlist);
va_end(vlist);
MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256);
Interfaces::Surface->GetTextSize(Font, wbuf, w, h);
}
void DrawStringOutlined(unsigned long& Font, Vector2D pos, Color c, unsigned int flags, const char* strText, ...)
{
wchar_t formated[128] = { '\0' };
wsprintfW(formated, L"%S", strText);
char buf[1024];
wchar_t wbuf[1024];
va_list vlist;
va_start(vlist, strText);
vsprintf(buf, strText, vlist);
MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256);
int w, h;
GetTextSize(Font, w, h, strText, vlist);
va_end(vlist);
if (flags & 1)
pos.x -= w / 2.0f;
if (flags & 2)
pos.y -= h / 2.0f;
Interfaces::Surface->DrawSetTextFont(Font);
Interfaces::Surface->DrawSetTextColor(0, 0, 0, 255);
Interfaces::Surface->DrawSetTextPos(pos.x + 1, pos.y + 1);
Interfaces::Surface->DrawPrintText(wbuf, wcslen(wbuf));
Interfaces::Surface->DrawSetTextPos(pos.x - 1, pos.y + 1);
Interfaces::Surface->DrawPrintText(wbuf, wcslen(wbuf));
Interfaces::Surface->DrawSetTextPos(pos.x + 1, pos.y - 1);
Interfaces::Surface->DrawPrintText(wbuf, wcslen(wbuf));
Interfaces::Surface->DrawSetTextPos(pos.x - 1, pos.y - 1);
Interfaces::Surface->DrawPrintText(wbuf, wcslen(wbuf));
Interfaces::Surface->DrawSetTextColor(c.r(), c.g(), c.b(), c.a());
Interfaces::Surface->DrawSetTextPos(pos.x, pos.y);
Interfaces::Surface->DrawPrintText(wbuf, wcslen(wbuf));
}
void FillRGBA(int x, int y, int w, int h, Color col)
{
Interfaces::Surface->DrawSetColor(col);
Interfaces::Surface->DrawFilledRect(x, y, x + w, y + h);
}
void DrawCircle(float x, float y, float r, float s, Color color)
{
float Step = M_PI * 2.0 / s;
for (float a = 0; a < (M_PI*2.0); a += Step)
{
float x1 = r * cos(a) + x;
float y1 = r * sin(a) + y;
float x2 = r * cos(a + Step) + x;
float y2 = r * sin(a + Step) + y;
DrawLine(x1, y1, x2, y2, color);
}
}
void DrawString(HFont font, int x, int y, Color color, DWORD 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;
Interfaces::Surface->GetTextSize(font, wbuf, width, height);
if (alignment & FONT_RIGHT)
x -= width;
if (alignment & FONT_CENTER)
x -= width / 2;
Interfaces::Surface->DrawSetTextFont(font);
Interfaces::Surface->DrawSetTextColor(r, g, b, a);
Interfaces::Surface->DrawSetTextPos(x, y - height / 2);
Interfaces::Surface->DrawPrintText(wbuf, wcslen(wbuf));
}