//
// DemonFilterSelectLayer::init from 0x140317950 to 0x140317f88 (1592 bytes)
//
// 5 xrefs:
// > LevelSearchLayer::onSpecialDemon @ 0x14030e24b
// > LevelSearchLayer::onSpecialDemon @ 0x14030e252
// > LevelSearchLayer::onSpecialDemon @ 0x14030e23c
// > ??> @ 0x14058b728
// > ??> @ 0x1406d49b8
//
// 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 DemonFilterSelectLayer::init(DemonFilterSelectLayer *a1)
{
bool result; // al
__int64 v3; // rcx
cocos2d::CCDirector *v4; // rax
struct cocos2d::CCRect *v5; // rax
struct cocos2d::extension::CCScale9Sprite *v6; // rdi
cocos2d::extension::CCScale9Sprite_vtbl *v7; // rbx
const cocos2d::CCSize *v8; // rax
float v9; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v10; // rbx
double v11; // xmm0_8
const cocos2d::CCPoint *v12; // rax
struct cocos2d::CCLabelBMFont *v13; // rdi
cocos2d::CCLabelBMFont_vtbl *v14; // rbx
const cocos2d::CCPoint *v15; // rax
__int64 v16; // rcx
cocos2d::CCArray *v17; // rax
__int64 v18; // rcx
cocos2d::CCArray *v19; // r13
__int64 v20; // rcx
cocos2d::CCMenu *v21; // rax
__int64 v22; // rcx
cocos2d::CCString *v23; // rax
void *v24; // rcx
CCMenuItemSpriteExtra *v25; // rdi
int i; // ebx
CCMenuItemSpriteExtra *v27; // r12
unsigned int v28; // esi
float v29; // xmm0_4
char *v30; // rax
cocos2d::CCString *v31; // rax
char *CString; // rax
size_t v33; // r8
void **v34; // rcx
struct cocos2d::CCSprite *v35; // r14
void *v36; // rcx
double v37; // xmm0_8
struct cocos2d::CCPoint v38; // rax
ButtonSprite *v39; // rbx
CCMenuItemSpriteExtra *v40; // rsi
CCMenuItemSpriteExtra_vtbl *v41; // rbx
struct cocos2d::CCPoint v42; // rax
float v43; // [rsp+48h] [rbp-49h]
cocos2d::CCSize v44; // [rsp+50h] [rbp-41h] BYREF
cocos2d::CCRect v45; // [rsp+58h] [rbp-39h] BYREF
void *Block[2]; // [rsp+68h] [rbp-29h] BYREF
__int64 v47; // [rsp+78h] [rbp-19h]
unsigned __int64 v48; // [rsp+80h] [rbp-11h]
result = FLAlertLayer::init_1(a1, 75);
if ( !result )
return result;
v4 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v3);
cocos2d::CCDirector::getWinSize(v4);
cocos2d::CCRect::CCRect(&v45, 0.0, 0.0, 80.0, 80.0);
v6 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v5);
v7 = v6->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize(&v44, 380.0, 180.0);
v7->setContentSize(v6, v8);
v9 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v6,
0xFFFFFFFFLL);
v10 = v6->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v11 = cocos2d::CCPoint::CCPoint(v9, v43 * 0.5);
v10->setPosition_0(v6, v12);
v13 = cocos2d::CCLabelBMFont::create("Demon Filter", (const char *)&qword_14052A4D8);
v14 = v13->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v11, v43 * 0.5);
v14->setPosition_0(v13, v15);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v13);
v17 = (cocos2d::CCArray *)cocos2d::CCArray::create(v16);
a1->m_demons = v17;
cocos2d::CCObject::retain(v17);
v19 = (cocos2d::CCArray *)cocos2d::CCArray::create(v18);
v21 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v20);
a1->m_buttonMenu = v21;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v21, 10);
v22 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v44 = (cocos2d::CCSize)operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280(*(_QWORD *)&v44);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v22 = qword_1406C2EC0;
}
v47 = 12;
v48 = 15;
strcpy((char *)Block, "demon_filter");
BYTE5(Block[1]) = 0;
HIWORD(Block[1]) = 0;
v23 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v22 + 344), Block);
LODWORD(v44.width) = cocos2d::CCString::intValue(v23);
if ( v48 > 0xF )
{
v24 = Block[0];
if ( v48 + 1 >= 0x1000 )
{
v24 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v24 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v24);
}
v25 = nullptr;
for ( i = 0; i <= 5; ++i )
{
v27 = v25;
v28 = 6;
switch ( i )
{
case 0:
v28 = 0;
break;
case 1:
v28 = 7;
break;
case 2:
v28 = 8;
break;
case 4:
v28 = 9;
break;
case 5:
v28 = 10;
break;
default:
break;
}
v29 = 0.0;
*(_OWORD *)Block = 0;
v47 = 0;
v48 = 15;
LOBYTE(Block[0]) = 0;
if ( i )
{
v31 = cocos2d::CCString::createWithFormat("difficulty_%02d_btn2_001.png", v28);
CString = (char *)cocos2d::CCString::getCString(v31);
v33 = -1;
do
++v33;
while ( CString[v33] );
sub_14003CCE0(Block, CString, v33);
v30 = (char *)Block[0];
}
else
{
v30 = (char *)sub_14003AA10(0x20u);
v47 = 25;
v48 = 31;
strcpy(v30, "difficulty_06_btn_001.png");
v29 = 6.4164041e-10;
Block[0] = v30;
}
v34 = Block;
if ( v48 > 0xF )
v34 = (void **)v30;
v35 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v34);
((void (__fastcall *)(struct cocos2d::CCSprite *))v35->setScale_0)(v35);
v45.origin = (cocos2d::CCPoint)operator new(0x208u);
v25 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(*(CCMenuItemSpriteExtra **)&v45.origin);
if ( v25 )
{
if ( CCMenuItemSpriteExtra::init(
v25,
v35,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)DemonFilterSelectLayer::selectRating) )
{
cocos2d::CCObject::autorelease(v25);
goto LABEL_28;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v25->~CCMenuItemSpriteExtra)(v25, 1);
}
v25 = nullptr;
LABEL_28:
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v25);
cocos2d::CCArray::addObject(a1->m_demons, v25);
v25->setTag(v25, v28);
cocos2d::CCArray::addObject(v19, v25);
if ( v28 != LODWORD(v44.width) )
v25 = v27;
if ( v48 > 0xF )
{
v36 = Block[0];
if ( v48 + 1 >= 0x1000 )
{
v36 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v36 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v36);
}
}
v37 = cocos2d::CCPoint::CCPoint(v29, v43 * 0.5);
v38 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v44);
GameToolbox::alignItemsHorisontally(v19, 18.0, v38, 0);
cocos2d::CCArray::removeAllObjects(v19);
v39 = ButtonSprite::create_1("OK", 0, 0, 1.0, 0, "goldFont.fnt", "GJ_button_01.png", 0.0);
v45.origin = (cocos2d::CCPoint)operator new(0x208u);
v40 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(*(CCMenuItemSpriteExtra **)&v45.origin);
if ( v40 )
{
if ( CCMenuItemSpriteExtra::init(v40, v39, nullptr, a1, (cocos2d::SEL_MenuHandler *)DemonFilterSelectLayer::onClose) )
{
cocos2d::CCObject::autorelease(v40);
goto LABEL_41;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v40->~CCMenuItemSpriteExtra)(v40, 1);
}
v40 = nullptr;
LABEL_41:
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v40);
cocos2d::CCArray::addObject(v19, v40);
v41 = v40->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v37, v43 * 0.5);
v42 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v44);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v41->setPosition_0)(v40, v42);
if ( v25 )
DemonFilterSelectLayer::selectRating(a1, v25);
return 1;
}