//
// DemonFilterSelectLayer::init from 0x10062f510 to 0x10062f9aa (1178 bytes)
//
// 2 xrefs:
// > DemonFilterSelectLayer::create @ 0x10062b9ba
// > ??> @ 0x100984b18
//
// 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)
{
bool result; // al
cocos2d::extension::CCScale9Sprite *v3; // r14
cocos2d::CCLabelBMFont *v4; // r14
cocos2d::CCLayer *m_mainLayer; // rdi
cocos2d::CCArray *v6; // rax
cocos2d::CCArray *v7; // rdi
cocos2d::CCMenu *v8; // rax
GameLevelManager *v9; // rax
CCMenuItemSpriteExtra *v10; // r15
int v11; // r13d
unsigned int v12; // r14d
cocos2d::CCString *v13; // rax
const char *CString; // rsi
const char *data; // rdi
cocos2d::CCSprite *v16; // r12
CCMenuItemSpriteExtra *v17; // r12
cocos2d::CCMenu *m_buttonMenu; // r14
cocos2d::CCPoint v19; // xmm1_8
cocos2d::CCArray *v20; // r12
ButtonSprite *v21; // rax
CCMenuItemSpriteExtra *v22; // r14
cocos2d::CCMenu *v23; // r12
unsigned int v24; // r14d
__int64 v25; // r15
__int64 v26; // r12
int m_currentDemon; // r13d
void *v28; // rsi
char v29; // [rsp+0h] [rbp-70h]
float v30; // [rsp+8h] [rbp-68h] BYREF
cocos2d::CCArray *v31; // [rsp+10h] [rbp-60h]
int IntForKey; // [rsp+1Ch] [rbp-54h]
std::string v33; // [rsp+20h] [rbp-50h] BYREF
float v34; // [rsp+3Ch] [rbp-34h] BYREF
float v35; // [rsp+40h] [rbp-30h]
bool v36; // [rsp+47h] [rbp-29h]
double v37; // 0:xmm0_8.8
cocos2d::CCRect v38; // 0:xmm0_8.8,8:xmm1_8.8
result = FLAlertLayer::init_1(a1, 75);
if ( result )
{
v36 = result;
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v34);
v38.origin = 0;
v38.size = 0;
sub_10028CC00((__int64)&v33, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v3 = cocos2d::extension::CCScale9Sprite::create_2("GJ_square01.png", v38);
sub_10028CBF0((float *)&v33, 380.0, 180.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v3->setContentSize)(v3, &v33);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v3,
0xFFFFFFFFLL);
sub_10028CBE0((float *)&v33, v34 * 0.5, v35 * 0.5);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v3->setPosition)(v3, &v33);
v4 = cocos2d::CCLabelBMFont::create_3("Demon Filter", "bigFont.fnt");
sub_10028CBE0((float *)&v33, v34 * 0.5, (float)((float)(v35 * 0.5) + 90.0) + -20.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string *))v4->setPosition)(v4, &v33);
m_mainLayer = a1->m_mainLayer;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))m_mainLayer->addChild)(m_mainLayer, v4);
v6 = (cocos2d::CCArray *)sub_10071F9E0(m_mainLayer, v4);
a1->m_demons = v6;
v7 = v6;
cocos2d::CCObject::retain(v6);
v31 = (cocos2d::CCArray *)sub_10071F9E0(v7, v4);
v8 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v8;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v8,
10);
v9 = GameLevelManager::sharedState();
IntForKey = GameLevelManager::getIntForKey(v9, "demon_filter");
v10 = nullptr;
v11 = 0;
while ( 2 )
{
v12 = 6;
switch ( v11 )
{
case 0:
memset(&v33, 0, sizeof(v33));
v12 = 0;
std::string::assign(&v33, "difficulty_06_btn_001.png");
goto LABEL_11;
case 1:
v12 = 7;
goto LABEL_10;
case 2:
v12 = 8;
goto LABEL_10;
case 4:
v12 = 9;
goto LABEL_10;
case 5:
v12 = 10;
goto LABEL_10;
default:
LABEL_10:
memset(&v33, 0, sizeof(v33));
v13 = (cocos2d::CCString *)sub_1007AB580("difficulty_%02d_btn2_001.png", v29);
CString = cocos2d::CCString::getCString(v13);
std::string::assign(&v33, CString);
LABEL_11:
data = v33.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v33.__r_.__value_.__s.0 & 1) != 0 )
data = v33.__r_.__value_.__l.__data_;
v16 = cocos2d::CCSprite::createWithSpriteFrameName(data);
((void (__fastcall *)(cocos2d::CCSprite *, float))v16->setScale)(v16, 1.1);
v17 = CCMenuItemSpriteExtra::create(
v16,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)DemonFilterSelectLayer::selectRating);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
v17);
sub_10071FCD0(a1->m_demons, v17);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v17->setTag)(v17, v12);
sub_10071FCD0(v31, v17);
if ( v12 == IntForKey )
v10 = v17;
if ( (*(_BYTE *)&v33.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v33.__r_.__value_.__l.__data_);
if ( ++v11 != 6 )
continue;
m_buttonMenu = a1->m_buttonMenu;
v19 = (cocos2d::CCPoint)LODWORD(v35);
v19.x = (float)(v35 * 0.5) + 3.0;
sub_10028CBE0(&v30, v34 * 0.5, v19.x);
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)&v33, (const cocos2d::CCPoint *)m_buttonMenu);
v20 = v31;
GameToolbox::alignItemsHorisontally(v31, 18.0, v19, (bool)&v33);
sub_100720270(v20);
v21 = sub_100092A30("OK");
v22 = CCMenuItemSpriteExtra::create(
v21,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)DemonFilterSelectLayer::onClose);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
v22);
sub_10071FCD0(v20, v22);
v23 = a1->m_buttonMenu;
sub_10028CBE0(&v30, v34 * 0.5, (float)((float)(0.5 * v35) + -90.0) + 25.0);
*(cocos2d::CCPoint *)&v37 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)&v33,
(const cocos2d::CCPoint *)v23);
((void (__fastcall *)(CCMenuItemSpriteExtra *, std::string *, double))v22->setPosition)(v22, &v33, v37);
if ( v10 )
{
a1->m_currentDemon = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))v10->getTag)(v10);
if ( (unsigned int)sub_100720070(a1->m_demons) )
{
v24 = 0;
do
{
v25 = sub_1007200C0(a1->m_demons, v24);
v26 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v25 + 1056LL))(v25);
m_currentDemon = a1->m_currentDemon;
v28 = &unk_100822740;
if ( m_currentDemon == (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v25 + 64LL))(v25) )
v28 = &unk_100822743;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v26 + 944LL))(v26, v28);
++v24;
}
while ( v24 < (unsigned int)sub_100720070(a1->m_demons) );
}
}
result = v36;
break;
}
break;
}
}
return result;
}