//
// DailyLevelPage::init from 0x1001b8f8c to 0x1001b99ec (2656 bytes)
//
// 1 xrefs:
// > DailyLevelPage::create @ 0x1001b8f40
//
// 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 __fastcall DailyLevelPage::init(DailyLevelPage *a1, GJTimedLevelType a2)
{
_BOOL4 v4; // w19
int v5; // w8
cocos2d::CCDirector *v6; // x0
int v7; // w23
std::string::size_type v8; // x22
std::string *v9; // x0
cocos2d::extension::CCScale9Sprite *v10; // x22
__n128 v11; // q0
__n128 v12; // q1
std::string *v13; // x0
cocos2d::CCSprite *v14; // x22
__n128 v15; // q0
__n128 v16; // q1
int i; // w26
std::string *v18; // x0
cocos2d::CCSprite *v19; // x24
__n128 v20; // q0
__n128 v21; // q1
cocos2d::CCSprite *v22; // x25
__n128 v23; // q0
__n128 v24; // q1
int v25; // w8
float v26; // s0
float v27; // s0
int v28; // w8
float v29; // s0
float v30; // w8
float v31; // s0
cocos2d::CCSprite *v32; // x0
CCMenuItemSpriteExtra *v33; // x22
cocos2d::CCMenu *v34; // x22
float v35; // s2
__n128 v36; // q0
__n128 v37; // q1
cocos2d::CCSprite *v38; // x0
CCMenuItemSpriteExtra *v39; // x22
__n128 v40; // q0
cocos2d::CCMenu *m_buttonMenu; // x23
__n128 v42; // q1
const char *p_p; // x0
__n128 v44; // q0
__n128 v45; // q0
cocos2d::CCLabelBMFont *m_timeLabel; // x21
__n128 v47; // q1
cocos2d::CCLabelBMFont *v48; // x21
float v49; // s8
float v50; // s9
__n128 v51; // q0
__n128 v52; // q1
LoadingCircle *v53; // x0
cocos2d::CCSprite *m_sprite; // x21
__n128 v55; // q0
__n128 v56; // q1
LoadingCircle *v57; // x0
cocos2d::CCSprite *v58; // x21
__n128 v59; // q0
__n128 v60; // q1
__int64 millitm; // x21
int time; // w22
GameLevelManager *v63; // x0
GameLevelManager *v64; // x0
GameLevelManager *v65; // x0
int ActiveDailyID; // w21
GameStatsManager *v67; // x0
GJGameLevel *SavedDailyLevel; // x1
GameLevelManager *v69; // x0
GameLevelManager *v70; // x0
_BOOL4 hasDailyStateBeenLoaded; // w0
__int64 m_type; // x1
GameLevelManager *v73; // x0
timeb __p; // [xsp+8h] [xbp-E8h] BYREF
char v76; // [xsp+1Fh] [xbp-D1h]
cocos2d::CCPoint v77; // [xsp+20h] [xbp-D0h] BYREF
float v78; // [xsp+28h] [xbp-C8h]
float v79; // [xsp+2Ch] [xbp-C4h]
std::string v80; // [xsp+30h] [xbp-C0h] BYREF
std::string v81; // [xsp+48h] [xbp-A8h] BYREF
std::string v82; // [xsp+60h] [xbp-90h] BYREF
cocos2d::CCPoint v83; // 0:kr08_8.8
cocos2d::SEL_SCHEDULE v84; // 0:x1.16
cocos2d::SEL_MenuHandler v85; // 0:x3.16
cocos2d::SEL_MenuHandler v86; // 0:x3.16
cocos2d::CCRect v87; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
FLAlertLayer::incrementForcePrio(a1);
LODWORD(v82.__r_.__value_.__l.__data_) = -1778384896;
v4 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::ccColor4B *)&v82);
if ( !v4 )
return v4;
a1->m_type = a2;
memset(&v82, 0, sizeof(v82));
memset(&v81, 0, sizeof(v81));
memset(&v80, 0, sizeof(v80));
if ( a2 == Event )
{
std::string::assign(&v82, "eventLevelLabel_001.png");
std::string::assign(&v81, "dailyLevelCorner_001.png");
std::string::assign(&v80, "GJ_square05.png");
v5 = -3;
}
else if ( a2 == 1 )
{
std::string::assign(&v82, "weeklyLevelLabel_001.png");
std::string::assign(&v81, "gauntletCorner_001.png");
std::string::assign(&v80, "GJ_square05.png");
v5 = -2;
}
else
{
std::string::assign(&v82, "dailyLevelLabel_001.png");
std::string::assign(&v81, "dailyLevelCorner_001.png");
std::string::assign(&v80, "GJ_square01.png");
v5 = -1;
}
a1->m_downloadLevelID = v5;
GameManager::sharedState()->m_dailyLevelPage = a1;
((void (__fastcall *)(DailyLevelPage *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(DailyLevelPage *, __int64))a1->setKeypadEnabled)(a1, 1);
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v6);
a1->m_mainLayer = cocos2d::CCLayer::create();
((void (__fastcall *)(DailyLevelPage *))a1->addChild)(a1);
v7 = SHIBYTE(v80.__r_.__value_.__r.__words[2]);
v8 = v80.__r_.__value_.__r.__words[0];
sub_100022990((float *)&__p, 0.0, 0.0, 80.0, 80.0);
if ( v7 >= 0 )
v9 = &v80;
else
v9 = (std::string *)v8;
v10 = cocos2d::extension::CCScale9Sprite::create((const char *)v9, v87);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v10->setOpacity)(v10, 255);
sub_100022988((float *)&__p, 420.0, 280.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, timeb *))v10->setContentSize)(v10, &__p);
v11 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v10,
0xFFFFFFFFLL);
v11.n128_f32[0] = v78 * 0.5;
v12.n128_f32[0] = v79 * 0.5;
sub_100022980(v11, v12, &__p);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, timeb *))v10->setPosition)(v10, &__p);
if ( a1->m_type == Event )
{
BYTE2(__p.time) = -14;
LOWORD(__p.time) = 12222;
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, timeb *))v10->setColor)(v10, &__p);
}
a1->m_joystickConnected = -1;
if ( (v82.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v13 = &v82;
else
v13 = (std::string *)v82.__r_.__value_.__r.__words[0];
v14 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v13);
v15 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v14,
20);
v15.n128_f32[0] = v78 * 0.5;
v16.n128_f32[0] = (float)((float)(v79 * 0.5) + 140.0) + -29.0;
sub_100022980(v15, v16, &__p);
((void (__fastcall *)(cocos2d::CCSprite *, timeb *))v14->setPosition)(v14, &__p);
for ( i = 0; i != 4; ++i )
{
if ( (v81.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v18 = &v81;
else
v18 = (std::string *)v81.__r_.__value_.__r.__words[0];
v19 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v18);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v19,
8);
if ( a1->m_type == 1 )
{
v22 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare20_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v22->setScaleX)(v22, 0.3);
((void (__fastcall *)(cocos2d::CCSprite *, float))v22->setScaleY)(v22, 0.8);
((void (__fastcall *)(cocos2d::CCSprite *, void *))v22->setColor)(v22, &unk_100639CD2);
v23 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float))v22->setRotation)(v22, -45.0);
v23.n128_u32[0] = 2.0;
v24.n128_u32[0] = 2.0;
sub_100022980(v23, v24, &__p);
((void (__fastcall *)(cocos2d::CCSprite *, timeb *))v22->setPosition)(v22, &__p);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSprite *, __int64))v19->addChild_0)(v19, v22, 1);
((void (__fastcall *)(cocos2d::CCSprite *, float))v19->setScale)(v19, 0.63);
}
if ( i > 1 )
{
if ( i != 2 )
{
v31 = ((float (__fastcall *)(cocos2d::CCSprite *))v19->getScaleX)(v19);
((void (__fastcall *)(cocos2d::CCSprite *, float))v19->setScaleX)(v19, -v31);
v25 = 1127809024;
goto LABEL_29;
}
v26 = ((float (__fastcall *)(cocos2d::CCSprite *))v19->getScaleX)(v19);
((void (__fastcall *)(cocos2d::CCSprite *, float))v19->setScaleX)(v19, -v26);
v27 = ((float (__fastcall *)(cocos2d::CCSprite *))v19->getScaleY)(v19);
((void (__fastcall *)(cocos2d::CCSprite *, float))v19->setScaleY)(v19, -v27);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v19->setVisible)(v19, 0);
v28 = 1127809024;
LABEL_27:
v20.n128_u32[0] = v28;
v30 = 115.0;
goto LABEL_30;
}
if ( i )
{
v29 = ((float (__fastcall *)(cocos2d::CCSprite *))v19->getScaleY)(v19);
((void (__fastcall *)(cocos2d::CCSprite *, float))v19->setScaleY)(v19, -v29);
v28 = -1019674624;
goto LABEL_27;
}
v25 = -1019674624;
LABEL_29:
v20.n128_u32[0] = v25;
v30 = -115.0;
LABEL_30:
v20.n128_f32[0] = v20.n128_f32[0] + (float)(v78 * 0.5);
v21.n128_f32[0] = v30 + (float)(v79 * 0.5);
sub_100022980(v20, v21, &__p);
((void (__fastcall *)(cocos2d::CCSprite *, timeb *))v19->setPosition)(v19, &__p);
}
v32 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v85.ptr = (void (__cdecl *)(cocos2d::CCObject *))DailyLevelPage::onClose;
v85.adj = 0;
v33 = CCMenuItemSpriteExtra::create(v32, nullptr, a1, v85);
CCMenuItemSpriteExtra::setSizeMult(v33, 1.6);
v34 = (cocos2d::CCMenu *)sub_1001D7ED0(v33);
v35 = v79;
v36.n128_f32[0] = (float)((float)(v78 * 0.5) + -210.0) + 10.0;
a1->m_buttonMenu = v34;
v37.n128_f32[0] = (float)((float)(v35 * 0.5) + 140.0) + -10.0;
sub_100022980(v36, v37, &__p);
((void (__fastcall *)(cocos2d::CCMenu *, timeb *))v34->setPosition)(v34, &__p);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
a1->m_buttonMenu,
10);
v38 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_safeBtn_001.png");
v86.ptr = (void (__cdecl *)(cocos2d::CCObject *))DailyLevelPage::onTheSafe;
v86.adj = 0;
v39 = CCMenuItemSpriteExtra::create(v38, nullptr, a1, v86);
CCMenuItemSpriteExtra::setSizeMult(v39, 1.6);
v40 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
v39);
m_buttonMenu = a1->m_buttonMenu;
v40.n128_f32[0] = (float)((float)(v78 * 0.5) + 210.0) + -30.0;
v42.n128_f32[0] = (float)((float)(v79 * 0.5) + 140.0) + -30.0;
sub_100022980(v40, v42, &v77);
v83 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v77);
((void (__fastcall *)(CCMenuItemSpriteExtra *, timeb *, float, float))v39->setPosition)(v39, &__p, v83.x, v83.y);
DailyLevelPage::getDailyTimeString(&__p, a1, 0);
if ( v76 >= 0 )
p_p = (const char *)&__p;
else
p_p = (const char *)__p.time;
a1->m_timeLabel = cocos2d::CCLabelBMFont::create_1(p_p, "goldFont.fnt");
if ( v76 < 0 )
operator delete((void *)__p.time);
((void (__fastcall *)(cocos2d::CCLayer *))a1->m_mainLayer->addChild_0)(a1->m_mainLayer);
v44.n128_u32[0] = 1053609165;
if ( a2 != Event )
v44.n128_f32[0] = 0.5;
v45 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, __n128))a1->m_timeLabel->setScale)(a1->m_timeLabel, v44);
m_timeLabel = a1->m_timeLabel;
v45.n128_u32[0] = 0;
v47.n128_u32[0] = 0.5;
sub_100022980(v45, v47, &__p);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, timeb *))m_timeLabel->setAnchorPoint)(m_timeLabel, &__p);
v48 = a1->m_timeLabel;
v49 = v78;
v50 = *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v48->getContentSize)(v48);
v51.n128_f64[0] = ((double (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_timeLabel->getScale)(a1->m_timeLabel);
v51.n128_f32[0] = (float)(v49 * 0.5) + (float)((float)-(float)(v50 * v51.n128_f32[0]) * 0.5);
v52.n128_f32[0] = (float)((float)(v79 * 0.5) + -140.0) + 15.0;
sub_100022980(v51, v52, &__p);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, timeb *))v48->setPosition)(v48, &__p);
v84.ptr = (void (__cdecl *)(float))DailyLevelPage::updateTimers;
v84.adj = 0;
cocos2d::CCNode::schedule(a1, v84, 1.0);
v53 = LoadingCircle::create();
a1->m_timeCircle = v53;
v53->m_parentLayer = a1->m_mainLayer;
v53->m_fade = 0;
LoadingCircle::show(v53);
m_sprite = a1->m_timeCircle->m_sprite;
v55.n128_f32[0] = v78 * 0.5;
v56.n128_f32[0] = (float)((float)(v79 * 0.5) + -140.0) + 17.0;
sub_100022980(v55, v56, &__p);
((void (__fastcall *)(cocos2d::CCSprite *, timeb *))m_sprite->setPosition)(m_sprite, &__p);
((void (__fastcall *)(cocos2d::CCSprite *, float))a1->m_timeCircle->m_sprite->setScale)(
a1->m_timeCircle->m_sprite,
0.28);
((void (__fastcall *)(LoadingCircle *, _QWORD))a1->m_timeCircle->setVisible)(a1->m_timeCircle, 0);
v57 = LoadingCircle::create();
a1->m_nodeCircle = v57;
v57->m_parentLayer = a1->m_mainLayer;
v57->m_fade = 0;
LoadingCircle::show(v57);
v58 = a1->m_nodeCircle->m_sprite;
v59.n128_f32[0] = v78 * 0.5;
v60.n128_f32[0] = v79 * 0.5;
sub_100022980(v59, v60, &__p);
((void (__fastcall *)(cocos2d::CCSprite *, timeb *))v58->setPosition)(v58, &__p);
((void (__fastcall *)(cocos2d::CCSprite *, float))a1->m_nodeCircle->m_sprite->setScale)(
a1->m_nodeCircle->m_sprite,
0.5);
((void (__fastcall *)(LoadingCircle *, _QWORD))a1->m_nodeCircle->setVisible)(a1->m_nodeCircle, 0);
ftime(&__p);
millitm = __p.millitm;
time = __p.time;
v63 = GameLevelManager::sharedState();
if ( (double)(millitm + 1000 * (unsigned __int64)(time & 0xFFFFF)) / 1000.0 > (double)GameLevelManager::getDailyTimer(
v63,
a1->m_type) )
{
v64 = GameLevelManager::sharedState();
GameLevelManager::resetDailyLevelState(v64, a1->m_type);
}
v65 = GameLevelManager::sharedState();
ActiveDailyID = GameLevelManager::getActiveDailyID(v65, a1->m_type);
if ( ActiveDailyID >= 1 )
{
v67 = GameStatsManager::sharedState();
if ( GameStatsManager::hasCompletedDailyLevel(v67, ActiveDailyID) )
{
SavedDailyLevel = nullptr;
}
else
{
v69 = GameLevelManager::sharedState();
SavedDailyLevel = GameLevelManager::getSavedDailyLevel(v69, ActiveDailyID);
}
DailyLevelPage::createDailyNode(a1, SavedDailyLevel, 1, 0.0, 0);
}
v70 = GameLevelManager::sharedState();
hasDailyStateBeenLoaded = GameLevelManager::hasDailyStateBeenLoaded(v70, a1->m_type);
m_type = (unsigned int)a1->m_type;
if ( hasDailyStateBeenLoaded )
{
((void (__fastcall *)(DailyLevelPage *, __int64))a1->dailyStatusFinished)(a1, m_type);
}
else
{
if ( (_DWORD)m_type != 2 )
{
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))a1->m_timeLabel->setVisible)(a1->m_timeLabel, 0);
((void (__fastcall *)(LoadingCircle *, __int64))a1->m_timeCircle->setVisible)(a1->m_timeCircle, 1);
}
v73 = GameLevelManager::sharedState();
GameLevelManager::getGJDailyLevelState(v73, a1->m_type);
if ( !a1->m_dailyNode )
((void (__fastcall *)(LoadingCircle *, __int64))a1->m_nodeCircle->setVisible)(a1->m_nodeCircle, 1);
}
GameLevelManager::sharedState()->m_GJDailyLevelDelegate = &a1->GJDailyLevelDelegate;
GameLevelManager::sharedState()->m_levelDownloadDelegate = &a1->LevelDownloadDelegate;
if ( SHIBYTE(v80.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v80.__r_.__value_.__l.__data_);
if ( SHIBYTE(v81.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v81.__r_.__value_.__l.__data_);
if ( SHIBYTE(v82.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v82.__r_.__value_.__l.__data_);
return v4;
}