//
// DemonFilterSelectLayer::init from 0x140440bb0 to 0x140441224 (1652 bytes)
//
// 5 xrefs:
// > LevelSearchLayer::onSpecialDemon @ 0x1404367c9
// > LevelSearchLayer::onSpecialDemon @ 0x1404367d0
// > LevelSearchLayer::onSpecialDemon @ 0x1404367ba
// > ??> @ 0x140790d78
// > ??> @ 0x140927080
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:32:21 +0000
//
// Hidden C++ exception states: #wind=4
bool __fastcall DemonFilterSelectLayer::init(__int64 a1)
{
bool result; // al
__int64 v3; // rcx
__int64 v4; // rax
__int64 v5; // rax
__int64 *v6; // rdi
__int64 v7; // rbx
__int64 v8; // rax
__int64 v9; // rbx
__int64 v10; // rax
struct cocos2d::CCLabelBMFont *v11; // rdi
__int64 v12; // rbx
__int64 v13; // rax
__int64 v14; // rcx
cocos2d::CCObject *v15; // rax
__int64 v16; // rcx
cocos2d::CCArray *v17; // r13
__int64 v18; // rcx
__int64 v19; // rax
__int64 v20; // rcx
cocos2d::CCString *v21; // rax
void *v22; // r8
cocos2d::CCObject *v23; // rsi
int i; // ebx
cocos2d::CCObject *v25; // r12
unsigned int v26; // edi
char *v27; // rax
cocos2d::CCString *v28; // rax
char *CString; // rax
size_t v30; // r8
void **v31; // rcx
__int64 *v32; // r14
void *v33; // rcx
__int64 v34; // rbx
__int64 v35; // rax
__int64 v36; // rax
__int64 *v37; // rbx
cocos2d::CCObject *v38; // r14
__int64 v39; // rdi
__int64 v40; // rbx
__int64 v41; // rax
__int64 v42; // rax
float v43; // [rsp+48h] [rbp-49h] BYREF
float v44; // [rsp+4Ch] [rbp-45h]
void *v45; // [rsp+50h] [rbp-41h] BYREF
__int64 v46[2]; // [rsp+58h] [rbp-39h] BYREF
void *Block[2]; // [rsp+68h] [rbp-29h] BYREF
__int64 v48; // [rsp+78h] [rbp-19h]
unsigned __int64 v49; // [rsp+80h] [rbp-11h]
result = FLAlertLayer::init_1(a1, 75);
if ( !result )
return result;
v4 = cocos2d::CCDirector::sharedDirector(v3);
cocos2d::CCDirector::getWinSize(v4, &v43);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v46, 0.0, 0.0, 80.0, 80.0);
v6 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v5);
v7 = *v6;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v45, 380.0, 180.0);
(*(void (__fastcall **)(__int64 *, __int64))(v7 + 312))(v6, v8);
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v6,
0xFFFFFFFFLL);
v9 = *v6;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v45, v43 * 0.5, v44 * 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v9 + 184))(v6, v10);
v11 = cocos2d::CCLabelBMFont::create("Demon Filter", (const char *)&qword_140704F78);
v12 = *(_QWORD *)v11;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v45, v43 * 0.5, (float)((float)(v44 * 0.5) + 90.0) - 20.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v12 + 184))(v11, v13);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v11);
v15 = (cocos2d::CCObject *)cocos2d::CCArray::create(v14);
*(_QWORD *)(a1 + 664) = v15;
cocos2d::CCObject::retain(v15);
v17 = (cocos2d::CCArray *)cocos2d::CCArray::create(v16);
v19 = cocos2d::CCMenu::create(v18);
*(_QWORD *)(a1 + 552) = v19;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v19, 10);
v20 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v45 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v45);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v20 = *(_QWORD *)&qword_14090BFB0;
}
v48 = 12;
v49 = 15;
strcpy((char *)Block, "demon_filter");
BYTE5(Block[1]) = 0;
HIWORD(Block[1]) = 0;
v21 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v20 + 848), Block);
LODWORD(v45) = cocos2d::CCString::intValue(v21);
if ( v49 > 0xF )
{
v22 = Block[0];
if ( v49 + 1 >= 0x1000 )
{
v22 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v22 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v22);
}
v23 = nullptr;
for ( i = 0; i <= 5; ++i )
{
v25 = v23;
v26 = 6;
switch ( i )
{
case 0:
v26 = 0;
break;
case 1:
v26 = 7;
break;
case 2:
v26 = 8;
break;
case 4:
v26 = 9;
break;
case 5:
v26 = 10;
break;
default:
break;
}
*(_OWORD *)Block = 0;
v48 = 0;
v49 = 15;
LOBYTE(Block[0]) = 0;
if ( i )
{
v28 = cocos2d::CCString::createWithFormat("difficulty_%02d_btn2_001.png", v26);
CString = (char *)cocos2d::CCString::getCString(v28);
v30 = -1;
do
++v30;
while ( CString[v30] );
sub_1400405A0(Block, CString, v30);
v27 = (char *)Block[0];
}
else
{
v27 = (char *)sub_14003D460(0x20u);
v48 = 25;
v49 = 31;
strcpy(v27, "difficulty_06_btn_001.png");
Block[0] = v27;
}
v31 = Block;
if ( v49 > 0xF )
v31 = (void **)v27;
v32 = (__int64 *)cocos2d::CCSprite::createWithSpriteFrameName((const char *)v31);
(*(void (__fastcall **)(__int64 *))(*v32 + 160))(v32);
v46[0] = (__int64)operator new(0x208u);
v23 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v46[0]);
if ( v23 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v23, v32, 0, a1, (__int64)DemonFilterSelectLayer::selectRating) )
{
cocos2d::CCObject::autorelease(v23);
goto LABEL_28;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v23 + 8LL))(v23, 1);
}
v23 = nullptr;
LABEL_28:
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v23);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 664), v23);
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v23 + 64LL))(v23, v26);
cocos2d::CCArray::addObject(v17, v23);
if ( v26 != (_DWORD)v45 )
v23 = v25;
if ( v49 > 0xF )
{
v33 = Block[0];
if ( v49 + 1 >= 0x1000 )
{
v33 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v33 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v33);
}
}
v34 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v46, v43 * 0.5, (float)(v44 * 0.5) + 3.0);
cocos2d::CCNode::convertToNodeSpace(v34, &v45, v35);
GameToolbox::alignItemsHorisontally((__int64)v17, 18.0, v36, 0);
cocos2d::CCArray::removeAllObjects(v17);
v37 = (__int64 *)ButtonSprite::create_1(
(int)"OK",
0,
0,
1.0,
0,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_01.png",
0);
v46[0] = (__int64)operator new(0x208u);
v38 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v46[0]);
if ( v38 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v38, v37, 0, a1, (__int64)DemonFilterSelectLayer::onClose) )
{
cocos2d::CCObject::autorelease(v38);
goto LABEL_41;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v38 + 8LL))(v38, 1);
}
v38 = nullptr;
LABEL_41:
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v38);
cocos2d::CCArray::addObject(v17, v38);
v39 = *(_QWORD *)v38;
v40 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v46, v43 * 0.5, (float)((float)(v44 * 0.5) - 90.0) + 25.0);
cocos2d::CCNode::convertToNodeSpace(v40, &v45, v41);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v39 + 184))(v38, v42);
if ( v23 )
DemonFilterSelectLayer::selectRating(a1, v23);
return 1;
}