Skip to content

Commit

Permalink
2.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiLko committed Jan 16, 2025
1 parent 798c2f7 commit 18a04f9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android copy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
branches:
- "main"
- "xD"

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
branches:
- "NO!"
- "main"

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# v2.3.10

* Added restore button for clickbot click settings.
* Fixed seed again cus i forgot sometinhg.
* Fixed android render trying to record audio even though it cant add it to the video.
* Fixed buttons scale JUST for viper.
* Fixed tps bypass speedups maybe.
* R

# v2.3.9
Expand Down
104 changes: 52 additions & 52 deletions src/hacks/clickbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,71 +91,71 @@ void Clickbot::setSound(std::string id, FMOD::Sound* sound) {
}

void Clickbot::playSound(std::string id) {
// auto& c = get();
// if (!c.system) return updateSounds();
auto& c = get();
if (!c.system) return updateSounds();

// auto& g = Global::get();
// matjson::Value data = g.mod->getSavedValue<matjson::Value>(id);
// ClickSetting settings = matjson::Serialize<ClickSetting>::from_json(data);
auto& g = Global::get();
matjson::Value data = g.mod->getSavedValue<matjson::Value>(id);
ClickSetting settings = matjson::Serialize<ClickSetting>::from_json(data);

// if (settings.disabled) return;
if (settings.disabled) return;

// FMOD::Sound* sound = getSound(id);
FMOD::Sound* sound = getSound(id);

// if (!sound) return;
if (!sound) return;

// int masterVol = g.mod->getSavedValue<int64_t>("clickbot_volume");
// if (settings.volume == 0 || masterVol == 0) return;
int masterVol = g.mod->getSavedValue<int64_t>("clickbot_volume");
if (settings.volume == 0 || masterVol == 0) return;

// FMOD_RESULT result;
FMOD_RESULT result;

// result = c.system->playSound(sound, nullptr, false, &c.channel);
// if (result != FMOD_OK) return log::debug("Click sound errored. ID: 2");
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) * (masterVol / 100.f));
// if (result != FMOD_OK) return log::debug("Click sound errored. ID: 3");
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);
// if (result != FMOD_OK) return log::debug("Click sound errored. ID: 4");
result = c.channel->setPitch(g.currentPitch);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 4");

// FMOD::DSP* pitchShifter = c.pitchShifter;
// if (!pitchShifter) return updateSounds();
FMOD::DSP* pitchShifter = c.pitchShifter;
if (!pitchShifter) return updateSounds();

// result = pitchShifter->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH, settings.pitch * g.mod->getSavedValue<float>("clickbot_pitch"));
// if (result != FMOD_OK) return log::debug("Click sound errored. ID: 6");
result = pitchShifter->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH, settings.pitch * g.mod->getSavedValue<float>("clickbot_pitch"));
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 6");

// result = c.channel->addDSP(0, pitchShifter);
// if (result != FMOD_OK) return log::debug("Click sound errored. ID: 7");
result = c.channel->addDSP(0, pitchShifter);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 7");
}

void Clickbot::updateSounds() {
// auto& c = get();
// FMOD_RESULT result;

// if (!c.system) {
// FMODAudioEngine* fmod = FMODAudioEngine::sharedEngine();
// c.system = fmod->m_system;
// }

// if (!c.system) return;

// for (std::string name : buttonNames) {
// matjson::Value data = Global::get().mod->getSavedValue<matjson::Value>(name);
// ClickSetting settings = matjson::Serialize<ClickSetting>::from_json(data);
// if (!std::filesystem::exists(settings.path)) continue;

// FMOD::Sound* sound = getSound(name);
// result = c.system->createSound(settings.path.string().c_str(), FMOD_DEFAULT, nullptr, &sound);
// if (result != FMOD_OK) {
// log::debug("Click sound errored. ID: 1");
// continue;
// }

// setSound(name, sound);
// }

// if (!c.pitchShifter) {
// result = c.system->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &c.pitchShifter);
// if (result != FMOD_OK) return log::debug("Click sound errored. ID: 5");
// }
auto& c = get();
FMOD_RESULT result;

if (!c.system) {
FMODAudioEngine* fmod = FMODAudioEngine::sharedEngine();
c.system = fmod->m_system;
}

if (!c.system) return;

for (std::string name : buttonNames) {
matjson::Value data = Global::get().mod->getSavedValue<matjson::Value>(name);
ClickSetting settings = matjson::Serialize<ClickSetting>::from_json(data);
if (!std::filesystem::exists(settings.path)) continue;

FMOD::Sound* sound = getSound(name);
result = c.system->createSound(settings.path.string().c_str(), FMOD_DEFAULT, nullptr, &sound);
if (result != FMOD_OK) {
log::debug("Click sound errored. ID: 1");
continue;
}

setSound(name, sound);
}

if (!c.pitchShifter) {
result = c.system->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &c.pitchShifter);
if (result != FMOD_OK) return log::debug("Click sound errored. ID: 5");
}
}
35 changes: 29 additions & 6 deletions src/ui/clickbot_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ bool ClickSettingsLayer::setup(std::string button, geode::Popup<>* layer) {
CCMenu* menu = CCMenu::create();
m_mainLayer->addChild(menu);

this->button = button;
this->clickbotLayer = layer;
button = button;
clickbotLayer = layer;

matjson::Value data = Mod::get()->getSavedValue<matjson::Value>(button);
settings = matjson::Serialize<ClickSetting>::from_json(data);
Expand Down Expand Up @@ -386,6 +386,12 @@ bool ClickSettingsLayer::setup(std::string button, geode::Popup<>* layer) {
lbl->setScale(0.45f);
menu->addChild(lbl);

spr = ButtonSprite::create("Restore");
spr->setScale(0.425f);
btn = CCMenuItemSpriteExtra::create(spr, this, menu_selector(ClickSettingsLayer::onRestore));
btn->setPosition({89, -69});
menu->addChild(btn);

return true;
}

Expand All @@ -400,12 +406,29 @@ void ClickSettingsLayer::onSelectFile(CCObject*) {
if (res->isOk()) {
std::filesystem::path path = res->unwrapOrDefault();

this->filenameLabel->setString(path.filename().string().c_str());
filenameLabel->setString(path.filename().string().c_str());

this->settings.path = path;
this->saveSettings();
settings.path = path;
saveSettings();

static_cast<ClickbotLayer*>(this->clickbotLayer)->updateLabels();
static_cast<ClickbotLayer*>(clickbotLayer)->updateLabels();
}
});
}

void ClickSettingsLayer::onRestore(CCObject*) {
pitchSlider->setValue(0.33333333f);
volumeSlider->setValue(0.33333333f);

updatePitch(nullptr);
updateVolume(nullptr);

std::filesystem::path path = Mod::get()->getResourcesDir() / fmt::format("default_{}.mp3", button);

filenameLabel->setString(path.filename().string().c_str());

settings.path = path;
saveSettings();

static_cast<ClickbotLayer*>(clickbotLayer)->updateLabels();
}
2 changes: 2 additions & 0 deletions src/ui/clickbot_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class ClickSettingsLayer : public geode::Popup<std::string, geode::Popup<>*> {
saveSettings();
}

void onRestore(CCObject*);

};


Expand Down

0 comments on commit 18a04f9

Please sign in to comment.