Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiLko committed Oct 30, 2024
1 parent 38e4cd1 commit b0d36a7
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 32 deletions.
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
16 changes: 11 additions & 5 deletions mod.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions src/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ int Global::getCurrentFrame() {

auto& g = Global::get();

double time = *reinterpret_cast<double*>(reinterpret_cast<char*>(pl) + timeOffset);
int frame = static_cast<int>(time * 240.0);
int frame = static_cast<int>(pl->m_gameState.m_levelTime * 240.0);

frame -= g.frameOffset;

Expand Down Expand Up @@ -318,6 +317,11 @@ SettingNode* ButtonSettingValue::createNode(float width) {
$execute{
auto & g = Global::get();

if (!g.mod->setSavedValue("defaults_set5", true)) {
g.mod->setSettingValue<std::filesystem::path>("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);
Expand Down
4 changes: 2 additions & 2 deletions src/hacks/other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 0 additions & 8 deletions src/macro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> safeValues = {
Expand Down
21 changes: 12 additions & 9 deletions src/renderer/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<std::filesystem::path>("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()) {
Expand All @@ -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<std::filesystem::path>("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;
}

}

}
Expand Down Expand Up @@ -146,7 +149,7 @@ void Renderer::start() {
auto now = std::chrono::system_clock::now();
auto timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(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<std::filesystem::path>("render_folder") / filename).string();

if (mod->getSavedValue<bool>("render_fix_shaders")) {
HWND hwnd = GetForegroundWindow();
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -462,7 +465,7 @@ void Renderer::handleRecording(PlayLayer* pl, int frame) {
lastFrame_t = pl->m_gameState.m_levelTime;

int correctMusicTime = static_cast<int>((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);
Expand Down
6 changes: 3 additions & 3 deletions src/ui/load_macro_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<const char*>(data.data()), data.size());
f2.close();
Expand Down
6 changes: 3 additions & 3 deletions src/ui/record_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>("render_fps").c_str());
}

Expand All @@ -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<std::string>("macro_speedhack").c_str());
}

Expand Down Expand Up @@ -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<std::filesystem::path>("render_folder");

if (std::filesystem::exists(path))
file::openFolder(path);
Expand Down

0 comments on commit b0d36a7

Please sign in to comment.