From 490b262f1d10355639e8aa0fe2c53556501b607c Mon Sep 17 00:00:00 2001 From: lcm7341 Date: Sat, 5 Aug 2023 18:16:21 -0500 Subject: [PATCH] Bro idk --- src/GUI/gui.cpp | 36 +++++++++++++++++++++++--- src/Hooks/hooks.cpp | 27 +++++++++++++++++--- src/Logic/logic.hpp | 2 ++ src/Recorder/recorder.cpp | 2 +- src/main.cpp | 53 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 9 deletions(-) diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 83f60ec..ad76739 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -600,11 +600,11 @@ void GUI::ui_editor() { if (docked) ImGui::SetNextItemWidth(tabWidth); - if (ImGui::BeginTabItem("Style") || !docked) { + if (ImGui::BeginTabItem("Theme") || !docked) { static float window_scale = 1.0f; if (!docked) { - ImGui::Begin("Style", nullptr, ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Begin("Theme", nullptr, ImGuiWindowFlags_AlwaysAutoResize); style_pos = ImGui::GetWindowPos(); } @@ -2112,8 +2112,9 @@ void GUI::clickbot() { } static char inputBuffer[256]; + strcpy(inputBuffer, logic.algorithm.c_str()); static bool typing_alg = false; - ImGui::PushItemWidth(250); + ImGui::PushItemWidth(200); if (ImGui::InputText("Algorithm", inputBuffer, sizeof(inputBuffer))) typing_alg = true; else typing_alg = false; ImGui::PopItemWidth(); @@ -2131,6 +2132,7 @@ void GUI::clickbot() { expression = "0+"; expression += inputBuffer; tokens = tokenizeExpression(expression); + logic.algorithm = inputBuffer; int index = 0; @@ -2996,6 +2998,21 @@ void readBinds() { })); \ Logic::get().keybinds.SetAction(#name, std::move(name)) +void appendToFile(double percent, const std::string& filename) { + std::ofstream outputFile; + outputFile.open(filename, std::ios::app); // Open the file in append mode + + if (!outputFile) { + std::cerr << "Error opening file: " << filename << std::endl; + return; + } + + // Append the value of 'percent' to the file + outputFile << percent << std::endl; + + outputFile.close(); +} + void GUI::init() { ImPlot::CreateContext(); @@ -3093,6 +3110,13 @@ void GUI::init() { } })); + std::unique_ptr outputPercentAction = std::unique_ptr(new Keybindable([this]() { + if (PLAYLAYER) { + float percent = min(100.f, (PLAYLAYER->m_pPlayer1->getPositionX() / PLAYLAYER->m_endPortal->getPositionX()) * 100.f); + appendToFile(percent, "PERCENTS.txt"); + } + })); + Logic::get().keybinds.SetAction("audioHack", std::move(audioSpeedHackAction)); Logic::get().keybinds.SetAction("anticheat", std::move(anticheatAction)); @@ -3106,6 +3130,8 @@ void GUI::init() { Logic::get().keybinds.SetAction("advancing", std::move(advanceAction)); Logic::get().keybinds.SetAction("resetLevel", std::move(resetAction)); + Logic::get().keybinds.SetAction("outputPercents", std::move(outputPercentAction)); + SET_BIND(realTimeMode, Logic::get().real_time_mode); SET_BIND(showFrame, Logic::get().show_frame); @@ -3132,7 +3158,9 @@ void GUI::init() { SET_BIND(menuBind, show_window); SET_BIND(showRecord, Logic::get().show_recording); - Logic::get().keybinds.GetKeybind("menuBind").SetKey(90, false, true, false); + Logic::get().keybinds.GetKeybind("menuBind").SetKey(164, false, false, true); + + //Logic::get().keybinds.GetKeybind("outputPercents").SetKey(77, false, false, false); // doki percents shit for Title Wave readBinds(); diff --git a/src/Hooks/hooks.cpp b/src/Hooks/hooks.cpp index bf72cf4..166d81e 100644 --- a/src/Hooks/hooks.cpp +++ b/src/Hooks/hooks.cpp @@ -194,8 +194,8 @@ void __fastcall Hooks::CCScheduler_update_h(CCScheduler* self, int, float dt) { g_disable_render = true; // min(static_cast(g_left_over / target_dt), 50) <- super fast but i think its inaccurate - //const int times = min(round((dt + g_left_over) / target_dt), 150); - const int times = min(static_cast(g_left_over / target_dt), 50); + const int times = min(round((dt + g_left_over) / target_dt), 150); + //const int times = min(static_cast(g_left_over / target_dt), 50); for (int i = 0; i < times; i++) { if (i == times - 1) { @@ -494,12 +494,19 @@ void __fastcall Hooks::PlayLayer::update_h(gd::PlayLayer* self, int, float dt) { char out[24]; sprintf_s(out, "CPS: %i/%i", logic.count_presses_in_last_second(false), logic.count_presses_in_last_second(true)); cps_counter->setString(out); - if (logic.current_cps > logic.max_cps) { + + if (self->m_pPlayer1->m_isHolding || self->m_pPlayer1->m_isHolding2 || self->m_pPlayer2->m_isHolding || self->m_pPlayer2->m_isHolding2) { + cps_counter->setColor({ 0, 255, 77 }); + } + else if (logic.current_cps > logic.max_cps) { cps_counter->setColor({ 255, 0, 0 }); } else if (logic.over_max_cps) { cps_counter->setColor({ 255, 72, 0 }); } + else { + cps_counter->setColor({ 255, 255, 255 }); + } cps_counter->setAnchorPoint({ 0, 0.5 }); cps_counter->setPosition(logic.cps_counter_x, logic.cps_counter_y); cps_counter->setOpacity(logic.cps_counter_opacity); @@ -671,7 +678,7 @@ int __fastcall Hooks::PlayLayer::pushButton_h(gd::PlayLayer* self, int, int idk, auto& logic = Logic::get(); if (!logic.is_playing() && !logic.is_recording()) { - logic.live_inputs.push_back({ logic.get_frame(), true, button, self->getPositionY(), self->getPositionX(), self->getRotation(), 0.f, 0.f }); + logic.live_inputs.push_back({ logic.get_frame(), true, !button, self->getPositionY(), self->getPositionX(), self->getRotation(), 0.f, 0.f }); } if ((logic.clickbot_enabled && !logic.is_playing()) || (logic.clickbot_enabled && logic.playback_clicking)) { @@ -684,6 +691,11 @@ int __fastcall Hooks::PlayLayer::pushButton_h(gd::PlayLayer* self, int, int idk, logic.clickbot_now = self->m_time; logic.cycleTime = logic.clickbot_now - logic.clickbot_start; + bool oldButton = button; + if (!self->m_level->twoPlayerMode) { + button = true; + } + bool micros = button ? logic.player_1_micros : logic.player_2_micros; bool softs = button ? logic.player_1_softs : logic.player_2_softs; bool hards = button ? logic.player_1_hards : logic.player_2_hards; @@ -748,6 +760,8 @@ int __fastcall Hooks::PlayLayer::pushButton_h(gd::PlayLayer* self, int, int idk, else { Clickbot::clickChannel2->setPaused(false); } + Clickbot::system->update(); + button = oldButton; } if (logic.playback_clicking) return 0; @@ -827,6 +841,10 @@ int __fastcall Hooks::PlayLayer::releaseButton_h(gd::PlayLayer* self, int, int i Clickbot::inited = true; } + bool oldButton = button; + if (!self->m_level->twoPlayerMode) { + button = true; + } logic.clickbot_now = self->m_time; logic.cycleTime = logic.clickbot_now - logic.clickbot_start; if (logic.cycleTime <= (button ? logic.player_1_micros_time / 1000.f : logic.player_2_micros_time / 1000.f)) @@ -893,6 +911,7 @@ int __fastcall Hooks::PlayLayer::releaseButton_h(gd::PlayLayer* self, int, int i Clickbot::releaseChannel2->setPaused(false); } Clickbot::system->update(); + button = oldButton; } if (logic.playback_releasing) return 0; diff --git a/src/Logic/logic.hpp b/src/Logic/logic.hpp index a32353c..926ff97 100644 --- a/src/Logic/logic.hpp +++ b/src/Logic/logic.hpp @@ -335,6 +335,8 @@ class Logic { HacksStr hacks; + std::string algorithm = "1"; + bool export_to_bot_location = false; bool clickbot_enabled = false; diff --git a/src/Recorder/recorder.cpp b/src/Recorder/recorder.cpp index 6b159a0..66f8373 100644 --- a/src/Recorder/recorder.cpp +++ b/src/Recorder/recorder.cpp @@ -117,7 +117,7 @@ void Recorder::start(const std::string& path) { { std::stringstream stream; stream << '"' << "ffmpeg\\ffmpeg.exe" << '"' << " -y -ss " << song_offset << " -i \"" << song_file - << "\" -i \"" << path << "\" -t " << total_time << " -c:v libx264 -preset fast -crf 10 "; + << "\" -i \"" << path << "\" -t " << total_time << " -c:v " << ((v_fade_in_time > 0 || v_fade_out_time > 0 || a_fade_in_time > 0 || a_fade_out_time > 0) ? "libx264 -preset fast -crf 10" : "copy") << " "; // Video fade-in and fade-out if (fade_in && v_fade_in_time > 0) diff --git a/src/main.cpp b/src/main.cpp index 4bb2101..1c59d6d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -173,6 +173,32 @@ void writeConfig() { j["clickbot_enabled"] = logic.clickbot_enabled; + j["volume_multiplier"] = logic.clickbot_volume_mult_saved; + j["p1_softs"] = logic.player_1_softs; + j["p2_softs"] = logic.player_2_softs; + j["p1_softs_time"] = logic.player_1_softs_time; + j["p2_softs_time"] = logic.player_2_softs_time; + j["p1_softs_volume"] = logic.player_1_softs_volume; + j["p2_softs_volume"] = logic.player_2_softs_volume; + + j["p1_hards"] = logic.player_1_hards; + j["p2_hards"] = logic.player_2_hards; + j["p1_hards_time"] = logic.player_1_hards_time; + j["p2_hards_time"] = logic.player_2_hards_time; + j["p1_hards_volume"] = logic.player_1_hards_volume; + j["p2_hards_volume"] = logic.player_2_hards_volume; + + j["p1_micros"] = logic.player_1_micros; + j["p2_micros"] = logic.player_2_micros; + j["p1_micros_time"] = logic.player_1_micros_time; + j["p2_micros_time"] = logic.player_2_micros_time; + j["p1_micros_volume"] = logic.player_1_micros_volume; + j["p2_micros_volume"] = logic.player_2_micros_volume; + + j["p1_clickpack"] = logic.player_1_path; + j["p2_clickpack"] = logic.player_2_path; + j["algorithm"] = logic.algorithm; + for (const auto& binding : logic.keybinds.bindings) { const std::string& action = binding.first; const Keybind& keybind = binding.second.first; @@ -309,6 +335,33 @@ void readConfig() { GUI::get().editor_auto_scroll = getOrDefault(j, "editor_auto_scroll", true); logic.clickbot_enabled = getOrDefault(j, "clickbot_enabled", false); + + logic.clickbot_volume_mult_saved = getOrDefault(j, "volume_multiplier", logic.clickbot_volume_mult_saved); + + logic.player_1_softs = getOrDefault(j, "p1_softs", logic.player_1_softs); + logic.player_2_softs = getOrDefault(j, "p2_softs", logic.player_2_softs); + logic.player_1_softs_time = getOrDefault(j, "p1_softs_time", logic.player_1_softs_time); + logic.player_2_softs_time = getOrDefault(j, "p2_softs_time", logic.player_2_softs_time); + logic.player_1_softs_volume = getOrDefault(j, "p1_softs_volume", logic.player_1_softs_volume); + logic.player_2_softs_volume = getOrDefault(j, "p2_softs_volume", logic.player_2_softs_volume); + + logic.player_1_hards = getOrDefault(j, "p1_hards", logic.player_1_hards); + logic.player_2_hards = getOrDefault(j, "p2_hards", logic.player_2_hards); + logic.player_1_hards_time = getOrDefault(j, "p1_hards_time", logic.player_1_hards_time); + logic.player_2_hards_time = getOrDefault(j, "p2_hards_time", logic.player_2_hards_time); + logic.player_1_hards_volume = getOrDefault(j, "p1_hards_volume", logic.player_1_hards_volume); + logic.player_2_hards_volume = getOrDefault(j, "p2_hards_volume", logic.player_2_hards_volume); + + logic.player_1_micros = getOrDefault(j, "p1_micros", logic.player_1_micros); + logic.player_2_micros = getOrDefault(j, "p2_micros", logic.player_2_micros); + logic.player_1_micros_time = getOrDefault(j, "p1_micros_time", logic.player_1_micros_time); + logic.player_2_micros_time = getOrDefault(j, "p2_micros_time", logic.player_2_micros_time); + logic.player_1_micros_volume = getOrDefault(j, "p1_micros_volume", logic.player_1_micros_volume); + logic.player_2_micros_volume = getOrDefault(j, "p2_micros_volume", logic.player_2_micros_volume); + + logic.player_1_path = getOrDefault(j, "p1_clickpack", logic.player_1_path); + logic.player_2_path = getOrDefault(j, "p2_clickpack", logic.player_2_path); + logic.algorithm = getOrDefault(j, "algorithm", logic.algorithm); file.close(); }