-
Автор темы
- #1
This is a simple cpp crosshair code for your paste it uses imgui for sizing so its mainly for externals but can be used for internals by changing the screen size function
Crosshair:
///crosshair bools and color callbacks
bool draw_circle = false;
ImColor circle_color = ImColor(255, 255, 255, 255);
float circle_size = 2.f;
bool draw_cross = false;
ImVec4 cross_color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
float cross_size = 10.0f;
bool draw_Xcross = false;
ImVec4 Xcross_color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
float Xcross_size = 10.0f;
///imgui shit
const char* items[] = { "None","Circle", "Cross","X"};
static int selected_item = -1;
if (ImGui::Combo("Crosshair Type", &selected_item, items, IM_ARRAYSIZE(items))) {
switch(selected_item) {
case 0:
draw_cross=false;
draw_Xcross=false;
draw_circle = false;
break;
case 1:
draw_cross=false;
draw_Xcross=false;
draw_circle = true;
break;
case 2:
draw_cross = true;
draw_Xcross=false;
draw_circle = false;
break;
case 3:
draw_cross=false;
draw_Xcross = true;
draw_circle = false;
break;
}
if (draw_circle) {
ImVec2 circle_pos;
ImVec2 window_pos = ImGui::GetWindowPos();
ImVec2 window_size = ImGui::GetWindowSize();
circle_pos = ImVec2(window_pos.x + window_size.x / 2, window_pos.y + window_size.y / 2);
ImGui::ColorEdit4("Circle Color", (float*)&circle_color, ImGuiColorEditFlags_NoInputs);
ImGui::SliderFloat("Circle Size", &circle_size, 0.f, 20.f);
}
if (draw_cross) {
ImVec2 cross_pos;
ImVec2 window_pos = ImGui::GetWindowPos();
ImVec2 window_size = ImGui::GetWindowSize();
cross_pos = ImVec2(window_pos.x + window_size.x / 2, window_pos.y + window_size.y / 2);
ImGui::ColorEdit4("Cross Color", (float*)&cross_color, ImGuiColorEditFlags_NoInputs);
ImGui::SliderFloat("Cross Size", &cross_size, 0.f, 20.f);
}
if (draw_Xcross) {
ImVec2 cross_pos;
ImVec2 window_pos = ImGui::GetWindowPos();
ImVec2 window_size = ImGui::GetWindowSize();
cross_pos = ImVec2(window_pos.x + window_size.x / 2, window_pos.y + window_size.y / 2);
ImGui::ColorEdit4("X Color", (float*)&Xcross_color, ImGuiColorEditFlags_NoInputs);
ImGui::SliderFloat("X Size", &Xcross_size, 0.f, 20.f);
}
///This needs to be under a overlay
ImVec2 window_pos = ImGui::GetWindowPos();
ImVec2 window_size = ImGui::GetWindowSize();
circle_pos = ImVec2(window_pos.x + window_size.x / 2, window_pos.y + window_size.y / 2);
cross_pos = ImVec2(window_pos.x + window_size.x / 2, window_pos.y + window_size.y / 2);
if (draw_cross) {
ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->AddLine(ImVec2(cross_pos.x - cross_size, cross_pos.y), ImVec2(cross_pos.x + cross_size, cross_pos.y), ImColor(cross_color), 1.0f);
draw_list->AddLine(ImVec2(cross_pos.x, cross_pos.y - cross_size), ImVec2(cross_pos.x, cross_pos.y + cross_size), ImColor(cross_color), 1.0f);
}
if (draw_Xcross) {
ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->AddLine(ImVec2(cross_pos.x - Xcross_size, cross_pos.y - Xcross_size), ImVec2(cross_pos.x + Xcross_size, cross_pos.y + Xcross_size), ImColor(Xcross_color), 1.0f);
draw_list->AddLine(ImVec2(cross_pos.x + Xcross_size, cross_pos.y - Xcross_size), ImVec2(cross_pos.x - Xcross_size, cross_pos.y + Xcross_size), ImColor(Xcross_color), 1.0f);
}
if (draw_circle) {
ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->AddCircleFilled(circle_pos, circle_size, circle_colo