//
// SongUsagePopup::init from 0xc8ced0 to 0xc8d2ec (1052 bytes)
//
// 2 xrefs:
// > SongUsagePopup::create @ 0xc8d478
// > ??> @ 0xd1bf0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:05:45 +0000
//
__int64 __fastcall SongUsagePopup::init(__int64 a1, int a2, __int64 a3, __int64 a4)
{
unsigned __int8 v8; // w0
unsigned int v9; // w21
__int64 v11; // x2
cocos2d::CCDirector *v12; // x0
cocos2d::CCDirector *v13; // x0
cocos2d::CCLayer *v14; // x0
__int64 v15; // x0
__int64 v16; // x22
const char *v17; // x2
cocos2d::CCLabelBMFont *v18; // x0
cocos2d::CCLabelBMFont *v19; // x0
const char *v20; // x2
cocos2d::CCLabelBMFont *v21; // x0
cocos2d::CCLabelBMFont *v22; // x0
cocos2d::CCMenu *v23; // x0
__int64 v24; // x0
__int64 v25; // x24
__int64 v26; // x24
__int64 v27; // x22
LoadingCircle *v28; // x0
__int64 v29; // x0
GameLevelManager *v30; // x0
GameLevelManager *v31; // x0
GameLevelManager *v32; // x0
__int64 v33; // [xsp+68h] [xbp+68h] BYREF
_BYTE v34[8]; // [xsp+70h] [xbp+70h] BYREF
_BYTE v35[16]; // [xsp+78h] [xbp+78h] BYREF
__int64 v36[2]; // [xsp+88h] [xbp+88h] BYREF
void *v37; // [xsp+98h] [xbp+98h]
__int64 v38[2]; // [xsp+A0h] [xbp+A0h] BYREF
void *v39; // [xsp+B0h] [xbp+B0h]
v35[0] = 0;
v35[1] = 0;
v35[2] = 0;
v35[3] = -106;
v8 = cocos2d::CCLayerColor::initWithColor(a1, v35);
v9 = v8;
if ( v8 )
{
v11 = *(_QWORD *)a1;
*(_DWORD *)(a1 + 672) = a2;
(*(void (__fastcall **)(__int64, __int64))(v11 + 1168))(a1, 4294967190LL);
FLAlertLayer::incrementForcePrio((cocos2d::CCObject *)a1);
*(_BYTE *)(a1 + 596) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1000LL))(a1, 1);
v12 = (cocos2d::CCDirector *)(*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1072LL))(a1, 1);
v13 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v12);
cocos2d::CCDirector::getWinSize(&v33, v13);
v14 = (cocos2d::CCLayer *)cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v34,
*(float *)&v33 * 0.5,
*((float *)&v33 + 1) * 0.5);
v15 = cocos2d::CCLayer::create(v14);
*(_QWORD *)(a1 + 584) = v15;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 456LL))(a1, v15);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v35, 0.0, 0.0, 80.0, 80.0);
v16 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v35);
(*(void (__fastcall **)(__int64, _BYTE *))(*(_QWORD *)v16 + 184LL))(v16, v34);
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v16,
4294967294LL);
*(_QWORD *)(a1 + 688) = v16;
v18 = (cocos2d::CCLabelBMFont *)(a3 + 1);
if ( (*(_BYTE *)a3 & 1) != 0 )
v18 = *(cocos2d::CCLabelBMFont **)(a3 + 16);
v19 = (cocos2d::CCLabelBMFont *)cocos2d::CCLabelBMFont::create(v18, "bigFont.fnt", v17);
*(_QWORD *)(a1 + 696) = v19;
cocos2d::CCLabelBMFont::limitLabelWidth(v19, 310.0, 0.7, 0.0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
*(_QWORD *)(a1 + 696));
v21 = (cocos2d::CCLabelBMFont *)(a4 + 1);
if ( (*(_BYTE *)a4 & 1) != 0 )
v21 = *(cocos2d::CCLabelBMFont **)(a4 + 16);
v22 = (cocos2d::CCLabelBMFont *)cocos2d::CCLabelBMFont::create(v21, "goldFont.fnt", v20);
*(_QWORD *)(a1 + 704) = v22;
cocos2d::CCLabelBMFont::limitLabelWidth(v22, 310.0, 0.6, 0.3);
v23 = (cocos2d::CCMenu *)(*(__int64 (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
*(_QWORD *)(a1 + 704));
v24 = cocos2d::CCMenu::create(v23);
*(_QWORD *)(a1 + 552) = v24;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 464LL))(*(_QWORD *)(a1 + 584), v24, 10);
(*(void (__fastcall **)(_QWORD, void *))(**(_QWORD **)(a1 + 552) + 184LL))(*(_QWORD *)(a1 + 552), &unk_155EE50);
*(_DWORD *)(a1 + 640) = -1;
v25 = cocos2d::CCSprite::createWithSpriteFrameName(
(cocos2d::CCSprite *)"GJ_closeBtn_001.png",
(const char *)0xFFFFFFFFLL);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v25 + 160LL))(v25, 0.8);
v26 = CCMenuItemSpriteExtra::create(v25, 0, a1, (__int64)SongUsagePopup::onClose, 0);
CCMenuItemSpriteExtra::setSizeMult(v26, 1.5);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 552) + 456LL))(*(_QWORD *)(a1 + 552), v26);
*(_QWORD *)(a1 + 712) = v26;
v36[0] = 0;
v36[1] = 0;
v37 = nullptr;
std::string::__init(v36, "Song Usage", 0xAu);
v38[0] = 0;
v38[1] = 0;
v39 = nullptr;
std::string::__init(
v38,
"Blue arrow = Levels uploaded with this song.\n"
"Star = Rated levels using this song.\n"
"Green arrow = Total downloads for rated levels.\n"
"Rated levels are grouped by difficulty and rating.\n"
"Only a level's main song is counted.",
0x101u);
v27 = InfoAlertButton::create((char *)v36, (char *)v38, 0.8);
if ( (v38[0] & 1) != 0 )
operator delete(v39);
if ( (v36[0] & 1) != 0 )
operator delete(v37);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 552) + 456LL))(*(_QWORD *)(a1 + 552), v27);
*(_QWORD *)(a1 + 720) = v27;
v28 = (LoadingCircle *)SongUsagePopup::layoutPopup((SongUsagePopup *)a1, 160.0);
v29 = LoadingCircle::create(v28);
*(_QWORD *)(a1 + 680) = v29;
*(_QWORD *)(v29 + 552) = *(_QWORD *)(a1 + 584);
*(_BYTE *)(*(_QWORD *)(a1 + 680) + 560LL) = 0;
cocos2d::CCObject::retain(*(cocos2d::CCObject **)(a1 + 680));
LoadingCircle::show(*(cocos2d::CCNode ***)(a1 + 680));
v30 = (GameLevelManager *)(*(__int64 (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(*(_QWORD *)(a1 + 680) + 544LL)
+ 184LL))(
*(_QWORD *)(*(_QWORD *)(a1 + 680) + 544LL),
a1 + 732);
v31 = (GameLevelManager *)GameLevelManager::sharedState(v30);
*((_QWORD *)v31 + 184) = a1 + 664;
v32 = (GameLevelManager *)GameLevelManager::sharedState(v31);
GameLevelManager::getSongUsage(v32, (const char *)*(unsigned int *)(a1 + 672));
}
return v9;
}