//
// GJGarageLayer::setupPage from 0x10036cd40 to 0x10036d374 (1588 bytes)
//
// 3 xrefs:
// > GJGarageLayer::onArrow @ 0x10036cbf9
// > GJGarageLayer::selectTab @ 0x10036cd2d
// > GJGarageLayer::onNavigate @ 0x10036d3b3
//
// 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)
{
IconType v3; // r15d
int v4; // r14d
GameManager *v6; // rax
__int64 active; // r12
GameManager *v8; // rax
int v9; // r13d
std::__tree_end_node *>::pointer left; // rax
std::__compressed_pair *>> *p_pair1; // r14
std::__compressed_pair *>> *v12; // r12
IconType v13; // r13d
std::__compressed_pair *>> *v14; // r15
std::__tree_end_node *> *v15; // rax
int v16; // r14d
cocos2d::CCArray *Items; // r12
ListButtonBar *m_iconSelection; // rdi
float v19; // xmm4_4
ListButtonBar *v20; // rax
cocos2d::CCSprite *m_cursor1; // r12
CCMenuItemSpriteExtra *m_currentIcon; // rdi
const cocos2d::CCPoint *v23; // r13
cocos2d::CCSprite *v24; // rdi
cocos2d::CCSprite_vtbl *v25; // rax
__int64 v26; // rsi
int v27; // r14d
_BOOL8 v28; // r12
cocos2d::CCMenu *m_navDotMenu; // rdi
void (__cdecl *setEnabled)(cocos2d::CCMenu *__hidden, bool); // rax
int v31; // r14d
cocos2d::CCSprite *v32; // r15
CCMenuItemSpriteExtra *v33; // r15
unsigned int v34; // eax
int v35; // r13d
unsigned int i; // r12d
__int64 v37; // r15
__int64 v38; // r15
cocos2d::CCSpriteFrameCache *v39; // rax
const char *v40; // rsi
cocos2d::CCSpriteFrame *v41; // rax
cocos2d::CCMenu *v42; // r14
GameManager *v43; // rax
bool GameVariable; // r15
ListButtonBar *v45; // r12
__int64 v46; // [rsp+38h] [rbp-78h] BYREF
float v47; // [rsp+40h] [rbp-70h] BYREF
__int64 v48; // [rsp+48h] [rbp-68h]
char v49; // [rsp+50h] [rbp-60h] BYREF
char v50[15]; // [rsp+51h] [rbp-5Fh] BYREF
void *__p; // [rsp+60h] [rbp-50h]
double v52; // [rsp+6Ch] [rbp-44h] BYREF
float v53; // [rsp+74h] [rbp-3Ch] BYREF
float v54; // [rsp+78h] [rbp-38h]
int v55; // [rsp+7Ch] [rbp-34h]
IconType v56; // [rsp+80h] [rbp-30h]
int v57; // [rsp+84h] [rbp-2Ch]
double v58; // 0:xmm0_8.8
double v59; // 0:xmm0_8.8
v3 = a3;
v4 = a2;
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);
return;
}
v6 = GameManager::sharedState();
active = (unsigned int)GameManager::activeIconForType(v6, v3);
v8 = GameManager::sharedState();
v9 = GameManager::countForType(v8, v3);
if ( a2 == -1 )
{
v4 = 0;
if ( (int)(float)(((int)active - 1) / 36) > 0 )
v4 = (int)(float)(((int)active - 1) / 36);
}
v48 = active;
v57 = v4;
left = a1->m_iconPages.__tree_.__pair1_.__value_.__left_;
v56 = v3;
v55 = v9;
if ( left )
{
while ( 1 )
{
while ( 1 )
{
v12 = (std::__compressed_pair *>> *)left;
if ( *((_DWORD *)left + 7) <= v3 )
break;
left = *(std::__tree_end_node *>::pointer *)left;
p_pair1 = v12;
if ( !v12->__value_.__left_ )
goto LABEL_13;
}
if ( *((_DWORD *)left + 7) >= v3 )
break;
left = *((std::__tree_end_node *>::pointer *)left + 1);
if ( !left )
{
p_pair1 = v12 + 1;
goto LABEL_13;
}
}
v16 = v57;
}
else
{
p_pair1 = &a1->m_iconPages.__tree_.__pair1_;
v12 = &a1->m_iconPages.__tree_.__pair1_;
LABEL_13:
v13 = v3;
v14 = v12;
v12 = (std::__compressed_pair *>> *)operator new(0x28u);
HIDWORD(v12[3].__value_.__left_) = v13;
LODWORD(v12[4].__value_.__left_) = 0;
*(_OWORD *)&v12->__value_.__left_ = 0;
v12[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v14;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v12;
v15 = (std::__tree_end_node *> *)a1->m_iconPages.__tree_.__begin_node_->__left_;
if ( v15 )
a1->m_iconPages.__tree_.__begin_node_ = v15;
sub_100054DD0((__int64 *)a1->m_iconPages.__tree_.__pair1_.__value_.__left_, (__int64 *)v12);
++a1->m_iconPages.__tree_.__pair3_.__value_;
v3 = v56;
v16 = v57;
v9 = v55;
}
LODWORD(v12[4].__value_.__left_) = v16;
cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v58 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v53);
Items = GJGarageLayer::getItems(a1, v9, v16, v3, v48);
m_iconSelection = a1->m_iconSelection;
if ( m_iconSelection )
{
((void (__fastcall *)(ListButtonBar *, double))m_iconSelection->removeMeAndCleanup)(m_iconSelection, v58);
a1->m_iconSelection = nullptr;
}
sub_10028CBE0((float *)&v52, v53 * 0.5, (float)((float)(v54 * 0.5) + -5.0) + -60.0);
v20 = ListButtonBar::create(Items, (cocos2d::CCPoint)1084227584LL, (int)&v52, 12, 5.0, 25.0, 220.0, v19, 3);
a1->m_iconSelection = v20;
BoomScrollLayer::togglePageIndicators(v20->m_scrollLayer, 0);
((void (__fastcall *)(GJGarageLayer *, ListButtonBar *, __int64))a1->addChild_0)(a1, a1->m_iconSelection, 100);
m_cursor1 = a1->m_cursor1;
m_currentIcon = a1->m_currentIcon;
if ( m_currentIcon )
{
v23 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))m_currentIcon->getParent)(m_currentIcon);
((void (__fastcall *)(CCMenuItemSpriteExtra *))a1->m_currentIcon->getPosition)(a1->m_currentIcon);
*(cocos2d::CCPoint *)&v59 = cocos2d::CCNode::convertToWorldSpace((cocos2d::CCNode *)&v52, v23);
((void (__fastcall *)(cocos2d::CCSprite *, double *, double))m_cursor1->setPosition)(m_cursor1, &v52, v59);
v24 = a1->m_cursor1;
v25 = v24->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v26 = 1;
}
else
{
v25 = m_cursor1->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v24 = a1->m_cursor1;
v26 = 0;
}
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v25->setVisible)(v24, v26);
v27 = v55;
v28 = v55 >= 37;
((void (__fastcall *)(CCMenuItemSpriteExtra *, _BOOL8))a1->m_leftArrow->setEnabled)(a1->m_leftArrow, v28);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _BOOL8))a1->m_leftArrow->setVisible)(a1->m_leftArrow, v28);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _BOOL8))a1->m_rightArrow->setEnabled)(a1->m_rightArrow, v28);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _BOOL8))a1->m_rightArrow->setVisible)(a1->m_rightArrow, v28);
m_navDotMenu = a1->m_navDotMenu;
setEnabled = m_navDotMenu->setEnabled;
if ( v27 < 37 )
{
((void (__fastcall *)(cocos2d::CCMenu *, _QWORD))setEnabled)(m_navDotMenu, 0);
((void (__fastcall *)(cocos2d::CCMenu *, _QWORD))a1->m_navDotMenu->setVisible)(a1->m_navDotMenu, 0);
if ( v3 != DeathEffect )
return;
goto LABEL_33;
}
((void (__fastcall *)(cocos2d::CCMenu *, __int64))setEnabled)(m_navDotMenu, 1);
((void (__fastcall *)(cocos2d::CCMenu *, __int64))a1->m_navDotMenu->setVisible)(a1->m_navDotMenu, 1);
((void (__fastcall *)(cocos2d::CCMenu *))a1->m_navDotMenu->removeAllChildren)(a1->m_navDotMenu);
v31 = (int)(float)((float)(v27 / 0x24u) + 1.0);
while ( (unsigned int)sub_100720070(a1->m_pageButtons) < v31 )
{
v32 = cocos2d::CCSprite::createWithSpriteFrameName("gj_navDotBtn_on_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v32->setScale)(v32, 0.89999998);
v33 = CCMenuItemSpriteExtra::create(
v32,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)GJGarageLayer::onNavigate);
v34 = sub_100720070(a1->m_pageButtons);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v33->setTag)(v33, v34);
sub_10071FCD0(a1->m_pageButtons, v33);
CCMenuItemSpriteExtra::setSizeMult(v33, 1.1);
}
v35 = v57;
if ( v31 > 0 )
{
for ( i = 0; i != v31; ++i )
{
v37 = sub_1007200C0(a1->m_pageButtons, i);
((void (__fastcall *)(cocos2d::CCMenu *, __int64))a1->m_navDotMenu->addChild)(a1->m_navDotMenu, v37);
v38 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v37 + 1056LL))(v37);
v39 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v40 = "gj_navDotBtn_off_001.png";
if ( v35 == i )
v40 = "gj_navDotBtn_on_001.png";
v41 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v39, v40);
(*(void (__fastcall **)(__int64, cocos2d::CCSpriteFrame *))(*(_QWORD *)v38 + 1144LL))(v38, v41);
}
}
cocos2d::CCMenu::alignItemsHorizontallyWithPadding(a1->m_navDotMenu, 6.0);
if ( v56 == DeathEffect )
{
LABEL_33:
v42 = cocos2d::CCMenu::create();
((void (__fastcall *)(ListButtonBar *, cocos2d::CCMenu *, __int64))a1->m_iconSelection->addChild_0)(
a1->m_iconSelection,
v42,
1);
sub_10028CBE0((float *)&v52, 8.0, 0.0);
v49 = 14;
strcpy(v50, "Explode");
v43 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v43, "0153");
sub_10028CBE0(&v47, (float)(v53 * 0.5) + -165.0, (float)((float)((float)(0.5 * v54) + -5.0) + -60.0) + -30.0);
v45 = a1->m_iconSelection;
sub_10028CC60(&v46, &v52);
GameToolbox::createToggleButton(
(unsigned int)&v49,
(unsigned int)GJGarageLayer::onSpecial,
0,
!GameVariable,
(_DWORD)v42,
(unsigned int)&v47,
(__int64)v45,
(__int64)v45,
(__int64)&v46,
(__int64)"goldFont.fnt",
0,
0,
0);
if ( (v49 & 1) != 0 )
operator delete(__p);
}
}