1+ #include < Geode/Geode.hpp>
2+ #include < Geode/modify/TutorialLayer.hpp>
3+ #include < Geode/utils/NodeIDs.hpp>
4+
5+ using namespace geode ::prelude;
6+ using namespace geode ::node_ids;
7+
8+ $register_ids(TutorialLayer) {
9+ if (auto tutorialLayer = setIDSafe<CCLayer>(this , 0 , " main-layer" )) {
10+ setIDSafe<CCScale9Sprite>(tutorialLayer, 0 , " background" );
11+ if (auto tutorialDetails = setIDSafe<CCLayer>(tutorialLayer, 0 , " tutorial-layer" )) {
12+ setIDSafe<CCSprite>(tutorialDetails, 0 , " tutorial-image-01" );
13+ setIDSafe<TextArea>(tutorialDetails, 0 , " tutorial-text-01" );
14+ }
15+
16+ if (auto tutorialMenu = setIDSafe<CCMenu>(tutorialLayer, 0 , " tutorial-menu" )) {
17+ setIDs (
18+ tutorialMenu,
19+ 0 ,
20+ " close-button" ,
21+ " next-button" ,
22+ " exit-button"
23+ );
24+ };
25+ setIDSafe<CCLabelBMFont>(tutorialLayer, 0 , " tutorial-title-label" );
26+ }
27+ }
28+
29+ struct TutorialLayerIDs : Modify<TutorialLayerIDs, TutorialLayer> {
30+ static void onModify (auto & self) {
31+ if (!self.setHookPriority (" TutorialLayer::init" , GEODE_ID_PRIORITY)) {
32+ log::warn (" Failed to set TutorialLayer::init hook priority, node IDs may not work properly" );
33+ }
34+
35+ if (!self.setHookPriority (" TutorialLayer::loadPage" , GEODE_ID_PRIORITY)) {
36+ log::warn (" Failed to set TutorialLayer::loadPage hook priority, node IDs may not work properly" );
37+ }
38+ }
39+
40+ bool init () {
41+ if (!TutorialLayer::init ()) return false ;
42+ NodeIDs::get ()->provide (this );
43+ return true ;
44+ }
45+
46+ void loadPage (int page) {
47+ TutorialLayer::loadPage (page);
48+
49+ if (auto spr = m_tutorialLayer->getChildByType <CCSprite>(0 )) {
50+ spr->setID (fmt::format (" tutorial-image-{:02}" , this ->m_page ));
51+ }
52+
53+ if (auto txtArea= m_tutorialLayer->getChildByType <TextArea>(0 )) {
54+ txtArea->setID (fmt::format (" tutorial-text-{:02}" , this ->m_page ));
55+ }
56+ }
57+ };
0 commit comments