Skip to content

Commit

Permalink
Bro idk
Browse files Browse the repository at this point in the history
  • Loading branch information
lcm7341 committed Aug 5, 2023
1 parent b305dd6 commit 490b262
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 9 deletions.
36 changes: 32 additions & 4 deletions src/GUI/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
Expand All @@ -2131,6 +2132,7 @@ void GUI::clickbot() {
expression = "0+";
expression += inputBuffer;
tokens = tokenizeExpression(expression);
logic.algorithm = inputBuffer;

int index = 0;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -3093,6 +3110,13 @@ void GUI::init() {
}
}));

std::unique_ptr<KeybindableBase> outputPercentAction = std::unique_ptr<KeybindableBase>(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));
Expand All @@ -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);
Expand All @@ -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();

Expand Down
27 changes: 23 additions & 4 deletions src/Hooks/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ void __fastcall Hooks::CCScheduler_update_h(CCScheduler* self, int, float dt) {
g_disable_render = true;

// min(static_cast<int>(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<int>(g_left_over / target_dt), 50);
const int times = min(round((dt + g_left_over) / target_dt), 150);
//const int times = min(static_cast<int>(g_left_over / target_dt), 50);

for (int i = 0; i < times; i++) {
if (i == times - 1) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/Logic/logic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ class Logic {

HacksStr hacks;

std::string algorithm = "1";

bool export_to_bot_location = false;

bool clickbot_enabled = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Recorder/recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
53 changes: 53 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 490b262

Please sign in to comment.