//
// TopArtistsLayer::init from 0x965d34 to 0x966434 (1792 bytes)
//
// 3 xrefs:
// > TopArtistsLayer::create @ 0x96651c
// > ??> @ 0x369c0
// > ??> @ 0x11bd440
//
// 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
//
bool TopArtistsLayer::init(TopArtistsLayer *a1)
{
char v2; // w25
cocos2d::CCDirector *v4; // x0
cocos2d::CCNode *v5; // x24
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x26
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
cocos2d::CCMenu *v8; // x0
cocos2d::CCLabelBMFont *v9; // x24
void (__fastcall *v10)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
cocos2d::CCSprite *v11; // x0
CCMenuItemSpriteExtra *v12; // x24
cocos2d::CCMenu *m_buttonMenu; // x27
void (__fastcall *v14)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
cocos2d::CCMenu *v15; // x24
float v16; // s9
cocos2d::CCSprite *v17; // x27
CCMenuItemSpriteExtra *v18; // x0
CCMenuItemSpriteExtra *m_prevButton; // x27
void (__fastcall *v20)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x28
cocos2d::CCSprite *v21; // x26
CCMenuItemSpriteExtra *v22; // x0
CCMenuItemSpriteExtra *m_nextButton; // x26
void (__fastcall *v24)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
LoadingCircle *v25; // x0
LoadingCircle *m_loadingCircle; // x0
cocos2d::CCLabelBMFont *v27; // x0
cocos2d::CCLabelBMFont *m_pageInfoLabel; // x24
void (__fastcall *v29)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
cocos2d::CCLabelBMFont *v30; // x24
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // x26
GameLevelManager *v32; // x0
char *TopArtistsKey; // x0
GameLevelManager *v34; // x0
cocos2d::CCArray *StoredOnlineLevels; // x23
void (__fastcall *setupPageInfo)(TopArtistsLayer *__hidden, std::string, const unsigned __int8 *); // x24
GameLevelManager *v37; // x0
char *PageInfo; // x0
void *v39; // x0
char *v40; // x0
unsigned int *v41; // x19
int v42; // w1
GameLevelManager *v43; // x0
GameLevelManager *v44; // x0
unsigned int *v45; // x1
int v46; // w2
__int64 v47; // [xsp+0h] [xbp+0h] BYREF
float v48; // [xsp+B8h] [xbp+B8h]
float v49; // [xsp+BCh] [xbp+BCh]
char *v50; // [xsp+C0h] [xbp+C0h] BYREF
cocos2d::CCRect v51; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCPoint v52; // 0:kr08_8.8
cocos2d::CCPoint v53; // 0:kr10_8.8
cocos2d::CCPoint v54; // 0:kr18_8.8
cocos2d::SEL_MenuHandler v55; // 0:x2.16
cocos2d::SEL_MenuHandler v56; // 0:x2.16
cocos2d::SEL_MenuHandler v57; // 0:x2.16
cocos2d::CCRect v58; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v2 = FLAlertLayer::init(a1, 0x96u);
if ( v2 )
{
v4 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v4);
cocos2d::CCRect::CCRect(&v51, 0.0, 0.0, 80.0, 80.0);
v5 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square02.png",
(const char *)&v51,
v58);
((void (__fastcall *)(cocos2d::CCNode *, __int64))v5->__vftable[1].~CCNode_0)(v5, 0xFFFFFFFFLL);
setContentSize = v5->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v51, 440.0, 290.0);
setContentSize(v5, (const cocos2d::CCSize *)&v51);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v5, -1);
setPosition = v5->setPosition;
cocos2d::CCPoint::CCPoint(&v51.origin, v48 * 0.5, v49 * 0.5);
setPosition(v5, &v51.origin);
v8 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v8;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v8, 10);
v9 = cocos2d::CCLabelBMFont::create();
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v9, 20);
v10 = v9->setPosition;
cocos2d::CCPoint::CCPoint(&v51.origin, v48 * 0.5, (float)((float)(v49 * 0.5) + 145.0) - 18.0);
v10(v9, &v51.origin);
v9->setScale(v9, 0.6);
a1->m_joystickConnected = -1;
v11 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v55.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v55.adj = (size_t)TopArtistsLayer::onClose;
v12 = CCMenuItemSpriteExtra::create(v11, nullptr, v55);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v12);
CCMenuItemSpriteExtra::setSizeMult(v12, 1.6);
m_buttonMenu = a1->m_buttonMenu;
v14 = v12->setPosition;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v50,
(float)((float)(v48 * 0.5) + -220.0) + 10.0,
(float)((float)(v49 * 0.5) + 145.0) - 10.0);
v52 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, (const cocos2d::CCPoint *)&v50);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v14)(v12, &v51, v52.x, v52.y);
v15 = cocos2d::CCMenu::create();
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v15, 10);
v16 = v49 * 0.5;
v17 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
v17->setScale(v17, 0.8);
v56.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v56.adj = (size_t)TopArtistsLayer::onPrevPage;
v18 = CCMenuItemSpriteExtra::create(v17, nullptr, v56);
a1->m_prevButton = v18;
CCMenuItemSpriteExtra::setSizeMult(v18, 1.2);
v15->addChild(v15, a1->m_prevButton);
m_prevButton = a1->m_prevButton;
v20 = m_prevButton->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v50, (float)((float)(v48 * 0.5) + -220.0) + 22.0, v16);
v53 = cocos2d::CCNode::convertToNodeSpace(v15, (const cocos2d::CCPoint *)&v50);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v20)(
m_prevButton,
&v51,
v53.x,
v53.y);
v21 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
v21->setScale(v21, 0.8);
cocos2d::CCSprite::setFlipX(v21, 1);
v57.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v57.adj = (size_t)TopArtistsLayer::onNextPage;
v22 = CCMenuItemSpriteExtra::create(v21, nullptr, v57);
a1->m_nextButton = v22;
CCMenuItemSpriteExtra::setSizeMult(v22, 1.2);
v15->addChild(v15, a1->m_nextButton);
m_nextButton = a1->m_nextButton;
v24 = m_nextButton->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v50, (float)((float)(v48 * 0.5) + 220.0) - 22.0, v16);
v54 = cocos2d::CCNode::convertToNodeSpace(v15, (const cocos2d::CCPoint *)&v50);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v24)(
m_nextButton,
&v51,
v54.x,
v54.y);
a1->m_prevButton->setVisible(a1->m_prevButton, 0);
a1->m_nextButton->setVisible(a1->m_nextButton, 0);
v25 = LoadingCircle::create();
a1->m_loadingCircle = v25;
v25->m_parentLayer = a1->m_mainLayer;
m_loadingCircle = a1->m_loadingCircle;
m_loadingCircle->m_fade = 0;
cocos2d::CCObject::retain(m_loadingCircle);
LoadingCircle::show(a1->m_loadingCircle);
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 0);
v27 = cocos2d::CCLabelBMFont::create();
a1->m_pageInfoLabel = v27;
a1->m_mainLayer->addChild(a1->m_mainLayer, v27);
m_pageInfoLabel = a1->m_pageInfoLabel;
v29 = m_pageInfoLabel->setPosition;
cocos2d::CCPoint::CCPoint(
&v51.origin,
(float)((float)(v48 * 0.5) + 220.0) - 8.0,
(float)((float)(v49 * 0.5) + 145.0) - 8.0);
v29(m_pageInfoLabel, &v51.origin);
v30 = a1->m_pageInfoLabel;
setAnchorPoint = v30->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v51.origin, 1.0, 1.0);
setAnchorPoint(v30, &v51.origin);
v32 = GameLevelManager::sharedState();
TopArtistsKey = (char *)GameLevelManager::getTopArtistsKey(v32, 0);
sub_D153B8((unsigned int)&v47 + 192, TopArtistsKey);
v34 = GameLevelManager::sharedState();
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v34, v50);
if ( StoredOnlineLevels )
{
setupPageInfo = a1->setupPageInfo;
v37 = GameLevelManager::sharedState();
PageInfo = (char *)GameLevelManager::getPageInfo(v37, v50);
sub_D153B8((int)&v51, PageInfo);
((void (__fastcall *)(TopArtistsLayer *, cocos2d::CCRect *, char *))setupPageInfo)(a1, &v51, v50);
v39 = (void *)(*(_QWORD *)&v51.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v51.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v45 = (unsigned int *)(*(_QWORD *)&v51.origin - 8LL);
do
v46 = __ldaxr(v45);
while ( __stlxr(v46 - 1, v45) );
}
else
{
v46 = *(_DWORD *)(*(_QWORD *)&v51.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v51.origin - 8LL) = v46 - 1;
}
if ( v46 <= 0 )
operator delete(v39);
}
a1->loadListFinished(a1, StoredOnlineLevels, (const unsigned __int8 *)v50);
}
else
{
v43 = GameLevelManager::sharedState();
GameLevelManager::makeTimeStamp(v43, "upd_artists");
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 1);
TopArtistsLayer::setupLeaderboard(a1, nullptr);
GameLevelManager::sharedState()->m_onlineListDelegate = &a1->OnlineListDelegate;
v44 = GameLevelManager::sharedState();
GameLevelManager::getTopArtists(v44, 0, 0);
}
v40 = v50 - 24;
if ( v50 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)(v50 - 8);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *((_DWORD *)v50 - 2);
*((_DWORD *)v50 - 2) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v40);
}
}
return v2;
}