@@ -23,7 +23,7 @@ static void RenderText(std::string_view text, const ImVec2& pos, const ImVec4& c
2323 {
2424 CurrentWindow->DrawList ->AddText (nullptr , 0 .f ,
2525 ImScreen + 0 .5f * State.dpiScale ,
26- ImGui::GetColorU32 (ImVec4 ( 0 . f , 0 . f , 0 . f , 0 . f ) ), text.data (), text.data () + text.length ());
26+ ImGui::GetColorU32 (IM_COL32_BLACK ), text.data (), text.data () + text.length ());
2727 }
2828
2929 CurrentWindow->DrawList ->AddText (nullptr , 0 .f , ImScreen, ImGui::GetColorU32 (color), text.data (), text.data () + text.length ());
@@ -59,7 +59,7 @@ static void RenderBox(const ImVec2& top, const ImVec2& bottom, const float heigh
5959 };
6060
6161 if (wantsShadow) {
62- const ImVec4& shadowColor = ImVec4 ( 0 . f , 0 . f , 0 . f , 0 . f );
62+ const ImVec4& shadowColor = ImGui::ColorConvertU32ToFloat4 ( ImGui::GetColorU32 (color) & IM_COL32_A_MASK );
6363 for (size_t i = 0 ; i < std::size (points); i += 2 ) {
6464 RenderLine (points[i] + 0 .5f * State.dpiScale , points[i + 1 ] + 0 .5f * State.dpiScale , shadowColor, false );
6565 }
@@ -69,6 +69,8 @@ static void RenderBox(const ImVec2& top, const ImVec2& bottom, const float heigh
6969 }
7070}
7171
72+ bool renderPlayerEsp = false ;
73+
7274void Esp::Render ()
7375{
7476 CurrentWindow = ImGui::GetCurrentWindow ();
@@ -77,11 +79,54 @@ void Esp::Render()
7779
7880 // Lock our mutex when we render (this will unlock when it goes out of scope)
7981 synchronized (instance.m_DrawingMutex ) {
82+ // testing some stuffs
83+ if (renderPlayerEsp) {
84+ for (auto & it : instance.m_Players )
85+ {
86+ if (const auto & player = it.playerData .validate ();
87+ player.has_value () // Verify PlayerControl hasn't been destroyed (happens when disconnected)
88+ && !player.is_Disconnected () // Sanity check, shouldn't ever be true
89+ && player.is_LocalPlayer () // highlight yourself, you're ugly
90+ && (!player.get_PlayerData ()->fields .IsDead || State.ShowEsp_Ghosts )
91+ && it.OnScreen )
92+ {
93+ if (State.ShowEsp_Box )
94+ {
95+ float width = GetScaleFromValue (35 .0f );
96+ float height = GetScaleFromValue (120 .0f );
97+
98+ ImVec2 top{ it.Position .x + width, it.Position .y };
99+ ImVec2 bottom{ it.Position .x - width, it.Position .y - height };
100+
101+ RenderBox (top, bottom, height, width, it.Color );
102+ }
103+
104+ // TODO: show x and y
105+ if (State.ShowEsp_Distance )
106+ {
107+ const ImVec2 position{ it.Position .x , it.Position .y + 15 .0f * State.dpiScale };
108+
109+ Vector2 mouse = {
110+ ImGui::GetMousePos ().x , ImGui::GetMousePos ().y
111+ };
112+
113+ std::string lel = std::to_string (ScreenToWorld (mouse).x ) + " , " + std::to_string (ScreenToWorld (mouse).y );
114+
115+ std::string lol = std::to_string (it.Position .x ) + " , " + std::to_string (it.Position .y );
116+ char * player = lol.data ();
117+
118+ RenderText (player, position, it.Color );
119+ }
120+ }
121+ }
122+ }
123+ // track player codes
80124 for (auto & it : instance.m_Players )
81125 {
82126 if (const auto & player = it.playerData .validate ();
83127 player.has_value () // Verify PlayerControl hasn't been destroyed (happens when disconnected)
84128 && !player.is_Disconnected () // Sanity check, shouldn't ever be true
129+ && !player.is_LocalPlayer () // Don't highlight yourself, you're ugly
85130 && (!player.get_PlayerData ()->fields .IsDead || State.ShowEsp_Ghosts )
86131 && it.OnScreen )
87132 {
@@ -98,28 +143,75 @@ void Esp::Render()
98143
99144 RenderBox (top, bottom, height, width, it.Color );
100145 }
101- if (!player.is_LocalPlayer ()) { // Don't highlight yourself, you're ugly
102- // ///////////////////////////////
103- // // Distance ///////////////////
104- // ///////////////////////////////
105- if (State.ShowEsp_Distance )
106- {
107- const ImVec2 position{ it.Position .x , it.Position .y + 15 .0f * State.dpiScale };
146+ // ///////////////////////////////
147+ // // Distance ///////////////////
148+ // ///////////////////////////////
149+
150+ if (State.ShowEsp_Distance )
151+ {
152+ // logic and calculation
153+ ImVec2 position = { it.Position .x , it.Position .y + 15 .0f * State.dpiScale };
154+ ImVec2 position2 = { it.Position .x , it.Position .y + 30 .0f * State.dpiScale };
155+
156+ // infamous trash codes
157+ float minX = 40 .0f , minY = 0 .0f ,
158+ maxX = DirectX::GetWindowSize ().x - 46 .0f , // 1320
159+ maxY = DirectX::GetWindowSize ().y - 38 .0f ; // 730
108160
109- char distance[ 32 ] ;
110- sprintf_s (distance, " [%.2fm] " , it. Distance ) ;
161+ float x = it. Position . x , y = it. Position . y ;
162+ float offset = 15 . 0f * State. dpiScale ;
111163
112- RenderText (distance, position, it.Color );
164+ if (x < minX) {
165+ x = minX;
113166 }
114- // ///////////////////////////////
115- // // Tracers ////////////////////
116- // ///////////////////////////////
117- if (State. ShowEsp_Tracers && !player. is_LocalPlayer ())
118- {
119- RenderLine (instance. LocalPosition , it. Position , it. Color , true ) ;
167+ else if (x > maxX) {
168+ x = maxX;
169+ }
170+
171+ if (y < minY) {
172+ y = minY ;
120173 }
174+ else if (y > maxY) {
175+ y = maxY;
176+ }
177+
178+ position = { x, y + offset };
179+ position2 = { x, y + 2 * offset };
180+
181+ // strings
182+ char distance[32 ];
183+ sprintf_s (distance, " [%.0fm]" , it.Distance );
184+
185+ std::string lol = it.Name ;
186+ char * player = lol.data ();
187+
188+ // std::string lol2 = std::to_string(it.Position.x) + ", " + std::to_string(it.Position.y);
189+ // char* pl = lol2.data();
190+
191+ // kill cd update
192+ GameOptions options;
193+ if (const auto & player = it.playerData .validate ();
194+ State.ShowKillCD
195+ && !player.get_PlayerData ()->fields .IsDead
196+ && player.get_PlayerData ()->fields .Role
197+ && player.get_PlayerData ()->fields .Role ->fields .CanUseKillButton
198+ ) {
199+ float killTimer = player.get_PlayerControl ()->fields .killTimer ;
200+ sprintf_s (distance, " [%.1fs]" , killTimer);
201+ }
202+
203+ // render info
204+ RenderText (player, position, it.Color );
205+ RenderText (distance, position2, it.Color );
206+ }
207+ // ///////////////////////////////
208+ // // Tracers ////////////////////
209+ // ///////////////////////////////
210+ if (State.ShowEsp_Tracers )
211+ {
212+ RenderLine (instance.LocalPosition , it.Position , it.Color , true );
121213 }
122214 }
123215 }
124216 }
125- }
217+ }
0 commit comments