//
// AchievementsLayer::loadPage from 0x140082350 to 0x14008252a (474 bytes)
//
// 6 xrefs:
// > AchievementsLayer::customSetup @ 0x140082287
// > AchievementsLayer::keyDown @ 0x14008230b
// > AchievementsLayer::keyDown @ 0x140082338
// > AchievementsLayer::onNextPage @ 0x140082538
// > AchievementsLayer::onPrevPage @ 0x140082548
// > ??> @ 0x1406c6a20
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void AchievementsLayer::loadPage(AchievementsLayer *a1, int a2)
{
int v2; // ebx
CCMenuItemSpriteExtra *m_prevPageButton; // rcx
cocos2d::CCArray *m_allAchievementsSorted; // rdi
__int64 v6; // rcx
cocos2d::CCArray *v7; // r15
int v8; // esi
signed int v9; // r12d
unsigned int v10; // ebx
struct cocos2d::CCObject *v11; // rax
unsigned int v12; // ebx
_BOOL8 v13; // rdx
_BOOL8 v14; // rdx
_BOOL8 v15; // rdx
signed int v16; // ebx
CCMenuItemSpriteExtra *m_nextPageButton; // rcx
CCMenuItemSpriteExtra_vtbl *v18; // rax
cocos2d::CCString *v19; // rax
const char *CString; // rax
_BOOL8 v21; // r8
CustomListView *v22; // rbx
int v23; // [rsp+20h] [rbp-48h]
v2 = a2;
a1->m_currentPage = a2;
m_prevPageButton = a1->m_prevPageButton;
if ( a2 <= 0 )
*(_QWORD *)&a2 = 0;
else
LOBYTE(a2) = 1;
m_prevPageButton->setVisible(m_prevPageButton, *(_QWORD *)&a2);
m_allAchievementsSorted = AchievementManager::sharedState()->m_allAchievementsSorted;
v7 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
v8 = 10 * v2;
v9 = cocos2d::CCArray::count(m_allAchievementsSorted);
if ( m_allAchievementsSorted )
{
if ( cocos2d::CCArray::count(m_allAchievementsSorted) )
{
v10 = 10 * v2;
if ( !__OFSUB__(v8, v8 + 10) )
{
do
{
if ( v10 > cocos2d::CCArray::count(m_allAchievementsSorted) - 1 )
break;
v11 = cocos2d::CCArray::objectAtIndex(m_allAchievementsSorted, v10);
cocos2d::CCArray::addObject(v7, v11);
++v10;
}
while ( (int)v10 < v8 + 10 );
}
}
}
v12 = v8 + cocos2d::CCArray::count(v7);
if ( v12 >= cocos2d::CCArray::count(m_allAchievementsSorted) )
v13 = 0;
else
LOBYTE(v13) = 1;
a1->m_nextPageButton->setVisible(a1->m_nextPageButton, v13);
if ( v8 )
LOBYTE(v14) = 1;
else
v14 = 0;
a1->m_prevPageButton->setVisible(a1->m_prevPageButton, v14);
v16 = v8 + 10;
m_nextPageButton = a1->m_nextPageButton;
v18 = m_nextPageButton->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( v8 + 10 < v9 )
{
LOBYTE(v15) = 1;
v18->setVisible(m_nextPageButton, v15);
}
else
{
v18->setVisible(m_nextPageButton, 0);
v16 = v9;
}
v19 = cocos2d::CCString::createWithFormat("%i to %i of %i", v8 + 1, v16, v9);
CString = cocos2d::CCString::getCString(v19);
a1->m_pageLabel->setString(&a1->m_pageLabel->cocos2d::CCLabelProtocol, CString);
LOBYTE(v21) = 1;
a1->m_listLayer->removeChildByTag(a1->m_listLayer, 9, v21);
v22 = CustomListView::create(v7, nullptr, 220.0, 356.0, v23, Achievement, 0.0);
v22->setTag(v22, 9);
a1->m_listLayer->addChild_0(a1->m_listLayer, v22, 6);
}