//
// TopArtistsLayer::init from 0x1003107b0 to 0x100310ee0 (1840 bytes)
//
// 2 xrefs:
// > TopArtistsLayer::create @ 0x100310768
// > ??> @ 0x10090fee0
//
// 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 __fastcall TopArtistsLayer::init(TopArtistsLayer *a1)
{
bool result; // al
cocos2d::extension::CCScale9Sprite *v2; // rbx
cocos2d::CCMenu *v3; // rax
cocos2d::CCLabelBMFont *v4; // rbx
cocos2d::CCSprite *v5; // rax
CCMenuItemSpriteExtra *v6; // rbx
cocos2d::CCMenu *m_buttonMenu; // r15
cocos2d::CCMenu *v8; // r15
cocos2d::CCSprite *v9; // rbx
CCMenuItemSpriteExtra *v10; // rax
CCMenuItemSpriteExtra *m_prevButton; // rbx
cocos2d::CCSprite *v12; // rbx
CCMenuItemSpriteExtra *v13; // rax
CCMenuItemSpriteExtra *m_nextButton; // rbx
LoadingCircle *v15; // rax
cocos2d::CCLabelBMFont *v16; // rax
cocos2d::CCLabelBMFont *m_pageInfoLabel; // rbx
cocos2d::CCLabelBMFont *v18; // rbx
GameLevelManager *v19; // rax
const char *TopArtistsKey; // r15
size_t v21; // rax
size_t v22; // rbx
char *v23; // r12
size_t v24; // r13
GameLevelManager *v25; // rax
char *v26; // r15
const char *v27; // rsi
GameLevelManager *v28; // rax
const char *v29; // rsi
size_t v30; // rax
size_t v31; // rbx
char *v32; // r12
void *v33; // rsi
char *v34; // rdx
GameLevelManager *v35; // rax
GameLevelManager *v36; // rax
size_t v37; // r13
char *v38; // rax
float v39; // [rsp+0h] [rbp-80h] BYREF
void *__src; // [rsp+8h] [rbp-78h]
_QWORD v41[2]; // [rsp+10h] [rbp-70h] BYREF
void *__p; // [rsp+20h] [rbp-60h]
cocos2d::CCArray *StoredOnlineLevels; // [rsp+28h] [rbp-58h]
_QWORD __dst[2]; // [rsp+30h] [rbp-50h] BYREF
void *v45; // [rsp+40h] [rbp-40h]
float v46; // [rsp+4Ch] [rbp-34h] BYREF
float v47; // [rsp+50h] [rbp-30h]
bool v48; // [rsp+57h] [rbp-29h]
cocos2d::CCRect v49; // 0:xmm0_8.8,8:xmm1_8.8
result = FLAlertLayer::init_1(a1, 150);
if ( !result )
return result;
v48 = result;
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v46);
v49.origin = 0;
v49.size = 0;
sub_10028CC00((__int64)__dst, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v2 = cocos2d::extension::CCScale9Sprite::create_2("GJ_square02.png", v49);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v2->setOpacity)(v2, 255);
sub_10028CBF0((float *)__dst, 440.0, 290.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, _QWORD *))v2->setContentSize)(v2, __dst);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v2,
0xFFFFFFFFLL);
sub_10028CBE0((float *)__dst, v46 * 0.5, v47 * 0.5);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, _QWORD *))v2->setPosition)(v2, __dst);
v3 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v3;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v3,
10);
v4 = cocos2d::CCLabelBMFont::create_3("Featured Artists", "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v4,
20);
sub_10028CBE0((float *)__dst, v46 * 0.5, (float)((float)(v47 * 0.5) + 145.0) + -18.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD *))v4->setPosition)(v4, __dst);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v4->setScale)(v4, 0.60000002);
a1->m_joystickConnected = -1;
v5 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v6 = CCMenuItemSpriteExtra::create(
v5,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)TopArtistsLayer::onClose);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v6);
CCMenuItemSpriteExtra::setSizeMult(v6, 1.6);
m_buttonMenu = a1->m_buttonMenu;
sub_10028CBE0(&v39, (float)((float)(v46 * 0.5) + -220.0) + 10.0, (float)((float)(v47 * 0.5) + 145.0) + -10.0);
v49.origin = cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)__dst, (const cocos2d::CCPoint *)m_buttonMenu);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD *, double))v6->setPosition)(v6, __dst, *(double *)&v49.origin);
v8 = cocos2d::CCMenu::create();
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v8,
10);
*(float *)&StoredOnlineLevels = v47 * 0.5;
v9 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v9->setScale)(v9, 0.80000001);
v10 = CCMenuItemSpriteExtra::create(
v9,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)TopArtistsLayer::onPrevPage);
a1->m_prevButton = v10;
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v8->addChild)(v8, v10);
m_prevButton = a1->m_prevButton;
sub_10028CBE0(&v39, (float)((float)(v46 * 0.5) + -220.0) + 22.0, *(float *)&StoredOnlineLevels);
v49.origin = cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)__dst, (const cocos2d::CCPoint *)v8);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD *, double))m_prevButton->setPosition)(
m_prevButton,
__dst,
*(double *)&v49.origin);
v12 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v12->setScale)(v12, 0.80000001);
cocos2d::CCSprite::setFlipX(v12, 1);
v13 = CCMenuItemSpriteExtra::create(
v12,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)TopArtistsLayer::onNextPage);
a1->m_nextButton = v13;
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v8->addChild)(v8, v13);
m_nextButton = a1->m_nextButton;
sub_10028CBE0(&v39, (float)((float)(v46 * 0.5) + 220.0) + -22.0, *(float *)&StoredOnlineLevels);
v49.origin = cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)__dst, (const cocos2d::CCPoint *)v8);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD *, double))m_nextButton->setPosition)(
m_nextButton,
__dst,
*(double *)&v49.origin);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_prevButton->setVisible)(a1->m_prevButton, 0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_nextButton->setVisible)(a1->m_nextButton, 0);
v15 = LoadingCircle::create();
a1->m_loadingCircle = v15;
v15->m_parentLayer = a1->m_mainLayer;
v15->m_fade = 0;
cocos2d::CCObject::retain(v15);
LoadingCircle::show(a1->m_loadingCircle);
((void (__fastcall *)(LoadingCircle *, _QWORD))a1->m_loadingCircle->setVisible)(a1->m_loadingCircle, 0);
v16 = cocos2d::CCLabelBMFont::create_3(" ", "goldFont.fnt");
a1->m_pageInfoLabel = v16;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v16);
m_pageInfoLabel = a1->m_pageInfoLabel;
sub_10028CBE0((float *)__dst, (float)((float)(v46 * 0.5) + 220.0) + -8.0, (float)((float)(0.5 * v47) + 145.0) + -8.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD *))m_pageInfoLabel->setPosition)(m_pageInfoLabel, __dst);
v18 = a1->m_pageInfoLabel;
sub_10028CBE0((float *)__dst, 1.0, 1.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD *))v18->setAnchorPoint)(v18, __dst);
v19 = GameLevelManager::sharedState();
TopArtistsKey = GameLevelManager::getTopArtistsKey(v19, 0);
v21 = strlen(TopArtistsKey);
if ( v21 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(COERCE_DOUBLE(1065353216));
v22 = v21;
if ( v21 >= 0x17 )
{
v24 = 26;
if ( (v21 | 7) != 0x17 )
v24 = (v21 | 7) + 1;
v23 = (char *)operator new(v24);
v45 = v23;
__dst[0] = v24 + 1;
__dst[1] = v22;
goto LABEL_9;
}
LOBYTE(__dst[0]) = 2 * v21;
v23 = (char *)__dst + 1;
if ( v21 )
LABEL_9:
memmove(v23, TopArtistsKey, v22);
v23[v22] = 0;
v25 = GameLevelManager::sharedState();
v26 = (char *)__dst + 1;
v27 = (char *)__dst + 1;
if ( (__dst[0] & 1) != 0 )
v27 = (const char *)v45;
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v25, v27);
if ( StoredOnlineLevels )
{
v28 = GameLevelManager::sharedState();
v29 = (char *)__dst + 1;
if ( (__dst[0] & 1) != 0 )
v29 = (const char *)v45;
__src = (void *)GameLevelManager::getPageInfo(v28, v29);
v30 = strlen((const char *)__src);
if ( v30 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(COERCE_DOUBLE(1065353216));
v31 = v30;
if ( v30 >= 0x17 )
{
v37 = 26;
if ( (v30 | 7) != 0x17 )
v37 = (v30 | 7) + 1;
v38 = (char *)operator new(v37);
v33 = __src;
v32 = v38;
__p = v38;
v41[0] = v37 | 1;
v41[1] = v31;
}
else
{
LOBYTE(v41[0]) = 2 * v30;
v32 = (char *)v41 + 1;
v33 = __src;
if ( !v30 )
{
BYTE1(v41[0]) = 0;
v34 = (char *)__dst + 1;
if ( (__dst[0] & 1) == 0 )
{
LABEL_20:
((void (__fastcall *)(TopArtistsLayer *, _QWORD *, char *))a1->setupPageInfo)(a1, v41, v34);
if ( (v41[0] & 1) != 0 )
operator delete(__p);
if ( (__dst[0] & 1) != 0 )
v26 = (char *)v45;
((void (__fastcall *)(TopArtistsLayer *, cocos2d::CCArray *, char *))a1->loadListFinished)(
a1,
StoredOnlineLevels,
v26);
goto LABEL_26;
}
LABEL_19:
v34 = (char *)v45;
goto LABEL_20;
}
}
memmove(v32, v33, v31);
v32[v31] = 0;
v34 = (char *)__dst + 1;
if ( (__dst[0] & 1) == 0 )
goto LABEL_20;
goto LABEL_19;
}
v35 = GameLevelManager::sharedState();
GameLevelManager::makeTimeStamp(v35, "upd_artists");
((void (__fastcall *)(LoadingCircle *, __int64))a1->m_loadingCircle->setVisible)(a1->m_loadingCircle, 1);
TopArtistsLayer::setupLeaderboard(a1, nullptr);
GameLevelManager::sharedState()->m_onlineListDelegate = &a1->OnlineListDelegate;
v36 = GameLevelManager::sharedState();
GameLevelManager::getTopArtists(v36, 0, 0);
LABEL_26:
if ( (__dst[0] & 1) != 0 )
operator delete(v45);
return v48;
}