//
// DemonFilterSelectLayer::init from 0x100057210 to 0x100057624 (1044 bytes)
//
// 2 xrefs:
// > DemonFilterSelectLayer::create @ 0x100054614
// > ??> @ 0x100772cd8
//
// 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
//
bool __fastcall DemonFilterSelectLayer::init(DemonFilterSelectLayer *a1)
{
_BOOL4 inited; // w0
cocos2d::CCDirector *v3; // x0
cocos2d::extension::CCScale9Sprite *v4; // x21
__n128 v5; // q0
__n128 v6; // q1
cocos2d::CCLabelBMFont *v7; // x21
__n128 v8; // q0
__n128 v9; // q1
__int64 v10; // x0
cocos2d::CCArray *v11; // x0
__int64 v12; // x0
cocos2d::CCArray *v13; // x22
cocos2d::CCMenu *v14; // x0
GameLevelManager *v15; // x0
int IntForKey; // w23
cocos2d::CCObject *v17; // x21
int i; // w24
__int64 v19; // x27
cocos2d::CCString *v20; // x0
const char *CString; // x0
std::string *v22; // x0
cocos2d::CCSprite *v23; // x28
CCMenuItemSpriteExtra *v24; // x28
__n128 v25; // q0
__n128 v26; // q0
__n128 v27; // q1
cocos2d::CCMenu *m_buttonMenu; // x23
cocos2d::CCNode *v29; // x0
CCMenuItemSpriteExtra *v30; // x23
__n128 v31; // q0
cocos2d::CCMenu *v32; // x22
__n128 v33; // q1
bool v35; // [xsp+14h] [xbp-8Ch]
cocos2d::CCPoint v36; // [xsp+18h] [xbp-88h] BYREF
std::string v37; // [xsp+20h] [xbp-80h] BYREF
float v38; // [xsp+38h] [xbp-68h]
float v39; // [xsp+3Ch] [xbp-64h]
cocos2d::CCPoint v40; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v41; // 0:x3.16
cocos2d::SEL_MenuHandler v42; // 0:x3.16
cocos2d::CCPoint v43; // 0:s1.4,4:s2.4
cocos2d::CCRect v44; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
inited = FLAlertLayer::init_1(a1, 75);
if ( !inited )
return inited;
v35 = inited;
v3 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v3);
sub_100022990((float *)&v37, 0.0, 0.0, 80.0, 80.0);
v4 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v44);
sub_100022988((float *)&v37, 380.0, 180.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v4->setContentSize)(v4, &v37);
v5 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v4,
0xFFFFFFFFLL);
v5.n128_f32[0] = v38 * 0.5;
v6.n128_f32[0] = v39 * 0.5;
sub_100022980(v5, v6, &v37);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v4->setPosition)(v4, &v37);
v7 = cocos2d::CCLabelBMFont::create_1("Demon Filter", "bigFont.fnt");
v8.n128_f32[0] = v38 * 0.5;
v9.n128_f32[0] = (float)((float)(v39 * 0.5) + 90.0) + -20.0;
sub_100022980(v8, v9, &v37);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string *))v7->setPosition)(v7, &v37);
v10 = ((__int64 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(
a1->m_mainLayer,
v7);
v11 = (cocos2d::CCArray *)sub_10024A15C(v10);
a1->m_demons = v11;
cocos2d::CCObject::retain(v11);
v13 = (cocos2d::CCArray *)sub_10024A15C(v12);
v14 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v14;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v14,
10);
v15 = GameLevelManager::sharedState();
IntForKey = GameLevelManager::getIntForKey(v15, "demon_filter");
v17 = nullptr;
for ( i = 0; i != 6; ++i )
{
v19 = 6;
if ( i > 1 )
{
switch ( i )
{
case 2:
v19 = 8;
break;
case 4:
v19 = 9;
break;
case 5:
v19 = 10;
break;
}
LABEL_13:
memset(&v37, 0, sizeof(v37));
v20 = (cocos2d::CCString *)sub_100268F4C("difficulty_%02d_btn2_001.png", v19);
CString = cocos2d::CCString::getCString(v20);
std::string::assign(&v37, CString);
goto LABEL_14;
}
if ( i )
{
if ( i == 1 )
v19 = 7;
goto LABEL_13;
}
memset(&v37, 0, sizeof(v37));
std::string::assign(&v37, "difficulty_06_btn_001.png");
v19 = 0;
LABEL_14:
if ( (v37.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v22 = &v37;
else
v22 = (std::string *)v37.__r_.__value_.__r.__words[0];
v23 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v22);
((void (__fastcall *)(cocos2d::CCSprite *, float))v23->setScale)(v23, 1.1);
v41.ptr = (void (__cdecl *)(cocos2d::CCObject *))DemonFilterSelectLayer::selectRating;
v41.adj = 0;
v24 = CCMenuItemSpriteExtra::create(v23, nullptr, a1, v41);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v24);
v25 = sub_10024A2D0(a1->m_demons, v24);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64, __n128))v24->setTag)(v24, v19, v25);
v26 = sub_10024A2D0(v13, v24);
if ( (_DWORD)v19 == IntForKey )
v17 = v24;
if ( SHIBYTE(v37.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v37.__r_.__value_.__l.__data_);
}
m_buttonMenu = a1->m_buttonMenu;
v26.n128_f32[0] = v38 * 0.5;
v27.n128_f32[0] = (float)(v39 * 0.5) + 3.0;
sub_100022980(v26, v27, &v36);
LODWORD(v43.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v36).y);
GameToolbox::alignItemsHorisontally(v13, 18.0, v43, (bool)&v37);
sub_10024A45C(v13);
v29 = (cocos2d::CCNode *)sub_10005F294("OK");
v42.ptr = (void (__cdecl *)(cocos2d::CCObject *))DemonFilterSelectLayer::onClose;
v42.adj = 0;
v30 = CCMenuItemSpriteExtra::create(v29, nullptr, a1, v42);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v30);
v31 = sub_10024A2D0(v13, v30);
v32 = a1->m_buttonMenu;
v31.n128_f32[0] = v38 * 0.5;
v33.n128_f32[0] = (float)((float)(v39 * 0.5) + -90.0) + 25.0;
sub_100022980(v31, v33, &v36);
v40 = cocos2d::CCNode::convertToNodeSpace(v32, &v36);
((void (__fastcall *)(CCMenuItemSpriteExtra *, std::string *, float, float))v30->setPosition)(v30, &v37, v40.x, v40.y);
if ( v17 )
DemonFilterSelectLayer::selectRating(a1, v17);
LOBYTE(inited) = v35;
return inited;
}