//
// RateDemonLayer::init from 0x14055cfe0 to 0x14055d5d6 (1526 bytes)
//
// 2 xrefs:
// > LevelInfoLayer::onRateDemon @ 0x140423f26
// > ??> @ 0x14092c174
//
// 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:34:13 +0000
//
// Hidden C++ exception states: #wind=5
bool __fastcall RateDemonLayer::init(__int64 a1, int a2)
{
bool result; // al
__int64 v5; // rax
__int64 v6; // rcx
bool v7; // al
__int64 v8; // rax
__int64 v9; // rax
__int64 *v10; // rdi
__int64 v11; // rbx
__int64 v12; // rax
__int64 v13; // rbx
__int64 v14; // rax
const char *v15; // rcx
struct cocos2d::CCLabelBMFont *v16; // rdi
__int64 v17; // rbx
__int64 v18; // rax
__int64 v19; // rcx
cocos2d::CCObject *v20; // rax
__int64 v21; // rcx
cocos2d::CCArray *v22; // rbp
__int64 v23; // rcx
__int64 v24; // rax
int i; // edi
int v26; // edx
cocos2d::CCString *v27; // rax
const char *CString; // rax
__int64 *v29; // r14
__int64 *v30; // rax
cocos2d::CCObject *v31; // rbx
__int64 v32; // rbx
__int64 v33; // rax
__int64 v34; // rax
__int64 *v35; // rdi
cocos2d::CCObject *v36; // rbx
__int64 *v37; // rdi
cocos2d::CCObject *v38; // rbx
__int64 v39; // rbx
__int64 v40; // rax
__int64 v41; // rax
_BYTE v42[16]; // [rsp+40h] [rbp-68h] BYREF
float v43; // [rsp+C0h] [rbp+18h] BYREF
float v44; // [rsp+C4h] [rbp+1Ch]
void *v45; // [rsp+C8h] [rbp+20h] BYREF
result = FLAlertLayer::init_1(a1, 75);
if ( !result )
return result;
v5 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v45 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v45);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v5 = qword_14090BFD0;
}
v6 = (unsigned int)(*(_DWORD *)(v5 + 1064) - *(_DWORD *)(v5 + 1068));
v7 = (_DWORD)v6 == 1 || (_DWORD)v6 == 2 || *(_BYTE *)(v5 + 1076);
*(_BYTE *)(a1 + 720) = v7;
*(_DWORD *)(a1 + 712) = a2;
*(_DWORD *)(a1 + 716) = -1;
v8 = cocos2d::CCDirector::sharedDirector(v6);
cocos2d::CCDirector::getWinSize(v8, &v43);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v42, 0.0, 0.0, 80.0, 80.0);
v10 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v9);
v11 = *v10;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v45, 380.0, 180.0);
(*(void (__fastcall **)(__int64 *, __int64))(v11 + 312))(v10, v12);
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v10,
0xFFFFFFFFLL);
v13 = *v10;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v45, v43 * 0.5, v44 * 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v13 + 184))(v10, v14);
v15 = "Advisor: Rate Demon";
if ( !*(_BYTE *)(a1 + 720) )
v15 = "Rate Demon";
v16 = cocos2d::CCLabelBMFont::create(v15, (const char *)&qword_140704F78);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v16 + 160LL))(v16);
v17 = *(_QWORD *)v16;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v45, v43 * 0.5, (float)((float)(v44 * 0.5) + 90.0) - 20.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v17 + 184))(v16, v18);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v16);
v20 = (cocos2d::CCObject *)cocos2d::CCArray::create(v19);
*(_QWORD *)(a1 + 696) = v20;
cocos2d::CCObject::retain(v20);
v22 = (cocos2d::CCArray *)cocos2d::CCArray::create(v21);
v24 = cocos2d::CCMenu::create(v23);
*(_QWORD *)(a1 + 552) = v24;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v24, 10);
for ( i = 1; i <= 5; ++i )
{
v26 = 6;
if ( i == 1 )
{
v26 = 7;
}
else if ( i == 2 )
{
v26 = 8;
}
else if ( i != 3 )
{
if ( i == 4 )
{
v26 = 9;
}
else if ( i == 5 )
{
v26 = 10;
}
}
v27 = cocos2d::CCString::createWithFormat("difficulty_%02d_btn2_001.png", v26);
CString = cocos2d::CCString::getCString(v27);
v29 = (__int64 *)cocos2d::CCSprite::createWithSpriteFrameName(CString);
(*(void (__fastcall **)(__int64 *))(*v29 + 160))(v29);
v45 = operator new(0x208u);
v30 = (__int64 *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v45);
v31 = (cocos2d::CCObject *)v30;
if ( v30 )
{
if ( CCMenuItemSpriteExtra::init(v30, v29, 0, a1, (__int64)RateDemonLayer::selectRating) )
{
cocos2d::CCObject::autorelease(v31);
goto LABEL_26;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v31 + 8LL))(v31, 1);
}
v31 = nullptr;
LABEL_26:
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v31);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 696), v31);
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v31 + 64LL))(v31, (unsigned int)i);
cocos2d::CCArray::addObject(v22, v31);
}
v32 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v45, v43 * 0.5, (float)(v44 * 0.5) + 3.0);
cocos2d::CCNode::convertToNodeSpace(v32, v42, v33);
GameToolbox::alignItemsHorisontally((__int64)v22, 18.0, v34, 0);
cocos2d::CCArray::removeAllObjects(v22);
v35 = (__int64 *)ButtonSprite::create_1(
(int)"Cancel",
0,
0,
1.0,
0,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_01.png",
0);
v45 = operator new(0x208u);
v36 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v45);
if ( v36 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v36, v35, 0, a1, (__int64)RateDemonLayer::onClose) )
{
cocos2d::CCObject::autorelease(v36);
goto LABEL_32;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v36 + 8LL))(v36, 1);
}
v36 = nullptr;
LABEL_32:
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v36);
cocos2d::CCArray::addObject(v22, v36);
v37 = (__int64 *)ButtonSprite::create_1(
(int)"Submit",
0,
0,
1.0,
0,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_01.png",
0);
v45 = operator new(0x208u);
v38 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v45);
if ( v38 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v38, v37, 0, a1, (__int64)RateDemonLayer::onRate) )
{
cocos2d::CCObject::autorelease(v38);
goto LABEL_37;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v38 + 8LL))(v38, 1);
}
v38 = nullptr;
LABEL_37:
*(_QWORD *)(a1 + 688) = v38;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v38);
cocos2d::CCArray::addObject(v22, *(struct cocos2d::CCObject **)(a1 + 688));
v39 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v45, v43 * 0.5, (float)((float)(v44 * 0.5) - 90.0) + 25.0);
cocos2d::CCNode::convertToNodeSpace(v39, v42, v40);
GameToolbox::alignItemsHorisontally((__int64)v22, 15.0, v41, 0);
RateDemonLayer::selectRating(a1, 0);
return 1;
}