From 017d3671423d97dba89be1a13727963d4c6143be Mon Sep 17 00:00:00 2001 From: rdbo Date: Tue, 12 Jan 2021 14:09:36 -0800 Subject: [PATCH] added more crosshair types --- src/base.cpp | 5 +- src/base.h | 3 + src/hacks/Crosshair.cpp | 159 +++++++++++++++++++++++++++++++------- src/hooks/SwapBuffers.cpp | 5 ++ 4 files changed, 142 insertions(+), 30 deletions(-) diff --git a/src/base.cpp b/src/base.cpp index 8931ac8..2f54158 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -34,13 +34,16 @@ HGLRC Base::Data::oContext = NULL; AC_Client Base::Data::game; bool Base::Data::Settings::EnableCrosshair = false; +int Base::Data::Settings::CrosshairType = 0; float Base::Data::Settings::CrosshairLength = 10; float Base::Data::Settings::CrosshairThickness = 3; -float Base::Data::Settings::CrosshairGap = 2; +float Base::Data::Settings::CrosshairGap = 10; bool Base::Data::Settings::CrosshairTop = true; bool Base::Data::Settings::CrosshairLeft = true; bool Base::Data::Settings::CrosshairBottom = true; bool Base::Data::Settings::CrosshairRight = true; +bool Base::Data::Settings::CrosshairDot = true; +bool Base::Data::Settings::CrosshairDotFilled = true; float Base::Data::Settings::CrosshairColor[4] = { 1.0f, 0.0f, 0.0f, 1.0f }; bool Base::Data::Settings::TeleportQueued = false; diff --git a/src/base.h b/src/base.h index 547c1f3..e53dceb 100644 --- a/src/base.h +++ b/src/base.h @@ -54,6 +54,7 @@ namespace Base namespace Settings { extern bool EnableCrosshair; + extern int CrosshairType; extern float CrosshairLength; extern float CrosshairThickness; extern float CrosshairGap; @@ -61,6 +62,8 @@ namespace Base extern bool CrosshairLeft; extern bool CrosshairBottom; extern bool CrosshairRight; + extern bool CrosshairDot; + extern bool CrosshairDotFilled; extern float CrosshairColor[4]; extern bool TeleportQueued; diff --git a/src/hacks/Crosshair.cpp b/src/hacks/Crosshair.cpp index 0798925..2a1b422 100644 --- a/src/hacks/Crosshair.cpp +++ b/src/hacks/Crosshair.cpp @@ -8,47 +8,148 @@ void Base::Hacks::Crosshair() ImDrawList* Draw = ImGui::GetBackgroundDrawList(); ImVec2 WindowCenter = ImVec2((float)Data::WindowWidth / 2, (float)Data::WindowHeight / 2); ImColor LineColor = ImColor(Data::Settings::CrosshairColor[0], Data::Settings::CrosshairColor[1], Data::Settings::CrosshairColor[2], Data::Settings::CrosshairColor[3]); + float LineLength = Data::Settings::CrosshairLength; float LineThickness = Data::Settings::CrosshairThickness; + float Gap = Data::Settings::CrosshairGap; - if (Data::Settings::CrosshairTop) + if (Data::Settings::CrosshairDot) { - ImVec2 LineTop[2] = { - ImVec2(WindowCenter.x, WindowCenter.y - Data::Settings::CrosshairGap), - ImVec2(WindowCenter.x, WindowCenter.y - Data::Settings::CrosshairGap - Data::Settings::CrosshairLength) - }; - - Draw->AddLine(LineTop[0], LineTop[1], LineColor, LineThickness); + if(Data::Settings::CrosshairDotFilled) + Draw->AddCircleFilled(WindowCenter, LineThickness, LineColor); + else + Draw->AddCircle(WindowCenter, LineThickness, LineColor); } - if (Data::Settings::CrosshairLeft) + switch(Data::Settings::CrosshairType) { - ImVec2 LineLeft[2] = { - ImVec2(WindowCenter.x - Data::Settings::CrosshairGap, WindowCenter.y), - ImVec2(WindowCenter.x - Data::Settings::CrosshairGap - Data::Settings::CrosshairLength, WindowCenter.y) - }; + case 0: //Default Crosshair + if (Data::Settings::CrosshairTop) + { + ImVec2 LineTop[2] = { + ImVec2(WindowCenter.x, WindowCenter.y - Gap), + ImVec2(WindowCenter.x, WindowCenter.y - Gap - LineLength) + }; - Draw->AddLine(LineLeft[0], LineLeft[1], LineColor, LineThickness); - } + Draw->AddLine(LineTop[0], LineTop[1], LineColor, LineThickness); + } - if (Data::Settings::CrosshairBottom) - { - ImVec2 LineBottom[2] = { - ImVec2(WindowCenter.x, WindowCenter.y + Data::Settings::CrosshairGap), - ImVec2(WindowCenter.x, WindowCenter.y + Data::Settings::CrosshairGap + Data::Settings::CrosshairLength) - }; + if (Data::Settings::CrosshairLeft) + { + ImVec2 LineLeft[2] = { + ImVec2(WindowCenter.x - Gap, WindowCenter.y), + ImVec2(WindowCenter.x - Gap - LineLength, WindowCenter.y) + }; - Draw->AddLine(LineBottom[0], LineBottom[1], LineColor, LineThickness); - } + Draw->AddLine(LineLeft[0], LineLeft[1], LineColor, LineThickness); + } + if (Data::Settings::CrosshairBottom) + { + ImVec2 LineBottom[2] = { + ImVec2(WindowCenter.x, WindowCenter.y + Gap), + ImVec2(WindowCenter.x, WindowCenter.y + Gap + LineLength) + }; - if (Data::Settings::CrosshairRight) - { - ImVec2 LineRight[2] = { - ImVec2(WindowCenter.x + Data::Settings::CrosshairGap, WindowCenter.y), - ImVec2(WindowCenter.x + Data::Settings::CrosshairGap + Data::Settings::CrosshairLength, WindowCenter.y) - }; + Draw->AddLine(LineBottom[0], LineBottom[1], LineColor, LineThickness); + } + + + if (Data::Settings::CrosshairRight) + { + ImVec2 LineRight[2] = { + ImVec2(WindowCenter.x + Gap, WindowCenter.y), + ImVec2(WindowCenter.x + Gap + LineLength, WindowCenter.y) + }; + + Draw->AddLine(LineRight[0], LineRight[1], LineColor, LineThickness); + } + + break; + + case 1: //Triangle Crosshair + LineLength += Gap; + if (Data::Settings::CrosshairTop) + { + ImVec2 LineTop[] = { + ImVec2(WindowCenter.x - LineLength, WindowCenter.y - LineLength / 2), + ImVec2(WindowCenter.x + LineLength, WindowCenter.y - LineLength / 2) + }; + + Draw->AddLine(LineTop[0], LineTop[1], LineColor, LineThickness); + } + + if (Data::Settings::CrosshairLeft) + { + ImVec2 LineLeft[] = { + ImVec2(WindowCenter.x - LineLength, WindowCenter.y - LineLength / 2), + ImVec2(WindowCenter.x, WindowCenter.y + LineLength / 2) + }; + + Draw->AddLine(LineLeft[0], LineLeft[1], LineColor, LineThickness); + } + + if (Data::Settings::CrosshairRight) + { + ImVec2 LineRight[] = { + ImVec2(WindowCenter.x, WindowCenter.y + LineLength / 2), + ImVec2(WindowCenter.x + LineLength, WindowCenter.y - LineLength / 2) + }; + + Draw->AddLine(LineRight[0], LineRight[1], LineColor, LineThickness); + } + + break; + + case 2: //Square Crosshair + LineLength += Gap; + if (Data::Settings::CrosshairTop) + { + ImVec2 LineTop[2] = { + ImVec2(WindowCenter.x - LineLength / 2, WindowCenter.y - LineLength / 2), + ImVec2(WindowCenter.x + LineLength / 2, WindowCenter.y - LineLength / 2) + }; + + Draw->AddLine(LineTop[0], LineTop[1], LineColor, LineThickness); + } + + if (Data::Settings::CrosshairLeft) + { + ImVec2 LineLeft[2] = { + ImVec2(WindowCenter.x - LineLength / 2, WindowCenter.y - LineLength / 2), + ImVec2(WindowCenter.x - LineLength / 2, WindowCenter.y + LineLength / 2) + }; + + Draw->AddLine(LineLeft[0], LineLeft[1], LineColor, LineThickness); + } + + if (Data::Settings::CrosshairBottom) + { + ImVec2 LineBottom[2] = { + ImVec2(WindowCenter.x - LineLength / 2, WindowCenter.y + LineLength / 2), + ImVec2(WindowCenter.x + LineLength / 2, WindowCenter.y + LineLength / 2) + }; + + Draw->AddLine(LineBottom[0], LineBottom[1], LineColor, LineThickness); + } + + + if (Data::Settings::CrosshairRight) + { + ImVec2 LineRight[2] = { + ImVec2(WindowCenter.x + LineLength / 2, WindowCenter.y + LineLength / 2), + ImVec2(WindowCenter.x + LineLength / 2, WindowCenter.y - LineLength / 2) + }; + + Draw->AddLine(LineRight[0], LineRight[1], LineColor, LineThickness); + } + break; + + case 3: //Circle Crosshair + LineLength += Gap; + + Draw->AddCircle(WindowCenter, LineLength, LineColor, 0, LineThickness); - Draw->AddLine(LineRight[0], LineRight[1], LineColor, LineThickness); + break; } } } \ No newline at end of file diff --git a/src/hooks/SwapBuffers.cpp b/src/hooks/SwapBuffers.cpp index 1f5f224..9cd79d5 100644 --- a/src/hooks/SwapBuffers.cpp +++ b/src/hooks/SwapBuffers.cpp @@ -56,6 +56,8 @@ BOOL __stdcall Base::Hooks::SwapBuffers(_In_ HDC hdc) ImGui::Checkbox("Enable Crosshair", &Data::Settings::EnableCrosshair); if (Data::Settings::EnableCrosshair) { + const char* CrosshairTypes[] = { "Default", "Triangle", "Square", "Circle" }; + ImGui::ListBox("Crosshair Type", &Data::Settings::CrosshairType, CrosshairTypes, 4); ImGui::SliderFloat("Crosshair Length", &Data::Settings::CrosshairLength, 0, 100, "%.0f"); ImGui::SliderFloat("Crosshair Thickness", &Data::Settings::CrosshairThickness, 0, 100, "%.0f"); ImGui::SliderFloat("Crosshair Gap", &Data::Settings::CrosshairGap, 0, 100, "%.0f"); @@ -63,6 +65,9 @@ BOOL __stdcall Base::Hooks::SwapBuffers(_In_ HDC hdc) ImGui::Checkbox("Crosshair Left", &Data::Settings::CrosshairLeft); ImGui::Checkbox("Crosshair Bottom", &Data::Settings::CrosshairBottom); ImGui::Checkbox("Crosshair Right", &Data::Settings::CrosshairRight); + ImGui::Checkbox("Crosshair Dot", &Data::Settings::CrosshairDot); + if (Data::Settings::CrosshairDot) + ImGui::Checkbox("Crosshair Dot Filled", &Data::Settings::CrosshairDotFilled); ImGui::ColorEdit4("Crosshair Color", Data::Settings::CrosshairColor); }