//
// LevelSelectLayer::init from 0x100401954 to 0x10040222c (2264 bytes)
//
// 1 xrefs:
// > LevelSelectLayer::create @ 0x100401908
//
// 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 LevelSelectLayer::init(LevelSelectLayer *a1, int a2)
{
_BOOL4 v4; // w19
GameStatsManager *v5; // x0
GameManager *v6; // x0
int v7; // w22
AchievementManager *v8; // x0
cocos2d::CCDirector *v9; // x0
cocos2d::CCSprite *v10; // x23
__n128 v11; // q0
__n128 v12; // q1
__n128 v13; // q0
cocos2d::CCSprite *m_backgroundSprite; // x23
__n128 v15; // q1
cocos2d::CCSprite *v16; // x0
GameManager *v17; // x0
GJGroundLayer *v18; // x0
float v19; // s0
cocos2d::CCSprite *v20; // x23
__n128 v21; // q0
__n128 v22; // q1
float v23; // s8
cocos2d::CCDirector *v24; // x0
__n128 v25; // q1
__n128 v26; // q0
cocos2d::CCSprite *v27; // x24
__n128 v28; // q0
__n128 v29; // q1
cocos2d::CCDirector *v30; // x0
float v31; // s8
cocos2d::CCDirector *v32; // x0
__n128 v33; // q1
__n128 v34; // q0
cocos2d::CCSprite *v35; // x23
__n128 v36; // q0
__n128 v37; // q1
cocos2d::CCDirector *v38; // x0
float v39; // s8
cocos2d::CCDirector *v40; // x0
__n128 v41; // q1
__n128 v42; // q0
cocos2d::CCArray *v43; // x23
cocos2d::CCArray *v44; // x24
GameLevelManager *v45; // x0
int v46; // w22
GJGameLevel *v47; // x22
float v48; // s0
GJGameLevel *v49; // x22
float v50; // s0
BoomScrollLayer *v51; // x0
BoomScrollLayer *m_scrollLayer; // x22
float v53; // s8
cocos2d::CCDirector *v54; // x0
__n128 v55; // q1
__n128 v56; // q0
BoomScrollLayer *v57; // x0
int v58; // w1
float v59; // s0
cocos2d::CCLabelBMFont *v60; // x21
CCMenuItemSpriteExtra *v61; // x21
__int64 v62; // x1
__int64 v63; // x2
__int64 v64; // x3
__int64 v65; // x4
__int64 v66; // x5
__int64 v67; // x6
__int64 v68; // x7
cocos2d::CCMenu *v69; // x21
float v70; // s8
cocos2d::CCDirector *v71; // x0
__n128 v72; // q1
__n128 v73; // q0
unsigned __int32 v74; // s8
float v75; // s10
cocos2d::CCMenu *v76; // x22
_BOOL4 isControllerConnected; // w21
const char *v78; // x0
cocos2d::CCSprite *v79; // x0
cocos2d::CCNode *v80; // x24
const char *v81; // x23
CCMenuItemSpriteExtra *v82; // x24
cocos2d::CCDirector *v83; // x0
__n128 v84; // q0
__n128 v85; // q1
cocos2d::CCSprite *v86; // x0
CCMenuItemSpriteExtra *v87; // x23
cocos2d::CCDirector *v88; // x0
__n128 v89; // q0
__n128 v90; // q1
cocos2d::CCSprite *v91; // x0
CCMenuItemSpriteExtra *v92; // x22
__int64 v93; // x1
__int64 v94; // x2
__int64 v95; // x3
__int64 v96; // x4
__int64 v97; // x5
__int64 v98; // x6
__int64 v99; // x7
cocos2d::CCMenu *v100; // x23
cocos2d::CCDirector *v101; // x0
float v102; // s8
cocos2d::CCDirector *v103; // x0
__n128 v104; // q1
__n128 v105; // q0
cocos2d::CCMenu *v106; // x23
cocos2d::CCSprite *v107; // x0
CCMenuItemSpriteExtra *v108; // x24
cocos2d::CCDirector *v109; // x0
float v110; // s8
cocos2d::CCDirector *v111; // x0
__n128 v112; // q1
__n128 v113; // q0
cocos2d::CCPoint v115; // [xsp+8h] [xbp-68h] BYREF
__int64 v116; // [xsp+10h] [xbp-60h] BYREF
float v117; // [xsp+18h] [xbp-58h]
float v118; // [xsp+1Ch] [xbp-54h]
cocos2d::CCPoint v119; // 0:kr08_8.8
cocos2d::CCPoint v120; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v121; // 0:x3.16
cocos2d::SEL_MenuHandler v122; // 0:x3.16
cocos2d::SEL_MenuHandler v123; // 0:x3.16
cocos2d::SEL_MenuHandler v124; // 0:x3.16
cocos2d::SEL_MenuHandler v125; // 0:x3.16
cocos2d::CCPoint v126; // 0:s0.4,4:s1.4
v4 = cocos2d::CCLayer::init(a1);
if ( v4 )
{
v5 = GameStatsManager::sharedState();
if ( GameStatsManager::isItemUnlocked(v5, GJItem, 4) )
{
v6 = GameManager::sharedState();
GameManager::setUGV(v6, "6", 1);
}
v7 = 1;
((void (__fastcall *)(LevelSelectLayer *, __int64))a1->setKeypadEnabled)(a1, 1);
((void (__fastcall *)(LevelSelectLayer *, __int64))a1->setKeyboardEnabled)(a1, 1);
byte_100886DC0 = 0;
v8 = AchievementManager::sharedState();
a1->m_masterDetectiveUnlocked = AchievementManager::isAchievementEarned(v8, "geometry.ach.secret04");
v9 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v9);
v10 = cocos2d::CCSprite::create("GJ_gradientBG.png");
a1->m_backgroundSprite = v10;
v11.n128_u32[0] = 0;
v12.n128_u32[0] = 0;
sub_100022980(v11, v12, &v116);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v10->setAnchorPoint)(v10, &v116);
((void (__fastcall *)(LevelSelectLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(
a1,
a1->m_backgroundSprite,
4294967294LL);
((void (__fastcall *)(cocos2d::CCSprite *, float))a1->m_backgroundSprite->setScaleX)(
a1->m_backgroundSprite,
(float)(v117 + 10.0) / a1->m_backgroundSprite->m_obRect.size.width);
v13 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float))a1->m_backgroundSprite->setScaleY)(
a1->m_backgroundSprite,
(float)(v118 + 10.0) / a1->m_backgroundSprite->m_obRect.size.height);
m_backgroundSprite = a1->m_backgroundSprite;
v13.n128_u32[0] = -5.0;
v15.n128_u32[0] = -5.0;
sub_100022980(v13, v15, &v116);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))m_backgroundSprite->setPosition)(m_backgroundSprite, &v116);
v16 = a1->m_backgroundSprite;
BYTE2(v116) = -1;
LOWORD(v116) = 32040;
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v16->setColor)(v16, &v116);
v17 = GameManager::sharedState();
v18 = GJGroundLayer::create(v17->m_loadedGroundID, 1);
a1->m_groundLayer = v18;
((void (__fastcall *)(LevelSelectLayer *, GJGroundLayer *, _QWORD))a1->addChild_0)(a1, v18, 0);
v19 = (float)(v118 * 0.5) + -110.0;
if ( v19 > 128.0 )
v19 = 128.0;
GJGroundLayer::positionGround(a1->m_groundLayer, v19);
v20 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_topBar_001.png");
v21.n128_u32[0] = 0.5;
v22.n128_u32[0] = 1.0;
sub_100022980(v21, v22, &v116);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v20->setAnchorPoint)(v20, &v116);
v23 = v117 * 0.5;
v24 = cocos2d::CCDirector::sharedDirector();
v25.n128_f32[0] = sub_1001768C8((__int64)v24) + 1.0;
v26.n128_f32[0] = v23;
sub_100022980(v26, v25, &v116);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v20->setPosition)(v20, &v116);
((void (__fastcall *)(LevelSelectLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v20, 1);
v27 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
v28.n128_u32[0] = 0;
v29.n128_u32[0] = 0;
sub_100022980(v28, v29, &v116);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v27->setAnchorPoint)(v27, &v116);
v30 = cocos2d::CCDirector::sharedDirector();
v31 = sub_1001768D8((__int64)v30) + -1.0;
v32 = cocos2d::CCDirector::sharedDirector();
v33.n128_f32[0] = sub_1001768D0((__int64)v32) + -1.0;
v34.n128_f32[0] = v31;
sub_100022980(v34, v33, &v116);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v27->setPosition)(v27, &v116);
((void (__fastcall *)(LevelSelectLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v27, 1);
v35 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
v36.n128_u32[0] = 1.0;
v37.n128_u32[0] = 0;
sub_100022980(v36, v37, &v116);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v35->setAnchorPoint)(v35, &v116);
v38 = cocos2d::CCDirector::sharedDirector();
v39 = sub_1001768E0((__int64)v38) + 1.0;
v40 = cocos2d::CCDirector::sharedDirector();
v41.n128_f32[0] = sub_1001768D0((__int64)v40) + -1.0;
v42.n128_f32[0] = v39;
sub_100022980(v42, v41, &v116);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v35->setPosition)(v35, &v116);
cocos2d::CCSprite::setFlipX(v35, 1);
((void (__fastcall *)(LevelSelectLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v35, 1);
v43 = (cocos2d::CCArray *)sub_10024A15C();
v44 = (cocos2d::CCArray *)sub_10024A15C();
do
{
v45 = GameLevelManager::sharedState();
GameLevelManager::getMainLevel(v45, v7, 1);
sub_10024A2D0((__int64)v44);
++v7;
}
while ( v7 != 23 );
v46 = 3;
do
{
LevelPage::create(nullptr);
sub_10024A2D0((__int64)v43);
--v46;
}
while ( v46 );
v47 = GJGameLevel::create_1();
v47->m_levelID.value = -2;
v48 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v47->m_levelID.seed = (int)v48;
v47->m_levelID.random = (int)v48 - 2;
sub_10024A2D0((__int64)v44);
v49 = GJGameLevel::create_1();
v49->m_levelID.value = -1;
v50 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v49->m_levelID.seed = (int)v50;
v49->m_levelID.random = (int)v50 - 1;
sub_10024A2D0((__int64)v44);
v51 = BoomScrollLayer::create(v43, 0, 1, v44, &a1->DynamicScrollDelegate);
a1->m_scrollLayer = v51;
((void (__fastcall *)(LevelSelectLayer *, BoomScrollLayer *))a1->addChild)(a1, v51);
m_scrollLayer = a1->m_scrollLayer;
v53 = v117 * 0.5;
v54 = cocos2d::CCDirector::sharedDirector();
v55.n128_f32[0] = sub_1001768D0((__int64)v54) + 15.0;
v56.n128_f32[0] = v53;
sub_100022980(v56, v55, &v116);
BoomScrollLayer::setPagesIndicatorPosition(m_scrollLayer, v126);
a1->m_width = v117;
v57 = a1->m_scrollLayer;
v57->m_extendedLayer->m_delegate = &a1->BoomScrollLayerDelegate;
if ( a2 )
{
if ( a2 == 23 )
{
BoomScrollLayer::instantMoveToPage(v57, 22);
v57 = a1->m_scrollLayer;
v58 = 23;
}
else
{
v58 = a2;
}
BoomScrollLayer::instantMoveToPage(v57, v58);
}
else
{
v59 = sub_1000229B8(&v116, &qword_10086E9E0);
((void (__fastcall *)(LevelSelectLayer *, __int64 *, float))a1->scrollLayerMoved)(a1, &v116, v59);
}
v60 = cocos2d::CCLabelBMFont::create_1("Download the soundtrack", "bigFont.fnt");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v60->setScale)(v60, 0.5);
v121.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelSelectLayer::onDownload;
v121.adj = 0;
v61 = CCMenuItemSpriteExtra::create(v60, nullptr, a1, v121);
CCMenuItemSpriteExtra::setSizeMult(v61, 1.1);
v69 = sub_1001D7ED0(v61, v62, v63, v64, v65, v66, v67, v68, 0);
((void (__fastcall *)(LevelSelectLayer *, cocos2d::CCMenu *))a1->addChild)(a1, v69);
v70 = v117 * 0.5;
v71 = cocos2d::CCDirector::sharedDirector();
v72.n128_f32[0] = sub_1001768D0((__int64)v71) + 35.0;
v73.n128_f32[0] = v70;
sub_100022980(v73, v72, &v116);
((void (__fastcall *)(cocos2d::CCMenu *, __int64 *))v69->setPosition)(v69, &v116);
*(float *)&v74 = v118 * 0.5;
if ( AppDelegate::get()->m_startupScriptFilename.m_data.m_short.shortStorage.__elems_[4] )
v75 = 50.0;
else
v75 = 25.0;
v76 = cocos2d::CCMenu::create();
((void (__fastcall *)(LevelSelectLayer *, cocos2d::CCMenu *, __int64))a1->addChild_0)(a1, v76, 5);
isControllerConnected = PlatformToolbox::isControllerConnected();
if ( isControllerConnected )
v78 = "controllerBtn_DPad_Left_001.png";
else
v78 = "navArrowBtn_001.png";
v79 = cocos2d::CCSprite::createWithSpriteFrameName(v78);
v80 = v79;
if ( isControllerConnected )
{
v81 = "controllerBtn_DPad_Right_001.png";
}
else
{
cocos2d::CCSprite::setFlipX(v79, 1);
v81 = "navArrowBtn_001.png";
}
v122.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelSelectLayer::onPrev;
v122.adj = 0;
v82 = CCMenuItemSpriteExtra::create(v80, nullptr, a1, v122);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v76->addChild)(v76, v82);
CCMenuItemSpriteExtra::setSizeMult(v82, 2.0);
v83 = cocos2d::CCDirector::sharedDirector();
v84.n128_f32[0] = v75 + sub_1001768D8((__int64)v83);
v85.n128_u32[0] = v74;
sub_100022980(v84, v85, &v115);
v119 = cocos2d::CCNode::convertToNodeSpace(v76, &v115);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))v82->setPosition)(
v82,
&v116,
v119.x,
v119.y);
v86 = cocos2d::CCSprite::createWithSpriteFrameName(v81);
v123.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelSelectLayer::onNext;
v123.adj = 0;
v87 = CCMenuItemSpriteExtra::create(v86, nullptr, a1, v123);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v76->addChild)(v76, v87);
CCMenuItemSpriteExtra::setSizeMult(v87, 2.0);
v88 = cocos2d::CCDirector::sharedDirector();
v89.n128_f32[0] = sub_1001768E0((__int64)v88) - v75;
v90.n128_u32[0] = v74;
sub_100022980(v89, v90, &v115);
v120 = cocos2d::CCNode::convertToNodeSpace(v76, &v115);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))v87->setPosition)(
v87,
&v116,
v120.x,
v120.y);
v91 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v124.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelSelectLayer::onBack;
v124.adj = 0;
v92 = CCMenuItemSpriteExtra::create(v91, nullptr, a1, v124);
CCMenuItemSpriteExtra::setSizeMult(v92, 1.6);
v100 = sub_1001D7ED0(v92, v93, v94, v95, v96, v97, v98, v99, 0);
((void (__fastcall *)(LevelSelectLayer *, cocos2d::CCMenu *, __int64))a1->addChild_0)(a1, v100, 1);
v101 = cocos2d::CCDirector::sharedDirector();
v102 = sub_1001768D8((__int64)v101) + 25.0;
v103 = cocos2d::CCDirector::sharedDirector();
v104.n128_f32[0] = sub_1001768C8((__int64)v103) + -22.0;
v105.n128_f32[0] = v102;
sub_100022980(v105, v104, &v116);
((void (__fastcall *)(cocos2d::CCMenu *, __int64 *))v100->setPosition)(v100, &v116);
GameManager::sharedState()->m_somethingInMenuLayer = 0;
v106 = cocos2d::CCMenu::create();
((void (__fastcall *)(LevelSelectLayer *, cocos2d::CCMenu *))a1->addChild)(a1, v106);
v107 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
v125.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelSelectLayer::onInfo;
v125.adj = 0;
v108 = CCMenuItemSpriteExtra::create(v107, nullptr, a1, v125);
CCMenuItemSpriteExtra::setSizeMult(v108, 2.0);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v106->addChild)(v106, v108);
v109 = cocos2d::CCDirector::sharedDirector();
v110 = sub_1001768E0((__int64)v109) + -20.0;
v111 = cocos2d::CCDirector::sharedDirector();
v112.n128_f32[0] = sub_1001768C8((__int64)v111) + -20.0;
v113.n128_f32[0] = v110;
sub_100022980(v113, v112, &v116);
((void (__fastcall *)(cocos2d::CCMenu *, __int64 *))v106->setPosition)(v106, &v116);
if ( isControllerConnected )
GameToolbox::addBackButton(a1, v92);
}
return v4;
}