Skip to content

Commit

Permalink
i wanna kms
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Sep 22, 2024
1 parent d51a511 commit 168344a
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 5 additions & 0 deletions src/Client/AndroidBall.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
1 change: 1 addition & 0 deletions src/Client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Types/TransitionCustomizerUI.hpp"
#include "Types/SmartStartposUI.hpp"
#include "Types/SetValueModule.hpp"
#include "Types/FontModule.hpp"

#include "idkwhattocallthis.hpp"

Expand Down
10 changes: 10 additions & 0 deletions src/Client/ClientSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cc>percentage / time</c> label to be the <cl>level font</c>"));

//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"));

Expand Down Expand Up @@ -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 <cr>[EXPERIMENTAL]</c>"));
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"));
Expand Down
56 changes: 56 additions & 0 deletions src/Client/Types/FontModule.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
24 changes: 24 additions & 0 deletions src/Client/Types/FontModule.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <Geode/Geode.hpp>
#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);
};
21 changes: 21 additions & 0 deletions src/Hacks/PercentageLevelFont.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/PlayLayer.hpp>
#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")
};
3 changes: 3 additions & 0 deletions src/Hacks/Speedhack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
17 changes: 16 additions & 1 deletion src/Labels/Labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ void StatusNode::updateVis()
if (hidden)
sLabels[i]->setVisible(false);
}

updateFont();
}

void StatusNode::updateFont()
{
std::string font = as<FontModule*>(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()
Expand All @@ -104,7 +119,7 @@ void StatusNode::reorderSides()

for (auto label : sLabels)
{
int side = as<DropdownModule*>(window->modules[i + 3]->options[0])->index;
int side = as<DropdownModule*>(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);
Expand Down
1 change: 1 addition & 0 deletions src/Labels/Labels.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class StatusNode : public CCNode

bool init();

void updateFont();
void updateVis();

static void postSetup(Window* wnd);
Expand Down
143 changes: 143 additions & 0 deletions src/Layers/ChooseFontPopup.cpp
Original file line number Diff line number Diff line change
@@ -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<CCNodeRGBA*>(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<CCNode*>(sender)->getID());
}

ChooseFontPopup* ChooseFontPopup::create(geode::utils::MiniFunction<void(std::string)> 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<void(std::string)> callback)
{
auto pRet = ChooseFontPopup::create(callback);

CCScene::get()->addChild(pRet, 99999);

return pRet;
}
27 changes: 27 additions & 0 deletions src/Layers/ChooseFontPopup.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <Geode/Geode.hpp>
#include "../Client/Module.h"
#include "../Hacks/SafeMode/SafeMode.hpp"

#include "SillyBaseLayer.h"

using namespace geode::prelude;

class ChooseFontPopup : public SillyBaseLayer
{
public:
MiniFunction<void(std::string)> callback; // callback is run whenever the value is changed by the user
int selectedIndex = 0;
std::vector<CCMenuItemToggler*> 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<void(std::string)> callback);
static ChooseFontPopup* addToScene(MiniFunction<void(std::string)> callback);
};

0 comments on commit 168344a

Please sign in to comment.