//
// DemonFilterSelectLayer::init from 0x6cdcac to 0x6ce134 (1160 bytes)
//
// 3 xrefs:
// > DemonFilterSelectLayer::create @ 0x6d5240
// > ??> @ 0x5c448
// > ??> @ 0x115aa20
//
// 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 DemonFilterSelectLayer::init(DemonFilterSelectLayer *a1)
{
char v2; // w27
cocos2d::CCDirector *v4; // x0
__int64 v5; // x21
cocos2d::CCObject *v6; // x24
cocos2d::CCNode *v7; // x19
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x23
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
cocos2d::CCLabelBMFont *v10; // x19
void (__fastcall *v11)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
cocos2d::CCArray *v12; // x0
cocos2d::CCArray *v13; // x0
cocos2d::CCArray *v14; // x0
cocos2d::CCArray *v15; // x26
cocos2d::CCMenu *v16; // x0
cocos2d::CCLayer *m_mainLayer; // x3
GameLevelManager *v18; // x0
unsigned int v19; // w23
cocos2d::CCString *v20; // x0
size_t v21; // x0
cocos2d::CCSprite *v22; // x19
CCMenuItemSpriteExtra *v23; // x19
__int64 *v24; // x0
cocos2d::CCMenu *m_buttonMenu; // x21
const char *v26; // x1
__int64 v27; // x2
__int64 v28; // x3
bool v29; // w4
__int64 v30; // x5
const char *v31; // x6
cocos2d::CCNode *v32; // x0
CCMenuItemSpriteExtra *v33; // x21
cocos2d::CCMenu *v34; // x25
void (__fastcall *v35)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
unsigned int *v36; // x1
int v37; // w2
__int64 v38; // [xsp+0h] [xbp+0h] BYREF
const char *v39; // [xsp+78h] [xbp+78h]
cocos2d::CCPoint *v40; // [xsp+80h] [xbp+80h]
cocos2d::CCString *v41; // [xsp+88h] [xbp+88h]
int IntForKey; // [xsp+94h] [xbp+94h]
const char *CString; // [xsp+98h] [xbp+98h]
float v44; // [xsp+A8h] [xbp+A8h]
float v45; // [xsp+ACh] [xbp+ACh]
cocos2d::CCPoint v46; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCRect v47; // [xsp+B8h] [xbp+B8h] BYREF
cocos2d::CCPoint v48; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v49; // 0:x2.16
cocos2d::SEL_MenuHandler v50; // 0:x2.16
cocos2d::CCPoint v51; // 0:s1.4,4:s2.4
cocos2d::CCRect v52; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v2 = FLAlertLayer::init(a1, 0x4Bu);
if ( v2 )
{
v4 = cocos2d::CCDirector::sharedDirector();
v5 = 0;
v6 = nullptr;
cocos2d::CCDirector::getWinSize(v4);
v40 = &v46;
cocos2d::CCRect::CCRect(&v47, 0.0, 0.0, 80.0, 80.0);
v7 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square01.png",
(const char *)&v47,
v52);
setContentSize = v7->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v47, 380.0, 180.0);
setContentSize(v7, (const cocos2d::CCSize *)&v47);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v7, -1);
setPosition = v7->setPosition;
cocos2d::CCPoint::CCPoint(&v47.origin, v44 * 0.5, v45 * 0.5);
setPosition(v7, &v47.origin);
v10 = cocos2d::CCLabelBMFont::create();
v11 = v10->setPosition;
cocos2d::CCPoint::CCPoint(&v47.origin, v44 * 0.5, (float)((float)(v45 * 0.5) + 90.0) - 20.0);
v11(v10, &v47.origin);
v12 = (cocos2d::CCArray *)((__int64 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(
a1->m_mainLayer,
v10);
v13 = (cocos2d::CCArray *)cocos2d::CCArray::create(v12);
a1->m_demons = v13;
cocos2d::CCObject::retain(v13);
v15 = (cocos2d::CCArray *)cocos2d::CCArray::create(v14);
v16 = cocos2d::CCMenu::create();
m_mainLayer = a1->m_mainLayer;
a1->m_buttonMenu = v16;
m_mainLayer->addChild_0(m_mainLayer, v16, 10);
v18 = GameLevelManager::sharedState();
IntForKey = GameLevelManager::getIntForKey(v18, "demon_filter");
v41 = (cocos2d::CCString *)"difficulty_%02d_btn2_001.png";
v39 = "difficulty_06_btn_001.png";
do
{
v47.origin = (cocos2d::CCPoint)&byte_124B6C8;
v19 = dword_EC8150[v5];
if ( v5 )
{
v20 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(v41, (const char *)v19);
CString = cocos2d::CCString::getCString(v20);
v21 = strlen(CString);
sub_D1798C(&v47, CString, v21);
}
else
{
sub_D1798C(&v47, v39, 25);
}
v22 = cocos2d::CCSprite::createWithSpriteFrameName(*(const char **)&v47.origin);
v22->setScale(v22, 1.1);
v49.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v49.adj = (size_t)DemonFilterSelectLayer::selectRating;
v23 = CCMenuItemSpriteExtra::create(v22, nullptr, v49);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v23);
cocos2d::CCArray::addObject(a1->m_demons, v23);
v23->setTag(v23, v19);
cocos2d::CCArray::addObject(v15, v23);
v24 = (__int64 *)(*(_QWORD *)&v47.origin - 24LL);
if ( v19 == IntForKey )
v6 = v23;
if ( v24 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v36 = (unsigned int *)(*(_QWORD *)&v47.origin - 8LL);
do
v37 = __ldaxr(v36);
while ( __stlxr(v37 - 1, v36) );
}
else
{
v37 = *(_DWORD *)(*(_QWORD *)&v47.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v47.origin - 8LL) = v37 - 1;
}
if ( v37 <= 0 )
operator delete(v24);
}
++v5;
}
while ( v5 != 6 );
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v46, v44 * 0.5, (float)(v45 * 0.5) + 3.0);
LODWORD(v51.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v46).y);
GameToolbox::alignItemsHorisontally(v15, 18.0, v51, (unsigned __int8)&v38 - 72);
cocos2d::CCArray::removeAllObjects(v15);
v32 = (cocos2d::CCNode *)ButtonSprite::create((ButtonSprite *)"OK", v26, v27, v28, v29, v30, v31);
v50.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v50.adj = (size_t)DemonFilterSelectLayer::onClose;
v33 = CCMenuItemSpriteExtra::create(v32, nullptr, v50);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v33);
cocos2d::CCArray::addObject(v15, v33);
v34 = a1->m_buttonMenu;
v35 = v33->setPosition;
cocos2d::CCPoint::CCPoint(&v46, v44 * 0.5, (float)((float)(v45 * 0.5) + -90.0) + 25.0);
v48 = cocos2d::CCNode::convertToNodeSpace(v34, &v46);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v35)(v33, &v47, v48.x, v48.y);
if ( v6 )
DemonFilterSelectLayer::selectRating(a1, v6);
}
return v2;
}