diff --git a/changelog.md b/changelog.md index 0435b0c..e516205 100644 --- a/changelog.md +++ b/changelog.md @@ -1,9 +1,12 @@ # 1.6.7 +- Fixed Speedhack not working with cbf enabled - Added **Toolbox Button Bypass** - Added **Scale Text Input** - Added **Free Scroll** - Added **No Trail Blending** +- Added **Percentage Level Font** +- Added **Label Font Customizer** # 1.6.6 diff --git a/src/Client/AndroidBall.h b/src/Client/AndroidBall.h index 37191d7..229e7d6 100644 --- a/src/Client/AndroidBall.h +++ b/src/Client/AndroidBall.h @@ -51,5 +51,10 @@ class AndroidBall : public CCLayer class $modify (QOLModTouchDispatcher, CCTouchDispatcher) { + static void onModify(auto& self) + { + self.setHookPriority("cocos2d::CCTouchDispatcher::touches", -99999999); + } + void touches(CCSet* touches, CCEvent* event, unsigned int type); }; \ No newline at end of file diff --git a/src/Client/Client.h b/src/Client/Client.h index 3e7d90a..298d4fe 100644 --- a/src/Client/Client.h +++ b/src/Client/Client.h @@ -10,6 +10,7 @@ #include "Types/TransitionCustomizerUI.hpp" #include "Types/SmartStartposUI.hpp" #include "Types/SetValueModule.hpp" +#include "Types/FontModule.hpp" #include "idkwhattocallthis.hpp" diff --git a/src/Client/ClientSetup.h b/src/Client/ClientSetup.h index 363f2c7..a70908a 100644 --- a/src/Client/ClientSetup.h +++ b/src/Client/ClientSetup.h @@ -126,6 +126,8 @@ class ClientUtils level->modules.push_back(new Module("Auto Clicker", "auto-clicker", "Automatically clicks (and holds for) every X ticks")); level->modules.push_back(new Module("Stop Triggers on Death", "stop-triggers-on-death", "Stops triggers whenever you die :3")); + level->modules.push_back(new Module("Percentage Level Font", "percentage-level-font", "Changes the font of the percentage / time label to be the level font")); + //level->modules.push_back(new Module("Gamemode Switcher", "gamemode-switcher", "Adds a button to the bottom of the pause menu to change your gamemode")); //level->modules.push_back(new Module("Frame Stepper", "frame-stepper", "Step the game through frames by tapping a button")); @@ -381,8 +383,16 @@ class ClientUtils replay->modules.push_back(new StatusOpacity()); replay->modules.push_back(new StatusScale()); + auto font = new FontModule("labels-font"); + font->onToggle = [font](bool) + { + if (StatusNode::get()) + StatusNode::get()->updateVis(); + }; + //replay->modules.push_back(new Module("Testmode", "status-testmode", "Show the test mode text if there's a startpos")); replay->modules.push_back(new Module("Labels In Editor", "labels-in-editor", "Shows your labels in the level editor [EXPERIMENTAL]")); + replay->modules.push_back(font); replay->modules.push_back(new Module("Cheat Indicator", "cheat-indicator", "Shows if you are cheating")); replay->modules.push_back(new Module("FPS Counter", "status-fps", "Shows your current game fps")); diff --git a/src/Client/Types/FontModule.cpp b/src/Client/Types/FontModule.cpp new file mode 100644 index 0000000..552b723 --- /dev/null +++ b/src/Client/Types/FontModule.cpp @@ -0,0 +1,56 @@ +#include "FontModule.hpp" +#include "../../Layers/ChooseFontPopup.hpp" + +FontModule::FontModule(std::string id) +{ + this->id = id; + font = "bigFont.fnt"; + + load(); +} + +void FontModule::save() +{ + Mod::get()->setSavedValue(fmt::format("{}_font", id), font); +} + +void FontModule::load() +{ + font = Mod::get()->getSavedValue(fmt::format("{}_font", id), font); + + save(); +} + +void FontModule::makeAndroid(CCNode* menu, CCPoint pos) +{ + auto btn = ButtonSprite::create("Change Font", 100, 0, 1.0f, false, getSelectedFont().c_str(), "GJ_button_05.png", 23); + + auto btn2 = CCMenuItemSpriteExtra::create(btn, this, menu_selector(FontModule::onChooseFont)); + btn2->setPosition(pos + ccp(135 / 2, 0)); + + menu->addChild(btn2); +} + +void FontModule::onChooseFont(CCObject* sender) +{ + ChooseFontPopup::addToScene([this](std::string font) + { + log::info("selected font: {}", font); + + this->font = font; + save(); + + if (onToggle) + onToggle(true); + + })->setSelected(getSelectedFont()); +} + +std::string FontModule::getSelectedFont() +{ + // if the font does not exist, return the default which probably already exists. if it doesn't exist gd would've crashed earlier + if (!CCFileUtils::sharedFileUtils()->isFileExist(CCFileUtils::sharedFileUtils()->fullPathForFilename(font.c_str(), false))) + return "bigFont.fnt"; + + return font; +} \ No newline at end of file diff --git a/src/Client/Types/FontModule.hpp b/src/Client/Types/FontModule.hpp new file mode 100644 index 0000000..30aac6f --- /dev/null +++ b/src/Client/Types/FontModule.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "../Module.h" +#include "../Dropdown.h" + +using namespace geode::prelude; + +class FontModule : public Module +{ + private: + std::string font; + public: + FontModule(std::string id); + + virtual void save(); + virtual void load(); + + void makeAndroid(CCNode* menu, CCPoint pos); + + std::string getSelectedFont(); + + void onChooseFont(CCObject* sender); +}; \ No newline at end of file diff --git a/src/Hacks/PercentageLevelFont.cpp b/src/Hacks/PercentageLevelFont.cpp new file mode 100644 index 0000000..494ffd2 --- /dev/null +++ b/src/Hacks/PercentageLevelFont.cpp @@ -0,0 +1,21 @@ +#include +#include +#include "../Client/Client.h" + +using namespace geode::prelude; + +class $modify (PlayLayer) +{ + void updateProgressbar() + { + PlayLayer::updateProgressbar(); + + if (m_percentageLabel && m_attemptLabel) + { + m_percentageLabel->setFntFile(m_attemptLabel->getFntFile()); + m_percentageLabel->setScale(32.5f * 0.5f / m_percentageLabel->getContentHeight()); + } + } + + QOLMOD_MOD_ALL_HOOKS("percentage-level-font") +}; \ No newline at end of file diff --git a/src/Hacks/Speedhack.cpp b/src/Hacks/Speedhack.cpp index a5030a3..56be339 100644 --- a/src/Hacks/Speedhack.cpp +++ b/src/Hacks/Speedhack.cpp @@ -38,6 +38,9 @@ float speedhackLogic(float dt) masterGroup->setPitch(SpeedhackMus::instance->enabled ? v : 1); #endif ColourUtility::update(dt * v); + + CCDirector::get()->setActualDeltaTime(CCDirector::get()->getActualDeltaTime() * v); + CCDirector::get()->setDeltaTime(CCDirector::get()->getDeltaTime() * v); return dt * v; } } diff --git a/src/Labels/Labels.cpp b/src/Labels/Labels.cpp index 30769e5..2cdb51e 100644 --- a/src/Labels/Labels.cpp +++ b/src/Labels/Labels.cpp @@ -86,6 +86,21 @@ void StatusNode::updateVis() if (hidden) sLabels[i]->setVisible(false); } + + updateFont(); +} + +void StatusNode::updateFont() +{ + std::string font = as(Client::GetModule("labels-font"))->getSelectedFont(); + + for (auto lbl : sLabels) + { + lbl->setFntFile(font.c_str()); + + // make sure all the labels are the same height + lbl->setScale((32.5f * lbl->getScale()) / lbl->getContentHeight()); + } } void StatusNode::reorderSides() @@ -104,7 +119,7 @@ void StatusNode::reorderSides() for (auto label : sLabels) { - int side = as(window->modules[i + 3]->options[0])->index; + int side = as(window->modules[i + 4]->options[0])->index; label->setAnchorPoint(ccp((side == 0 || side == 2) ? 0 : 1, (side == 2 || side == 3) ? 0 : 1)); label->setAlignment((side == 0 || side == 2) ? CCTextAlignment::kCCTextAlignmentLeft : CCTextAlignment::kCCTextAlignmentRight); diff --git a/src/Labels/Labels.h b/src/Labels/Labels.h index a203794..f10c297 100644 --- a/src/Labels/Labels.h +++ b/src/Labels/Labels.h @@ -137,6 +137,7 @@ class StatusNode : public CCNode bool init(); + void updateFont(); void updateVis(); static void postSetup(Window* wnd); diff --git a/src/Layers/ChooseFontPopup.cpp b/src/Layers/ChooseFontPopup.cpp new file mode 100644 index 0000000..54f2eb4 --- /dev/null +++ b/src/Layers/ChooseFontPopup.cpp @@ -0,0 +1,143 @@ +#include "ChooseFontPopup.hpp" + +void ChooseFontPopup::customSetup() +{ + // 59 being the custom song count + int fontCount = 59 + 3; + float cellSize = 30; + + auto border = geode::ListBorders::create(); + border->setContentSize(ccp(320, 210)); + border->setZOrder(69); + border->setSpriteFrames("geode.loader/geode-list-top.png", "geode.loader/geode-list-side.png", 2.25f); + + for (auto child : CCArrayExt(border->getChildren())) + { + child->setColor(ccc3(0, 0, 0)); + } + + auto filter = CCScale9Sprite::create("GJ_square01.png"); + filter->setContentSize((border->getContentSize() + ccp(0, 5)) * 2); + filter->setScale(1.0f / 2.0f); + auto clipping = CCClippingNode::create(filter); + clipping->setAlphaThreshold(0.01f); + + auto scroll = ScrollLayer::create(filter->getContentSize() / 2); + scroll->m_contentLayer->setContentHeight(cellSize * fontCount); + scroll->moveToTop(); + scroll->m_contentLayer->setLayout(AxisLayout::create(Axis::Column)->setAutoScale(false)->setGap(0)->setAxisReverse(true)); + + for (size_t i = 0; i < fontCount; i++) + { + std::string name; + std::string font; + + name = fmt::format("Font {}", i + 1 - 3); + + if (i == 0) + name = "Pusab"; + else if (i == 1) + name = "Pusab (Gold)"; + else if (i == 2) + name = "Comment Font"; + + if (i == 0) + font = "bigFont.fnt"; + else if (i == 1) + font = "goldFont.fnt"; + else if (i == 2) + font = "chatFont.fnt"; + else if (i - 2 < 10) + font = fmt::format("gjFont0{}.fnt", i - 2); + else + font = fmt::format("gjFont{}.fnt", i - 2); + + auto cell = CCLayerColor::create(ccc4(0, 0, 0, i % 2 ? 150 : 75)); + cell->ignoreAnchorPointForPosition(false); + cell->setContentWidth(320); + cell->setContentHeight(cellSize); + cell->setAnchorPoint(ccp(0, 1)); + + auto menu = CCMenu::create(); + menu->setAnchorPoint(ccp(0, 0)); + menu->setScale(0.6f); + + auto btn = CCMenuItemToggler::create(CCSprite::createWithSpriteFrameName("GJ_selectSongBtn_001.png"), CCSprite::createWithSpriteFrameName("GJ_selectSongOnBtn_001.png"), this, menu_selector(ChooseFontPopup::onSelect)); + btn->setTag(i); + btn->setID(font); + menu->addChild(btn); + + toggles.push_back(btn); + + auto lbl = CCLabelBMFont::create(name.c_str(), font.c_str()); + lbl->setAnchorPoint(ccp(0, 0.5f)); + lbl->setScale(20 / lbl->getContentHeight()); + + cell->addChildAtPosition(menu, Anchor::Right, ccp(-17.5f, 0)); + cell->addChildAtPosition(lbl, Anchor::Left, ccp(6, 0)); + scroll->m_contentLayer->addChild(cell); + } + + scroll->m_contentLayer->updateLayout(); + clipping->addChildAtPosition(scroll, Anchor::BottomLeft, -scroll->getContentSize() / 2); + baseLayer->addChildAtPosition(clipping, Anchor::Center, ccp(0, 5)); + baseLayer->addChildAtPosition(border, Anchor::Center, ccp(0, 5)); + + setSelected(0); +} + +void ChooseFontPopup::setSelected(int id) +{ + for (size_t i = 0; i < toggles.size(); i++) + { + toggles[i]->setEnabled(i != id); + toggles[i]->toggle(i == id); + } +} + +void ChooseFontPopup::setSelected(std::string id) +{ + for (size_t i = 0; i < toggles.size(); i++) + { + if (toggles[i]->getID() == id) + { + setSelected(i); + return; + } + } + + setSelected(0); +} + +void ChooseFontPopup::onSelect(CCObject* sender) +{ + setSelected(sender->getTag()); + + if (callback) + callback(as(sender)->getID()); +} + +ChooseFontPopup* ChooseFontPopup::create(geode::utils::MiniFunction callback) +{ + auto pRet = new ChooseFontPopup(); + + pRet->callback = callback; + + if (pRet && pRet->initWithSizeAndName(ccp(400, 290), "Choose Font")) + { + pRet->autorelease(); + return pRet; + } + + CC_SAFE_DELETE(pRet); + return nullptr; +} + +ChooseFontPopup* ChooseFontPopup::addToScene(geode::utils::MiniFunction callback) +{ + auto pRet = ChooseFontPopup::create(callback); + + CCScene::get()->addChild(pRet, 99999); + + return pRet; +} \ No newline at end of file diff --git a/src/Layers/ChooseFontPopup.hpp b/src/Layers/ChooseFontPopup.hpp new file mode 100644 index 0000000..2ac15b2 --- /dev/null +++ b/src/Layers/ChooseFontPopup.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include "../Client/Module.h" +#include "../Hacks/SafeMode/SafeMode.hpp" + +#include "SillyBaseLayer.h" + +using namespace geode::prelude; + +class ChooseFontPopup : public SillyBaseLayer +{ + public: + MiniFunction callback; // callback is run whenever the value is changed by the user + int selectedIndex = 0; + std::vector toggles; + + void setSelected(int id); + void setSelected(std::string font); // selects the node based of a font name, if the font does not exist just sets it to bigFont + + void onSelect(CCObject* sender); + + virtual void customSetup(); + + static ChooseFontPopup* create(MiniFunction callback); + static ChooseFontPopup* addToScene(MiniFunction callback); +}; \ No newline at end of file