//
// DailyLevelPage::init from 0x4d4d00 to 0x4d553c (2108 bytes)
//
// 1 xrefs:
// > DailyLevelPage::create @ 0x4d5614
//
// 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 DailyLevelPage::init(DailyLevelPage *a1, GJTimedLevelType a2)
{
int v3; // r3
cocos2d::CCDirector *v4; // r0
cocos2d::CCLayer *v5; // r0
DailyLevelPage_vtbl *v6; // r3
cocos2d::extension::CCScale9Sprite *v7; // r5
cocos2d::CCNode *v8; // r5
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // r7
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // r3
cocos2d::CCSprite *v12; // r0
cocos2d::CCSprite *v13; // r5
void (__fastcall *v14)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
int i; // r9
cocos2d::CCSprite *v16; // r5
cocos2d::CCSprite_vtbl *v17; // r3
cocos2d::CCSprite *v18; // r7
void (__fastcall *v19)(cocos2d::CCSprite *__hidden, float); // r7
int v20; // r0
float v21; // s15
void (__fastcall *setScaleX)(cocos2d::CCSprite *__hidden, float); // r7
int v23; // r0
void (__fastcall *setScaleY)(cocos2d::CCSprite *__hidden, float); // r7
int v25; // r0
void (__fastcall *v26)(cocos2d::CCSprite *__hidden, float); // r7
int v27; // r0
float v28; // s14
void (__fastcall *v29)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
cocos2d::CCSprite *v30; // r0
CCMenuItemSpriteExtra *v31; // r5
cocos2d::CCMenu *v32; // r0
cocos2d::CCMenu_vtbl *v33; // r3
cocos2d::CCMenu *v34; // r6
void (__fastcall *v35)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
cocos2d::CCSprite *v36; // r0
CCMenuItemSpriteExtra *v37; // r7
void (__fastcall *v38)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9
float v39; // r1
cocos2d::CCLabelBMFont *m_timeLabel; // r7
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // r9
cocos2d::CCLabelBMFont *v42; // r0
float v43; // s19
void (__fastcall *v44)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9
float *v45; // r0
cocos2d::CCLabelBMFont *v46; // r7
float v47; // s18
float v48; // r0
LoadingCircle *v49; // r0
cocos2d::CCLayer *m_mainLayer; // r3
LoadingCircle *m_timeCircle; // r0
cocos2d::CCSprite *m_sprite; // r6
void (__fastcall *v53)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
LoadingCircle *v54; // r0
cocos2d::CCLayer *v55; // r3
LoadingCircle *m_nodeCircle; // r0
cocos2d::CCSprite *v57; // r6
void (__fastcall *v58)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
double v59; // d8
GameLevelManager *v60; // r0
GameLevelManager *v61; // r0
GameLevelManager *v62; // r0
int ActiveDailyID; // r5
GameLevelManager *v64; // r0
GameStatsManager *v66; // r0
GameLevelManager *v67; // r0
GJGameLevel *SavedDailyLevel; // r1
GameLevelManager *v69; // r0
float v71; // r2
float v72; // r3
int v74; // [sp+10h] [bp-64h]
cocos2d::CCMenu *m_buttonMenu; // [sp+14h] [bp-60h]
void (__fastcall *v76)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [sp+18h] [bp-5Ch]
cocos2d::CCSprite *v77; // [sp+2Ch] [bp-48h] BYREF
cocos2d::CCSprite *v78; // [sp+30h] [bp-44h] BYREF
cocos2d::extension::CCScale9Sprite *v79; // [sp+34h] [bp-40h] BYREF
cocos2d::CCLabelBMFont *v80; // [sp+38h] [bp-3Ch] BYREF
cocos2d::CCSize v81; // [sp+3Ch] [bp-38h] BYREF
void (*v82)(DailyLevelPage *, cocos2d::CCObject *); // [sp+44h] [bp-30h]
int v83; // [sp+48h] [bp-2Ch]
void (*v84)(DailyLevelPage *, cocos2d::CCObject *); // [sp+4Ch] [bp-28h]
int v85; // [sp+50h] [bp-24h]
cocos2d::CCPoint v86; // [sp+54h] [bp-20h] BYREF
cocos2d::CCRect v87; // [sp+5Ch] [bp-18h] BYREF
cocos2d::CCSize v88; // 0:^0.8
cocos2d::CCRect v89; // 0:kr00_16.16
FLAlertLayer::incrementForcePrio(a1);
v87.origin.x = -1.034e-25;
v74 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::_ccColor4B *)&v87);
if ( !v74 )
return v74;
a1->m_type = a2;
v77 = (cocos2d::CCSprite *)&unk_ACDDA8;
v78 = (cocos2d::CCSprite *)&unk_ACDDA8;
v79 = (cocos2d::extension::CCScale9Sprite *)&unk_ACDDA8;
if ( a2 == 1 )
{
sub_7753D4((int)&v77, "weeklyLevelLabel_001.png");
sub_7753D4((int)&v78, "gauntletCorner_001.png");
sub_7753D4((int)&v79, "GJ_square05.png");
v3 = -2;
}
else if ( a2 == Event )
{
sub_7753D4((int)&v77, "eventLevelLabel_001.png");
sub_7753D4((int)&v78, "dailyLevelCorner_001.png");
sub_7753D4((int)&v79, "GJ_square05.png");
v3 = -3;
}
else
{
sub_7753D4((int)&v77, "dailyLevelLabel_001.png");
sub_7753D4((int)&v78, "dailyLevelCorner_001.png");
sub_7753D4((int)&v79, "GJ_square01.png");
v3 = -1;
}
a1->m_downloadLevelID = v3;
GameManager::sharedState()->m_dailyLevelPage = a1;
a1->setTouchEnabled(a1, 1);
a1->setKeypadEnabled(a1, 1);
v4 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v81, v4);
v5 = cocos2d::CCLayer::create();
v6 = a1->FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_mainLayer = v5;
v6->addChild(a1, v5);
v7 = v79;
cocos2d::CCRect::CCRect(&v87, 0.0, 0.0, 80.0, 80.0);
v89.origin.x = v71;
v89.origin.y = v72;
v89.size = v88;
v8 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(v7, (const char *)&v87, v89);
((void (__fastcall *)(cocos2d::CCNode *, int))v8->__vftable[1].~CCNode_0)(v8, 255);
setContentSize = v8->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v87, 420.0, 280.0);
setContentSize(v8, (const cocos2d::CCSize *)&v87);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v8, -1);
setPosition = v8->setPosition;
cocos2d::CCPoint::CCPoint(&v87.origin, v81.width * 0.5, v81.height * 0.5);
setPosition(v8, &v87.origin);
if ( a1->m_type == Event )
{
getTag = v8->__vftable[1].getTag;
LOWORD(v87.origin.x) = 12222;
BYTE2(v87.origin.x) = -14;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))getTag)(v8, &v87);
}
v12 = v77;
a1->m_joystickConnected = -1;
v13 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v12);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v13, 20);
v14 = v13->setPosition;
cocos2d::CCPoint::CCPoint(&v87.origin, v81.width * 0.5, (float)((float)(v81.height * 0.5) + 140.0) - 29.0);
v14(v13, &v87.origin);
for ( i = 0; i != 4; ++i )
{
v16 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v78);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v16, 8);
if ( a1->m_type == 1 )
{
v18 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare20_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, int))v18->setScaleX)(v18, 1050253722);
((void (__fastcall *)(cocos2d::CCSprite *, int))v18->setScaleY)(v18, 1061997773);
v18->setColor(v18, &stru_9AC6D4);
((void (__fastcall *)(cocos2d::CCSprite *, int))v18->setRotation)(v18, -1036779520);
v76 = v18->setPosition;
cocos2d::CCPoint::CCPoint(&v87.origin, 2.0, 2.0);
v76(v18, &v87.origin);
v16->addChild_0(v16, v18, 1);
((void (__fastcall *)(cocos2d::CCSprite *, int))v16->setScale)(v16, 1059145646);
}
v17 = v16->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
switch ( i )
{
case 2:
setScaleX = v17->setScaleX;
v23 = ((int (__fastcall *)(cocos2d::CCSprite *))v17->getScaleX)(v16);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned int))setScaleX)(v16, v23 ^ 0x80000000);
setScaleY = v16->setScaleY;
v25 = ((int (__fastcall *)(cocos2d::CCSprite *))v16->getScaleY)(v16);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned int))setScaleY)(v16, v25 ^ 0x80000000);
v16->setVisible(v16, 0);
v21 = 115.0;
LABEL_20:
v28 = 185.0;
goto LABEL_21;
case 3:
v26 = v17->setScaleX;
v27 = ((int (__fastcall *)(cocos2d::CCSprite *))v17->getScaleX)(v16);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned int))v26)(v16, v27 ^ 0x80000000);
v21 = -115.0;
goto LABEL_20;
case 1:
v19 = v17->setScaleY;
v20 = ((int (__fastcall *)(cocos2d::CCSprite *))v17->getScaleY)(v16);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned int))v19)(v16, v20 ^ 0x80000000);
v21 = 115.0;
break;
default:
v21 = -115.0;
break;
}
v28 = -185.0;
LABEL_21:
v29 = v16->setPosition;
cocos2d::CCPoint::CCPoint(&v87.origin, v28 + (float)(v81.width * 0.5), v21 + (float)(v81.height * 0.5));
v29(v16, &v87.origin);
}
v30 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v83 = 0;
v82 = DailyLevelPage::onClose;
v31 = CCMenuItemSpriteExtra::create(
v30,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(DailyLevelPage::onClose, (unsigned int)a1));
CCMenuItemSpriteExtra::setSizeMult(v31, 1.6);
v32 = (cocos2d::CCMenu *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v31, nullptr);
v33 = v32->cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v34 = v32;
a1->m_buttonMenu = v32;
v35 = v33->setPosition;
cocos2d::CCPoint::CCPoint(
&v87.origin,
(float)((float)(v81.width * 0.5) - 210.0) + 10.0,
(float)((float)(v81.height * 0.5) + 140.0) - 10.0);
v35(v34, &v87.origin);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, a1->m_buttonMenu, 10);
v36 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_safeBtn_001.png");
v85 = 0;
v84 = DailyLevelPage::onTheSafe;
v37 = CCMenuItemSpriteExtra::create(
v36,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(DailyLevelPage::onTheSafe, (unsigned int)a1));
CCMenuItemSpriteExtra::setSizeMult(v37, 1.6);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v37);
v38 = v37->setPosition;
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(
&v86,
(float)((float)(v81.width * 0.5) + 210.0) - 30.0,
(float)((float)(v81.height * 0.5) + 140.0) - 30.0);
cocos2d::CCNode::convertToNodeSpace(&v87.origin, m_buttonMenu, &v86);
v38(v37, &v87.origin);
DailyLevelPage::getDailyTimeString((DailyLevelPage *)&v80, (int)a1, 0);
a1->m_timeLabel = cocos2d::CCLabelBMFont::create();
sub_774008(&v80);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, a1->m_timeLabel, 20);
if ( a2 == Event )
v39 = 0.4;
else
v39 = 0.5;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _DWORD))a1->m_timeLabel->setScale)(a1->m_timeLabel, LODWORD(v39));
m_timeLabel = a1->m_timeLabel;
setAnchorPoint = m_timeLabel->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v87.origin, 0.0, 0.5);
setAnchorPoint(m_timeLabel, &v87.origin);
v42 = a1->m_timeLabel;
v43 = v81.width * 0.5;
v44 = v42->setPosition;
v45 = (float *)v42->getContentSize(v42);
v46 = a1->m_timeLabel;
v47 = *v45;
v48 = v46->getScale(v46);
cocos2d::CCPoint::CCPoint(
&v87.origin,
v43 - (float)((float)(v47 * v48) * 0.5),
(float)((float)(v81.height * 0.5) - 140.0) + 15.0);
v44(v46, &v87.origin);
LODWORD(v86.x) = DailyLevelPage::updateTimers;
v86.y = 0.0;
cocos2d::CCNode::schedule(a1, (cocos2d::SEL_SCHEDULE)(unsigned int)DailyLevelPage::updateTimers);
v49 = LoadingCircle::create();
m_mainLayer = a1->m_mainLayer;
a1->m_timeCircle = v49;
v49->m_parentLayer = m_mainLayer;
m_timeCircle = a1->m_timeCircle;
m_timeCircle->m_fade = 0;
LoadingCircle::show(m_timeCircle);
m_sprite = a1->m_timeCircle->m_sprite;
v53 = m_sprite->setPosition;
cocos2d::CCPoint::CCPoint(&v87.origin, v81.width * 0.5, (float)((float)(v81.height * 0.5) - 140.0) + 17.0);
v53(m_sprite, &v87.origin);
((void (__fastcall *)(cocos2d::CCSprite *, int))a1->m_timeCircle->m_sprite->setScale)(
a1->m_timeCircle->m_sprite,
1049582633);
a1->m_timeCircle->setVisible(a1->m_timeCircle, 0);
v54 = LoadingCircle::create();
v55 = a1->m_mainLayer;
a1->m_nodeCircle = v54;
v54->m_parentLayer = v55;
m_nodeCircle = a1->m_nodeCircle;
m_nodeCircle->m_fade = 0;
LoadingCircle::show(m_nodeCircle);
v57 = a1->m_nodeCircle->m_sprite;
v58 = v57->setPosition;
cocos2d::CCPoint::CCPoint(&v87.origin, v81.width * 0.5, v81.height * 0.5);
v58(v57, &v87.origin);
((void (__fastcall *)(_DWORD, _DWORD))a1->m_nodeCircle->m_sprite->setScale)(a1->m_nodeCircle->m_sprite, 0.5);
a1->m_nodeCircle->setVisible(a1->m_nodeCircle, 0);
clock_gettime(0, (struct timespec *)&v87);
v59 = (double)SLODWORD(v87.origin.x) + (double)SLODWORD(v87.origin.y) / 1000000000.0;
v60 = GameLevelManager::sharedState();
if ( v59 > (double)GameLevelManager::getDailyTimer(v60, a1->m_type) )
{
v62 = GameLevelManager::sharedState();
GameLevelManager::resetDailyLevelState(v62, a1->m_type);
}
v61 = GameLevelManager::sharedState();
ActiveDailyID = GameLevelManager::getActiveDailyID(v61, a1->m_type);
if ( ActiveDailyID > 0 )
{
v66 = GameStatsManager::sharedState();
if ( GameStatsManager::hasCompletedDailyLevel(v66, ActiveDailyID) )
{
SavedDailyLevel = nullptr;
}
else
{
v67 = GameLevelManager::sharedState();
SavedDailyLevel = GameLevelManager::getSavedDailyLevel(v67, ActiveDailyID);
}
DailyLevelPage::createDailyNode(a1, SavedDailyLevel, 1, 0.0, 0);
}
v64 = GameLevelManager::sharedState();
if ( GameLevelManager::hasDailyStateBeenLoaded(v64, a1->m_type) )
{
a1->dailyStatusFinished(a1, a1->m_type);
}
else
{
if ( a1->m_type != Event )
{
a1->m_timeLabel->setVisible(a1->m_timeLabel, 0);
a1->m_timeCircle->setVisible(a1->m_timeCircle, 1);
}
v69 = GameLevelManager::sharedState();
GameLevelManager::getGJDailyLevelState(v69, a1->m_type);
if ( !a1->m_dailyNode )
a1->m_nodeCircle->setVisible(a1->m_nodeCircle, 1);
}
GameLevelManager::sharedState()->m_GJDailyLevelDelegate = &a1->GJDailyLevelDelegate;
GameLevelManager::sharedState()->m_levelDownloadDelegate = &a1->LevelDownloadDelegate;
sub_774008(&v79);
sub_774008(&v78);
sub_774008(&v77);
return v74;
}