//
// SelectListIconLayer::init from 0x1403091e0 to 0x1403099cb (2027 bytes)
//
// 2 xrefs:
// > LevelListLayer::onSelectIcon @ 0x140307d87
// > ??> @ 0x1406d45f8
//
// 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 SelectListIconLayer::init(SelectListIconLayer *a1, int a2)
{
unsigned int v4; // esi
bool result; // al
_BOOL8 v6; // rdx
__int64 v7; // rcx
__int64 v8; // rax
cocos2d::CCTouchDispatcher *v9; // rax
_BOOL8 v10; // rdx
__int64 v11; // rcx
cocos2d::CCDirector *v12; // rax
cocos2d::CCLayer *v13; // rax
struct cocos2d::CCRect *v14; // rax
struct cocos2d::extension::CCScale9Sprite *v15; // rdi
cocos2d::extension::CCScale9Sprite_vtbl *v16; // rbx
const cocos2d::CCSize *v17; // rax
float v18; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v19; // rbx
double v20; // xmm0_8
const cocos2d::CCPoint *v21; // rax
struct cocos2d::CCLabelBMFont *v22; // rdi
cocos2d::CCLabelBMFont_vtbl *v23; // rbx
const cocos2d::CCPoint *v24; // rax
__int64 v25; // rcx
cocos2d::CCArray *v26; // rax
__int64 v27; // rcx
cocos2d::CCArray *v28; // r13
__int64 v29; // rcx
cocos2d::CCMenu *v30; // rax
float v31; // xmm0_4
int v32; // edi
bool v33; // zf
unsigned int v34; // ebx
int v35; // edx
cocos2d::CCString *v36; // rax
const char *CString; // rax
size_t v38; // r8
const char *v39; // rcx
struct cocos2d::CCSprite *v40; // r12
CCMenuItemSpriteExtra *v41; // r14
cocos2d::CCString *v42; // rax
float v43; // xmm0_4
void *v44; // rcx
ButtonSprite *v45; // rbx
CCMenuItemSpriteExtra *v46; // rdi
float v47; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v48; // rbx
struct cocos2d::CCPoint v49; // rax
struct cocos2d::CCObject *v50; // rbx
int v51; // eax
void (__fastcall *v52)(int *, __int16 *); // r8
__int16 *v53; // rdx
int v54; // [rsp+58h] [rbp-B0h] BYREF
float v55; // [rsp+60h] [rbp-A8h]
__int16 v56; // [rsp+68h] [rbp-A0h]
cocos2d::CCSize v57; // [rsp+6Ch] [rbp-9Ch] BYREF
cocos2d::CCRect v58; // [rsp+78h] [rbp-90h] BYREF
struct cocos2d::CCPoint v59; // [rsp+88h] [rbp-80h] BYREF
CCMenuItemSpriteExtra *v60; // [rsp+90h] [rbp-78h] BYREF
__int128 v61; // [rsp+98h] [rbp-70h] BYREF
__int64 v62; // [rsp+A8h] [rbp-60h]
unsigned __int64 v63; // [rsp+B0h] [rbp-58h]
v4 = 0;
v54 = -1778384896;
result = cocos2d::CCLayerColor::initWithColor(a1, (const struct cocos2d::_ccColor4B *)&v54);
if ( !result )
return result;
if ( !a1->m_forcePrioRegistered )
{
a1->m_forcePrioRegistered = 1;
v8 = cocos2d::CCDirector::sharedDirector(v7);
v9 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v8 + 144LL))(v8);
cocos2d::CCTouchDispatcher::registerForcePrio(v9, a1, 2);
}
a1->m_currentDifficulty = a2;
LOBYTE(v6) = 1;
a1->setTouchEnabled(a1, v6);
LOBYTE(v10) = 1;
a1->setKeypadEnabled(a1, v10);
v12 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v11);
cocos2d::CCDirector::getWinSize(v12);
v13 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
a1->m_mainLayer = v13;
a1->addChild_1(a1, v13);
cocos2d::CCRect::CCRect(&v58, 0.0, 0.0, 80.0, 80.0);
v15 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v14);
v16 = v15->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize(&v57, 360.0, 240.0);
v16->setContentSize(v15, v17);
v18 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v15,
0xFFFFFFFFLL);
v19 = v15->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v20 = cocos2d::CCPoint::CCPoint(v18, v55 * 0.5);
v19->setPosition_0(v15, v21);
v22 = cocos2d::CCLabelBMFont::create("Select Icon", (const char *)&qword_14052A4D8);
v23 = v22->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v20, v55 * 0.5);
v23->setPosition_0(v22, v24);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v22);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v22->setScale_0)(v22);
v26 = (cocos2d::CCArray *)cocos2d::CCArray::create(v25);
a1->m_difficulties = v26;
cocos2d::CCObject::retain(v26);
v28 = (cocos2d::CCArray *)cocos2d::CCArray::create(v27);
v30 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v29);
a1->m_buttonMenu = v30;
v31 = ((float (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v30,
10);
cocos2d::CCPoint::CCPoint(v31, v55 * 0.5);
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v59);
v32 = 0;
v33 = 0;
do
{
if ( v33 )
{
v34 = -1;
LABEL_7:
v35 = 0;
goto LABEL_8;
}
v34 = v32;
if ( v32 )
{
if ( (unsigned int)v32 > 0xA )
goto LABEL_7;
v35 = v32;
if ( v32 == 6 || v32 == 7 )
{
v35 = v32 + 1;
}
else if ( v32 == 8 )
{
v35 = 6;
goto LABEL_25;
}
if ( v35 <= 5 )
{
LABEL_8:
v36 = cocos2d::CCString::createWithFormat("difficulty_%02d_btn_001.png", v35);
CString = cocos2d::CCString::getCString(v36);
v61 = 0;
v62 = 0;
v63 = 0;
v38 = -1;
do
++v38;
while ( CString[v38] );
LABEL_10:
sub_14003A930(&v61, CString, v38);
goto LABEL_11;
}
LABEL_25:
v42 = cocos2d::CCString::createWithFormat("difficulty_%02d_btn2_001.png", v35);
CString = cocos2d::CCString::getCString(v42);
v61 = 0;
v62 = 0;
v63 = 0;
v38 = -1;
do
++v38;
while ( CString[v38] );
goto LABEL_10;
}
v61 = 0;
v62 = 0;
v63 = 15;
*(_QWORD *)&v61 = sub_14003AA10(0x20u);
v62 = 27;
v63 = 31;
strcpy((char *)v61, "difficulty_auto_btn_001.png");
LABEL_11:
v39 = (const char *)&v61;
if ( v63 > 0xF )
v39 = (const char *)v61;
v40 = cocos2d::CCSprite::createWithSpriteFrameName(v39);
cocos2d::CCArray::addObject(a1->m_difficulties, v40);
((void (__fastcall *)(struct cocos2d::CCSprite *))v40->setScale_0)(v40);
v60 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v41 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v60);
if ( v41 )
{
if ( CCMenuItemSpriteExtra::init(v41, v40, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectListIconLayer::onSelect) )
{
cocos2d::CCObject::autorelease(v41);
goto LABEL_30;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v41->~CCMenuItemSpriteExtra)(v41, 1);
}
v41 = nullptr;
LABEL_30:
v40->setTag(v40, v34);
v41->setTag(v41, v34);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v41);
cocos2d::CCArray::addObject(v28, v41);
v43 = floorf((float)(v32 / 6)) * -60.0;
cocos2d::CCPoint::CCPoint(v43, (float)((float)((float)(v32 % 6) * 52.0) - 156.0) + 26.0);
cocos2d::CCPoint::operator+(&v59, &v57);
v41->setPosition_0(v41, (const cocos2d::CCPoint *)&v57);
if ( v63 > 0xF )
{
v44 = (void *)v61;
if ( v63 + 1 >= 0x1000 )
{
v44 = *(void **)(v61 - 8);
if ( (unsigned __int64)(v61 - (_QWORD)v44 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v44);
}
v33 = ++v32 == 11;
}
while ( v32 <= 11 );
a1->m_joystickConnected = -1;
cocos2d::CCArray::removeAllObjects(v28);
v58.origin = (cocos2d::CCPoint)operator new(0x2C0u);
v45 = ButtonSprite::ButtonSprite(*(ButtonSprite **)&v58.origin);
if ( v45 )
{
if ( ButtonSprite::init_1(v45, "OK", 40, 0, 0.80000001, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v45);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v45->~ButtonSprite)(v45, 1);
v45 = nullptr;
}
}
v58.origin = (cocos2d::CCPoint)operator new(0x208u);
v46 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(*(CCMenuItemSpriteExtra **)&v58.origin);
if ( v46 )
{
if ( CCMenuItemSpriteExtra::init(v46, v45, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectListIconLayer::onClose) )
{
cocos2d::CCObject::autorelease(v46);
goto LABEL_45;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v46->~CCMenuItemSpriteExtra)(v46, 1);
}
v46 = nullptr;
LABEL_45:
v47 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v46);
v48 = v46->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v47, v55 * 0.5);
v49 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v60);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v48->setPosition_0)(v46, v49);
if ( cocos2d::CCArray::count(a1->m_difficulties) )
{
do
{
v50 = cocos2d::CCArray::objectAtIndex(a1->m_difficulties, v4);
v51 = v50->getTag(v50);
v52 = **(void (__fastcall ***)(int *, __int16 *))&v50[5].m_unknown2;
if ( a1->m_currentDifficulty == v51 )
{
v53 = &word_140529B54;
}
else
{
v56 = 32125;
memset(&v54, 125, 3);
v53 = (__int16 *)&v54;
}
v52(&v50[5].m_unknown2, v53);
++v4;
}
while ( v4 < cocos2d::CCArray::count(a1->m_difficulties) );
}
a1->m_noElasticity = 1;
return 1;
}