//
// GJRateLevelLayer::init from 0x822b10 to 0x82342c (2332 bytes)
//
// 2 xrefs:
// > GJRateLevelLayer::create @ 0x823654
// > ??> @ 0xc0360
//
// 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 GJRateLevelLayer::init(GJRateLevelLayer *a1, GJGameLevel *a2)
{
bool v4; // w26
void *v5; // x0
GJGameLevel *v6; // x0
int v7; // w20
cocos2d::CCDirector *v8; // x0
cocos2d::CCArray *v9; // x0
cocos2d::CCArray *v10; // x0
cocos2d::CCArray *v11; // x0
cocos2d::CCArray *v12; // x24
cocos2d::CCArray *v13; // x27
cocos2d::CCMenu *v14; // x0
cocos2d::CCLayer *m_mainLayer; // x3
cocos2d::CCSprite *v16; // x0
cocos2d::CCSprite_vtbl *v17; // x1
cocos2d::CCSprite *m_coinSprite; // x0
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x3
CCMenuItemSpriteExtra *StarsButton; // x28
cocos2d::CCMenu *v21; // x23
cocos2d::CCMenu *v22; // x23
GJDifficultySprite *v23; // x0
GJDifficultySprite_vtbl *v24; // x1
CCMenuItemSpriteExtra *v25; // x23
void (__fastcall *v26)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
float v27; // s3
float v28; // s4
void *v29; // x23
cocos2d::CCNode *v30; // x20
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // x2
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x27
float v33; // s0
float v34; // s1
LoadingCircle *v35; // x0
LoadingCircle_vtbl *v36; // x1
LoadingCircle *m_loadingCircle; // x0
cocos2d::CCNode *v38; // x0
cocos2d::CCNode_vtbl *v39; // x1
cocos2d::CCSprite *m_sprite; // x20
void (__fastcall *v41)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x23
__int64 v42; // x0
const char *v43; // x6
const char *v44; // x6
const char *v45; // x1
__int64 v46; // x2
__int64 v47; // x3
bool v48; // w4
__int64 v49; // x5
const char *v50; // x6
cocos2d::CCNode *v51; // x0
CCMenuItemSpriteExtra *v52; // x20
const char *v53; // x1
__int64 v54; // x2
__int64 v55; // x3
bool v56; // w4
__int64 v57; // x5
const char *v58; // x6
cocos2d::CCNode *v59; // x0
CCMenuItemSpriteExtra *v60; // x0
cocos2d::CCMenu *v61; // x20
GameLevelManager *v62; // x0
unsigned int *v64; // x1
int v65; // w2
unsigned int *v66; // x20
int v67; // w0
CCMenuItemSpriteExtra *v68; // [xsp+B0h] [xbp+80h]
cocos2d::CCMenu *m_buttonMenu; // [xsp+B8h] [xbp+88h]
CCMenuItemSpriteExtra *v70; // [xsp+C0h] [xbp+90h]
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [xsp+C0h] [xbp+90h]
cocos2d::CCPoint *v72; // [xsp+C8h] [xbp+98h]
cocos2d::CCPoint *v73; // [xsp+C8h] [xbp+98h]
float v74; // [xsp+D8h] [xbp+A8h]
float v75; // [xsp+DCh] [xbp+ACh]
cocos2d::CCPoint v76; // [xsp+E0h] [xbp+B0h] BYREF
cocos2d::CCPoint v77; // [xsp+E8h] [xbp+B8h] BYREF
cocos2d::CCPoint v78; // [xsp+F0h] [xbp+C0h] BYREF
cocos2d::CCRect v79; // [xsp+F8h] [xbp+C8h] BYREF
cocos2d::CCPoint v80; // 0:kr08_8.8
cocos2d::CCPoint v81; // 0:kr20_8.8
cocos2d::SEL_MenuHandler v82; // 0:x2.16
cocos2d::SEL_MenuHandler v83; // 0:x2.16
cocos2d::SEL_MenuHandler v84; // 0:x2.16
cocos2d::SEL_MenuHandler v85; // 0:x2.16
cocos2d::SEL_MenuHandler v86; // 0:x2.16
cocos2d::CCPoint v87; // 0:s0.4,4:s1.4
cocos2d::CCPoint v88; // 0:s0.4,4:s1.4
cocos2d::CCPoint v89; // 0:s0.4,4:s1.4
cocos2d::CCPoint v90; // 0:s1.4,4:s2.4
cocos2d::CCPoint v91; // 0:s1.4,4:s2.4
cocos2d::CCPoint v92; // 0:s1.4,4:s2.4
cocos2d::CCRect v93; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
if ( !a2 )
return 0;
v4 = SetupTriggerPopup::init(a1, nullptr, nullptr, 420.0, 290.0, 1);
if ( !v4 )
return 0;
SetupTriggerPopup::preSetup(a1);
sub_D153B8((int)&v79, "Suggest Rating");
SetupTriggerPopup::addTitle(a1, (std::string)&v79);
v5 = (void *)(*(_QWORD *)&v79.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v79.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v64 = (unsigned int *)(*(_QWORD *)&v79.origin - 8LL);
do
v65 = __ldaxr(v64);
while ( __stlxr(v65 - 1, v64) );
}
else
{
v65 = *(_DWORD *)(*(_QWORD *)&v79.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v79.origin - 8LL) = v65 - 1;
}
if ( v65 <= 0 )
operator delete(v5);
}
v6 = a2;
a1->m_level = a2;
v7 = 1;
cocos2d::CCObject::retain(v6);
a1->m_stars = -1;
v8 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v8);
v10 = (cocos2d::CCArray *)cocos2d::CCArray::create(v9);
a1->m_starButtons = v10;
cocos2d::CCObject::retain(v10);
v12 = (cocos2d::CCArray *)cocos2d::CCArray::create(v11);
v13 = (cocos2d::CCArray *)cocos2d::CCArray::create(v12);
v14 = cocos2d::CCMenu::create();
m_mainLayer = a1->m_mainLayer;
a1->m_buttonMenu = v14;
m_mainLayer->addChild_0(m_mainLayer, v14, 10);
v16 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_coinsIcon2_001.png");
v17 = v16->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_coinSprite = v16;
((void (__fastcall *)(float))v17->setScale)(1.4);
v82.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v82.adj = (size_t)GJRateLevelLayer::onToggleCoins;
v70 = CCMenuItemSpriteExtra::create(a1->m_coinSprite, nullptr, v82);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v70);
v68 = v70;
m_buttonMenu = a1->m_buttonMenu;
setPosition = v70->setPosition;
cocos2d::CCPoint::CCPoint(
&v78,
-(float)((float)(a1->m_width * 0.5) - (float)(v74 * 0.5)),
(float)(a1->m_height * 0.5) + (float)(v75 * 0.5));
v80 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v78);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))setPosition)(v68, &v79, v80.x, v80.y);
a1->m_coinsToggled = 0;
m_coinSprite = a1->m_coinSprite;
setColor = m_coinSprite->setColor;
memset(&v79, 50, 3);
setColor(m_coinSprite, (const cocos2d::ccColor3B *)&v79);
GJRateLevelLayer::onToggleCoins(a1, nullptr);
do
{
while ( 1 )
{
v83.ptr = (void (__cdecl *)(cocos2d::CCObject *))GJRateLevelLayer::selectRating;
v83.adj = 0;
StarsButton = GJRateLevelLayer::getStarsButton(a1, v7, v83, a1->m_buttonMenu, 0.75);
cocos2d::CCArray::addObject(a1->m_starButtons, StarsButton);
StarsButton->setTag(StarsButton, v7);
if ( v7 > 5 )
break;
++v7;
cocos2d::CCArray::addObject(v12, StarsButton);
if ( v7 == 11 )
goto LABEL_8;
}
++v7;
cocos2d::CCArray::addObject(v13, StarsButton);
}
while ( v7 != 11 );
LABEL_8:
v21 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v78, (float)(v74 * 0.5) + -90.0, (float)((float)(v75 * 0.5) + 19.55) + 75.0);
LODWORD(v90.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(v21, &v78).y);
GameToolbox::alignItemsHorisontally(v12, 13.6, v90, (bool)&v79);
v22 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v78, (float)(v74 * 0.5) + -90.0, (float)((float)(v75 * 0.5) + -19.55) + 75.0);
LODWORD(v91.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(v22, &v78).y);
GameToolbox::alignItemsHorisontally(v13, 13.6, v91, (bool)&v79);
cocos2d::CCPoint::CCPoint(&v76, (float)((float)(v74 * 0.5) + -90.0) + 140.0, (float)(v75 * 0.5) + 75.0);
v23 = GJDifficultySprite::create(0, Long);
v24 = v23->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_difficultySprite = v23;
((void (__fastcall *)(float))v24->setScale)(1.2);
v84.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v84.adj = (size_t)GJRateLevelLayer::onFeature;
v25 = CCMenuItemSpriteExtra::create(a1->m_difficultySprite, nullptr, v84);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v25);
v26 = v25->setPosition;
v81 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v76);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v26)(v25, &v79, v81.x, v81.y);
sub_D153B8((int)&v79, "Rank:");
cocos2d::CCPoint::CCPoint(&v77, 90.0, 0.0);
cocos2d::CCPoint::operator+(&v78, &v76, &v77);
v87.y = 0.0;
v87.x = 0.75;
SetupTriggerPopup::createValueControlAdvanced(
a1,
-1,
(std::string)&v79,
v87,
0.0,
(bool)&v78,
Float,
2,
4,
v27,
v28,
1,
0,
ChatLabel,
0,
2,
0);
v29 = (void *)(*(_QWORD *)&v79.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v79.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v66 = (unsigned int *)(*(_QWORD *)&v79.origin - 8LL);
do
v67 = __ldaxr(v66);
while ( __stlxr(v67 - 1, v66) );
}
else
{
v67 = *(_DWORD *)(*(_QWORD *)&v79.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v79.origin - 8LL) = v67 - 1;
}
if ( v67 <= 0 )
operator delete(v29);
}
SetupTriggerPopup::updateValue(a1, -1, 1.0);
a1->toggleGroup(a1, 1, 0);
cocos2d::CCArray::removeAllObjects(v12);
cocos2d::CCRect::CCRect(&v79, 0.0, 0.0, 80.0, 80.0);
v30 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square02.png",
(const char *)&v79,
v93);
getTag = v30->__vftable[1].getTag;
LOWORD(v79.origin.x) = 0;
BYTE2(v79.origin.x) = 0;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))getTag)(v30, &v79);
((void (__fastcall *)(cocos2d::CCNode *, __int64))v30->__vftable[1].~CCNode_0)(v30, 75);
setContentSize = v30->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v79, 280.0, 110.0);
setContentSize(v30, (const cocos2d::CCSize *)&v79);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v30, 1);
cocos2d::CCPoint::CCPoint(&v79.origin, (float)(v74 * 0.5) + 50.0, (float)(v75 * 0.5) + -32.0);
cocos2d::CCPoint::operator=(&a1->m_center, v33, v34);
v30->setPosition(v30, &a1->m_center);
v35 = LoadingCircle::create();
v36 = v35->cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_loadingCircle = v35;
((void (__fastcall *)(float))v36->setScale)(0.7);
a1->m_loadingCircle->m_parentLayer = a1->m_mainLayer;
m_loadingCircle = a1->m_loadingCircle;
m_loadingCircle->m_fade = 0;
cocos2d::CCObject::retain(m_loadingCircle);
v38 = v30;
v39 = v30->__vftable;
m_sprite = a1->m_loadingCircle->m_sprite;
v41 = m_sprite->setPosition;
v42 = (__int64)v39->getPosition(v38);
v41(m_sprite, (const cocos2d::CCPoint *)v42);
LoadingCircle::show(a1->m_loadingCircle);
v72 = (cocos2d::CCPoint *)ButtonSprite::create(
(ButtonSprite *)"Unrate",
nullptr,
0,
0,
0.4,
"bigFont.fnt",
"GJ_button_05.png",
v43,
25.0);
cocos2d::CCPoint::CCPoint(&v79.origin, (float)(v74 * 0.5) + -150.0, a1->m_center.y + 40.0);
SetupTriggerPopup::addCustomButton(a1, -2, (ButtonSprite *)v72, v88, (int)&v79, 0);
v73 = (cocos2d::CCPoint *)ButtonSprite::create(
(ButtonSprite *)"RankOnly",
nullptr,
0,
0,
0.4,
"bigFont.fnt",
"GJ_button_05.png",
v44,
25.0);
cocos2d::CCPoint::CCPoint(&v79.origin, (float)(v74 * 0.5) + -150.0, a1->m_center.y + 0.0);
SetupTriggerPopup::addCustomButton(a1, -4, (ButtonSprite *)v73, v89, (int)&v79, 0);
v51 = (cocos2d::CCNode *)ButtonSprite::create((ButtonSprite *)"Cancel", v45, v46, v47, v48, v49, v50);
v85.adj = 1320;
v85.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v52 = CCMenuItemSpriteExtra::create(v51, nullptr, v85);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v52);
cocos2d::CCArray::addObject(v12, v52);
v59 = (cocos2d::CCNode *)ButtonSprite::create((ButtonSprite *)"Submit", v53, v54, v55, v56, v57, v58);
v86.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v86.adj = (size_t)GJRateLevelLayer::onRate;
v60 = CCMenuItemSpriteExtra::create(v59, nullptr, v86);
a1->m_submitButton = v60;
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v60);
cocos2d::CCArray::addObject(v12, a1->m_submitButton);
v61 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v78, v74 * 0.5, 25.0 - (float)((float)(a1->m_height * 0.5) - (float)(v75 * 0.5)));
LODWORD(v92.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(v61, &v78).y);
GameToolbox::alignItemsHorisontally(v12, 15.0, v92, (bool)&v79);
GJRateLevelLayer::selectRating(a1, nullptr);
GameLevelManager::sharedState()->m_levelRateInfoDelegate = &a1->LevelRateInfoDelegate;
v62 = GameLevelManager::sharedState();
GameLevelManager::getLevelRateInfo(v62, a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed);
SetupTriggerPopup::postSetup(a1);
return v4;
}