forked from SrSeanMC/Valorant-External-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.hpp
241 lines (211 loc) · 7.31 KB
/
renderer.hpp
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
typedef struct
{
DWORD R;
DWORD G;
DWORD B;
DWORD A;
}RGBA;
class Color
{
public:
RGBA red = { 255,0,0,255 };
RGBA Magenta = { 255,0,255,255 };
RGBA yellow = { 255,255,0,255 };
RGBA grayblue = { 128,128,255,255 };
RGBA green = { 0, 255, 0, 255 };
RGBA darkgreen = { 0,224,128,255 };
RGBA brown = { 192,96,0,255 };
RGBA pink = { 255,168,255,255 };
RGBA DarkYellow = { 216,216,0,255 };
RGBA SilverWhite = { 236,236,236,255 };
RGBA purple = { 144,0,255,255 };
RGBA Navy = { 88,48,224,255 };
RGBA skyblue = { 0,136,255,255 };
RGBA graygreen = { 128,160,128,255 };
RGBA blue = { 0,96,192,255 };
RGBA orange = { 255,128,0,255 };
RGBA peachred = { 255,80,128,255 };
RGBA reds = { 255,128,192,255 };
RGBA darkgray = { 96,96,96,255 };
RGBA Navys = { 0,0,128,255 };
RGBA darkgreens = { 0,128,0,255 };
RGBA darkblue = { 0,128,128,255 };
RGBA redbrown = { 128,0,0,255 };
RGBA purplered = { 128,0,128,255 };
RGBA greens = { 25,255,25,140 };
RGBA envy = { 0,255,255,255 };
RGBA black = { 0,0,0,200 };
RGBA neger = { 215, 240, 180, 255 };
RGBA negernot = { 222, 180, 200, 255 };
RGBA gray = { 128,128,128,255 };
RGBA white = { 255,255,255,200 };
RGBA whitelow = { 255,255,255,100 };
RGBA blues = { 30,144,255,255 };
RGBA lightblue = { 135,206,250,255 };
RGBA Scarlet = { 220, 20, 60, 160 };
RGBA white_ = { 255,255,255,200 };
RGBA gray_ = { 128,128,128,200 };
RGBA black_ = { 0,0,0,200 };
RGBA red_ = { 255,0,0,200 };
RGBA Magenta_ = { 255,0,255,200 };
RGBA yellow_ = { 255,255,0,200 };
RGBA grayblue_ = { 128,128,255,200 };
RGBA green_ = { 128,224,0,200 };
RGBA darkgreen_ = { 0,224,128,200 };
RGBA brown_ = { 192,96,0,200 };
RGBA pink_ = { 255,168,255,200 };
RGBA darkyellow_ = { 216,216,0,200 };
RGBA silverwhite_ = { 236,236,236,200 };
RGBA purple_ = { 144,0,255,200 };
RGBA Blue_ = { 88,48,224,200 };
RGBA skyblue_ = { 0,136,255,200 };
RGBA graygreen_ = { 128,160,128,200 };
RGBA blue_ = { 0,96,192,200 };
RGBA orange_ = { 255,128,0,200 };
RGBA pinks_ = { 255,80,128,200 };
RGBA Fuhong_ = { 255,128,192,200 };
RGBA darkgray_ = { 96,96,96,200 };
RGBA Navy_ = { 0,0,128,200 };
RGBA darkgreens_ = { 0,128,0,200 };
RGBA darkblue_ = { 0,128,128,200 };
RGBA redbrown_ = { 128,0,0,200 };
RGBA purplered_ = { 128,0,128,200 };
RGBA greens_ = { 0,255,0,200 };
RGBA envy_ = { 0,255,255,200 };
RGBA glassblack = { 0, 0, 0, 100 };
RGBA GlassBlue = { 65,105,225,80 };
RGBA glassyellow = { 255,255,0,160 };
RGBA glass = { 200,200,200,60 };
RGBA filled = { 144, 0, 255, 30 };
RGBA Plum = { 221,160,221,160 };
RGBA cyan = { 0, 255, 255, 255 };
RGBA valo = { 255, 70, 85, 255 };
RGBA VisibleColor = { 255 / 255, 0, 0 };
RGBA InvisibleColor = { 0, 255 / 255, 0 };
RGBA rainbow() {
static float x = 0, y = 0;
static float r = 0, g = 0, b = 0;
if (y >= 0.0f && y < 255.0f) {
r = 255.0f;
g = 0.0f;
b = x;
}
else if (y >= 255.0f && y < 510.0f) {
r = 255.0f - x;
g = 0.0f;
b = 255.0f;
}
else if (y >= 510.0f && y < 765.0f) {
r = 0.0f;
g = x;
b = 255.0f;
}
else if (y >= 765.0f && y < 1020.0f) {
r = 0.0f;
g = 255.0f;
b = 255.0f - x;
}
else if (y >= 1020.0f && y < 1275.0f) {
r = x;
g = 255.0f;
b = 0.0f;
}
else if (y >= 1275.0f && y < 1530.0f) {
r = 255.0f;
g = 255.0f - x;
b = 0.0f;
}
float rainbow_speed = 0.25f;
x += rainbow_speed; //increase this value to switch colors faster
if (x >= 255.0f)
x = 0.0f;
y += rainbow_speed; //increase this value to switch colors faster
if (y > 1530.0f)
y = 0.0f;
return RGBA{ (DWORD)r, (DWORD)g, (DWORD)b, 255 };
}
};
static Color Col;
class RGBColor
{
public:
ImColor white{ 255, 255, 255, 255 };
ImColor cyan{ 0, 255, 255, 255 };
ImColor red{ 255, 0, 0, 255 };
ImColor green{ 0, 255, 0, 255 };
ImColor whitelow{ 255, 255, 255, 100 };
ImColor redlow{ 255, 0, 0, 100 };
ImColor valo{ 255, 70, 85, 255 };
};
RGBColor RGBCol;
static auto string_To_UTF8(const std::string& str) -> std::string
{
int nwLen = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
wchar_t* pwBuf = new wchar_t[nwLen + 1];
ZeroMemory(pwBuf, nwLen * 2 + 2);
::MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen);
int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
char* pBuf = new char[nLen + 1];
ZeroMemory(pBuf, nLen + 1);
::WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
std::string retStr(pBuf);
delete[]pwBuf;
delete[]pBuf;
pwBuf = NULL;
pBuf = NULL;
return retStr;
}
static auto WStringToUTF8(const wchar_t* lpwcszWString) -> std::string
{
char* pElementText;
int iTextLen = ::WideCharToMultiByte(CP_UTF8, 0, (LPWSTR)lpwcszWString, -1, NULL, 0, NULL, NULL);
pElementText = new char[iTextLen + 1];
memset((void*)pElementText, 0, (iTextLen + 1) * sizeof(char));
::WideCharToMultiByte(CP_UTF8, 0, (LPWSTR)lpwcszWString, -1, pElementText, iTextLen, NULL, NULL);
std::string strReturn(pElementText);
delete[] pElementText;
return strReturn;
}
static auto MBytesToWString(const char* lpcszString) -> std::wstring
{
int len = strlen(lpcszString);
int unicodeLen = ::MultiByteToWideChar(CP_ACP, 0, lpcszString, -1, NULL, 0);
wchar_t* pUnicode = new wchar_t[unicodeLen + 1];
memset(pUnicode, 0, (unicodeLen + 1) * sizeof(wchar_t));
::MultiByteToWideChar(CP_ACP, 0, lpcszString, -1, (LPWSTR)pUnicode, unicodeLen);
std::wstring wString = (wchar_t*)pUnicode;
delete[] pUnicode;
return wString;
}
static auto DrawLine(int x1, int y1, int x2, int y2, RGBA* color, int thickness) -> void
{
ImGui::GetOverlayDrawList()->AddLine(ImVec2(x1, y1), ImVec2(x2, y2), ImGui::ColorConvertFloat4ToU32(ImVec4(color->R / 255.0, color->G / 255.0, color->B / 255.0, color->A / 255.0)), thickness);
}
static auto DrawFilledRect(int x, int y, int w, int h, RGBA* color)-> void
{
ImGui::GetOverlayDrawList()->AddRectFilled(ImVec2(x, y), ImVec2(x + w, y + h), ImGui::ColorConvertFloat4ToU32(ImVec4(color->R / 255.0, color->G / 255.0, color->B / 255.0, color->A / 255.0)), 0, 0);
}
static auto DrawNewText(int x, int y, RGBA* color, const char* str) -> void
{
ImFont a;
std::string utf_8_1 = std::string(str);
std::string utf_8_2 = string_To_UTF8(utf_8_1);
ImGui::GetOverlayDrawList()->AddText(ImVec2(x, y), ImGui::ColorConvertFloat4ToU32(ImVec4(color->R / 255.0, color->G / 255.0, color->B / 255.0, color->A / 255.0)), utf_8_2.c_str());
}
void DrawPlayerBar(int x, int y, RGBA* back_color, RGBA* main_color, const char* pText, ...)
{
va_list va_alist;
char buf[1024] = { 0 };
va_start(va_alist, pText);
_vsnprintf_s(buf, sizeof(buf), pText, va_alist);
va_end(va_alist);
std::string text = WStringToUTF8(MBytesToWString(buf).c_str());
const ImVec2 text_dimension = ImGui::CalcTextSize(text.c_str());
const float text_width = text_dimension.x + 5.f;
const float mid_width = x - (text_width / 2.f);
//RGBA green_color = { 255,255,255,150 };
RGBA green_color = { 0, 255, 255, 150 };
DrawFilledRect(mid_width + 2.f, y - 25.f, text_width + 10.f, text_dimension.y + 5.f, back_color);
DrawLine(mid_width, y - 25.f, mid_width, (y - 25.f) + text_dimension.y + 5.f, &green_color, 3.f);
DrawNewText(mid_width + 6.f, (y - 25.f) + 2.f, main_color, text.c_str());
}