-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
TheSillyDoggo
committed
Sep 22, 2024
1 parent
d51a511
commit 168344a
Showing
12 changed files
with
310 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |