Skip to content

Commit

Permalink
feat: fix a bug and small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
stdNullPtr committed Dec 14, 2024
1 parent efac699 commit c220445
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions um-client/src/global.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace g
static const int screen_height{GetSystemMetrics(SM_CYSCREEN)};

static ImVec4 espColor{255.0f, 0.0f, 0.0f, 255.0f};
static float espBoxThickness{1.0f};
static ImVec4 espHealthColor{0.0f, 255.0f, 0.0f, 255.0f};
static ImVec4 textColor{0.0f, 255.0f, 0.0f, 255.0f};

Expand Down
16 changes: 12 additions & 4 deletions um-client/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ int main()
const auto entity_spotted{entity->is_spotted(driver)};
const auto entity_name{entity->get_name(driver)};
const auto is_scoped{entity->is_scoped(driver)};
const auto weaponName{entity->get_weapon_name(driver).substr(7)}; //get rid of weapon_ prefix
auto weaponName{entity->get_weapon_name(driver)};
if (!weaponName.empty())
{
weaponName = weaponName.substr(7); //get rid of weapon_ prefix
}

const auto entity_eyes_pos_screen{render::world_to_screen(view_matrix, entity->get_eye_pos(driver))};
const auto entity_feet_pos_screen{render::world_to_screen(view_matrix, entity->get_vec_origin(driver))};
Expand Down Expand Up @@ -165,6 +169,8 @@ int main()
{
const auto espBoxColor{g::espColor};
const auto espHealthColor{g::espHealthColor};
const auto espBoxThickness{g::espBoxThickness};

constexpr float widthShrinkCoefficient{0.35f};
constexpr float heightShrinkCoefficient{0.15f};

Expand All @@ -174,9 +180,9 @@ int main()
const auto mainEspTopLeft{ImVec2{entity_eyes_pos_screen.x - widthRelativeToPlayerDistance, entity_eyes_pos_screen.y - heightRelativeToPlayerDistance}};
const auto mainEspBotRight{ImVec2{entity_feet_pos_screen.x + widthRelativeToPlayerDistance, entity_feet_pos_screen.y + heightRelativeToPlayerDistance}};

const auto espBox{render::DrawCache::build_rect(mainEspTopLeft, mainEspBotRight, false, espBoxColor)};
const auto espBox{render::DrawCache::build_rect(mainEspTopLeft, mainEspBotRight, false, espBoxColor, espBoxThickness)};

const auto healthBox{render::DrawCache::build_rect(ImVec2{mainEspTopLeft.x - 10.0f, mainEspTopLeft.y}, ImVec2{mainEspTopLeft.x, mainEspBotRight.y}, false, espBoxColor)};
const auto healthBox{render::DrawCache::build_rect(ImVec2{mainEspTopLeft.x - 10.0f, mainEspTopLeft.y}, ImVec2{mainEspTopLeft.x, mainEspBotRight.y}, false, espBoxColor, espBoxThickness)};

float healthBarHeight = healthBox.get_bottom_right().y - healthBox.get_top_left().y;
float topLeftY = healthBox.get_bottom_right().y - (healthBarHeight * (static_cast<float>(player_health) / 100.0f));
Expand All @@ -191,7 +197,9 @@ int main()
healthBox.get_bottom_right().y - healthBox.get_thickness()
},
true,
espHealthColor)
espHealthColor,
espBoxThickness
)
};

const auto textColor{g::textColor};
Expand Down
14 changes: 13 additions & 1 deletion um-client/src/render/Render.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ namespace render
ImGui::TextUnformatted(ICON_FA_EXCLAMATION_TRIANGLE);
ImGui::PopStyleColor();

ImGui::Checkbox(XOR("[F4] ESP"), &esp_hack);
ImGui::Checkbox(XOR("[F4] ESP "), &esp_hack);
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 1.0f, 0.0f, 1.0f));
ImGui::TextUnformatted(ICON_FA_EYE);
ImGui::PopStyleColor();
if (is_paused)
{
ImGui::EndDisabled();
Expand Down Expand Up @@ -168,6 +172,14 @@ namespace render
ImGui::ColorEdit3(XOR("Health"), reinterpret_cast<float*>(&g::espHealthColor));
ImGui::ColorEdit3(XOR("Text"), reinterpret_cast<float*>(&g::textColor));

ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 128, 255, 255));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(5, 2));
ImGui::SeparatorText(XOR("ESP Config"));
ImGui::PopStyleVar();
ImGui::PopStyleColor();

ImGui::SliderFloat(XOR("Thickness"), &g::espBoxThickness, 1.0f, 3.0f);

ImGui::End();

ImGui::PopStyleVar(2);
Expand Down

0 comments on commit c220445

Please sign in to comment.