//
// SelectSettingLayer::init from 0x140323220 to 0x140323961 (1857 bytes)
//
// 2 xrefs:
// > SelectSettingLayer::create @ 0x1403231d1
// > ??> @ 0x1406d4d3c
//
// 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
//
// Hidden C++ exception states: #wind=4
bool SelectSettingLayer::init(SelectSettingLayer *a1, SelectSettingType a2, int a3)
{
float v3; // xmm0_4
__int64 v7; // rcx
int v8; // edi
__int64 v9; // rax
cocos2d::CCTouchDispatcher *v10; // rax
cocos2d::CCLayer *v11; // rax
__int64 v12; // rcx
cocos2d::CCMenu *v13; // rax
__int64 v14; // rcx
unsigned int v15; // r14d
int v16; // ebx
int v17; // ebx
int v18; // ebx
cocos2d::CCDirector *v19; // rax
_BOOL8 v20; // rdx
SelectSettingType m_type; // eax
const char *v22; // r15
int v23; // r12d
float v24; // xmm7_4
_BOOL8 v25; // rdx
struct cocos2d::CCRect *v26; // rax
struct cocos2d::extension::CCScale9Sprite *v27; // rdi
cocos2d::extension::CCScale9Sprite_vtbl *v28; // rbx
const cocos2d::CCSize *v29; // rax
float v30; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v31; // rbx
double v32; // xmm0_8
const cocos2d::CCPoint *v33; // rax
struct cocos2d::CCLabelBMFont *v34; // rdi
cocos2d::CCLabelBMFont_vtbl *v35; // rbx
const cocos2d::CCPoint *v36; // rax
__int64 v37; // rcx
cocos2d::CCArray *v38; // rax
__int64 v39; // rcx
unsigned int i; // r15d
const char *v41; // rcx
struct cocos2d::CCSprite *v42; // rbx
CCMenuItemSpriteExtra *v43; // rdi
__int64 v44; // rdx
float v45; // xmm0_4
ButtonSprite *v46; // rbx
CCMenuItemSpriteExtra *v47; // rdi
float v48; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v49; // rbx
struct cocos2d::CCPoint v50; // rax
int *p_m_unknown2; // rcx
void (__fastcall **v52)(char *, cocos2d::CCArray **); // r8
cocos2d::CCArray **v53; // rdx
cocos2d::CCArray *v55; // [rsp+58h] [rbp-B0h] BYREF
float v56; // [rsp+60h] [rbp-A8h]
__int16 v57; // [rsp+68h] [rbp-A0h]
cocos2d::CCSize v58; // [rsp+6Ch] [rbp-9Ch] BYREF
cocos2d::CCRect v59; // [rsp+78h] [rbp-90h] BYREF
struct cocos2d::CCPoint v60; // [rsp+88h] [rbp-80h] BYREF
CCMenuItemSpriteExtra *v61; // [rsp+90h] [rbp-78h] BYREF
_QWORD v62[4]; // [rsp+98h] [rbp-70h] BYREF
LODWORD(v55) = -1778384896;
if ( !cocos2d::CCLayerColor::initWithColor(a1, (const struct cocos2d::_ccColor4B *)&v55) )
return 0;
v8 = 2;
if ( !a1->m_forcePrioRegistered )
{
a1->m_forcePrioRegistered = 1;
v9 = cocos2d::CCDirector::sharedDirector(v7);
v10 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 144LL))(v9);
cocos2d::CCTouchDispatcher::registerForcePrio(v10, a1, 2);
}
v11 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
a1->m_mainLayer = v11;
a1->addChild_1(a1, v11);
v13 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v12);
a1->m_buttonMenu = v13;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v13, 10);
a1->m_type = a2;
v15 = 0;
if ( a2 == StartingSpeed )
{
if ( !a3 )
{
LABEL_10:
v8 = 1;
goto LABEL_15;
}
v16 = a3 - 1;
if ( v16 )
{
v17 = v16 - 1;
if ( !v17 )
goto LABEL_15;
v18 = v17 - 1;
if ( v18 )
{
if ( v18 != 1 )
goto LABEL_10;
v8 = 4;
}
else
{
v8 = 3;
}
}
else
{
v8 = 0;
}
}
else
{
v8 = a3;
}
LABEL_15:
a1->m_settingID = v8;
v19 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v14);
cocos2d::CCDirector::getWinSize(v19);
cocos2d::CCPoint::CCPoint(v3, v56 * 0.5);
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v60);
m_type = a1->m_type;
if ( (unsigned int)m_type < StartingSpeed )
{
v22 = "Select Mode";
v23 = 8;
v24 = 42.0;
goto LABEL_19;
}
if ( m_type != StartingSpeed )
return 0;
v22 = "Select Speed";
v23 = 5;
v24 = 60.0;
LABEL_19:
LOBYTE(v20) = 1;
a1->setTouchEnabled(a1, v20);
LOBYTE(v25) = 1;
a1->setKeypadEnabled(a1, v25);
cocos2d::CCRect::CCRect(&v59, 0.0, 0.0, 80.0, 80.0);
v27 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v26);
v28 = v27->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize(&v58, 360.0, 160.0);
v28->setContentSize(v27, v29);
v30 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v27,
0xFFFFFFFFLL);
v31 = v27->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v32 = cocos2d::CCPoint::CCPoint(v30, v56 * 0.5);
v31->setPosition_0(v27, v33);
v34 = cocos2d::CCLabelBMFont::create(v22, (const char *)&qword_14052A4D8);
v35 = v34->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v32, v56 * 0.5);
v35->setPosition_0(v34, v36);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v34);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v34->setScale_0)(v34);
v38 = (cocos2d::CCArray *)cocos2d::CCArray::create(v37);
a1->m_settingSprites = v38;
cocos2d::CCObject::retain(v38);
v55 = (cocos2d::CCArray *)cocos2d::CCArray::create(v39);
for ( i = 0; (int)i < v23; ++i )
{
SelectSettingLayer::frameForItem(v62, (unsigned int)a1->m_type, i);
v41 = (const char *)v62;
if ( v62[3] > 0xFu )
v41 = (const char *)v62[0];
v42 = cocos2d::CCSprite::createWithSpriteFrameName(v41);
cocos2d::CCArray::addObject(a1->m_settingSprites, v42);
((void (__fastcall *)(struct cocos2d::CCSprite *))v42->setScale_0)(v42);
v61 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v43 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v61);
if ( !v43 )
goto LABEL_26;
if ( !CCMenuItemSpriteExtra::init(v43, v42, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectSettingLayer::onSelect) )
{
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v43->~CCMenuItemSpriteExtra)(v43, 1);
LABEL_26:
v43 = nullptr;
goto LABEL_27;
}
cocos2d::CCObject::autorelease(v43);
LABEL_27:
if ( a2 == StartingModePlatformer && (i == 4 || i == 7) )
{
v43->setEnabled(v43, 0);
LOBYTE(v44) = 125;
v42->setOpacity(&v42->cocos2d::CCRGBAProtocol, v44);
}
v43->setTag(v43, i);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v43);
cocos2d::CCArray::addObject(v55, v43);
v45 = floorf((float)(int)(i / v23)) * -35.0;
cocos2d::CCPoint::CCPoint(
v45,
(float)((float)((float)(int)(i % v23) * v24) - (float)((float)((float)v23 * 0.5) * v24)) + (float)(v24 * 0.5));
cocos2d::CCPoint::operator+(&v60, &v58);
v43->setPosition_0(v43, (const cocos2d::CCPoint *)&v58);
sub_14003A830((__int64)v62);
}
a1->m_joystickConnected = -1;
cocos2d::CCArray::removeAllObjects(v55);
v59.origin = (cocos2d::CCPoint)operator new(0x2C0u);
v46 = ButtonSprite::ButtonSprite(*(ButtonSprite **)&v59.origin);
if ( v46 )
{
if ( ButtonSprite::init_1(v46, "OK", 40, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v46);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v46->~ButtonSprite)(v46, 1);
v46 = nullptr;
}
}
v59.origin = (cocos2d::CCPoint)operator new(0x208u);
v47 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(*(CCMenuItemSpriteExtra **)&v59.origin);
if ( v47 )
{
if ( CCMenuItemSpriteExtra::init(v47, v46, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectSettingLayer::onClose) )
{
cocos2d::CCObject::autorelease(v47);
goto LABEL_41;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v47->~CCMenuItemSpriteExtra)(v47, 1);
}
v47 = nullptr;
LABEL_41:
v48 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v47);
v49 = v47->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v48, v56 * 0.5);
v50 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v61);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v49->setPosition_0)(v47, v50);
if ( cocos2d::CCArray::count(a1->m_settingSprites) )
{
do
{
p_m_unknown2 = &cocos2d::CCArray::objectAtIndex(a1->m_settingSprites, v15)[5].m_unknown2;
v52 = *(void (__fastcall ***)(char *, cocos2d::CCArray **))p_m_unknown2;
if ( a1->m_settingID == v15 )
{
v53 = (cocos2d::CCArray **)&unk_140529B78;
}
else
{
v57 = 32125;
memset(&v55, 125, 3);
v53 = &v55;
}
(*v52)((char *)p_m_unknown2, v53);
++v15;
}
while ( v15 < cocos2d::CCArray::count(a1->m_settingSprites) );
}
a1->m_noElasticity = 1;
return 1;
}