diff --git a/changelog.md b/changelog.md index 976650b..6df7439 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,14 @@ +# v2.0.0 + +* Changed render FPS cap to 240 (more than 240 fps would need tps bypass lol). +* Changed speedhack limit to 10 (it was 9 for some reason). +* Changed frame offset setting limit to 8 instead of 60. +* Changed render error id 12 message. +* Made speedhack work everywhere. +* Fixed macros importing as .gdr instead of .gdr.json. +* Added warning when rendering if CBF is loaded. +* Added render save location setting. + # v2.0.0-beta.7 * Fixed show trajectory not working. diff --git a/mod.json b/mod.json index 2091200..b79e81c 100644 --- a/mod.json +++ b/mod.json @@ -1,10 +1,10 @@ { - "geode": "3.8.0", + "geode": "3.8.1", "gd": { "win": "2.206", "android": "2.206" }, - "version": "v2.0.0-beta.7", + "version": "v2.0.0", "id": "zilko.xdbot", "name": "xdBot", "developer": "Zilko", @@ -32,14 +32,14 @@ "description": "Adds a frame offset when recording or playing macros", "type": "int", "default": 0, - "min": -60, - "max": 60 + "min": -8, + "max": 8 }, "endscreen_button": { "name": "Button at Endscreen", "description": "Shows the menu button at the endscreen.", "type": "bool", - "default": false + "default": false }, "ffmpeg_path": { "name": "ffmpeg.exe Path", @@ -48,6 +48,12 @@ "default": "", "platforms": ["win"] }, + "render_folder": { + "name": "Render Save Location", + "type": "folder", + "default": "{gd_dir}/renders", + "platforms": ["win"] + }, "background_color": { "name": "Menu background color", "type": "color", diff --git a/src/global.cpp b/src/global.cpp index 94d2e04..da788db 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -151,8 +151,7 @@ int Global::getCurrentFrame() { auto& g = Global::get(); - double time = *reinterpret_cast(reinterpret_cast(pl) + timeOffset); - int frame = static_cast(time * 240.0); + int frame = static_cast(pl->m_gameState.m_levelTime * 240.0); frame -= g.frameOffset; @@ -318,6 +317,11 @@ SettingNode* ButtonSettingValue::createNode(float width) { $execute{ auto & g = Global::get(); + if (!g.mod->setSavedValue("defaults_set5", true)) { + g.mod->setSettingValue("render_folder", g.mod->getSaveDir() / "renders"); + g.mod->setSavedValue("macro_hide_playing_label", true); + } + if (!g.mod->setSavedValue("defaults_set4", true)) { g.mod->setSavedValue("macro_noclip_p1", true); g.mod->setSavedValue("macro_noclip_p2", true); diff --git a/src/hacks/other.cpp b/src/hacks/other.cpp index 050439a..a6ed7c3 100644 --- a/src/hacks/other.cpp +++ b/src/hacks/other.cpp @@ -19,7 +19,7 @@ class $modify(CCScheduler) { return CCScheduler::update(dt); } - if (!PlayLayer::get() || g.renderer.recording || g.renderer.recordingAudio) { + if (g.renderer.recording || g.renderer.recordingAudio) { if (g.currentPitch != 1.f) Global::updatePitch(1.f); @@ -58,7 +58,7 @@ class $modify(CCScheduler) { Global::updatePitch(speedhack); } - if (speedhack != 1.f) + if (speedhack != 1.f && PlayLayer::get()) g.safeMode = true; CCScheduler::update(dt * speedhack); diff --git a/src/macro.hpp b/src/macro.hpp index c23699a..81660ed 100644 --- a/src/macro.hpp +++ b/src/macro.hpp @@ -8,14 +8,6 @@ using namespace geode::prelude; -#ifdef GEODE_IS_WINDOWS -const int timeOffset = 968; -#elif defined(GEODE_IS_ANDROID32) -const int timeOffset = 800; -#elif defined(GEODE_IS_ANDROID64) -const int timeOffset = 952; -#endif - #define DIF(a, b) (std::fabs((a) - (b)) > 0.001f) const std::vector safeValues = { diff --git a/src/renderer/renderer.cpp b/src/renderer/renderer.cpp index bd1e326..3518282 100644 --- a/src/renderer/renderer.cpp +++ b/src/renderer/renderer.cpp @@ -43,6 +43,8 @@ class $modify(CCScheduler) { void update(float dt) { if (!Global::get().renderer.recording) return CCScheduler::update(dt); + // CCScheduler::update(1.f / 240.f); + using namespace std::literals; float newDt = 1.f / 240.f; @@ -67,12 +69,15 @@ class $modify(CCScheduler) { bool Renderer::toggle() { auto& g = Global::get(); + if (Loader::get()->isModLoaded("syzzi.click_between_frames")) { + FLAlertLayer::create("Render", "Disable CBF in Geode to render a level.", "OK"); + return false; + } + std::filesystem::path ffmpegPath = g.mod->getSettingValue("ffmpeg_path"); if (g.renderer.recording || g.renderer.recordingAudio) { - g.renderer.recordingAudio ? g.renderer.stopAudio() : g.renderer.stop(Global::getCurrentFrame()); - } else if (std::filesystem::exists(ffmpegPath) && ffmpegPath.filename().string() == "ffmpeg.exe") { if (!PlayLayer::get()) { @@ -81,19 +86,17 @@ bool Renderer::toggle() { } g.renderer.ffmpegPath = ffmpegPath.string(); - std::filesystem::path path = g.mod->getSaveDir() / "renders"; + std::filesystem::path path = Mod::get()->getSettingValue("render_folder"); if (std::filesystem::exists(path)) g.renderer.start(); else { - if (std::filesystem::create_directory(path)) g.renderer.start(); else { FLAlertLayer::create("Error", "There was an error getting the renders folder. ID: 11", "Ok")->show(); return false; } - } } @@ -146,7 +149,7 @@ void Renderer::start() { auto now = std::chrono::system_clock::now(); auto timestamp = std::chrono::duration_cast(now.time_since_epoch()).count(); std::string filename = fmt::format("render_{}_{}.mp4", std::string_view(pl->m_level->m_levelName), std::to_string(timestamp)); - std::string path = (mod->getSaveDir() / "renders" / filename).string(); + std::string path = (Mod::get()->getSettingValue("render_folder") / filename).string(); if (mod->getSavedValue("render_fix_shaders")) { HWND hwnd = GetForegroundWindow(); @@ -189,7 +192,7 @@ void Renderer::start() { if (pl->m_level->m_songID == 0) songFile = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(songFile.c_str(), false); - float songOffset = pl->m_levelSettings->m_songOffset + (fmod->m_unkInt1a4 / 1000.f) + (levelStartFrame / 240.f); + float songOffset = pl->m_levelSettings->m_songOffset + (fmod->m_musicOffset / 1000.f) + (levelStartFrame / 240.f); bool fadeIn = pl->m_levelSettings->m_fadeIn; bool fadeOut = pl->m_levelSettings->m_fadeOut; @@ -235,7 +238,7 @@ void Renderer::start() { if (process.close()) { Loader::get()->queueInMainThread([] { - FLAlertLayer::create("Error", "There was an error saving the render. ID: 12", "Ok")->show(); + FLAlertLayer::create("Error", "There was an error saving the render. Wrong render args.", "Ok")->show(); }); return; } @@ -462,7 +465,7 @@ void Renderer::handleRecording(PlayLayer* pl, int frame) { lastFrame_t = pl->m_gameState.m_levelTime; int correctMusicTime = static_cast((frame / 240.f + pl->m_levelSettings->m_songOffset) * 1000); - correctMusicTime += fmod->m_unkInt1a4; // Global music offset + correctMusicTime += fmod->m_musicOffset; // Global music offset if (fmod->getMusicTimeMS(0) - correctMusicTime >= 110) fmod->setMusicTimeMS(correctMusicTime, true, 0); diff --git a/src/ui/load_macro_layer.cpp b/src/ui/load_macro_layer.cpp index 30c4be7..880f44a 100644 --- a/src/ui/load_macro_layer.cpp +++ b/src/ui/load_macro_layer.cpp @@ -180,7 +180,7 @@ void LoadMacroLayer::onImportMacro(CCObject*) { std::string pathString = newPath.string(); - while (std::filesystem::exists(pathString + ".gdr")) { + while (std::filesystem::exists(pathString + ".gdr.json")) { iterations++; if (iterations > 1) { @@ -191,10 +191,10 @@ void LoadMacroLayer::onImportMacro(CCObject*) { pathString += fmt::format(" ({})", std::to_string(iterations)); } - pathString += ".gdr"; + pathString += ".gdr.json"; std::ofstream f2(Utils::widen(pathString), std::ios::binary); - auto data = tempMacro.exportData(false); + auto data = tempMacro.exportData(true); f2.write(reinterpret_cast(data.data()), data.size()); f2.close(); diff --git a/src/ui/record_layer.cpp b/src/ui/record_layer.cpp index 31ffa95..020c339 100644 --- a/src/ui/record_layer.cpp +++ b/src/ui/record_layer.cpp @@ -298,7 +298,7 @@ void RecordLayer::textChanged(CCTextInputNode* node) { mod->setSavedValue("render_bitrate", std::string(bitrateInput->getString())); if (std::string_view(fpsInput->getString()) != "" && node == fpsInput) { - if (std::stoi(fpsInput->getString()) > 60) + if (std::stoi(fpsInput->getString()) > 240) return fpsInput->setString(mod->getSavedValue("render_fps").c_str()); } @@ -309,7 +309,7 @@ void RecordLayer::textChanged(CCTextInputNode* node) { if (value == ".") speedhackInput->setString("0."); - else if (std::count(value.begin(), value.end(), '.') == 2 || std::stof(value) > 9) + else if (std::count(value.begin(), value.end(), '.') == 2 || std::stof(value) > 10) return speedhackInput->setString(mod->getSavedValue("macro_speedhack").c_str()); } @@ -417,7 +417,7 @@ void RecordLayer::openKeybinds(CCObject*) { } void RecordLayer::openRendersFolder(CCObject*) { - std::filesystem::path path = Global::get().mod->getSaveDir() / "renders"; + std::filesystem::path path = Mod::get()->getSettingValue("render_folder"); if (std::filesystem::exists(path)) file::openFolder(path);