//
// RateStarsLayer::init from 0x824a9c to 0x8250ac (1552 bytes)
//
// 2 xrefs:
// > RateStarsLayer::create @ 0x8251cc
// > ??> @ 0xb4c78
//
// 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 RateStarsLayer::init(RateStarsLayer *a1, int a2, bool a3, bool a4)
{
_BOOL4 v4; // w21
char v8; // w26
cocos2d::CCDirector *v10; // x0
cocos2d::CCNode *v11; // x19
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x25
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x25
cocos2d::CCLabelBMFont *v14; // x19
void (__fastcall *v15)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x21
cocos2d::CCArray *v16; // x0
cocos2d::CCArray *v17; // x0
cocos2d::CCArray *v18; // x0
cocos2d::CCArray *v19; // x25
cocos2d::CCArray *v20; // x27
cocos2d::CCMenu *v21; // x0
cocos2d::CCLayer *m_mainLayer; // x3
int i; // w19
CCMenuItemSpriteExtra *StarsButton; // x21
cocos2d::CCMenu *m_buttonMenu; // x21
cocos2d::CCMenu *v26; // x21
GJDifficultySprite *v27; // x0
GJDifficultySprite_vtbl *v28; // x1
CCMenuItemSpriteExtra *v29; // x24
void (__fastcall *v30)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x21
const char *v31; // x1
__int64 v32; // x2
__int64 v33; // x3
bool v34; // w4
__int64 v35; // x5
const char *v36; // x6
cocos2d::CCNode *v37; // x0
CCMenuItemSpriteExtra *v38; // x21
const char *v39; // x1
__int64 v40; // x2
__int64 v41; // x3
bool v42; // w4
__int64 v43; // x5
const char *v44; // x6
cocos2d::CCNode *v45; // x0
CCMenuItemSpriteExtra *v46; // x0
cocos2d::CCMenu *v47; // x2
cocos2d::CCMenu *v48; // x21
cocos2d::CCArray **p_m_pTargetArray; // x0
unsigned int *p_m_nExtraKerning; // x2
int m_nExtraKerning; // w1
_QWORD v52[2]; // [xsp+0h] [xbp+0h] BYREF
__int64 v53; // [xsp+68h] [xbp+68h]
float v54; // [xsp+78h] [xbp+78h]
float v55; // [xsp+7Ch] [xbp+7Ch]
cocos2d::CCLabelBMFont *v56; // [xsp+80h] [xbp+80h] BYREF
cocos2d::CCPoint v57; // [xsp+88h] [xbp+88h] BYREF
cocos2d::CCPoint v58; // [xsp+90h] [xbp+90h] BYREF
cocos2d::CCRect v59; // [xsp+98h] [xbp+98h] BYREF
cocos2d::CCPoint v60; // 0:kr18_8.8
cocos2d::SEL_MenuHandler v61; // 0:x2.16
cocos2d::SEL_MenuHandler v62; // 0:x2.16
cocos2d::SEL_MenuHandler v63; // 0:x2.16
cocos2d::SEL_MenuHandler v64; // 0:x2.16
cocos2d::CCPoint v65; // 0:s1.4,4:s2.4
cocos2d::CCPoint v66; // 0:s1.4,4:s2.4
cocos2d::CCPoint v67; // 0:s1.4,4:s2.4
cocos2d::CCRect v68; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v4 = a3;
v8 = FLAlertLayer::init(a1, 0x4Bu);
if ( !v8 )
return v8;
a1->m_moderator = a4;
a1->m_starsRate = -1;
a1->m_levelID = a2;
v53 = 0xFFFFFFFFLL;
v10 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v10);
cocos2d::CCRect::CCRect(&v59, 0.0, 0.0, 80.0, 80.0);
v11 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square01.png",
(const char *)&v59,
v68);
setContentSize = v11->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v59, 380.0, 180.0);
setContentSize(v11, (const cocos2d::CCSize *)&v59);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v11, v53);
setPosition = v11->setPosition;
cocos2d::CCPoint::CCPoint(&v59.origin, v54 * 0.5, v55 * 0.5);
setPosition(v11, &v59.origin);
sub_D153B8((unsigned int)v52 + 128, "Rate ");
if ( a1->m_moderator )
{
sub_D1798C(&v56, "Mod: Suggest ", 13);
if ( !v4 )
goto LABEL_5;
}
else if ( !v4 )
{
LABEL_5:
sub_D15FD4(&v56, "Stars", 5);
goto LABEL_6;
}
sub_D15FD4(&v56, "Moons", 5);
LABEL_6:
v14 = cocos2d::CCLabelBMFont::create();
v15 = v14->setPosition;
cocos2d::CCPoint::CCPoint(&v59.origin, v54 * 0.5, (float)((float)(v55 * 0.5) + 90.0) - 20.0);
v15(v14, &v59.origin);
v16 = (cocos2d::CCArray *)((__int64 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(
a1->m_mainLayer,
v14);
v17 = (cocos2d::CCArray *)cocos2d::CCArray::create(v16);
a1->m_buttons = v17;
cocos2d::CCObject::retain(v17);
v19 = (cocos2d::CCArray *)cocos2d::CCArray::create(v18);
v20 = (cocos2d::CCArray *)cocos2d::CCArray::create(v19);
v21 = cocos2d::CCMenu::create();
m_mainLayer = a1->m_mainLayer;
a1->m_buttonMenu = v21;
m_mainLayer->addChild_0(m_mainLayer, v21, 10);
for ( i = 1; i != 11; ++i )
{
while ( 1 )
{
v61.ptr = (void (__cdecl *)(cocos2d::CCObject *))RateStarsLayer::selectRating;
v61.adj = 0;
StarsButton = RateStarsLayer::getStarsButton(a1, i, v61, a1->m_buttonMenu, 1.0);
cocos2d::CCArray::addObject(a1->m_buttons, StarsButton);
StarsButton->setTag(StarsButton, i);
if ( i > 5 )
break;
cocos2d::CCArray::addObject(v19, StarsButton);
if ( ++i == 11 )
goto LABEL_10;
}
cocos2d::CCArray::addObject(v20, StarsButton);
}
LABEL_10:
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v58, (float)(v54 * 0.5) + -30.0, (float)((float)(v55 * 0.5) + 23.0) + 3.0);
LODWORD(v65.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v58).y);
GameToolbox::alignItemsHorisontally(v19, 18.0, v65, (unsigned __int8)v52 - 104);
v26 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v58, (float)(v54 * 0.5) + -30.0, (float)((float)(v55 * 0.5) + -23.0) + 3.0);
LODWORD(v66.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(v26, &v58).y);
GameToolbox::alignItemsHorisontally(v20, 18.0, v66, (unsigned __int8)v52 - 104);
cocos2d::CCPoint::CCPoint(&v58, (float)(v54 * 0.5) + -30.0, v55 * 0.5);
cocos2d::CCPoint::CCPoint(&v59.origin, 172.0, 2.0);
cocos2d::CCPoint::operator+(&v57, &v58, &v59);
v27 = GJDifficultySprite::create(0, Long);
v28 = v27->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_difficultySprite = v27;
((void (__fastcall *)(float))v28->setScale)(1.2);
if ( a1->m_moderator )
{
v62.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v62.adj = (size_t)RateStarsLayer::onFeature;
v29 = CCMenuItemSpriteExtra::create(a1->m_difficultySprite, nullptr, v62);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v29);
v30 = v29->setPosition;
v60 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v57);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v30)(v29, &v59, v60.x, v60.y);
}
else
{
a1->m_mainLayer->addChild_0(a1->m_mainLayer, a1->m_difficultySprite, 11);
a1->m_difficultySprite->setPosition(a1->m_difficultySprite, &v57);
}
cocos2d::CCArray::removeAllObjects(v19);
v37 = (cocos2d::CCNode *)ButtonSprite::create((ButtonSprite *)"Cancel", v31, v32, v33, v34, v35, v36);
v63.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v63.adj = (size_t)RateStarsLayer::onClose;
v38 = CCMenuItemSpriteExtra::create(v37, nullptr, v63);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v38);
cocos2d::CCArray::addObject(v19, v38);
v45 = (cocos2d::CCNode *)ButtonSprite::create((ButtonSprite *)"Submit", v39, v40, v41, v42, v43, v44);
v64.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v64.adj = (size_t)RateStarsLayer::onRate;
v46 = CCMenuItemSpriteExtra::create(v45, nullptr, v64);
v47 = a1->m_buttonMenu;
a1->m_submitButton = v46;
v47->addChild(v47, v46);
cocos2d::CCArray::addObject(v19, a1->m_submitButton);
v48 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v58, v54 * 0.5, (float)((float)(v55 * 0.5) + -90.0) + 25.0);
LODWORD(v67.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(v48, &v58).y);
GameToolbox::alignItemsHorisontally(v19, 15.0, v67, (unsigned __int8)v52 - 104);
RateStarsLayer::selectRating(a1, nullptr);
p_m_pTargetArray = &v56[-1].m_pTargetArray;
if ( &v56[-1].m_pTargetArray != (cocos2d::CCArray **)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_nExtraKerning = (unsigned int *)&v56[-1].m_nExtraKerning;
do
m_nExtraKerning = __ldaxr(p_m_nExtraKerning);
while ( __stlxr(m_nExtraKerning - 1, p_m_nExtraKerning) );
}
else
{
m_nExtraKerning = v56[-1].m_nExtraKerning;
v56[-1].m_nExtraKerning = m_nExtraKerning - 1;
}
if ( m_nExtraKerning <= 0 )
operator delete(p_m_pTargetArray);
}
return v8;
}