//
// LevelLeaderboard::setupLeaderboard from 0x1002506f0 to 0x100250884 (404 bytes)
//
// 4 xrefs:
// > LevelLeaderboard::init @ 0x100250010
// > LevelLeaderboard::onUpdate @ 0x1002504e0
// > LevelLeaderboard::loadScores @ 0x10025068c
// > LevelLeaderboard::loadLeaderboardFinished @ 0x100250efc
//
// 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 LevelLeaderboard::setupLeaderboard(LevelLeaderboard *a1, cocos2d::CCArray *a2)
{
cocos2d::CCDirector *v4; // x0
cocos2d::CCTouchDispatcher *v5; // x0
cocos2d::CCDirector *v6; // x0
GJGameLevel *m_level; // x0
cocos2d::ccArray *data; // x8
__int64 num; // x9
cocos2d::CCObject **arr; // x8
unsigned __int64 v11; // x9
cocos2d::CCObject *v12; // x11
BoomListType v13; // w3
CustomListView *v14; // x0
GJCommentListLayer *v15; // x0
__n128 v16; // q0
GJCommentListLayer *m_list; // x19
__n128 v18; // q1
_DWORD v19[4]; // [xsp+0h] [xbp-20h] BYREF
if ( a1->m_list )
{
v4 = cocos2d::CCDirector::sharedDirector();
v5 = (cocos2d::CCTouchDispatcher *)((__int64 (__fastcall *)(cocos2d::CCDirector *))v4->getTouchDispatcher)(v4);
cocos2d::CCTouchDispatcher::unregisterForcePrio(v5, a1->m_list);
((void (__fastcall *)(GJCommentListLayer *))a1->m_list->removeMeAndCleanup)(a1->m_list);
a1->m_list = nullptr;
}
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v6);
if ( a2 )
{
m_level = a1->m_level;
if ( m_level )
{
if ( GJGameLevel::isPlatformer(m_level) && a1->m_type != Local )
{
data = a2->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v11 = (unsigned __int64)&arr[num - 1];
do
{
v12 = *arr;
if ( !*arr )
break;
v12[14].m_nTag = 1;
v12[14].m_uReference = a1->m_mode;
++arr;
}
while ( (unsigned __int64)arr <= v11 );
}
}
}
if ( a1->m_type == Local )
v13 = LocalLevelScore;
else
v13 = Comment4|Achievement;
v14 = CustomListView::create(a2, nullptr, 220.0, 340.0, 0, v13, 0.0);
}
else
{
v14 = nullptr;
}
v15 = GJCommentListLayer::create(v14, "Scores", (cocos2d::ccColor4B)-12684609, 340.0, 220.0, 1);
a1->m_list = v15;
v16 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, GJCommentListLayer *))a1->m_mainLayer->addChild)(
a1->m_mainLayer,
v15);
v16.n128_f32[0] = (float)(*(float *)&v19[2] + -340.0) * 0.5;
m_list = a1->m_list;
v18.n128_f32[0] = (float)((float)(*(float *)&v19[3] + -220.0) * 0.5) + -10.0;
sub_100022980(v16, v18, v19);
((void (__fastcall *)(GJCommentListLayer *, _DWORD *))m_list->setPosition)(m_list, v19);
}