//
// RateDemonLayer::init from 0x1403c8b50 to 0x1403c911d (1485 bytes)
//
// 2 xrefs:
// > LevelInfoLayer::onRateDemon @ 0x1402fe838
// > ??> @ 0x1406d7994
//
// 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
//
// Hidden C++ exception states: #wind=5
bool RateDemonLayer::init(RateDemonLayer *a1, int a2)
{
bool result; // al
__int64 v5; // rax
__int64 v6; // rcx
bool v7; // al
cocos2d::CCDirector *v8; // rax
struct cocos2d::CCRect *v9; // rax
struct cocos2d::extension::CCScale9Sprite *v10; // rdi
cocos2d::extension::CCScale9Sprite_vtbl *v11; // rbx
const cocos2d::CCSize *v12; // rax
float v13; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v14; // rbx
double v15; // xmm0_8
const cocos2d::CCPoint *v16; // rax
const char *v17; // rcx
struct cocos2d::CCLabelBMFont *v18; // rdi
cocos2d::CCLabelBMFont_vtbl *v19; // rbx
double v20; // xmm0_8
const cocos2d::CCPoint *v21; // rax
__int64 v22; // rcx
cocos2d::CCArray *v23; // rax
__int64 v24; // rcx
cocos2d::CCArray *v25; // rbp
__int64 v26; // rcx
cocos2d::CCMenu *v27; // rax
int i; // edi
int v29; // edx
cocos2d::CCString *v30; // rax
const char *CString; // rax
struct cocos2d::CCSprite *v32; // r14
CCMenuItemSpriteExtra *v33; // rax
cocos2d::CCNode *v34; // rbx
double v35; // xmm0_8
struct cocos2d::CCPoint v36; // rax
ButtonSprite *v37; // rdi
CCMenuItemSpriteExtra *v38; // rbx
ButtonSprite *v39; // rdi
CCMenuItemSpriteExtra *v40; // rbx
struct cocos2d::CCPoint v41; // rax
cocos2d::CCRect v42; // [rsp+40h] [rbp-68h] BYREF
float v43; // [rsp+C0h] [rbp+18h]
CCMenuItemSpriteExtra *v44; // [rsp+C8h] [rbp+20h] BYREF
result = FLAlertLayer::init_1(a1, 75);
if ( !result )
return result;
v5 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v44 = (CCMenuItemSpriteExtra *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v44);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v5 = qword_1406C2ED8;
}
v6 = (unsigned int)(*(_DWORD *)(v5 + 1012) - *(_DWORD *)(v5 + 1016));
v7 = (_DWORD)v6 == 1 || (_DWORD)v6 == 2 || *(_BYTE *)(v5 + 1024);
a1->m_moderator = v7;
a1->m_levelID = a2;
a1->m_demonRate = -1;
v8 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v6);
cocos2d::CCDirector::getWinSize(v8);
cocos2d::CCRect::CCRect(&v42, 0.0, 0.0, 80.0, 80.0);
v10 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v9);
v11 = v10->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v44, 380.0, 180.0);
v11->setContentSize(v10, v12);
v13 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v10,
0xFFFFFFFFLL);
v14 = v10->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v15 = cocos2d::CCPoint::CCPoint(v13, v43 * 0.5);
v14->setPosition_0(v10, v16);
v17 = "Mod: Rate Demon";
if ( !a1->m_moderator )
v17 = "Rate Demon";
v18 = cocos2d::CCLabelBMFont::create(v17, (const char *)&qword_14052A4D8);
v19 = v18->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v20 = cocos2d::CCPoint::CCPoint(*(float *)&v15, v43 * 0.5);
v19->setPosition_0(v18, v21);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v18);
v23 = (cocos2d::CCArray *)cocos2d::CCArray::create(v22);
a1->m_demons = v23;
cocos2d::CCObject::retain(v23);
v25 = (cocos2d::CCArray *)cocos2d::CCArray::create(v24);
v27 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v26);
a1->m_buttonMenu = v27;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v27, 10);
for ( i = 1; i <= 5; ++i )
{
v29 = 6;
if ( i == 1 )
{
v29 = 7;
}
else if ( i == 2 )
{
v29 = 8;
}
else if ( i != 3 )
{
if ( i == 4 )
{
v29 = 9;
}
else if ( i == 5 )
{
v29 = 10;
}
}
v30 = cocos2d::CCString::createWithFormat("difficulty_%02d_btn2_001.png", v29);
CString = cocos2d::CCString::getCString(v30);
v32 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
((void (__fastcall *)(struct cocos2d::CCSprite *))v32->setScale_0)(v32);
v44 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v33 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v44);
v34 = v33;
if ( v33 )
{
if ( CCMenuItemSpriteExtra::init(v33, v32, nullptr, a1, (cocos2d::SEL_MenuHandler *)RateDemonLayer::selectRating) )
{
cocos2d::CCObject::autorelease(v34);
goto LABEL_26;
}
((void (__fastcall *)(cocos2d::CCNode *, __int64))v34->~CCNode)(v34, 1);
}
v34 = nullptr;
LABEL_26:
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v34);
cocos2d::CCArray::addObject(a1->m_demons, v34);
v34->setTag(v34, i);
cocos2d::CCArray::addObject(v25, v34);
}
v35 = cocos2d::CCPoint::CCPoint(*(float *)&v20, v43 * 0.5);
v36 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v42.origin);
GameToolbox::alignItemsHorisontally(v25, 18.0, v36, 0);
cocos2d::CCArray::removeAllObjects(v25);
v37 = ButtonSprite::create_1("Cancel", 0, 0, 1.0, 0, "goldFont.fnt", "GJ_button_01.png", 0.0);
v44 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v38 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v44);
if ( v38 )
{
if ( CCMenuItemSpriteExtra::init(v38, v37, nullptr, a1, (cocos2d::SEL_MenuHandler *)RateDemonLayer::onClose) )
{
cocos2d::CCObject::autorelease(v38);
goto LABEL_32;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v38->~CCMenuItemSpriteExtra)(v38, 1);
}
v38 = nullptr;
LABEL_32:
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v38);
cocos2d::CCArray::addObject(v25, v38);
v39 = ButtonSprite::create_1("Submit", 0, 0, 1.0, 0, "goldFont.fnt", "GJ_button_01.png", 0.0);
v44 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v40 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v44);
if ( v40 )
{
if ( CCMenuItemSpriteExtra::init(v40, v39, nullptr, a1, (cocos2d::SEL_MenuHandler *)RateDemonLayer::onRate) )
{
cocos2d::CCObject::autorelease(v40);
goto LABEL_37;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v40->~CCMenuItemSpriteExtra)(v40, 1);
}
v40 = nullptr;
LABEL_37:
a1->m_submitButton = v40;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v40);
cocos2d::CCArray::addObject(v25, a1->m_submitButton);
cocos2d::CCPoint::CCPoint(*(float *)&v35, v43 * 0.5);
v41 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v42.origin);
GameToolbox::alignItemsHorisontally(v25, 15.0, v41, 0);
RateDemonLayer::selectRating(a1, nullptr);
return 1;
}