Skip to content

Commit

Permalink
added more crosshair types
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbo committed Jan 12, 2021
1 parent a0df0ed commit 017d367
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 30 deletions.
5 changes: 4 additions & 1 deletion src/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ namespace Base
namespace Settings
{
extern bool EnableCrosshair;
extern int CrosshairType;
extern float CrosshairLength;
extern float CrosshairThickness;
extern float CrosshairGap;
extern bool CrosshairTop;
extern bool CrosshairLeft;
extern bool CrosshairBottom;
extern bool CrosshairRight;
extern bool CrosshairDot;
extern bool CrosshairDotFilled;
extern float CrosshairColor[4];

extern bool TeleportQueued;
Expand Down
159 changes: 130 additions & 29 deletions src/hacks/Crosshair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
5 changes: 5 additions & 0 deletions src/hooks/SwapBuffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ 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");
ImGui::Checkbox("Crosshair Top", &Data::Settings::CrosshairTop);
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);
}

Expand Down

0 comments on commit 017d367

Please sign in to comment.