//
// DailyLevelPage::init from 0x914788 to 0x9153e0 (3160 bytes)
//
// 2 xrefs:
// > DailyLevelPage::create @ 0x915518
// > ??> @ 0x4ef18
//
// 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)
{
double v4; // d0
double v5; // d0
cocos2d::CCDirector *v6; // x0
cocos2d::CCLayer *v7; // x0
DailyLevelPage_vtbl *v8; // x2
cocos2d::extension::CCScale9Sprite *v9; // x21
cocos2d::CCNode *v10; // x21
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x22
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
cocos2d::CCSprite *v13; // x0
cocos2d::CCSprite *v14; // x21
void (__fastcall *v15)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x22
int i; // w22
cocos2d::CCSprite *v17; // x21
float v18; // s1
float v19; // s0
void (__fastcall *v20)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x25
cocos2d::CCSprite *v21; // x0
CCMenuItemSpriteExtra *v22; // x21
cocos2d::CCMenu *v23; // x21
float v24; // s2
void (__fastcall *v25)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
cocos2d::CCSprite *v26; // x0
CCMenuItemSpriteExtra *v27; // x22
void (__fastcall *v28)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
cocos2d::CCMenu *m_buttonMenu; // x25
cocos2d::CCArray **p_m_pTargetArray; // x0
long double v31; // q0
cocos2d::CCLabelBMFont *m_timeLabel; // x21
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // x22
cocos2d::CCLabelBMFont *v34; // x0
float v35; // s8
void (__fastcall *v36)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
float *v37; // x0
cocos2d::CCLabelBMFont *v38; // x21
float v39; // s9
float v40; // s0
LoadingCircle *v41; // x0
LoadingCircle *m_timeCircle; // x0
cocos2d::CCSprite *m_sprite; // x21
void (__fastcall *v44)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x22
LoadingCircle *v45; // x0
LoadingCircle *m_nodeCircle; // x0
cocos2d::CCSprite *v47; // x21
void (__fastcall *v48)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x22
double v49; // d8
GameLevelManager *v50; // x0
GameLevelManager *v51; // x0
GameLevelManager *v52; // x0
int ActiveDailyID; // w21
GameStatsManager *v54; // x0
GameLevelManager *v55; // x0
GJGameLevel *SavedDailyLevel; // x1
GameLevelManager *v57; // x0
GameLevelManager *v58; // x0
char *v59; // x0
char *v60; // x0
char *p_m_fBrVertexMod; // x21
double v63; // d0
double v64; // d0
void (__fastcall *v65)(cocos2d::CCSprite *__hidden, float); // x25
float v66; // s0
void (__fastcall *setScaleX)(cocos2d::CCSprite *__hidden, float); // x25
float v68; // s0
void (__fastcall *setScaleY)(cocos2d::CCSprite *__hidden, float); // x25
float v70; // s0
void (__fastcall *v71)(cocos2d::CCSprite *__hidden, float); // x25
float v72; // s0
cocos2d::CCSprite *v73; // x25
double v74; // d0
double v75; // d0
unsigned int *p_m_fTextureTop; // x19
int m_fTextureTop_low; // w0
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // x2
unsigned int *v79; // x1
int v80; // w2
unsigned int *v81; // x1
int v82; // w2
unsigned int *p_m_nExtraKerning; // x2
int m_nExtraKerning; // w1
void (__fastcall *v85)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+A0h] [xbp+A0h]
char v86; // [xsp+AFh] [xbp+AFh]
cocos2d::CCSprite *v87; // [xsp+C0h] [xbp+C0h] BYREF
const char *v88; // [xsp+C8h] [xbp+C8h] BYREF
char *v89; // [xsp+D0h] [xbp+D0h] BYREF
float v90; // [xsp+D8h] [xbp+D8h]
float v91; // [xsp+DCh] [xbp+DCh]
cocos2d::CCLabelBMFont *v92; // [xsp+E0h] [xbp+E0h] BYREF
cocos2d::CCRect v93; // [xsp+E8h] [xbp+E8h] BYREF
cocos2d::CCPoint v94; // 0:kr08_8.8
cocos2d::SEL_SCHEDULE v95; // 0:x1.16
cocos2d::SEL_MenuHandler v96; // 0:x2.16
cocos2d::SEL_MenuHandler v97; // 0:x2.16
cocos2d::CCRect v98; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
FLAlertLayer::incrementForcePrio(a1);
v93.origin.x = -1.034e-25;
v86 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::_ccColor4B *)&v93);
if ( v86 )
{
a1->m_type = a2;
v87 = (cocos2d::CCSprite *)&byte_124B6C8;
v88 = &byte_124B6C8;
v89 = &byte_124B6C8;
if ( a2 == 1 )
{
*(_QWORD *)&v63 = sub_D1798C(&v87, "weeklyLevelLabel_001.png", 24).n128_u64[0];
*(_QWORD *)&v64 = sub_D1798C(&v88, "gauntletCorner_001.png", 22, v63).n128_u64[0];
sub_D1798C(&v89, "GJ_square05.png", 15, v64);
a1->m_downloadLevelID = -2;
}
else if ( a2 == Event )
{
*(_QWORD *)&v4 = sub_D1798C(&v87, "eventLevelLabel_001.png", 23).n128_u64[0];
*(_QWORD *)&v5 = sub_D1798C(&v88, "dailyLevelCorner_001.png", 24, v4).n128_u64[0];
sub_D1798C(&v89, "GJ_square05.png", 15, v5);
a1->m_downloadLevelID = -3;
}
else
{
*(_QWORD *)&v74 = sub_D1798C(&v87, "dailyLevelLabel_001.png", 23).n128_u64[0];
*(_QWORD *)&v75 = sub_D1798C(&v88, "dailyLevelCorner_001.png", 24, v74).n128_u64[0];
sub_D1798C(&v89, "GJ_square01.png", 15, v75);
a1->m_downloadLevelID = -1;
}
GameManager::sharedState()->m_dailyLevelPage = a1;
a1->setTouchEnabled(a1, 1);
a1->setKeypadEnabled(a1, 1);
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v6);
v7 = cocos2d::CCLayer::create();
v8 = a1->FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_mainLayer = v7;
v8->addChild(a1, v7);
v9 = (cocos2d::extension::CCScale9Sprite *)v89;
cocos2d::CCRect::CCRect(&v93, 0.0, 0.0, 80.0, 80.0);
v10 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(v9, (const char *)&v93, v98);
((void (__fastcall *)(cocos2d::CCNode *, __int64))v10->__vftable[1].~CCNode_0)(v10, 0xFFFFFFFFLL);
setContentSize = v10->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v93, 420.0, 280.0);
setContentSize(v10, (const cocos2d::CCSize *)&v93);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v10, -1);
setPosition = v10->setPosition;
cocos2d::CCPoint::CCPoint(&v93.origin, v90 * 0.5, v91 * 0.5);
setPosition(v10, &v93.origin);
if ( a1->m_type == Event )
{
getTag = v10->__vftable[1].getTag;
LOWORD(v93.origin.x) = 12222;
BYTE2(v93.origin.x) = -14;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))getTag)(v10, &v93);
}
v13 = v87;
a1->m_joystickConnected = -1;
v14 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v13);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v14, 20);
v15 = v14->setPosition;
cocos2d::CCPoint::CCPoint(&v93.origin, v90 * 0.5, (float)((float)(v91 * 0.5) + 140.0) - 29.0);
v15(v14, &v93.origin);
for ( i = 0; i != 4; ++i )
{
v17 = cocos2d::CCSprite::createWithSpriteFrameName(v88);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v17, 8);
if ( a1->m_type == 1 )
{
v73 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare20_001.png");
v73->setScaleX(v73, 0.3);
v73->setScaleY(v73, 0.8);
v73->setColor(v73, (const cocos2d::ccColor3B *)&unk_EF3588);
v73->setRotation(v73, -45.0);
v85 = v73->setPosition;
cocos2d::CCPoint::CCPoint(&v93.origin, 2.0, 2.0);
v85(v73, &v93.origin);
v17->addChild_0(v17, v73, 1);
v17->setScale(v17, 0.63);
}
if ( i == 2 )
{
setScaleX = v17->setScaleX;
v68 = v17->getScaleX(v17);
setScaleX(v17, -v68);
setScaleY = v17->setScaleY;
v70 = v17->getScaleY(v17);
setScaleY(v17, -v70);
v17->setVisible(v17, 0);
v18 = 115.0;
v19 = 185.0;
}
else if ( i == 3 )
{
v65 = v17->setScaleX;
v66 = v17->getScaleX(v17);
v65(v17, -v66);
v18 = -115.0;
v19 = 185.0;
}
else
{
if ( i == 1 )
{
v71 = v17->setScaleY;
v72 = v17->getScaleY(v17);
v71(v17, -v72);
v18 = 115.0;
}
else
{
v18 = -115.0;
}
v19 = -185.0;
}
v20 = v17->setPosition;
cocos2d::CCPoint::CCPoint(&v93.origin, v19 + (float)(v90 * 0.5), v18 + (float)(v91 * 0.5));
v20(v17, &v93.origin);
}
v21 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v96.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v96.adj = (size_t)DailyLevelPage::onClose;
v22 = CCMenuItemSpriteExtra::create(v21, nullptr, v96);
CCMenuItemSpriteExtra::setSizeMult(v22, 1.6);
v23 = (cocos2d::CCMenu *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v22, nullptr);
v24 = v90;
a1->m_buttonMenu = v23;
v25 = v23->setPosition;
cocos2d::CCPoint::CCPoint(
&v93.origin,
(float)((float)(v24 * 0.5) + -210.0) + 10.0,
(float)((float)(v91 * 0.5) + 140.0) - 10.0);
v25(v23, &v93.origin);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, a1->m_buttonMenu, 10);
v26 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_safeBtn_001.png");
v97.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v97.adj = (size_t)DailyLevelPage::onTheSafe;
v27 = CCMenuItemSpriteExtra::create(v26, nullptr, v97);
CCMenuItemSpriteExtra::setSizeMult(v27, 1.6);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v27);
v28 = v27->setPosition;
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v92,
(float)((float)(v90 * 0.5) + 210.0) - 30.0,
(float)((float)(v91 * 0.5) + 140.0) - 30.0);
v94 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, (const cocos2d::CCPoint *)&v92);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v28)(v27, &v93, v94.x, v94.y);
DailyLevelPage::getDailyTimeString(a1, nullptr, (__int64)&v92);
a1->m_timeLabel = cocos2d::CCLabelBMFont::create();
p_m_pTargetArray = &v92[-1].m_pTargetArray;
if ( &v92[-1].m_pTargetArray != (cocos2d::CCArray **)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_nExtraKerning = (unsigned int *)&v92[-1].m_nExtraKerning;
do
m_nExtraKerning = __ldaxr(p_m_nExtraKerning);
while ( __stlxr(m_nExtraKerning - 1, p_m_nExtraKerning) );
}
else
{
m_nExtraKerning = v92[-1].m_nExtraKerning;
v92[-1].m_nExtraKerning = m_nExtraKerning - 1;
}
if ( m_nExtraKerning <= 0 )
operator delete(p_m_pTargetArray);
}
((void (__fastcall *)(cocos2d::CCLayer *))a1->m_mainLayer->addChild_0)(a1->m_mainLayer);
if ( a2 == Event )
LODWORD(v31) = 1053609165;
else
LODWORD(v31) = 0.5;
a1->m_timeLabel->setScale(a1->m_timeLabel, v31);
m_timeLabel = a1->m_timeLabel;
setAnchorPoint = m_timeLabel->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v93.origin, 0.0, 0.5);
setAnchorPoint(m_timeLabel, &v93.origin);
v34 = a1->m_timeLabel;
v35 = v90 * 0.5;
v36 = v34->setPosition;
v37 = (float *)v34->getContentSize(v34);
v38 = a1->m_timeLabel;
v39 = *v37;
v40 = v38->getScale(v38);
cocos2d::CCPoint::CCPoint(
&v93.origin,
v35 - (float)((float)(v39 * v40) * 0.5),
(float)((float)(v91 * 0.5) + -140.0) + 15.0);
v36(v38, &v93.origin);
v95.adj = 0;
v95.ptr = (void (__cdecl *)(float))DailyLevelPage::updateTimers;
cocos2d::CCNode::schedule(a1, v95);
v41 = LoadingCircle::create();
a1->m_timeCircle = v41;
v41->m_parentLayer = a1->m_mainLayer;
m_timeCircle = a1->m_timeCircle;
m_timeCircle->m_fade = 0;
LoadingCircle::show(m_timeCircle);
m_sprite = a1->m_timeCircle->m_sprite;
v44 = m_sprite->setPosition;
cocos2d::CCPoint::CCPoint(&v93.origin, v90 * 0.5, (float)((float)(v91 * 0.5) + -140.0) + 17.0);
v44(m_sprite, &v93.origin);
a1->m_timeCircle->m_sprite->setScale(a1->m_timeCircle->m_sprite, 0.28);
a1->m_timeCircle->setVisible(a1->m_timeCircle, 0);
v45 = LoadingCircle::create();
a1->m_nodeCircle = v45;
v45->m_parentLayer = a1->m_mainLayer;
m_nodeCircle = a1->m_nodeCircle;
m_nodeCircle->m_fade = 0;
LoadingCircle::show(m_nodeCircle);
v47 = a1->m_nodeCircle->m_sprite;
v48 = v47->setPosition;
cocos2d::CCPoint::CCPoint(&v93.origin, v90 * 0.5, v91 * 0.5);
v48(v47, &v93.origin);
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 *)&v93);
v49 = (double)(__int64)v93.origin + (double)(__int64)v93.size / 1000000000.0;
v50 = GameLevelManager::sharedState();
if ( (double)GameLevelManager::getDailyTimer(v50, a1->m_type) < v49 )
{
v51 = GameLevelManager::sharedState();
GameLevelManager::resetDailyLevelState(v51, a1->m_type);
}
v52 = GameLevelManager::sharedState();
ActiveDailyID = GameLevelManager::getActiveDailyID(v52, a1->m_type);
if ( ActiveDailyID > 0 )
{
v54 = GameStatsManager::sharedState();
if ( GameStatsManager::hasCompletedDailyLevel(v54, ActiveDailyID) )
{
SavedDailyLevel = nullptr;
}
else
{
v55 = GameLevelManager::sharedState();
SavedDailyLevel = GameLevelManager::getSavedDailyLevel(v55, ActiveDailyID);
}
DailyLevelPage::createDailyNode(a1, SavedDailyLevel, 1, 0.0, 0);
}
v57 = GameLevelManager::sharedState();
if ( GameLevelManager::hasDailyStateBeenLoaded(v57, 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);
}
v58 = GameLevelManager::sharedState();
GameLevelManager::getGJDailyLevelState(v58, 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;
v59 = v89 - 24;
if ( v89 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v81 = (unsigned int *)(v89 - 8);
do
v82 = __ldaxr(v81);
while ( __stlxr(v82 - 1, v81) );
}
else
{
v82 = *((_DWORD *)v89 - 2);
*((_DWORD *)v89 - 2) = v82 - 1;
}
if ( v82 <= 0 )
operator delete(v59);
}
v60 = (char *)(v88 - 24);
if ( v88 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v79 = (unsigned int *)(v88 - 8);
do
v80 = __ldaxr(v79);
while ( __stlxr(v80 - 1, v79) );
}
else
{
v80 = *((_DWORD *)v88 - 2);
*((_DWORD *)v88 - 2) = v80 - 1;
}
if ( v80 <= 0 )
operator delete(v60);
}
p_m_fBrVertexMod = (char *)&v87[-1].m_fBrVertexMod;
if ( (__int64 *)&v87[-1].m_fBrVertexMod != &qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_fTextureTop = (unsigned int *)&v87[-1].m_fTextureTop;
do
m_fTextureTop_low = __ldaxr(p_m_fTextureTop);
while ( __stlxr(m_fTextureTop_low - 1, p_m_fTextureTop) );
}
else
{
m_fTextureTop_low = LODWORD(v87[-1].m_fTextureTop);
LODWORD(v87[-1].m_fTextureTop) = m_fTextureTop_low - 1;
}
if ( m_fTextureTop_low <= 0 )
operator delete(p_m_fBrVertexMod);
}
}
return v86;
}