//
// SelectPremadeLayer::init from 0x14059e0f0 to 0x14059e707 (1559 bytes)
//
// 5 xrefs:
// > SetupAdvFollowPopup::onPremade @ 0x14059d16c
// > SetupAdvFollowPopup::onPremade @ 0x14059d173
// > SetupAdvFollowPopup::onPremade @ 0x14059d15d
// > ??> @ 0x1407e7388
// > ??> @ 0x14092d338
//
// 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:34:36 +0000
//
// Hidden C++ exception states: #wind=5
bool __fastcall SelectPremadeLayer::init(__int64 a1)
{
bool result; // al
__int64 v3; // rcx
__int64 v4; // rax
__int64 v5; // rax
__int64 *v6; // rdi
__int64 v7; // rbx
__int64 v8; // rax
__int64 v9; // rbx
__int64 v10; // rax
struct cocos2d::CCLabelBMFont *v11; // rdi
__int64 v12; // rbx
__int64 v13; // rax
__int64 v14; // rcx
__int64 v15; // rax
__int64 v16; // rbx
__int64 v17; // rax
int i; // r14d
unsigned __int64 v19; // rdi
__int128 *v20; // rsi
cocos2d::CCObject *v21; // rbx
cocos2d::CCObject *v22; // rdi
float v23; // xmm0_4
__int64 v24; // rax
void *v25; // rcx
cocos2d::CCObject *v26; // rbx
cocos2d::CCObject *v27; // rsi
__int64 v28; // rdi
__int64 v29; // rbx
__int64 v30; // rax
__int64 v31; // rax
float v32; // [rsp+58h] [rbp-B0h] BYREF
float v33; // [rsp+5Ch] [rbp-ACh]
__int64 v34; // [rsp+60h] [rbp-A8h] BYREF
__int64 v35[2]; // [rsp+68h] [rbp-A0h] BYREF
__int64 v36; // [rsp+78h] [rbp-90h] BYREF
void *v37; // [rsp+80h] [rbp-88h] BYREF
void *v38; // [rsp+88h] [rbp-80h]
__int128 v39; // [rsp+90h] [rbp-78h] BYREF
__int64 v40; // [rsp+A0h] [rbp-68h]
unsigned __int64 v41; // [rsp+A8h] [rbp-60h]
result = FLAlertLayer::init_1(a1, 150);
if ( !result )
return result;
v4 = cocos2d::CCDirector::sharedDirector(v3);
cocos2d::CCDirector::getWinSize(v4, &v32);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v35, 0.0, 0.0, 80.0, 80.0);
v6 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v5);
v7 = *v6;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v34, 360.0, 260.0);
(*(void (__fastcall **)(__int64 *, __int64))(v7 + 312))(v6, v8);
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v6,
0xFFFFFFFFLL);
v9 = *v6;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v34, v32 * 0.5, v33 * 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v9 + 184))(v6, v10);
v11 = cocos2d::CCLabelBMFont::create("Select Premade", (const char *)&qword_140704F78);
v12 = *(_QWORD *)v11;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v34, v32 * 0.5, (float)((float)(v33 * 0.5) + 130.0) - 20.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v12 + 184))(v11, v13);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v11);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v11 + 160LL))(v11);
v15 = cocos2d::CCMenu::create(v14);
*(_QWORD *)(a1 + 552) = v15;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v15, 10);
v16 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v34, v32 * 0.5, (float)((float)(v33 * 0.5) + 22.5) + 50.0);
cocos2d::CCNode::convertToNodeSpace(v16, &v36, v17);
for ( i = 0; i < 2; ++i )
{
v39 = 0;
v40 = 1;
v19 = 15;
v41 = 15;
LOWORD(v39) = 45;
if ( i )
{
if ( i != 1 )
goto LABEL_8;
v40 = 11;
memmove(&v39, "Homing\nBall", 0xBu);
BYTE11(v39) = 0;
}
else
{
v40 = 14;
memmove(&v39, "Homing\nMissile", 0xEu);
BYTE14(v39) = 0;
}
v19 = v41;
LABEL_8:
v20 = &v39;
if ( v19 > 0xF )
v20 = (__int128 *)v39;
v38 = operator new(0x2C8u);
v21 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v38);
if ( v21 )
{
if ( ButtonSprite::init_1(
(__int64)v21,
(__int64)v20,
40,
0,
1061997773,
1,
"goldFont.fnt",
(__int64)"GJ_button_04.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v21);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v21 + 8LL))(v21, 1);
v21 = nullptr;
}
}
v37 = operator new(0x208u);
v22 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v37);
if ( v22 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v22, (__int64 *)v21, 0, a1, (__int64)sub_14059E710) )
{
cocos2d::CCObject::autorelease(v22);
goto LABEL_19;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v22 + 8LL))(v22, 1);
}
v22 = nullptr;
LABEL_19:
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v22);
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v22 + 64LL))(v22, (unsigned int)i);
v23 = floorf((float)(i / 3)) * -45.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v35, (float)((float)((float)(i % 3) * 110.0) - 110.0) + 55.0, v23);
cocos2d::CCPoint::operator+(&v36, &v34, v24);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64 *))(*(_QWORD *)v22 + 184LL))(v22, &v34);
if ( v41 > 0xF )
{
v25 = (void *)v39;
if ( v41 + 1 >= 0x1000 )
{
v25 = *(void **)(v39 - 8);
if ( (unsigned __int64)(v39 - (_QWORD)v25 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v25);
}
}
v35[0] = (__int64)operator new(0x2C8u);
v26 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite(v35[0]);
if ( v26 )
{
if ( ButtonSprite::init_1(
(__int64)v26,
(__int64)"Cancel",
40,
0,
1061997773,
1,
"goldFont.fnt",
(__int64)"GJ_button_01.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v26);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v26 + 8LL))(v26, 1);
v26 = nullptr;
}
}
v35[0] = (__int64)operator new(0x208u);
v27 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v35[0]);
if ( v27 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v27, (__int64 *)v26, 0, a1, (__int64)PagedListPopup::onClose) )
{
cocos2d::CCObject::autorelease(v27);
goto LABEL_34;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v27 + 8LL))(v27, 1);
}
v27 = nullptr;
LABEL_34:
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v27);
v28 = *(_QWORD *)v27;
v29 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v35, v32 * 0.5, (float)((float)(v33 * 0.5) - 130.0) + 25.0);
cocos2d::CCNode::convertToNodeSpace(v29, &v37, v30);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v28 + 184))(v27, v31);
return 1;
}