1+ #include < Geode/Bindings.hpp>
2+ #include < Geode/modify/StarInfoPopup.hpp>
3+ #include < Geode/utils/NodeIDs.hpp>
4+
5+ using namespace geode ::prelude;
6+ using namespace geode ::node_ids;
7+
8+ struct StarInfoPopupIDs : Modify<StarInfoPopupIDs, StarInfoPopup> {
9+ struct Fields {
10+ int m_daily = 0 ;
11+ int m_gauntlet = 0 ;
12+ bool m_platformer = false ;
13+ };
14+
15+ static void onModify (auto & self) {
16+ if (!self.setHookPriority (" StarInfoPopup::init" , GEODE_ID_PRIORITY)) {
17+ log::warn (" Failed to set StarInfoPopup::init hook priority, node IDs may not work properly" );
18+ }
19+ }
20+
21+ bool init (int a, int b, int c, int d, int e, int f, int gauntlet, int daily, int unknown, bool platformer) {
22+ if (!StarInfoPopup::init (a,b,c,d,e,f,gauntlet,daily,unknown,platformer)) return false ;
23+
24+ m_fields->m_daily = daily;
25+ m_fields->m_gauntlet = gauntlet;
26+ m_fields->m_platformer = platformer;
27+
28+ NodeIDs::get ()->provide (this );
29+
30+ return true ;
31+ }
32+ };
33+
34+ $register_ids(StarInfoPopup) {
35+ m_mainLayer->setID (" main-layer" );
36+ m_buttonMenu->setID (" main-menu" );
37+ setIDSafe (m_buttonMenu, 0 , " ok-button" );
38+
39+ size_t idx = 0 ;
40+
41+ auto self = reinterpret_cast <StarInfoPopupIDs*>(this );
42+ auto mode = self->m_fields ->m_platformer ? " platformer" : " classic" ;
43+
44+ setIDs (m_mainLayer, idx,
45+ " background" ,
46+ " main-menu" ,
47+ fmt::format (" {}-title" , mode).c_str ()
48+ );
49+ idx += 3 ;
50+
51+ std::array<char const *, 6 > diffNames = {
52+ " auto" ,
53+ " easy" ,
54+ " normal" ,
55+ " hard" ,
56+ " harder" ,
57+ " insane"
58+ };
59+
60+ for (auto const & diff : diffNames) {
61+ setIDs (m_mainLayer, idx,
62+ fmt::format (" {}-sprite" , diff).c_str (),
63+ fmt::format (" {}-{}" , diff, mode).c_str ()
64+ );
65+ idx += 2 ;
66+ }
67+
68+ if (!self->m_fields ->m_platformer ) {
69+ if (self->m_fields ->m_gauntlet ) setIDSafe (m_mainLayer, idx++, " gauntlet-text" );
70+ if (self->m_fields ->m_daily ) setIDSafe (m_mainLayer, idx++, " daily-text" );
71+ }
72+
73+ auto winSize = CCDirector::sharedDirector ()->getWinSize ();
74+
75+ // bottom right menu
76+ auto bottomRight = CCMenu::create ();
77+ bottomRight->setPosition ((winSize.width / 2 + 190 ) - 12 , (winSize.height / 2 - 105 ) + 14 );
78+ bottomRight->setID (" bottom-right-menu" );
79+ bottomRight->setAnchorPoint ({1 , 0 });
80+ bottomRight->setZOrder (1 );
81+ bottomRight->setContentSize ({ 40 .f , 100 .f });
82+ bottomRight->setScale (.4f );
83+ bottomRight->setLayout (
84+ ColumnLayout::create ()
85+ ->setAxisAlignment (AxisAlignment::Start)
86+ ->setCrossAxisLineAlignment (AxisAlignment::End)
87+ ->setGap (14 .f )
88+ );
89+ m_mainLayer->addChild (bottomRight);
90+
91+ if (auto gauntlet = m_mainLayer->getChildByID (" gauntlet-text" )) switchToMenu (gauntlet, bottomRight);
92+ if (auto daily = m_mainLayer->getChildByID (" daily-text" )) switchToMenu (daily, bottomRight);
93+
94+ bottomRight->updateLayout ();
95+
96+ // identical menu on bottom left for mods to use
97+ auto bottomLeft = CCMenu::create ();
98+ bottomLeft->setPosition ((winSize.width / 2 - 190 ) + 12 , (winSize.height / 2 - 105 ) + 14 );
99+ bottomLeft->setID (" bottom-left-menu" );
100+ bottomLeft->setAnchorPoint ({0 , 0 });
101+ bottomLeft->setZOrder (1 );
102+ bottomLeft->setContentSize ({ 40 .f , 100 .f });
103+ bottomLeft->setScale (.4f );
104+ bottomLeft->setLayout (
105+ ColumnLayout::create ()
106+ ->setAxisAlignment (AxisAlignment::Start)
107+ ->setCrossAxisLineAlignment (AxisAlignment::Start)
108+ ->setGap (14 .f )
109+ );
110+ m_mainLayer->addChild (bottomLeft);
111+
112+ handleTouchPriority (this );
113+ }
0 commit comments