Skip to content

Commit

Permalink
2.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiLko committed Jan 12, 2025
1 parent 9056d88 commit 7905323
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 24 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v2.3.5

* Added render warning.
* Fixed clickbot not working.
* Fixed render audio recording bugs.
* Fixed on level end auto save not working.

# v2.3.4

* Fixed render green video?.
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"win": "2.2074",
"android": "2.2074"
},
"version": "2.3.4",
"version": "2.3.5",
"id": "zilko.xdbot",
"name": "xdBot",
"developer": "Zilko",
Expand Down
8 changes: 5 additions & 3 deletions src/hacks/clickbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ void Clickbot::playSound(std::string id) {

FMOD_RESULT result;

FMOD::Channel* channel = nullptr;
result = c.system->playSound(sound, nullptr, true, &channel);
result = c.system->playSound(sound, nullptr, false, &c.channel);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 2");

result = c.channel->setVolume((settings.volume / 100.f) * (g.mod->getSavedValue<int64_t>("clickbot_volume") / 100.f));
int masterVol = g.mod->getSavedValue<int64_t>("clickbot_volume");
if (settings.volume == 0 || masterVol == 0) return;

result = c.channel->setVolume((settings.volume / 100.f) * (masterVol / 100.f));
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 3");

result = c.channel->setPitch(g.currentPitch);
Expand Down
6 changes: 6 additions & 0 deletions src/hacks/other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ class $modify(PlayLayer) {
void levelComplete() {
auto& g = Global::get();

g.firstAttempt = true;

if (g.state == state::recording && g.autosaveEnabled && g.mod->getSavedValue<bool>("autosave_levelend_enabled"))
Macro::autoSave(nullptr, g.currentSession);

bool wasTestMode = m_isTestMode;

if (g.safeMode && g.mod->getSavedValue<bool>("macro_auto_safe_mode"))
Expand All @@ -157,6 +162,7 @@ class $modify(PlayLayer) {
g.safeMode = false;

PlayLayer::levelComplete();

Macro::resetState(true);

m_isTestMode = wasTestMode;
Expand Down
2 changes: 1 addition & 1 deletion src/macro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const std::vector<float> safeValues = {
1.0f / 5, 1.0f / 4, 1.0f / 3, 1.0f / 2
};

const std::string xdBotVersion = "v2.3.4";
const std::string xdBotVersion = "v2.3.5";

enum state {
none,
Expand Down
29 changes: 14 additions & 15 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,6 @@ class $modify(PlayLayer) {
g.ignoreRecordAction = false;
}

void levelComplete() {
PlayLayer::levelComplete();

auto& g = Global::get();

g.firstAttempt = true;

if (g.state == state::recording && g.autosaveEnabled && g.mod->getSavedValue<bool>("autosave_levelend_enabled"))
Macro::autoSave(nullptr, g.currentSession);

Macro::resetState(true);
}

};

class $modify(BGLHook, GJBaseGameLayer) {
Expand Down Expand Up @@ -468,14 +455,26 @@ class $modify(PauseLayer) {

void onQuit(CCObject * sender) {
PauseLayer::onQuit(sender);
auto& g = Global::get();

Macro::resetState();

Loader::get()->queueInMainThread([] {
auto& g = Global::get();
if (g.renderer.recording) g.renderer.stop();
if (g.renderer.recordingAudio) g.renderer.stopAudio();
});
}

void goEdit() {
PauseLayer::goEdit();
auto& g = Global::get();

Macro::resetState();

Loader::get()->queueInMainThread([] {
auto& g = Global::get();
if (g.renderer.recording) g.renderer.stop();
if (g.renderer.recordingAudio) g.renderer.stopAudio();
});
}

};
17 changes: 13 additions & 4 deletions src/renderer/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ void Renderer::start() {
settings.m_fps = fps;
settings.m_outputFile = path;

if (!Mod::get()->setSavedValue("first_render_", true)) {
FLAlertLayer::create(
"Warning",
"If you have a macro for the level, <cl>let it run</c> to allow the level to render.",
"Ok"
)->show();
}

std::thread([&, path, songFile, songOffset, fadeIn, fadeOut, extension, bitrateApi, settings]() {
if (!codec.empty()) codec = "-c:v " + codec + " ";
if (!bitrate.empty()) bitrate = "-b:v " + bitrate + " ";
Expand Down Expand Up @@ -508,13 +516,13 @@ void Renderer::start() {

void Renderer::stop(int frame) {
renderedFrames.clear();
finishFrame = frame;
finishFrame = Global::getCurrentFrame();
pause = true;
recording = false;
timeAfter = 0.f;

if (PlayLayer* pl = PlayLayer::get()) {
if (pl->m_hasCompletedLevel) {
if (pl->m_levelEndAnimationStarted) {
finishFrame = 0;
levelFinished = true;
}
Expand All @@ -527,7 +535,8 @@ void Renderer::stop(int frame) {
xdbot->onClose(nullptr);
}
}
}
} else
audioMode = AudioMode::Off;

if (audioMode == AudioMode::Record) {
recordingAudio = true;
Expand Down Expand Up @@ -661,7 +670,7 @@ void Renderer::captureFrame() {
}

void Renderer::handleRecording(PlayLayer* pl, int frame) {
if (!pl) stop();
if (!pl) stop(frame);
isPlatformer = pl->m_levelSettings->m_platformerMode;
if (dontRender || pl->m_player1->m_isDead) return;

Expand Down
6 changes: 6 additions & 0 deletions src/ui/macro_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class $modify(CCEGLView) {

if (!editLayer) return;

CCScene* scene = CCDirector::get()->getRunningScene();
if (MacroEditLayer* layer = scene->getChildByType<MacroEditLayer>(0))
editLayer = layer;
else
return;

editLayer->updateHover(getMousePos());

}
Expand Down

0 comments on commit 7905323

Please sign in to comment.