Skip to content

Commit f63332f

Browse files
committed
dont use getChildBySpriteFrameName reimplementation in PauseLayer
1 parent e0d4a04 commit f63332f

File tree

2 files changed

+11
-38
lines changed

2 files changed

+11
-38
lines changed

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "4.0.1",
2+
"geode": "4.1.2",
33
"gd": {
44
"win": "2.2074",
55
"android": "2.2074",

src/PauseLayer.cpp

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,6 @@
88
using namespace geode::prelude;
99
using namespace geode::node_ids;
1010

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-
3811
$register_ids(PauseLayer) {
3912
int idx = 0;
4013
setIDs(
@@ -83,7 +56,7 @@ inline CCNode* getChildBySpriteFrameName(CCNode* parent, const char* name) {
8356
setIDSafe(this, idx, "center-button-menu");
8457
idx += 1;
8558

86-
if(auto practiceTxt = ::getChildBySpriteFrameName(this, "GJ_practiceTxt_001.png")) {
59+
if(auto practiceTxt = getChildBySpriteFrameName(this, "GJ_practiceTxt_001.png")) {
8760
practiceTxt->setID("practice-arrow-text");
8861
idx += 1;
8962
}
@@ -154,47 +127,47 @@ inline CCNode* getChildBySpriteFrameName(CCNode* parent, const char* name) {
154127
if (auto menu = this->getChildByID("center-button-menu")) {
155128

156129
int idx = 0;
157-
if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_editBtn_001.png")) {
130+
if (auto* node = getChildBySpriteFrameName(menu, "GJ_editBtn_001.png")) {
158131
node->setID("edit-button");
159132
++idx;
160133
}
161134

162-
if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_replayFullBtn_001.png")) {
135+
if (auto* node = getChildBySpriteFrameName(menu, "GJ_replayFullBtn_001.png")) {
163136
node->setID("full-restart-button");
164137
++idx;
165138
}
166139

167-
if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_menuBtn_001.png")) {
140+
if (auto* node = getChildBySpriteFrameName(menu, "GJ_menuBtn_001.png")) {
168141
node->setID("exit-button");
169142
++idx;
170143
}
171144

172-
if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_menuBtn_001.png")) {
145+
if (auto* node = getChildBySpriteFrameName(menu, "GJ_menuBtn_001.png")) {
173146
node->setID("exit-button");
174147
++idx;
175148
}
176149

177-
if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_normalBtn_001.png")) {
150+
if (auto* node = getChildBySpriteFrameName(menu, "GJ_normalBtn_001.png")) {
178151
node->setID("practice-button");
179152
++idx;
180153
}
181154

182-
if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_practiceBtn_001.png")) {
155+
if (auto* node = getChildBySpriteFrameName(menu, "GJ_practiceBtn_001.png")) {
183156
node->setID("practice-button");
184157
++idx;
185158
}
186159

187-
if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_playBtn2_001.png")) {
160+
if (auto* node = getChildBySpriteFrameName(menu, "GJ_playBtn2_001.png")) {
188161
node->setID("play-button");
189162
++idx;
190163
}
191164

192-
if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_replayBtn_001.png")) {
165+
if (auto* node = getChildBySpriteFrameName(menu, "GJ_replayBtn_001.png")) {
193166
node->setID("retry-button");
194167
++idx;
195168
}
196169

197-
if (auto* node = ::getChildBySpriteFrameName(menu, "GJ_optionsBtn_001.png")) {
170+
if (auto* node = getChildBySpriteFrameName(menu, "GJ_optionsBtn_001.png")) {
198171
node->setID("options-button");
199172
node->removeFromParentAndCleanup(false);
200173
rightMenu->addChild(node);

0 commit comments

Comments
 (0)