//
// SelectSettingLayer::init from 0x14045c400 to 0x14045cb21 (1825 bytes)
//
// 2 xrefs:
// > SelectSettingLayer::create @ 0x14045c3af
// > ??> @ 0x140927d40
//
// 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:32:32 +0000
//
// Hidden C++ exception states: #wind=4
char __fastcall SelectSettingLayer::init(__int64 a1, int a2, int a3)
{
__int64 v6; // rax
__int64 v7; // rcx
__int64 v8; // rax
__int64 v9; // rcx
unsigned int v10; // r14d
int v11; // ebx
int v12; // ebx
int v13; // ebx
__int64 v14; // rax
__int64 v15; // rbx
__int64 v16; // rax
__int64 v17; // rdx
unsigned int v18; // eax
const char *v19; // r15
int v20; // r13d
float v21; // xmm7_4
__int64 v22; // rdx
__int64 v23; // rax
__int64 *v24; // rdi
__int64 v25; // rbx
__int64 v26; // rax
__int64 v27; // rbx
__int64 v28; // rax
struct cocos2d::CCLabelBMFont *v29; // rdi
__int64 v30; // rbx
__int64 v31; // rax
__int64 v32; // rcx
cocos2d::CCObject *v33; // rax
__int64 v34; // rcx
unsigned int i; // r15d
const char *v36; // rcx
struct cocos2d::CCSprite *v37; // rbx
__int64 *v38; // rdi
__int64 v39; // rdx
float v40; // xmm0_4
__int64 v41; // rax
cocos2d::CCObject *v42; // rbx
cocos2d::CCObject *v43; // r15
__int64 v44; // rdi
__int64 v45; // rbx
__int64 v46; // rax
__int64 v47; // rax
char *v48; // rcx
void (__fastcall **v49)(char *, cocos2d::CCArray **); // r8
cocos2d::CCArray **v50; // rdx
cocos2d::CCArray *v52; // [rsp+58h] [rbp-B0h] BYREF
float v53; // [rsp+60h] [rbp-A8h] BYREF
float v54; // [rsp+64h] [rbp-A4h]
__int16 v55; // [rsp+68h] [rbp-A0h]
_BYTE v56[12]; // [rsp+6Ch] [rbp-9Ch] BYREF
__int64 v57[2]; // [rsp+78h] [rbp-90h] BYREF
char v58[8]; // [rsp+88h] [rbp-80h] BYREF
void *v59; // [rsp+90h] [rbp-78h] BYREF
_QWORD v60[4]; // [rsp+98h] [rbp-70h] BYREF
LODWORD(v52) = -1778384896;
if ( !cocos2d::CCLayerColor::initWithColor((cocos2d::CCLayerColor *)a1, (const struct cocos2d::_ccColor4B *)&v52) )
return 0;
FLAlertLayer::incrementForcePrio((struct cocos2d::CCObject *)a1);
v6 = cocos2d::CCLayer::create();
*(_QWORD *)(a1 + 584) = v6;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v6);
v8 = cocos2d::CCMenu::create(v7);
*(_QWORD *)(a1 + 552) = v8;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v8, 10);
*(_DWORD *)(a1 + 676) = a2;
v10 = 0;
if ( a2 != 2 )
goto LABEL_13;
if ( a3 )
{
v11 = a3 - 1;
if ( !v11 )
{
a3 = 0;
goto LABEL_13;
}
v12 = v11 - 1;
if ( !v12 )
{
a3 = 2;
goto LABEL_13;
}
v13 = v12 - 1;
if ( !v13 )
{
a3 = 3;
goto LABEL_13;
}
if ( v13 == 1 )
{
a3 = 4;
goto LABEL_13;
}
}
a3 = 1;
LABEL_13:
*(_DWORD *)(a1 + 672) = a3;
v14 = cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::getWinSize(v14, &v53);
v15 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v56, v53 * 0.5, (float)(v54 * 0.5) + 5.0);
cocos2d::CCNode::convertToNodeSpace(v15, v58, v16);
v18 = *(_DWORD *)(a1 + 676);
if ( v18 < 2 )
{
v19 = "Select Mode";
v20 = 8;
v21 = 42.0;
goto LABEL_17;
}
if ( v18 != 2 )
return 0;
v19 = "Select Speed";
v20 = 5;
v21 = 60.0;
LABEL_17:
LOBYTE(v17) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 920LL))(a1, v17);
LOBYTE(v22) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 992LL))(a1, v22);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v57, 0.0, 0.0, 80.0, 80.0);
v24 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v23);
v25 = *v24;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v56, 360.0, 160.0);
(*(void (__fastcall **)(__int64 *, __int64))(v25 + 312))(v24, v26);
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v24,
0xFFFFFFFFLL);
v27 = *v24;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v56, v53 * 0.5, v54 * 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v27 + 184))(v24, v28);
v29 = cocos2d::CCLabelBMFont::create(v19, (const char *)&qword_140704F78);
v30 = *(_QWORD *)v29;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v56, v53 * 0.5, (float)((float)(v54 * 0.5) + 80.0) - 20.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v30 + 184))(v29, v31);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v29);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v29 + 160LL))(v29);
v33 = (cocos2d::CCObject *)cocos2d::CCArray::create(v32);
*(_QWORD *)(a1 + 664) = v33;
cocos2d::CCObject::retain(v33);
v52 = (cocos2d::CCArray *)cocos2d::CCArray::create(v34);
for ( i = 0; (int)i < v20; ++i )
{
SelectSettingLayer::frameForItem(v60, *(unsigned int *)(a1 + 676), i);
v36 = (const char *)v60;
if ( v60[3] > 0xFu )
v36 = (const char *)v60[0];
v37 = cocos2d::CCSprite::createWithSpriteFrameName(v36);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 664), v37);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v37 + 160LL))(v37);
v59 = operator new(0x208u);
v38 = (__int64 *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v59);
if ( !v38 )
goto LABEL_24;
if ( !CCMenuItemSpriteExtra::init(v38, (__int64 *)v37, 0, a1, (__int64)SelectSettingLayer::onSelect) )
{
(*(void (__fastcall **)(__int64 *, __int64))(*v38 + 8))(v38, 1);
LABEL_24:
v38 = nullptr;
goto LABEL_25;
}
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v38);
LABEL_25:
if ( a2 == 1 && (i == 4 || i == 7) )
{
(*(void (__fastcall **)(__int64 *, _QWORD))(*v38 + 936))(v38, 0);
LOBYTE(v39) = 125;
(*(void (__fastcall **)(__int64, __int64))(*((_QWORD *)v37 + 40) + 40LL))((__int64)v37 + 320, v39);
}
(*(void (__fastcall **)(__int64 *, _QWORD))(*v38 + 64))(v38, i);
(*(void (__fastcall **)(_QWORD, __int64 *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v38);
cocos2d::CCArray::addObject(v52, (struct cocos2d::CCObject *)v38);
v40 = floorf((float)(int)(i / v20)) * -35.0;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v57,
(float)((float)((float)(int)(i % v20) * v21) - (float)((float)((float)v20 * 0.5) * v21)) + (float)(v21 * 0.5),
v40);
cocos2d::CCPoint::operator+(v58, v56, v41);
(*(void (__fastcall **)(__int64 *, _BYTE *))(*v38 + 184))(v38, v56);
sub_14003D310((__int64)v60);
}
*(_DWORD *)(a1 + 640) = -1;
cocos2d::CCArray::removeAllObjects(v52);
v57[0] = (__int64)operator new(0x2C8u);
v42 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite(v57[0]);
if ( v42 )
{
if ( ButtonSprite::init_1(
(__int64)v42,
(__int64)"OK",
40,
0,
1061997773,
1,
"goldFont.fnt",
(__int64)"GJ_button_01.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v42);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v42 + 8LL))(v42, 1);
v42 = nullptr;
}
}
v57[0] = (__int64)operator new(0x208u);
v43 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v57[0]);
if ( v43 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v43, (__int64 *)v42, 0, a1, (__int64)SelectSettingLayer::onClose) )
{
cocos2d::CCObject::autorelease(v43);
goto LABEL_39;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v43 + 8LL))(v43, 1);
}
v43 = nullptr;
LABEL_39:
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v43);
v44 = *(_QWORD *)v43;
v45 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v57, v53 * 0.5, (float)((float)(v54 * 0.5) - 80.0) + 25.0);
cocos2d::CCNode::convertToNodeSpace(v45, &v59, v46);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v44 + 184))(v43, v47);
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 664)) )
{
do
{
v48 = (char *)cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 664), v10) + 320;
v49 = *(void (__fastcall ***)(char *, cocos2d::CCArray **))v48;
if ( *(_DWORD *)(a1 + 672) == v10 )
{
v50 = (cocos2d::CCArray **)&unk_1407044BC;
}
else
{
v55 = 32125;
memset(&v52, 125, 3);
v50 = &v52;
}
(*v49)(v48, v50);
++v10;
}
while ( v10 < cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 664)) );
}
*(_BYTE *)(a1 + 596) = 1;
return 1;
}