|
8 | 8 | using namespace geode::prelude; |
9 | 9 | using namespace geode::node_ids; |
10 | 10 |
|
11 | | -// this code sux but oh well |
12 | | -// maybe it should be in geode utils |
13 | | -inline CCNode* getChildBySpriteFrameName(CCNode* parent, const char* name) { |
14 | | - auto cache = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name); |
15 | | - if (!cache) return nullptr; |
16 | | - |
17 | | - auto* texture = cache->getTexture(); |
18 | | - auto rect = cache->getRect(); |
19 | | - |
20 | | - for (int i = 0; i < parent->getChildrenCount(); ++i) { |
21 | | - auto* child = parent->getChildren()->objectAtIndex(i); |
22 | | - if (auto* spr = typeinfo_cast<CCSprite*>(child)) { |
23 | | - if (spr->getTexture() == texture && spr->getTextureRect() == rect) { |
24 | | - return spr; |
25 | | - } |
26 | | - } else if (auto* btn = typeinfo_cast<CCMenuItemSprite*>(child)) { |
27 | | - auto* img = btn->getNormalImage(); |
28 | | - if (auto* spr = typeinfo_cast<CCSprite*>(img)) { |
29 | | - if (spr->getTexture() == texture && spr->getTextureRect() == rect) { |
30 | | - return btn; |
31 | | - } |
32 | | - } |
33 | | - } |
34 | | - } |
35 | | - return nullptr; |
36 | | -} |
37 | | - |
38 | 11 | $register_ids(PauseLayer) { |
39 | 12 | int idx = 0; |
40 | 13 | setIDs( |
@@ -83,7 +56,7 @@ inline CCNode* getChildBySpriteFrameName(CCNode* parent, const char* name) { |
83 | 56 | setIDSafe(this, idx, "center-button-menu"); |
84 | 57 | idx += 1; |
85 | 58 |
|
86 | | - if(auto practiceTxt = ::getChildBySpriteFrameName(this, "GJ_practiceTxt_001.png")) { |
| 59 | + if(auto practiceTxt = getChildBySpriteFrameName(this, "GJ_practiceTxt_001.png")) { |
87 | 60 | practiceTxt->setID("practice-arrow-text"); |
88 | 61 | idx += 1; |
89 | 62 | } |
@@ -154,47 +127,47 @@ inline CCNode* getChildBySpriteFrameName(CCNode* parent, const char* name) { |
154 | 127 | if (auto menu = this->getChildByID("center-button-menu")) { |
155 | 128 |
|
156 | 129 | int idx = 0; |
157 | | - if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_editBtn_001.png")) { |
| 130 | + if (auto* node = getChildBySpriteFrameName(menu, "GJ_editBtn_001.png")) { |
158 | 131 | node->setID("edit-button"); |
159 | 132 | ++idx; |
160 | 133 | } |
161 | 134 |
|
162 | | - if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_replayFullBtn_001.png")) { |
| 135 | + if (auto* node = getChildBySpriteFrameName(menu, "GJ_replayFullBtn_001.png")) { |
163 | 136 | node->setID("full-restart-button"); |
164 | 137 | ++idx; |
165 | 138 | } |
166 | 139 |
|
167 | | - if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_menuBtn_001.png")) { |
| 140 | + if (auto* node = getChildBySpriteFrameName(menu, "GJ_menuBtn_001.png")) { |
168 | 141 | node->setID("exit-button"); |
169 | 142 | ++idx; |
170 | 143 | } |
171 | 144 |
|
172 | | - if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_menuBtn_001.png")) { |
| 145 | + if (auto* node = getChildBySpriteFrameName(menu, "GJ_menuBtn_001.png")) { |
173 | 146 | node->setID("exit-button"); |
174 | 147 | ++idx; |
175 | 148 | } |
176 | 149 |
|
177 | | - if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_normalBtn_001.png")) { |
| 150 | + if (auto* node = getChildBySpriteFrameName(menu, "GJ_normalBtn_001.png")) { |
178 | 151 | node->setID("practice-button"); |
179 | 152 | ++idx; |
180 | 153 | } |
181 | 154 |
|
182 | | - if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_practiceBtn_001.png")) { |
| 155 | + if (auto* node = getChildBySpriteFrameName(menu, "GJ_practiceBtn_001.png")) { |
183 | 156 | node->setID("practice-button"); |
184 | 157 | ++idx; |
185 | 158 | } |
186 | 159 |
|
187 | | - if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_playBtn2_001.png")) { |
| 160 | + if (auto* node = getChildBySpriteFrameName(menu, "GJ_playBtn2_001.png")) { |
188 | 161 | node->setID("play-button"); |
189 | 162 | ++idx; |
190 | 163 | } |
191 | 164 |
|
192 | | - if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_replayBtn_001.png")) { |
| 165 | + if (auto* node = getChildBySpriteFrameName(menu, "GJ_replayBtn_001.png")) { |
193 | 166 | node->setID("retry-button"); |
194 | 167 | ++idx; |
195 | 168 | } |
196 | 169 |
|
197 | | - if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_optionsBtn_001.png")) { |
| 170 | + if (auto* node = getChildBySpriteFrameName(menu, "GJ_optionsBtn_001.png")) { |
198 | 171 | node->setID("options-button"); |
199 | 172 | node->removeFromParentAndCleanup(false); |
200 | 173 | rightMenu->addChild(node); |
|
0 commit comments