diff --git a/src/Config.cpp b/src/Config.cpp index 404340b..df80fd1 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -50,6 +50,8 @@ void toad::misc::loadConfig(const std::string configPath) toad::double_clicker::enabled = data["dclicker_enabled"]; toad::double_clicker::delay = data["dclicker_delay"]; toad::double_clicker::chance = data["dclicker_chance"]; + toad::double_clicker::keycode = data["dclicker_keycode"]; + toad::double_clicker::key = data["dclicker_key"]; //slot whitelist toad::clicker::slot_whitelist = data["slot_whitelist"]; @@ -78,6 +80,7 @@ void toad::misc::loadConfig(const std::string configPath) toad::misc::compatibility_mode = data["compatibility_mode"]; toad::misc::hide_key = data["hide_key"]; toad::misc::selectedClickWindow = data["selected_click_window"]; + toad::misc::compatibility_mode = data["compatibility_mode"]; toad::theme::main_col[0] = data["main_colr"]; toad::theme::main_col[1] = data["main_colg"]; toad::theme::main_col[2] = data["main_colb"]; @@ -112,6 +115,8 @@ void toad::misc::saveConfig(std::string name) j["lenableoption"] = toad::clicker::selectedEnableOption; //double clicker + j["dclicker_key"] = toad::double_clicker::key; + j["dclicker_keycode"] = toad::double_clicker::keycode; j["dclicker_enabled"] = toad::double_clicker::enabled; j["dclicker_delay"] = toad::double_clicker::delay; j["dclicker_chance"] = toad::double_clicker::chance; @@ -143,6 +148,7 @@ void toad::misc::saveConfig(std::string name) j["compatibility_mode"] = toad::misc::compatibility_mode; j["hide_key"] = toad::misc::hide_key; j["selected_click_window"] = toad::misc::selectedClickWindow; + j["compatibility_mode"] = toad::misc::compatibility_mode; j["main_colr"] = toad::theme::main_col[0]; j["main_colg"] = toad::theme::main_col[1]; j["main_colb"] = toad::theme::main_col[2]; diff --git a/src/gui.cpp b/src/gui.cpp index 7bcc84a..ac7a6d8 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -68,6 +68,7 @@ void decorations() { style->Colors[ImGuiCol_TitleBgActive] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f); } +// handles all hotkey presses void toad::hotkey_handler(const HWND& window) { if (!binding) { //misc Hide and Unhide @@ -126,6 +127,7 @@ void toad::hotkey_handler(const HWND& window) { toad::clickrecorder::enabled = !toad::clickrecorder::enabled; } + //click playback if (GetAsyncKeyState(toad::clickrecorder::keycode_playback) & 1 && !toad::clickrecorder::click_delays.empty()) { @@ -136,9 +138,27 @@ void toad::hotkey_handler(const HWND& window) { toad::clickrecorder::playback_enabled = !toad::clickrecorder::playback_enabled; } + + if (GetAsyncKeyState(toad::double_clicker::keycode) & 1) + { + toad::double_clicker::enabled = !toad::double_clicker::enabled; + + if (toad::double_clicker::enabled) + { + log_debug("starting thread"); + p_doubleClicker->start_thread(); + } + else + { + log_debug("stopping thread"); + p_doubleClicker->stop_thread(); + } + } } + + // when binding to a button else if (binding) { - //(1)lmb - (123)f12 + // (1)lmb - (123)f12 for (int i = 3; i < 123; i++) { if (toad::clicker::key == "..") { if (GetAsyncKeyState(i) & 0x8000) { @@ -175,6 +195,13 @@ void toad::hotkey_handler(const HWND& window) { } if (toad::clickrecorder::key_playback != "..") binding = false; } + else if (toad::double_clicker::key == "..") { + if (GetAsyncKeyState(i) & 0x8000) { + if (i == VK_ESCAPE) { toad::double_clicker::key = "none"; binding = false; toad::double_clicker::keycode = 0; } + else { toad::double_clicker::key = toad::keys[i - 1]; toad::double_clicker::keycode = i; } + } + if (toad::double_clicker::key != "..") binding = false; + } } } } @@ -376,6 +403,8 @@ void toad::renderUI(const HWND& hwnd) { p_doubleClicker->stop_thread(); } } + ImGui::SameLine(); ImGui::TextColored(ImColor(51, 51, 51), "[%s]", &toad::double_clicker::key); + if (ImGui::IsItemClicked()) { toad::double_clicker::key = ".."; binding = true; } ImGui::Text("delay"); ImGui::SliderInt("##delay", &toad::double_clicker::delay, 0, 200, "%dms"); ImGui::Text("chance"); diff --git a/src/toad.h b/src/toad.h index cbca299..c6fb802 100644 --- a/src/toad.h +++ b/src/toad.h @@ -63,6 +63,9 @@ namespace toad inline bool enabled = false; inline int delay = 50; inline int chance = 75; + + inline std::string key = "none"; + inline int keycode = 0; } namespace jitter { @@ -222,7 +225,7 @@ namespace toad inline bool clickplayback_thread_exists = false; inline bool clickrecord_thread_exists = false; - constexpr const char* APP_VER = "1.6.0"; + constexpr const char* APP_VER = "1.6.1"; static std::vector mapHotkeys(std::vector& hotkeys); inline std::vector hotbarVKCodes;