//
// GJGarageLayer::setupPage from 0x406148 to 0x40654e (1030 bytes)
//
// 3 xrefs:
// > GJGarageLayer::onArrow @ 0x4065f8
// > GJGarageLayer::onNavigate @ 0x406614
// > GJGarageLayer::selectTab @ 0x406676
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void GJGarageLayer::setupPage(GJGarageLayer *a1, int a2, IconType a3)
{
cocos2d::CCSprite *m_cursor2; // r0
cocos2d::CCSprite_vtbl *v6; // r3
GameManager *v7; // r0
int active; // r4
GameManager *v9; // r0
int v10; // r2
int v11; // r8
float v12; // r0
cocos2d::CCDirector *v13; // r0
cocos2d::CCArray *Items; // r5
ListButtonBar *m_iconSelection; // r0
cocos2d::CCPoint v16; // r1
ListButtonBar *v17; // r0
cocos2d::CCSprite *m_cursor1; // r5
CCMenuItemSpriteExtra *m_currentIcon; // r1
cocos2d::CCSprite_vtbl *v20; // r3
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCNode *v22; // r11
const cocos2d::CCPoint *v23; // r0
void (*setEnabled)(void); // r3
int v25; // s19
cocos2d::CCSprite *v26; // r8
CCMenuItemSpriteExtra *v27; // r8
void (__fastcall *setTag)(cocos2d::CCObject *__hidden, int); // r5
int v29; // r0
signed int i; // r8
cocos2d::CCNode *v31; // r11
int v32; // r11
void (__fastcall *v33)(int, cocos2d::CCSpriteFrame *); // r5
cocos2d::CCSpriteFrameCache *v34; // r0
const char *v35; // r1
cocos2d::CCSpriteFrame *v36; // r0
cocos2d::CCMenu *v37; // r10
GameManager *v38; // r0
bool v39; // r6
ListButtonBar *v40; // r8
int v41; // [sp+14h] [bp-68h]
IconType v42[2]; // [sp+34h] [bp-48h] BYREF
char v43[4]; // [sp+40h] [bp-3Ch] BYREF
cocos2d::CCSize v44; // [sp+44h] [bp-38h] BYREF
cocos2d::CCPoint v45; // [sp+4Ch] [bp-30h] BYREF
cocos2d::CCPoint v46; // [sp+54h] [bp-28h] BYREF
cocos2d::CCPoint v47; // [sp+5Ch] [bp-20h] BYREF
void (*v48)(GJGarageLayer *, cocos2d::CCObject *); // [sp+64h] [bp-18h]
int v49; // [sp+68h] [bp-14h]
cocos2d::CCPoint v50; // [sp+6Ch] [bp-10h] BYREF
a1->m_iconType = a3;
m_cursor2 = a1->m_cursor2;
v6 = m_cursor2->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v42[0] = a3;
v6->setVisible(m_cursor2, a3 == Special);
if ( a1->m_iconType == Special )
{
GJGarageLayer::setupSpecialPage(a1);
}
else
{
v7 = GameManager::sharedState();
active = GameManager::activeIconForType(v7, v42[0]);
v9 = GameManager::sharedState();
v11 = GameManager::countForType(v9, v42[0]);
if ( a2 == -1 )
{
v12 = floorf((float)((active - 1) / 36));
a2 = (int)v12 & ~((int)v12 >> 31);
}
*(_DWORD *)std::map::operator[](&a1->m_iconPages.compare.pad, v42, v10) = a2;
v13 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v44, v13);
Items = GJGarageLayer::getItems((unsigned int)a1, v11, a2, v42[0], active);
m_iconSelection = a1->m_iconSelection;
if ( m_iconSelection )
{
m_iconSelection->removeMeAndCleanup(m_iconSelection);
a1->m_iconSelection = nullptr;
}
cocos2d::CCPoint::CCPoint(&v50, v44.width * 0.5, (float)((float)(v44.height * 0.5) - 5.0) - 60.0);
LODWORD(v16.y) = 12;
LODWORD(v16.x) = &v50;
v17 = ListButtonBar::create(Items, v16, 3, COERCE_INT(5.0), 5.0, 25.0, 220.0, COERCE_FLOAT(1), v41);
a1->m_iconSelection = v17;
BoomScrollLayer::togglePageIndicators(v17->m_scrollLayer, 0);
a1->addChild_0(a1, a1->m_iconSelection, 100);
m_cursor1 = a1->m_cursor1;
m_currentIcon = a1->m_currentIcon;
v20 = m_cursor1->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( m_currentIcon )
{
setPosition = v20->setPosition;
v22 = m_currentIcon->getParent(a1->m_currentIcon);
v23 = a1->m_currentIcon->getPosition(a1->m_currentIcon);
cocos2d::CCNode::convertToWorldSpace(&v50, v22, v23);
setPosition(m_cursor1, &v50);
a1->m_cursor1->setVisible(a1->m_cursor1, 1);
}
else
{
v20->setVisible(a1->m_cursor1, 0);
}
a1->m_leftArrow->setEnabled(a1->m_leftArrow, v11 > 36);
a1->m_leftArrow->setVisible(a1->m_leftArrow, v11 > 36);
a1->m_rightArrow->setEnabled(a1->m_rightArrow, v11 > 36);
a1->m_rightArrow->setVisible(a1->m_rightArrow, v11 > 36);
setEnabled = (void (*)(void))a1->m_navDotMenu->setEnabled;
if ( v11 <= 36 )
{
setEnabled();
a1->m_navDotMenu->setVisible(a1->m_navDotMenu, v11 > 36);
}
else
{
setEnabled();
a1->m_navDotMenu->setVisible(a1->m_navDotMenu, 1);
a1->m_navDotMenu->removeAllChildren(a1->m_navDotMenu);
v25 = (int)(float)(floorf((float)(v11 / 36)) + 1.0);
while ( (unsigned int)v25 > cocos2d::CCArray::count(a1->m_pageButtons) )
{
v26 = cocos2d::CCSprite::createWithSpriteFrameName("gj_navDotBtn_on_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, int))v26->setScale)(v26, 1063675494);
v49 = 0;
v48 = GJGarageLayer::onNavigate;
v27 = CCMenuItemSpriteExtra::create(
v26,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(GJGarageLayer::onNavigate, (unsigned int)a1));
setTag = v27->setTag;
v29 = cocos2d::CCArray::count(a1->m_pageButtons);
setTag(v27, v29);
cocos2d::CCArray::addObject(a1->m_pageButtons, v27);
CCMenuItemSpriteExtra::setSizeMult(v27, 1.1);
}
for ( i = 0; i < v25; ++i )
{
v31 = (cocos2d::CCNode *)cocos2d::CCArray::objectAtIndex(a1->m_pageButtons, i);
a1->m_navDotMenu->addChild(a1->m_navDotMenu, v31);
v32 = ((int (__fastcall *)(cocos2d::CCNode *))v31->__vftable[1].setScale_0)(v31);
v33 = *(void (__fastcall **)(int, cocos2d::CCSpriteFrame *))(*(_DWORD *)v32 + 572);
v34 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
if ( i == a2 )
v35 = "gj_navDotBtn_on_001.png";
else
v35 = "gj_navDotBtn_off_001.png";
v36 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v34, v35);
v33(v32, v36);
}
cocos2d::CCMenu::alignItemsHorizontallyWithPadding(a1->m_navDotMenu, 6.0);
}
if ( v42[0] == DeathEffect )
{
v37 = cocos2d::CCMenu::create();
a1->m_iconSelection->addChild_0(a1->m_iconSelection, v37, 1);
cocos2d::CCPoint::CCPoint(&v45, 8.0, 0.0);
sub_776584((int)v43, "Explode");
LODWORD(v50.x) = GJGarageLayer::onSpecial;
v50.y = 0.0;
v38 = GameManager::sharedState();
v39 = !GameManager::getGameVariable(v38, "0153");
cocos2d::CCPoint::CCPoint(
&v46,
(float)(v44.width * 0.5) - 165.0,
(float)((float)((float)(v44.height * 0.5) - 5.0) - 60.0) - 30.0);
v40 = a1->m_iconSelection;
cocos2d::CCPoint::CCPoint(&v47, &v45);
GameToolbox::createToggleButton(
(int)v43,
LODWORD(v50.x),
LODWORD(v50.y),
v39,
v37,
&v46,
v40,
v40,
0.6,
0.5,
80.0,
(int)&v47,
(int)"goldFont.fnt",
0,
0,
nullptr);
sub_774008(v43);
}
}
}