//
// GJGarageLayer::setupPage from 0x100304b8c to 0x100305104 (1400 bytes)
//
// 3 xrefs:
// > GJGarageLayer::onArrow @ 0x100304a9c
// > GJGarageLayer::selectTab @ 0x100304b70
// > GJGarageLayer::onNavigate @ 0x100305154
//
// 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 __fastcall GJGarageLayer::setupPage(GJGarageLayer *a1, int a2, IconType a3)
{
GameManager *v6; // x0
int active; // w22
GameManager *v8; // x0
int v9; // w21
cocos2d::CCDirector *v10; // x0
cocos2d::CCArray *Items; // x22
__n128 v12; // q0
__n128 v13; // q1
ListButtonBar *m_iconSelection; // x0
float v15; // s4
float v16; // s5
ListButtonBar *v17; // x0
CCMenuItemSpriteExtra *m_currentIcon; // x0
cocos2d::CCSprite *m_cursor1; // x22
cocos2d::CCNode *v20; // x23
const cocos2d::CCPoint *v21; // x0
void (*setEnabled)(void); // x8
int v23; // w24
cocos2d::CCSprite *v24; // x23
CCMenuItemSpriteExtra *v25; // x23
__int64 v26; // x0
unsigned int i; // w21
__int64 v28; // x22
__int64 v29; // x22
cocos2d::CCSpriteFrameCache *v30; // x0
const char *v31; // x1
cocos2d::CCSpriteFrame *v32; // x0
cocos2d::CCMenu *v33; // x20
__n128 v34; // q0
__n128 v35; // q1
GameManager *v36; // x0
bool GameVariable; // w21
__n128 v38; // q0
__n128 v39; // q1
ListButtonBar *v40; // x19
__int64 v41; // [xsp+20h] [xbp-90h] BYREF
cocos2d::CCPoint v42; // [xsp+28h] [xbp-88h] BYREF
void *__p[2]; // [xsp+30h] [xbp-80h] BYREF
char v44; // [xsp+47h] [xbp-69h]
__int64 v45; // [xsp+4Ch] [xbp-64h] BYREF
IconType v46; // [xsp+54h] [xbp-5Ch] BYREF
IconType *v47; // [xsp+58h] [xbp-58h] BYREF
cocos2d::CCPoint v48; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v49; // 0:x3.16
cocos2d::CCPoint v50; // 0:s0.4,4:s1.4
v46 = a3;
a1->m_iconType = a3;
((void (__fastcall *)(cocos2d::CCSprite *, bool))a1->m_cursor2->setVisible)(a1->m_cursor2, a3 == Special);
if ( a1->m_iconType == Special )
{
GJGarageLayer::setupSpecialPage(a1);
}
else
{
v6 = GameManager::sharedState();
active = GameManager::activeIconForType(v6, a3);
v8 = GameManager::sharedState();
v9 = GameManager::countForType(v8, a3);
if ( a2 == -1 )
a2 = (int)(float)((active - 1) / 36) & ~((int)(float)((active - 1) / 36) >> 31);
v47 = &v46;
*((_DWORD *)sub_1001A6048((__int64)&a1->m_iconPages, (int *)&v46, (__int64)&unk_100644D9D, (unsigned int **)&v47) + 8) = a2;
v10 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v10);
Items = GJGarageLayer::getItems(a1, v9, a2, v46, active);
m_iconSelection = a1->m_iconSelection;
if ( m_iconSelection )
{
((void (__fastcall *)(ListButtonBar *))m_iconSelection->removeMeAndCleanup)(m_iconSelection);
a1->m_iconSelection = nullptr;
}
v12.n128_f32[0] = *(float *)&v47 * 0.5;
v13.n128_f32[0] = (float)((float)(*((float *)&v47 + 1) * 0.5) + -5.0) + -60.0;
sub_100022980(v12, v13, &v45);
v50.x = 5.0;
v50.y = 5.0;
v17 = ListButtonBar::create(Items, v50, (int)&v45, 12, 25.0, 220.0, v15, v16, 3);
a1->m_iconSelection = v17;
BoomScrollLayer::togglePageIndicators(v17->m_scrollLayer, 0);
((void (__fastcall *)(GJGarageLayer *, ListButtonBar *, __int64))a1->addChild_0)(a1, a1->m_iconSelection, 100);
m_currentIcon = a1->m_currentIcon;
m_cursor1 = a1->m_cursor1;
if ( m_currentIcon )
{
v20 = (cocos2d::CCNode *)((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))m_currentIcon->getParent)(m_currentIcon);
v21 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))a1->m_currentIcon->getPosition)(a1->m_currentIcon);
v48 = cocos2d::CCNode::convertToWorldSpace(v20, v21);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *, float, float))m_cursor1->setPosition)(
m_cursor1,
&v45,
v48.x,
v48.y);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_cursor1->setVisible)(a1->m_cursor1, 1);
}
else
{
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))m_cursor1->setVisible)(a1->m_cursor1, 0);
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_leftArrow->setEnabled)(a1->m_leftArrow, v9 > 36);
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_leftArrow->setVisible)(a1->m_leftArrow, v9 > 36);
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_rightArrow->setEnabled)(a1->m_rightArrow, v9 > 36);
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_rightArrow->setVisible)(a1->m_rightArrow, v9 > 36);
setEnabled = (void (*)(void))a1->m_navDotMenu->setEnabled;
if ( v9 < 37 )
{
setEnabled();
((void (__fastcall *)(cocos2d::CCMenu *, _QWORD))a1->m_navDotMenu->setVisible)(a1->m_navDotMenu, 0);
}
else
{
setEnabled();
((void (__fastcall *)(cocos2d::CCMenu *, __int64))a1->m_navDotMenu->setVisible)(a1->m_navDotMenu, 1);
((void (__fastcall *)(cocos2d::CCMenu *))a1->m_navDotMenu->removeAllChildren)(a1->m_navDotMenu);
v23 = (int)(float)((float)(v9 / 0x24u) + 1.0);
while ( (unsigned int)sub_10024A36C((__int64)a1->m_pageButtons) < v23 )
{
v24 = cocos2d::CCSprite::createWithSpriteFrameName("gj_navDotBtn_on_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v24->setScale)(v24, 0.9);
v49.ptr = (void (__cdecl *)(cocos2d::CCObject *))GJGarageLayer::onNavigate;
v49.adj = 0;
v25 = CCMenuItemSpriteExtra::create(v24, nullptr, a1, v49);
v26 = sub_10024A36C((__int64)a1->m_pageButtons);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v25->setTag)(v25, v26);
sub_10024A2D0((__int64)a1->m_pageButtons);
CCMenuItemSpriteExtra::setSizeMult(v25, 1.1);
}
if ( v23 >= 1 )
{
for ( i = 0; i != v23; ++i )
{
v28 = sub_10024A388((__int64)a1->m_pageButtons, i);
((void (__fastcall *)(cocos2d::CCMenu *, __int64))a1->m_navDotMenu->addChild)(a1->m_navDotMenu, v28);
v29 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v28 + 1056LL))(v28);
v30 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
if ( a2 == i )
v31 = "gj_navDotBtn_on_001.png";
else
v31 = "gj_navDotBtn_off_001.png";
v32 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v30, v31);
(*(void (__fastcall **)(__int64, cocos2d::CCSpriteFrame *))(*(_QWORD *)v29 + 1144LL))(v29, v32);
}
}
cocos2d::CCMenu::alignItemsHorizontallyWithPadding(a1->m_navDotMenu, 6.0);
}
if ( v46 == DeathEffect )
{
v33 = cocos2d::CCMenu::create();
v34 = ((__n128 (__fastcall *)(ListButtonBar *, cocos2d::CCMenu *, __int64))a1->m_iconSelection->addChild_0)(
a1->m_iconSelection,
v33,
1);
v34.n128_u32[0] = 8.0;
v35.n128_u32[0] = 0;
sub_100022980(v34, v35, &v45);
sub_100009900(__p, "Explode");
v36 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v36, "0153");
v38.n128_f32[0] = (float)(*(float *)&v47 * 0.5) + -165.0;
v39.n128_f32[0] = (float)((float)((float)(*((float *)&v47 + 1) * 0.5) + -5.0) + -60.0) + -30.0;
sub_100022980(v38, v39, &v42);
v40 = a1->m_iconSelection;
sub_1000229B8(&v41, &v45);
GameToolbox::createToggleButton(
(const char *)__p,
(void (__cdecl *)(cocos2d::CCObject *))GJGarageLayer::onSpecial,
0,
!GameVariable,
v33,
&v42,
v40,
v40,
0.6,
0.5,
80.0,
(float *)&v41,
"goldFont.fnt",
0,
0,
0);
if ( v44 < 0 )
operator delete(__p[0]);
}
}
}