#include <sstream>
#include <Windows.h>
#include "imgui/imgui.h"
#include "GUI.h"
#include "Config.h"
#include "Hacks/Misc.h"
#include "Hacks/Visuals.h"
constexpr auto windowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
void GUI::style() noexcept
{
#define HI(v) ImVec4(0.502f, 0.075f, 0.256f, v)
#define MED(v) ImVec4(0.455f, 0.198f, 0.301f, v)
#define LOW(v) ImVec4(0.232f, 0.201f, 0.271f, v)
// backgrounds (@todo: complete with BG_MED, BG_LOW)
#define BG(v) ImVec4(0.200f, 0.220f, 0.270f, v)
// text
#define TEXT(v) ImVec4(0.860f, 0.930f, 0.890f, v)
auto &style = ImGui::GetStyle();
style.Colors[ImGuiCol_Text] = TEXT(0.78f);
style.Colors[ImGuiCol_TextDisabled] = TEXT(0.28f);
style.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.14f, 0.17f, 1.00f);
style.Colors[ImGuiCol_PopupBg] = BG(0.9f);
style.Colors[ImGuiCol_Border] = ImVec4(0.31f, 0.31f, 1.00f, 0.00f);
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
style.Colors[ImGuiCol_FrameBg] = BG(1.00f);
style.Colors[ImGuiCol_FrameBgHovered] = MED(0.78f);
style.Colors[ImGuiCol_FrameBgActive] = MED(1.00f);
style.Colors[ImGuiCol_TitleBg] = LOW(1.00f);
style.Colors[ImGuiCol_TitleBgActive] = HI(1.00f);
style.Colors[ImGuiCol_TitleBgCollapsed] = BG(0.75f);
style.Colors[ImGuiCol_MenuBarBg] = BG(0.47f);
style.Colors[ImGuiCol_ScrollbarBg] = BG(1.00f);
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.09f, 0.15f, 0.16f, 1.00f);
style.Colors[ImGuiCol_ScrollbarGrabHovered] = MED(0.78f);
style.Colors[ImGuiCol_ScrollbarGrabActive] = MED(1.00f);
style.Colors[ImGuiCol_CheckMark] = ImVec4(0.71f, 0.22f, 0.27f, 1.00f);
style.Colors[ImGuiCol_SliderGrab] = ImVec4(0.47f, 0.77f, 0.83f, 0.14f);
style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.71f, 0.22f, 0.27f, 1.00f);
style.Colors[ImGuiCol_Button] = ImVec4(0.47f, 0.77f, 0.83f, 0.14f);
style.Colors[ImGuiCol_ButtonHovered] = MED(0.86f);
style.Colors[ImGuiCol_ButtonActive] = MED(1.00f);
style.Colors[ImGuiCol_Header] = MED(0.76f);
style.Colors[ImGuiCol_HeaderHovered] = MED(0.86f);
style.Colors[ImGuiCol_HeaderActive] = HI(1.00f);
style.Colors[ImGuiCol_ResizeGrip] = ImVec4(0.47f, 0.77f, 0.83f, 0.04f);
style.Colors[ImGuiCol_ResizeGripHovered] = MED(0.78f);
style.Colors[ImGuiCol_ResizeGripActive] = MED(1.00f);
style.Colors[ImGuiCol_PlotLines] = TEXT(0.63f);
style.Colors[ImGuiCol_PlotLinesHovered] = MED(1.00f);
style.Colors[ImGuiCol_PlotHistogram] = TEXT(0.63f);
style.Colors[ImGuiCol_PlotHistogramHovered] = MED(1.00f);
style.Colors[ImGuiCol_TextSelectedBg] = MED(0.43f);
// [...]
style.WindowPadding = ImVec2(6, 4);
style.WindowRounding = 0.0f;
style.FramePadding = ImVec2(5, 2);
style.FrameRounding = 3.0f;
style.ItemSpacing = ImVec2(7, 1);
style.ItemInnerSpacing = ImVec2(1, 1);
style.TouchExtraPadding = ImVec2(0, 0);
style.IndentSpacing = 6.0f;
style.ScrollbarSize = 12.0f;
style.ScrollbarRounding = 16.0f;
style.GrabMinSize = 20.0f;
style.GrabRounding = 2.0f;
style.WindowTitleAlign.x = 0.50f;
style.Colors[ImGuiCol_Border] = ImVec4(0.539f, 0.479f, 0.255f, 0.162f);
style.FrameBorderSize = 0.0f;
style.WindowBorderSize = 1.0f;
}
void GUI::render() noexcept
{
renderMenuBar();
renderGlowWindow();
renderVisualsWindow();
renderMiscWindow();
}
void GUI::checkBoxAndColorPicker(const std::string& name, bool* enable, float* color) noexcept
{
ImGui::Checkbox(("##" + name).c_str(), enable);
ImGui::SameLine(0.0f, 5.0f);
bool openPopup = ImGui::ColorButton(("##" + name + "ColorButton").c_str(), ImColor{ color[0], color[1], color[2] }, ImGuiColorEditFlags_NoTooltip);
ImGui::SameLine(0.0f, 5.0f);
ImGui::Text(name.c_str());
if (openPopup)
ImGui::OpenPopup(("##" + name + "Popup").c_str());
if (ImGui::BeginPopup(("##" + name + "Popup").c_str())) {
ImGui::ColorPicker3(("##" + name + "Picker").c_str(), color, ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_NoSidePreview);
ImGui::EndPopup();
}
}
void GUI::hotkey(int& key) noexcept
{
ImGui::Text((std::ostringstream{ } << "[ " << (key ? std::to_string(key) : "key") << " ]").str().c_str());
if (ImGui::IsItemHovered()) {
ImGuiIO& io = ImGui::GetIO();
for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++)
if (ImGui::IsKeyPressed(i) && i != VK_INSERT)
key = i != VK_ESCAPE ? i : 0;
}
}
void GUI::renderMenuBar() noexcept
{
if (ImGui::BeginMainMenuBar()) {
auto &style = ImGui::GetStyle();
ImGui::MenuItem("glow", nullptr, &window.glow);
ImGui::MenuItem("visuals", nullptr, &window.visuals);
ImGui::MenuItem("misc", nullptr, &window.misc);
if (ImGui::BeginMenu("config")) {
if (ImGui::MenuItem("load"))
config.load();
if (ImGui::MenuItem("save"))
config.save();
if (ImGui::MenuItem("reset"))
config.reset();
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
}
void GUI::renderGlowWindow() noexcept
{
if (window.glow) {
auto &style = ImGui::GetStyle();
ImGui::SetNextWindowSize({ 320.0f, 185.0f });
ImGui::Begin("glow", &window.glow, windowFlags);
ImGui::Columns(2, nullptr, false);
ImGui::SetColumnOffset(1, 170.0f);
ImGui::PushItemWidth(150.0f);
ImGui::Checkbox("Enable", &config.glow.enabled);
ImGui::SliderFloat("##1", &config.glow.thickness, 0.0f, 1.0f, "Thiccness: %.2f");
ImGui::SliderFloat("##2", &config.glow.alpha, 0.0f, 1.0f, "Alpha: %.2f");
ImGui::SliderInt("##3", &config.glow.style, 0, 3, "Style: %d");
checkBoxAndColorPicker("Temmates", &config.glow.allies, config.glow.alliesColor);
checkBoxAndColorPicker("Enemies", &config.glow.enemies, config.glow.enemiesColor);
ImGui::NextColumn();
checkBoxAndColorPicker("Local Player", &config.glow.localPlayer, config.glow.localPlayerColor);
checkBoxAndColorPicker("Weapons", &config.glow.weapons, config.glow.weaponsColor);
checkBoxAndColorPicker("C4", &config.glow.C4, config.glow.C4Color);
checkBoxAndColorPicker("Planted C4", &config.glow.plantedC4, config.glow.plantedC4Color);
checkBoxAndColorPicker("Chickens", &config.glow.chickens, config.glow.chickensColor);
ImGui::End();
}
}
void GUI::renderVisualsWindow() noexcept
{
if (window.visuals) {
auto &style = ImGui::GetStyle();
ImGui::SetNextWindowSize({ 520.0f, 315.0f });
ImGui::Begin("Visuals", &window.visuals, windowFlags);
ImGui::Columns(2, nullptr, false);
ImGui::SetColumnOffset(1, 210.0f);
ImGui::Checkbox("Off visual recoil", &config.visuals.noVisualRecoil);
ImGui::Checkbox("Off sleeves", &config.visuals.noSleeves);
ImGui::Checkbox("Off smoke", &config.visuals.noSmoke);
ImGui::Checkbox("No blur", &config.visuals.noBlur);
ImGui::Checkbox("Off scope overlay", &config.visuals.noScopeOverlay);
ImGui::Checkbox("Wireframe smoke", &config.visuals.wireframeSmoke);
ImGui::Checkbox("Sniper crosshair", &config.misc.sniperCrosshair);
ImGui::NextColumn();
ImGui::Checkbox("Third person", &config.visuals.thirdperson);
ImGui::SameLine();
hotkey(config.visuals.thirdpersonKey);
ImGui::PushItemWidth(290.0f);
ImGui::SliderInt("##1", &config.visuals.thirdpersonDistance, 0, 200, "Third person distance: %d");
ImGui::SliderInt("##2", &config.visuals.viewmodelFov, -60, 60, "Viewmodel fov: %d");
ImGui::SliderInt("##3", &config.visuals.flashReduction, 0, 100, "Flash reduction: %d%%");
ImGui::SliderFloat("##4", &config.visuals.brightness, 0.0f, 1.0f, "Brightness: %.2f");
ImGui::PopItemWidth();
ImGui::Combo("Skybox", &config.visuals.skybox, "Default\0cs_baggage_skybox_\0cs_tibet\0embassy\0italy\0jungle\0nukeblank\0office\0sky_cs15_daylight01_hdr\0sky_cs15_daylight02_hdr\0sky_cs15_daylight03_hdr\0sky_cs15_daylight04_hdr\0sky_csgo_cloudy01\0sky_csgo_night_flat\0sky_csgo_night02\0sky_day02_05_hdr\0sky_day02_05\0sky_dust\0sky_l4d_rural02_ldr\0sky_venice\0vertigo_hdr\0vertigo\0vertigoblue_hdr\0vietnam");
ImGui::ColorEdit3("World color", config.visuals.worldColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoTooltip);
ImGui::End();
}
}
void GUI::renderMiscWindow() noexcept
{
if (window.misc) {
auto &style = ImGui::GetStyle();
ImGui::SetNextWindowSize({ 220.0f, 340.0f });
ImGui::Begin("Misc", &window.misc, windowFlags);
ImGui::Checkbox("Bhop", &config.misc.bunnyHop);
static char buffer[16];
ImGui::PushItemWidth(120.0f);
ImGui::InputText("##1", buffer, IM_ARRAYSIZE(buffer));
ImGui::SameLine();
if (ImGui::Button("Clantag")) {
Misc::setClanTag(buffer);
Misc::animateClanTag(buffer);
}
ImGui::Checkbox("Animate clantag", &config.misc.animatedClanTag);
ImGui::Checkbox("Spectators", &config.misc.spectatorList);
ImGui::Checkbox("Watermark", &config.misc.watermark);
ImGui::Checkbox("Fast duck", &config.misc.fastDuck);
ImGui::Checkbox("Reveal ranks", &config.misc.ranks);
ImGui::Checkbox("Auto pistol", &config.misc.autoPistol);
ImGui::End();
}
}