//
// SongUsagePopup::init from 0x140101e80 to 0x14010231a (1178 bytes)
//
// 2 xrefs:
// > SongUsagePopup::create @ 0x140101e40
// > ??> @ 0x1409158a8
//
// This function is hookable on this platform (idp: pc, 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 11:26:43 +0000
//
// Hidden C++ exception states: #wind=3
bool __fastcall SongUsagePopup::init(__int64 a1, int a2, const char *a3, const char *a4)
{
bool result; // al
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v11; // rdx
__int64 v12; // rcx
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rbx
cocos2d::CCLabelBMFont *v17; // rax
cocos2d::CCLabelBMFont *v18; // rax
__int64 v19; // rax
struct cocos2d::CCSprite *v20; // rax
int v21; // ebx
cocos2d::CCObject *v22; // rbx
_QWORD *v23; // r8
_OWORD *v24; // rcx
const char *v25; // rax
__int64 v26; // rdx
__int64 v27; // rbx
cocos2d::CCLayerColor *v28; // rax
__int64 v29; // rcx
__int128 v30; // [rsp+30h] [rbp-50h] BYREF
__int64 v31; // [rsp+40h] [rbp-40h]
__int64 v32; // [rsp+48h] [rbp-38h]
float v33[2]; // [rsp+50h] [rbp-30h] BYREF
_BYTE v34[8]; // [rsp+58h] [rbp-28h] BYREF
_QWORD v35[4]; // [rsp+60h] [rbp-20h] BYREF
LODWORD(v30) = -1778384896;
result = cocos2d::CCLayerColor::initWithColor((cocos2d::CCLayerColor *)a1, (const struct cocos2d::_ccColor4B *)&v30);
if ( result )
{
*(_DWORD *)(a1 + 672) = a2;
LOBYTE(v9) = -106;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)(a1 + 408) + 40LL))(a1 + 408, v9);
FLAlertLayer::incrementForcePrio((struct cocos2d::CCObject *)a1);
*(_BYTE *)(a1 + 596) = 1;
LOBYTE(v10) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 920LL))(a1, v10);
LOBYTE(v11) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 992LL))(a1, v11);
v13 = cocos2d::CCDirector::sharedDirector(v12);
cocos2d::CCDirector::getWinSize(v13, v33);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v34, v33[0] * 0.5, v33[1] * 0.5);
v14 = cocos2d::CCLayer::create();
*(_QWORD *)(a1 + 584) = v14;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v14);
v15 = cocos2d::CCRect::CCRect((cocos2d::CCRect *)&v30, 0.0, 0.0, 80.0, 80.0);
v16 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v15);
(*(void (__fastcall **)(__int64, _BYTE *))(*(_QWORD *)v16 + 184LL))(v16, v34);
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v16,
4294967294LL);
*(_QWORD *)(a1 + 688) = v16;
if ( *((_QWORD *)a3 + 3) > 0xFu )
a3 = *(const char **)a3;
v17 = cocos2d::CCLabelBMFont::create(a3, (const char *)&qword_140704F78);
*(_QWORD *)(a1 + 696) = v17;
cocos2d::CCLabelBMFont::limitLabelWidth(v17, 310.0, 0.69999999, 0.0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
*(_QWORD *)(a1 + 696));
if ( *((_QWORD *)a4 + 3) > 0xFu )
a4 = *(const char **)a4;
v18 = cocos2d::CCLabelBMFont::create(a4, "goldFont.fnt");
*(_QWORD *)(a1 + 704) = v18;
cocos2d::CCLabelBMFont::limitLabelWidth(v18, 310.0, 0.60000002, 0.30000001);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
*(_QWORD *)(a1 + 704));
v19 = cocos2d::CCMenu::create();
*(_QWORD *)(a1 + 552) = v19;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v19, 10);
(*(void (__fastcall **)(_QWORD, void *))(**(_QWORD **)(a1 + 552) + 184LL))(*(_QWORD *)(a1 + 552), &unk_14090A1A8);
*(_DWORD *)(a1 + 640) = -1;
v20 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v21 = (int)v20;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v20 + 160LL))(v20);
v22 = CCMenuItemSpriteExtra::create(v21, 0, a1, (__int64)PagedListPopup::onClose);
*((_DWORD *)v22 + 93) = 1069547520;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v22);
*(_QWORD *)(a1 + 712) = v22;
v30 = 0;
v31 = 0;
v32 = 0;
v23 = sub_14003D460(0x110u);
*(_QWORD *)&v30 = v23;
v31 = 257;
v32 = 271;
v24 = v23;
v25 = "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.";
v26 = 2;
do
{
*v24 = *(_OWORD *)v25;
v24[1] = *((_OWORD *)v25 + 1);
v24[2] = *((_OWORD *)v25 + 2);
v24[3] = *((_OWORD *)v25 + 3);
v24[4] = *((_OWORD *)v25 + 4);
v24[5] = *((_OWORD *)v25 + 5);
v24[6] = *((_OWORD *)v25 + 6);
v24 += 8;
*(v24 - 1) = *((_OWORD *)v25 + 7);
v25 += 128;
--v26;
}
while ( v26 );
*(_BYTE *)v24 = *v25;
*((_BYTE *)v23 + 257) = 0;
v35[1] = 25959;
v35[2] = 10;
v35[3] = 15;
v35[0] = 0x61735520676E6F53LL;
v27 = InfoAlertButton::create(v35, &v30);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v27);
*(_QWORD *)(a1 + 720) = v27;
SongUsagePopup::layoutPopup(a1);
v28 = LoadingCircle::create();
*(_QWORD *)(a1 + 680) = v28;
*((_QWORD *)v28 + 69) = *(_QWORD *)(a1 + 584);
*(_BYTE *)(*(_QWORD *)(a1 + 680) + 560LL) = 0;
cocos2d::CCObject::retain(*(cocos2d::CCObject **)(a1 + 680));
LoadingCircle::show(*(_QWORD *)(a1 + 680));
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(*(_QWORD *)(a1 + 680) + 544LL) + 184LL))(
*(_QWORD *)(*(_QWORD *)(a1 + 680) + 544LL),
a1 + 732);
v29 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
*(_QWORD *)&v30 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager(v30);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v29 = *(_QWORD *)&qword_14090BFB0;
}
*(_QWORD *)(v29 + 1600) = a1 + 664;
GameLevelManager::getSongUsage(v29, *(unsigned int *)(a1 + 672));
return 1;
}
return result;
}