//
// GJGarageLayer::setupPage from 0x140276090 to 0x140276721 (1681 bytes)
//
// 4 xrefs:
// > GJGarageLayer::onArrow @ 0x140275f65
// > GJGarageLayer::onNavigate @ 0x140275f93
// > GJGarageLayer::selectTab @ 0x140276078
// > ??> @ 0x1406d0f74
//
// 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
//
// Hidden C++ exception states: #wind=5
void GJGarageLayer::setupPage(GJGarageLayer *a1, int a2, IconType a3)
{
float v3; // xmm0_4
int v4; // r12d
GameManager *v6; // rcx
GameManager *v7; // rcx
int active; // ebx
IconType v9; // r9d
int v10; // r14d
__int64 v11; // rcx
cocos2d::CCDirector *v12; // rax
cocos2d::CCArray *Items; // rbx
ListButtonBar *m_iconSelection; // rcx
cocos2d::CCPoint v15; // rax
ListButtonBar *v16; // rax
bool v17; // dl
CCMenuItemSpriteExtra *m_currentIcon; // rdx
cocos2d::CCSprite_vtbl *v19; // r15
CCMenuItemSpriteExtra *v20; // rdi
cocos2d::CCNode *v21; // rax
struct cocos2d::CCPoint v22; // rax
_BOOL8 v23; // rdx
_BOOL8 v24; // rdx
cocos2d::CCMenu *m_navDotMenu; // rcx
cocos2d::CCMenu_vtbl *v26; // r8
_BOOL8 v27; // rdx
unsigned int v28; // r15d
struct cocos2d::CCSprite *v29; // rbx
CCMenuItemSpriteExtra *v30; // rax
cocos2d::CCObject *v31; // rdi
cocos2d::CCObject_vtbl *v32; // rbx
unsigned int v33; // eax
signed int i; // edi
cocos2d::CCNode *v35; // rbx
__int64 *v36; // r14
__int64 v37; // rbx
__int64 v38; // rcx
cocos2d::CCSpriteFrameCache *v39; // rcx
const char *v40; // rdx
struct cocos2d::CCSpriteFrame *v41; // rax
__int64 v42; // rcx
cocos2d::CCNode *v43; // r15
float v44; // xmm0_4
GameManager *v45; // r14
ListButtonBar *v46; // rsi
double v47; // xmm0_8
float *v48; // rax
float *v49; // rdi
struct cocos2d::CCPoint v50; // rax
struct cocos2d::CCPoint v51; // rbx
bool GameVariable; // al
int v53; // [rsp+48h] [rbp-89h]
void *v54; // [rsp+90h] [rbp-41h]
cocos2d::CCPoint v55; // [rsp+98h] [rbp-39h] BYREF
char v56[8]; // [rsp+A8h] [rbp-29h] BYREF
__int64 v57; // [rsp+B0h] [rbp-21h]
__int64 v58; // [rsp+B8h] [rbp-19h]
__int64 v59; // [rsp+C0h] [rbp-11h]
float v60; // [rsp+138h] [rbp+67h]
IconType v61; // [rsp+148h] [rbp+77h] BYREF
CCMenuItemSpriteExtra *v62; // [rsp+150h] [rbp+7Fh] BYREF
v61 = a3;
v4 = a2;
a1->m_iconType = a3;
LOBYTE(a2) = a3 == Special;
a1->m_cursor2->setVisible(a1->m_cursor2, a2);
if ( a1->m_iconType == Special )
{
GJGarageLayer::setupSpecialPage(a1);
return;
}
v6 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v62 = (CCMenuItemSpriteExtra *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v62);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v6 = (GameManager *)qword_1406C2ED8;
}
active = GameManager::activeIconForType(v6, v61);
if ( !v7 )
{
v62 = (CCMenuItemSpriteExtra *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v62);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v9 = v61;
}
v10 = GameManager::countForType(v7, v9);
if ( v4 == -1 )
{
v3 = floorf((float)((active - 1) / 36));
v4 = 0;
if ( (int)v3 > 0 )
v4 = (int)v3;
}
*(_DWORD *)sub_14012CE70((__int64 *)&a1->m_iconPages, (int *)&v61) = v4;
v12 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v11);
cocos2d::CCDirector::getWinSize(v12);
Items = GJGarageLayer::getItems(a1, v10, v4, v61, active);
m_iconSelection = a1->m_iconSelection;
if ( m_iconSelection )
{
m_iconSelection->removeMeAndCleanup(m_iconSelection);
a1->m_iconSelection = nullptr;
}
cocos2d::CCPoint::CCPoint(v3, v60 * 0.5);
v16 = ListButtonBar::create(Items, v15, 12, 3, 5.0, 5.0, 25.0, 220.0, v53);
a1->m_iconSelection = v16;
BoomScrollLayer::togglePageIndicators(v16->m_scrollLayer, v17);
a1->addChild_0(a1, a1->m_iconSelection, 100);
m_currentIcon = a1->m_currentIcon;
v19 = a1->m_cursor1->__vftable;
if ( m_currentIcon )
{
v20 = a1->m_currentIcon;
m_currentIcon->getPosition_0(v20);
v21 = v20->getParent(v20);
v22 = cocos2d::CCNode::convertToWorldSpace(v21, (const struct cocos2d::CCPoint *)&v62);
((void (__fastcall *)(cocos2d::CCSprite *, struct cocos2d::CCPoint))v19->setPosition_0)(a1->m_cursor1, v22);
LOBYTE(v23) = 1;
a1->m_cursor1->setVisible(a1->m_cursor1, v23);
}
else
{
((void (*)(void))v19->setVisible)();
}
a1->m_leftArrow->setEnabled(a1->m_leftArrow, v10 > 36);
a1->m_leftArrow->setVisible(a1->m_leftArrow, v10 > 36);
a1->m_rightArrow->setEnabled(a1->m_rightArrow, v10 > 36);
a1->m_rightArrow->setVisible(a1->m_rightArrow, v10 > 36);
m_navDotMenu = a1->m_navDotMenu;
v26 = m_navDotMenu->cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( v10 <= 36 )
{
v26->setEnabled(m_navDotMenu, 0);
a1->m_navDotMenu->setVisible(a1->m_navDotMenu, 0);
}
else
{
LOBYTE(v24) = 1;
v26->setEnabled(m_navDotMenu, v24);
LOBYTE(v27) = 1;
a1->m_navDotMenu->setVisible(a1->m_navDotMenu, v27);
a1->m_navDotMenu->removeAllChildren(a1->m_navDotMenu);
v28 = (int)(float)(floorf((float)(v10 / 36)) + 1.0);
if ( v28 > cocos2d::CCArray::count(a1->m_pageButtons) )
{
while ( 1 )
{
v29 = cocos2d::CCSprite::createWithSpriteFrameName("gj_navDotBtn_on_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v29->setScale_0)(v29);
v62 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v30 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v62);
v31 = v30;
if ( !v30 )
goto LABEL_21;
if ( !CCMenuItemSpriteExtra::init(v30, v29, nullptr, a1, (cocos2d::SEL_MenuHandler *)GJGarageLayer::onNavigate) )
break;
cocos2d::CCObject::autorelease(v31);
LABEL_22:
v32 = v31->__vftable;
v33 = cocos2d::CCArray::count(a1->m_pageButtons);
v32->setTag(v31, v33);
cocos2d::CCArray::addObject(a1->m_pageButtons, v31);
v31[6].m_uUnknown = 1066192077;
if ( v28 <= cocos2d::CCArray::count(a1->m_pageButtons) )
goto LABEL_23;
}
((void (__fastcall *)(cocos2d::CCObject *, __int64))v31->~CCObject)(v31, 1);
LABEL_21:
v31 = nullptr;
goto LABEL_22;
}
LABEL_23:
for ( i = 0; i < (int)v28; ++i )
{
v35 = (cocos2d::CCNode *)cocos2d::CCArray::objectAtIndex(a1->m_pageButtons, i);
a1->m_navDotMenu->addChild_1(a1->m_navDotMenu, v35);
v36 = (__int64 *)((__int64 (__fastcall *)(cocos2d::CCNode *))v35->__vftable[1].setTag)(v35);
v37 = *v36;
v39 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v38);
v40 = "gj_navDotBtn_on_001.png";
if ( i != v4 )
v40 = "gj_navDotBtn_off_001.png";
v41 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v39, v40);
(*(void (__fastcall **)(__int64 *, struct cocos2d::CCSpriteFrame *))(v37 + 992))(v36, v41);
}
cocos2d::CCMenu::alignItemsHorizontallyWithPadding(a1->m_navDotMenu, 6.0);
}
if ( v61 == DeathEffect )
{
v43 = (cocos2d::CCNode *)cocos2d::CCMenu::create(v42);
v44 = ((float (__fastcall *)(ListButtonBar *, cocos2d::CCNode *, __int64))a1->m_iconSelection->addChild_0)(
a1->m_iconSelection,
v43,
1);
cocos2d::CCPoint::CCPoint(v44, 8.0);
v57 = 0;
v58 = 7;
v59 = 15;
strcpy(v56, "Explode");
v45 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v54 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v45 = (GameManager *)qword_1406C2ED8;
}
v46 = a1->m_iconSelection;
v47 = cocos2d::CCPoint::CCPoint(&v55);
v49 = v48;
cocos2d::CCPoint::CCPoint(*(float *)&v47, (float)(v60 * 0.5) - 165.0);
v51 = v50;
GameVariable = GameManager::getGameVariable(v45, "0153");
GameToolbox::createToggleButton(
v56,
(cocos2d::SEL_MenuHandler *)GJGarageLayer::onSpecial,
!GameVariable,
v43,
v51,
v46,
v46,
0.60000002,
0.5,
80.0,
v49,
"goldFont.fnt",
0,
0,
nullptr);
}
}