Alpha's Geode Utils
Alpha's Geode Utils
Miscellaneous Geode utils to make development easier:
Modifying any CCObject
Familiar modify syntax as Geode, supporting fields. class $objectModify(SomeObject) or class $nodeModify(SomeNode)
You can name the modified node/object the same way as well class $objectModify(MySomeObject, SomeObject) or class $nodeModify(MySomeNode, SomeNode)
$nodeModify and $objectModify do the same thing, except $nodeModify is a base of CCNode while $objectModify is a base of CCObject
There is also $classModify which will use the base class you pass in instead of a generic CCNode or CCObject. class $classModify(MyMenuLayer, MenuLayer)
To use this, you will create a void modify() method within that class and inside of there you can change the node to your hearts content. You can use the fields struct just like in Geode to add fields if needed.
To edit the priority (lets say another mod modifies the same node using this) you can add static int modifyPrio() to the class which should return an integer value that is the priority you wish to set.
Include ObjectModify.hpp to access these macros.
Full Example modifying BetterInfo's CustomCreatorLayer:
class $nodeModify(MyCustomCreatorLayer, CustomCreatorLayer) {
static int modifyPrio() {
return 10;
}
struct Fields {
int m_number = 0;
};
void modify() {
CCSprite* spr = CCSprite::createWithSpriteFrameName("GJ_playBtn_001.png");
CCMenuItemSpriteExtra* btn = CCMenuItemSpriteExtra::create(spr, this, menu_selector(MyCustomCreatorLayer::onEpicButton));
btn->setID("epic-button"_spr);
if (CCMenu* creatorButtonsMenu = typeinfo_cast<CCMenu*>(getChildByID("cvolton.betterinfo/creator-buttons-menu"))) {
creatorButtonsMenu->addChild(btn);
creatorButtonsMenu->updateLayout();
}
}
void onEpicButton(CCObject* obj) {
log::info("m_number {}", m_fields->m_number);
m_fields->m_number++;
}
};
There's also a useful utility for modifying all classes with a specific Base class. class $baseModify(SomeClass)
It works just like above:
class $baseModify(MyFLAlertLayer, FLAlertLayer) {
void modify() {
m_noElasticity = true;
m_mainLayer->setScale(0.5f);
}
}
General Utils
Include Utils.hpp to access these utils.
alpha::utils::cocos namespace:
Getting sprites while ignoring Texture Loader fallback:
std::optional<cocos2d::CCSprite*> getSprite(const char* sprName)
std::optional<cocos2d::CCSprite*> getSpriteByFrameName(const char* sprFrameName)
Getting a layer from the scene even during transition:
std::optional<cocos2d::CCNode*> getLayer()
std::optional<cocos2d::CCNode*> getLayerByClassName(std::string className)
Setting a node color by hex code:
bool setColorByHex(cocos2d::CCRGBAProtocol* node, std::string colorHex)
Checking if a parent node contains a node anywhere in a tree:
bool hasNode(cocos2d::CCNode* child, cocos2d::CCNode* parent)
Getting a child by class name dynamically:
std::optional<cocos2d::CCNode*> getChildByClassName(cocos2d::CCNode* node, std::string name, int index = 0)
Getting an objects class name by template:
std::string_view getObjectName<T>()
1.2.4
- Cleanup on close
1.2.3
- Made a mistake oops, fixed
1.2.2
- Bug fixes
1.2.1
- Fixed a bug that leaked user objects and fields
1.2.0
- Move out of beta
1.2.0-beta.2
- Geode Alpha 2 support
- Performance Improvements
- Added $baseModify
1.2.0-beta.1
- Cleanup everything
- Added $classModify to use a base class instead of CCNode or CCObject
modifymethod is not required anymore if you wish to merely use fields- Removed some redundant utils that are now in Geode
- Added templated
getObjectNamemethod
1.1.8
- Quick fixes you'll never see as an end user
- Code cleanup
1.1.7
- Fix a Cocos2d-x 2.2.3 bug where for some godforsaken reason, autorelease can be called on a nullptr in CCDictionary::createWithContentsOfFile. Thank you cocos devs :)
1.1.6
- iOS rebuild
- New icon
1.1.5
- API fix
1.1.4
- Attempt to fix a crash
1.1.3
- Fix an oopsie
1.1.2
- Fix a leak and crash
1.1.1
- Separate Node and Object modify macros
- $nodeModify now has a base class of CCNode
- $objectModify has a base class of CCObject
1.1.0
- Fields and User Objects can now be used with CCObjects in the same way as CCNodes
1.0.5
- iOS support
1.0.4
- Add tags
1.0.3
- Add string variant for getLayer
- Fix a bug with getLayer
1.0.2
- Fix a typo
1.0.1
- Code cleanup
1.0.0
- Initial Release
.geode files you get from this page. Some mods also require other mods as dependencies; you will need to find and install them yourself.