1+ #include < Geode/Geode.hpp>
2+ #include < UIBuilder.hpp>
3+ #include < Geode/ui/MDPopup.hpp>
4+ #include < Geode/cocos/menu_nodes/CCMenu.h>
5+ #include < Geode/modify/CCMenu.hpp>
6+ #include < Geode/utils/web.hpp>
7+ using namespace geode ::prelude;
8+ class YoutubeButton : public CCLayer {
9+ public:
10+ void Link (CCObject*) {
11+ geode::utils::web::openLinkInBrowser (" https://www.youtube.com/channel/UC3A8dtlO94rHEkn4Kz7aB7g" );
12+ }
13+ };
14+
15+ CCNode* menu = nullptr ;
16+ void inityoutubeandsuch () {
17+ geode::log::debug (" Found ui" );
18+ };
19+ inline bool isSpriteFrameName (CCNode* node, const char * name) {
20+ auto cache = CCSpriteFrameCache::sharedSpriteFrameCache ()->spriteFrameByName (name);
21+ if (!cache) return false ;
22+
23+ auto * texture = cache->getTexture ();
24+ auto rect = cache->getRect ();
25+
26+ if (auto * spr = typeinfo_cast<CCSprite*>(node)) {
27+ if (spr->getTexture () == texture && spr->getTextureRect () == rect) {
28+ return true ;
29+ }
30+ } else if (auto * btn = typeinfo_cast<CCMenuItemSprite*>(node)) {
31+ auto * img = btn->getNormalImage ();
32+ if (auto * spr = typeinfo_cast<CCSprite*>(img)) {
33+ if (spr->getTexture () == texture && spr->getTextureRect () == rect) {
34+ return true ;
35+ }
36+ }
37+ }
38+ return false ;
39+ }
40+
41+ inline CCNode* getChildBySpriteFrameName (CCNode* parent, const char * name) {
42+ for (auto child : CCArrayExt<CCNode*>(parent->getChildren ())) {
43+ if (::isSpriteFrameName (static_cast <CCNode*>(child), name)) {
44+ return child;
45+ }
46+ }
47+ return nullptr ;
48+ }
49+
50+ class $modify(CCMenu) {
51+ static void onModify (auto & self) { self.setHookPriority (" CCMenu::addChild" , 1000 ); };
52+ virtual void addChild (CCNode* Child, int zORDER, int tag) {
53+ CCMenu::addChild (Child, zORDER, tag);
54+ if (auto object = typeinfo_cast<CCMenuItemSpriteExtra*>(Child->getParent ()->getChildren ()->objectAtIndex (0 ))) {
55+ if (object == Child) {
56+ if (!object->getParent ()) {
57+ return ;
58+ };
59+
60+ if (menu == object->getParent ()) {
61+ return ;
62+ }
63+ if (!object->getParent ()->getParent ()) {
64+ return ;
65+ }
66+ auto cccccc = object->getParent ()->getParent ();
67+ if (!cccccc) {
68+ return ;
69+ }
70+ geode::Loader::get ()->queueInMainThread ([this ,cccccc,object] {
71+ CCNode* a111111 = nullptr ;
72+ for (auto items : CCArrayExt<CCNode*>(cccccc->getChildren ())) {
73+ if (items->getChildrenCount () == 2 ) {
74+ a111111 = items;
75+ break ;
76+ };
77+ }
78+ if (!a111111) {
79+ return ;
80+ }
81+ if (a111111->getChildrenCount () < 2 ) {
82+ return ;
83+ }
84+ cocos2d::CCNode* a22222 = typeinfo_cast<CCNode*>(a111111->getChildren ()->objectAtIndex (0 ));
85+ if (!a22222) {
86+ return ;
87+ }
88+ cocos2d::CCLabelBMFont* a333333 = getChildOfType<CCLabelBMFont>(a22222,0 );
89+ if (!a333333) {
90+ return ;
91+ }
92+ std::string id = a333333->getString ();
93+ if (id == " (ID: muhammadgames.bettermenu)" ) {
94+
95+ menu = typeinfo_cast<CCMenu*>(typeinfo_cast<CCNode*>(a22222->getChildren ()->objectAtIndex (7 ))->getChildren ()->objectAtIndex (1 ));
96+
97+ inityoutubeandsuch ();
98+ auto btn = CCSprite::createWithSpriteFrameName (" gj_ytIcon_001.png" );
99+ btn->setScale (0.7 );
100+ auto btnee = CCMenuItemSpriteExtra::create (btn, menu, menu_selector (YoutubeButton::Link));
101+ btnee->setPosition (typeinfo_cast<CCMenuItemSpriteExtra*>(menu->getChildren ()->objectAtIndex (0 ))->getPosition ());
102+ typeinfo_cast<CCMenuItemSpriteExtra*>(menu->getChildren ()->objectAtIndex (0 ))->removeFromParent ();
103+ menu->addChild (btnee);
104+ typeinfo_cast<CCMenuItemSpriteExtra*>(menu->getChildren ()->objectAtIndex (2 ))->removeFromParent ();
105+ } else { return ; }
106+ });
107+
108+ }
109+ }
110+ }
111+ }; // geode.loader/homepage.png
0 commit comments