//
// ChallengesPage::init from 0x907e70 to 0x9086f4 (2180 bytes)
//
// 3 xrefs:
// > ChallengesPage::create @ 0x908814
// > ??> @ 0xafe78
// > ??> @ 0x11a8150
//
// 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 ChallengesPage::init(ChallengesPage *a1)
{
char v2; // w25
cocos2d::CCDirector *v4; // x0
int v5; // w22
cocos2d::CCArray *v6; // x0
cocos2d::CCArray *v7; // x0
cocos2d::CCDictionary *v8; // x0
cocos2d::CCNode *v9; // x21
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x23
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
cocos2d::CCSprite *v12; // x21
void (__fastcall *v13)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x23
void (__fastcall *v14)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x22
int v15; // w21
cocos2d::CCSprite *v16; // x0
CCMenuItemSpriteExtra *v17; // x22
cocos2d::CCMenu *v18; // x22
void (__fastcall *v19)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
cocos2d::CCLabelBMFont *v20; // x0
cocos2d::CCLabelBMFont *m_countdownLabel; // x22
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // x23
cocos2d::CCLabelBMFont *v23; // x0
void (__fastcall *v24)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
float *v25; // x0
cocos2d::CCLabelBMFont *v26; // x22
float v27; // s10
float v28; // s0
int v29; // w1
LoadingCircle *v30; // x0
int v31; // w22
LoadingCircle *m_circle; // x0
cocos2d::CCSprite *m_sprite; // x21
void (__fastcall *v34)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x26
cocos2d::CCLabelBMFont *v35; // x21
float v36; // s1
void (__fastcall *v37)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
double v38; // d8
GameStatsManager *v39; // x0
GameLevelManager *v40; // x0
cocos2d::CCNode *v41; // x23
void *v42; // x0
void *v43; // x0
cocos2d::CCMenu *m_buttonMenu; // x21
void (__fastcall *v45)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x19
float v46; // s0
void (__fastcall *v47)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x23
GameStatsManager *v48; // x0
unsigned int *v49; // x1
int v50; // w2
unsigned int *v51; // x1
int v52; // w2
float v53; // [xsp+D0h] [xbp+D0h]
float v54; // [xsp+D4h] [xbp+D4h]
cocos2d::CCPoint v55; // [xsp+D8h] [xbp+D8h] BYREF
cocos2d::CCPoint v56; // [xsp+E0h] [xbp+E0h] BYREF
cocos2d::CCRect v57; // [xsp+E8h] [xbp+E8h] BYREF
cocos2d::CCPoint v58; // 0:kr08_8.8
cocos2d::SEL_SCHEDULE v59; // 0:x1.16
cocos2d::SEL_MenuHandler v60; // 0:x2.16
cocos2d::CCRect v61; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v2 = FLAlertLayer::init(a1, 0x96u);
if ( !v2 )
return v2;
v4 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v4);
v5 = 1;
v7 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
a1->m_dots = v7;
cocos2d::CCObject::retain(v7);
v8 = cocos2d::CCDictionary::create();
a1->m_challengeNodes = v8;
cocos2d::CCObject::retain(v8);
cocos2d::CCRect::CCRect(&v57, 0.0, 0.0, 80.0, 80.0);
v9 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square01.png",
(const char *)&v57,
v61);
((void (__fastcall *)(cocos2d::CCNode *, __int64))v9->__vftable[1].~CCNode_0)(v9, 0xFFFFFFFFLL);
setContentSize = v9->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v57, 420.0, 280.0);
setContentSize(v9, (const cocos2d::CCSize *)&v57);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v9, -1);
setPosition = v9->setPosition;
cocos2d::CCPoint::CCPoint(&v57.origin, v53 * 0.5, v54 * 0.5);
setPosition(v9, &v57.origin);
while ( 1 )
{
while ( 1 )
{
v12 = cocos2d::CCSprite::createWithSpriteFrameName("dailyLevelCorner_001.png");
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v12, 8);
if ( v5 != 3 )
break;
cocos2d::CCSprite::setFlipX(v12, 1);
cocos2d::CCSprite::setFlipY(v12, 1);
v46 = 185.0;
LABEL_22:
++v5;
v47 = v12->setPosition;
cocos2d::CCPoint::CCPoint(&v57.origin, v46 + (float)(v53 * 0.5), (float)(v54 * 0.5) + 115.0);
v47(v12, &v57.origin);
}
if ( v5 == 4 )
break;
if ( v5 == 2 )
{
cocos2d::CCSprite::setFlipY(v12, 1);
v46 = -185.0;
goto LABEL_22;
}
v13 = v12->setPosition;
cocos2d::CCPoint::CCPoint(&v57.origin, (float)(v53 * 0.5) + -185.0, (float)(v54 * 0.5) + -115.0);
v13(v12, &v57.origin);
++v5;
}
cocos2d::CCSprite::setFlipX(v12, 1);
v14 = v12->setPosition;
cocos2d::CCPoint::CCPoint(&v57.origin, (float)(v53 * 0.5) + 185.0, (float)(v54 * 0.5) + -115.0);
v14(v12, &v57.origin);
v15 = 1;
v16 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v60.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v60.adj = (size_t)ChallengesPage::onClose;
v17 = CCMenuItemSpriteExtra::create(v16, nullptr, v60);
CCMenuItemSpriteExtra::setSizeMult(v17, 1.6);
v18 = (cocos2d::CCMenu *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v17, nullptr);
a1->m_buttonMenu = v18;
v19 = v18->setPosition;
cocos2d::CCPoint::CCPoint(
&v57.origin,
(float)((float)(v53 * 0.5) + -210.0) + 10.0,
(float)((float)(v54 * 0.5) + 140.0) - 10.0);
v19(v18, &v57.origin);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, a1->m_buttonMenu, 10);
v20 = cocos2d::CCLabelBMFont::create();
a1->m_countdownLabel = v20;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v20, 20);
a1->m_countdownLabel->setScale(a1->m_countdownLabel, 0.5);
m_countdownLabel = a1->m_countdownLabel;
setAnchorPoint = m_countdownLabel->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v57.origin, 0.0, 0.5);
setAnchorPoint(m_countdownLabel, &v57.origin);
v23 = a1->m_countdownLabel;
v24 = v23->setPosition;
v25 = (float *)v23->getContentSize(v23);
v26 = a1->m_countdownLabel;
v27 = *v25;
v28 = v26->getScale(v26);
cocos2d::CCPoint::CCPoint(
&v57.origin,
-(float)((float)((float)(v27 * v28) * 0.5) - (float)(v53 * 0.5)),
(float)((float)(v54 * 0.5) + -140.0) + 15.0);
v24(v26, &v57.origin);
v59.adj = 0;
v59.ptr = (void (__cdecl *)(float))ChallengesPage::updateTimers;
cocos2d::CCNode::schedule(a1, v59);
GameLevelManager::sharedState()->m_GJChallengeDelegate = &a1->GJChallengeDelegate;
do
{
v29 = v15++;
ChallengesPage::createChallengeNode(a1, v29, 1, 0.0, 0);
}
while ( v15 != 4 );
v30 = LoadingCircle::create();
a1->m_circle = v30;
v30->m_parentLayer = a1->m_mainLayer;
v31 = 0;
m_circle = a1->m_circle;
m_circle->m_fade = 0;
LoadingCircle::show(m_circle);
m_sprite = a1->m_circle->m_sprite;
v34 = m_sprite->setPosition;
cocos2d::CCPoint::CCPoint(&v57.origin, v53 * 0.5, (float)((float)(v54 * 0.5) + -140.0) + 17.0);
v34(m_sprite, &v57.origin);
a1->m_circle->m_sprite->setScale(a1->m_circle->m_sprite, 0.28);
a1->m_circle->setVisible(a1->m_circle, 0);
cocos2d::CCPoint::CCPoint(&v55, (float)((float)(v53 * 0.5) + 210.0) - 30.0, (float)((float)(v54 * 0.5) + 80.0) + 5.0);
do
{
v35 = cocos2d::CCLabelBMFont::create();
v35->setScale(v35, 1.4);
v35->setColor(v35, (const cocos2d::ccColor3B *)&unk_EF2DE0);
v35->setOpacity(v35, 100);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v35, 1);
v36 = (float)v31++;
v37 = v35->setPosition;
cocos2d::CCPoint::CCPoint(&v57.origin, v55.x, v55.y - (float)(v36 * 80.0));
v37(v35, &v57.origin);
v35->setVisible(v35, 0);
cocos2d::CCArray::addObject(a1->m_dots, v35);
}
while ( v31 != 3 );
clock_gettime(0, (struct timespec *)&v57);
v38 = (double)(__int64)v57.origin + (double)(__int64)v57.size / 1000000000.0;
if ( GameStatsManager::sharedState()->m_challengeTime < v38 )
{
v48 = GameStatsManager::sharedState();
GameStatsManager::resetChallengeTimer(v48);
}
v39 = GameStatsManager::sharedState();
if ( GameStatsManager::areChallengesLoaded(v39) )
{
a1->challengeStatusFinished(a1);
}
else
{
a1->m_countdownLabel->setVisible(a1->m_countdownLabel, 0);
v40 = GameLevelManager::sharedState();
GameLevelManager::getGJChallenges(v40);
a1->m_circle->setVisible(a1->m_circle, 1);
}
sub_D153B8((int)&v56, "Quests");
sub_D153B8(
(int)&v57,
"Quests are small daily challenges that give rewards. The type of quest is decided randomly. You can "
"have maximum 3 active and 3 queued at a time. Queued quests are indicated by dots to the right of a quest.");
v41 = (cocos2d::CCNode *)InfoAlertButton::create(1.0);
v42 = (void *)(*(_QWORD *)&v57.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v57.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v49 = (unsigned int *)(*(_QWORD *)&v57.origin - 8LL);
do
v50 = __ldaxr(v49);
while ( __stlxr(v50 - 1, v49) );
}
else
{
v50 = *(_DWORD *)(*(_QWORD *)&v57.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v57.origin - 8LL) = v50 - 1;
}
if ( v50 <= 0 )
operator delete(v42);
}
v43 = (void *)(*(_QWORD *)&v56 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v56 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v51 = (unsigned int *)(*(_QWORD *)&v56 - 8LL);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *(_DWORD *)(*(_QWORD *)&v56 - 8LL);
*(_DWORD *)(*(_QWORD *)&v56 - 8LL) = v52 - 1;
}
if ( v52 <= 0 )
operator delete(v43);
}
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v41);
m_buttonMenu = a1->m_buttonMenu;
v45 = v41->setPosition;
cocos2d::CCPoint::CCPoint(&v56, (float)((float)(v53 * 0.5) + 210.0) - 5.0, (float)((float)(v54 * 0.5) + 140.0) - 5.0);
v58 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v56);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *, float, float))v45)(v41, &v57, v58.x, v58.y);
return v2;
}