Alpha's Geode Utils

Alphalaneous

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(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++;
	}
};

General Utils

Include Utils.hpp to access these utils.

alpha::utils::cocos namespace:

Getting sprites while ignoring Texture Loader fallback: std::optional getSprite(const char* sprName) std::optional getSpriteByFrameName(const char* sprFrameName)

Getting a layer from the scene even during transition: std::optional getLayer() std::optional 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 getChildByClassName(cocos2d::CCNode* node, std::string name, int index = 0)

Getting an objects class name by template: std::string_view getObjectName()

1.2.0-beta.1

  • Cleanup everything
  • Added $classModify to use a base class instead of CCNode or CCObject
  • modify method is not required anymore if you wish to merely use fields
  • Removed some redundant utils that are now in Geode
  • Added templated getObjectName method

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

Original Site made by HJfod. Geode 2 parody-ish by MeFinity.

Geode-SDK is the property of the Geode Team.


This website (Geode 2, Codename Malachite) is not affiliated with the Geode Team in any way shape or form.