Skip to content

Commit

Permalink
Doubleclicker can now be binded
Browse files Browse the repository at this point in the history
- Added a bind function for the double clicker
  • Loading branch information
Steve987321 committed Sep 15, 2022
1 parent f7405a4 commit fe6afa3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
31 changes: 30 additions & 1 deletion src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
{
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
}
}
}
Expand Down Expand Up @@ -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");
Expand Down
5 changes: 4 additions & 1 deletion src/toad.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<int> mapHotkeys(std::vector<std::string>& hotkeys);
inline std::vector<int> hotbarVKCodes;
Expand Down

0 comments on commit fe6afa3

Please sign in to comment.