//
// MapSelectLayer::init from 0x100267f40 to 0x1002685e4 (1700 bytes)
//
// 1 xrefs:
// > ??> @ 0x1008eb0a8
//
// 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 MapSelectLayer::init(MapSelectLayer *a1)
{
__int64 v1; // rsi
bool result; // al
bool v4; // r13
cocos2d::CCArray *v5; // rax
cocos2d::CCSprite *v6; // rax
CCMenuItemSpriteExtra *v7; // rax
int v8; // r14d
int v9; // edx
int v10; // ecx
int v11; // r8d
int v12; // r9d
__int64 v13; // r14
cocos2d::CCDirector *v14; // rax
cocos2d::CCDirector *v15; // rax
double v16; // xmm0_8
GJBigSprite *v17; // r14
cocos2d::CCNode *v18; // rax
GameManager *v19; // rax
SimplePlayer *v20; // rax
GJMapObject *v21; // r14
double v22; // xmm0_8
SimplePlayer *m_player; // r15
SimplePlayer *v24; // r15
GameManager *v25; // r12
GameManager *v26; // rax
GameManager *v27; // r12
GameManager *v28; // rax
GameManager *v29; // rax
SimplePlayer *v30; // r15
GameManager *v31; // r12
GameManager *v32; // rax
unsigned int v33; // r15d
unsigned int v34; // eax
int v35; // ecx
int v36; // r8d
int v37; // r9d
cocos2d::CCAction *v38; // rax
int v39; // r12d
GJMapObject *Monster; // r15
int v41; // eax
int v42; // eax
double v43; // xmm0_8
GJMapObject *v44; // r14
double v45; // xmm0_8
GameLevelManager *v46; // rax
GJGameLevel *LocalLevelByName; // r14
GameLevelManager *v48; // rax
LevelEditorLayer *v49; // rax
LevelEditorLayer *m_editorLayer; // rsi
LevelEditorLayer *v51; // rdi
char v52; // [rsp+8h] [rbp-68h] BYREF
char v53[15]; // [rsp+9h] [rbp-67h] BYREF
void *__p; // [rsp+18h] [rbp-58h]
std::string __str; // [rsp+20h] [rbp-50h] BYREF
cocos2d::ccColor3B v56; // [rsp+38h] [rbp-38h] BYREF
float v57; // [rsp+3Ch] [rbp-34h]
cocos2d::ccColor3B v58[16]; // [rsp+40h] [rbp-30h] BYREF
result = cocos2d::CCLayer::init(a1);
if ( result )
{
v4 = result;
v5 = (cocos2d::CCArray *)sub_10071F9E0(a1, v1);
a1->m_monsters = v5;
cocos2d::CCObject::retain(v5);
v6 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v7 = CCMenuItemSpriteExtra::create(
v6,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)MapSelectLayer::onBack);
v8 = (int)v7;
CCMenuItemSpriteExtra::setSizeMult(v7, 1.6);
v13 = sub_100792C50(v8, 0, v9, v10, v11, v12);
((void (__fastcall *)(MapSelectLayer *, __int64, __int64))a1->addChild_0)(a1, v13, 1);
v14 = cocos2d::CCDirector::sharedDirector();
v57 = sub_100484D90(v14) + 25.0;
v15 = cocos2d::CCDirector::sharedDirector();
v16 = sub_100484D70(v15);
sub_10028CBE0(v58, v57, *(float *)&v16 + -22.0);
(*(void (__fastcall **)(__int64, cocos2d::ccColor3B *))(*(_QWORD *)v13 + 184LL))(v13, v58);
GameManager::sharedState()->m_somethingInMenuLayer = 0;
v17 = (GJBigSprite *)operator new(0x170u);
cocos2d::CCNode::CCNode(v17);
v17->__vftable = (GJBigSprite_vtbl *)off_1008EB5D0;
*(_OWORD *)&v17->m_spritesLoaded.__begin_ = 0;
v17->m_spritesLoaded.__end_cap_.__value_ = nullptr;
*(_WORD *)&v17->m_loadSprites = 0;
if ( GJBigSprite::init(v17) )
{
cocos2d::CCObject::autorelease(v17);
}
else
{
((void (__fastcall *)(GJBigSprite *))v17->~GJBigSprite_0)(v17);
v17 = nullptr;
}
a1->m_bigSprite = v17;
sub_10028CBE0(v58, -165.0, -800.0);
((void (__fastcall *)(GJBigSprite *, cocos2d::ccColor3B *))v17->setPosition)(v17, v58);
GJBigSprite::updateSpriteVisibility(a1->m_bigSprite);
a1->m_bigSprite->m_loadSprites = 1;
v18 = cocos2d::CCNode::create();
a1->m_mainLayer = v18;
((void (__fastcall *)(GJBigSprite *, cocos2d::CCNode *, __int64))a1->m_bigSprite->addChild_0)(
a1->m_bigSprite,
v18,
20);
v19 = GameManager::sharedState();
v20 = SimplePlayer::create(v19->m_playerFrame.random - v19->m_playerFrame.seed);
a1->m_player = v20;
((void (__fastcall *)(SimplePlayer *, float))v20->setScale)(v20, 0.5);
v21 = GJMapObject::create(a1->m_player);
((void (__fastcall *)(cocos2d::CCNode *, GJMapObject *, _QWORD))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v21,
0);
sub_10028CBE0(v58, 462.0, 950.0);
v21->m_objectOffset = 0.0;
v22 = sub_10028CC90();
((void (__fastcall *)(GJMapObject *, cocos2d::ccColor3B *, double))v21->setPosition)(v21, v58, v22);
m_player = a1->m_player;
m_player->m_hasGlowOutline = GameManager::sharedState()->m_playerGlow;
v24 = a1->m_player;
v25 = GameManager::sharedState();
v26 = GameManager::sharedState();
v58[0] = GameManager::colorForIdx(v25, v26->m_playerColor.random - v26->m_playerColor.seed);
v27 = GameManager::sharedState();
v28 = GameManager::sharedState();
v56 = GameManager::colorForIdx(v27, v28->m_playerColor2.random - v28->m_playerColor2.seed);
SimplePlayer::setColors(v24, v58, &v56);
v29 = GameManager::sharedState();
v30 = a1->m_player;
if ( v29->m_playerGlowColor.random >= v29->m_playerGlowColor.seed )
{
v31 = GameManager::sharedState();
v32 = GameManager::sharedState();
v58[0] = GameManager::colorForIdx(v31, v32->m_playerGlowColor.random - v32->m_playerGlowColor.seed);
SimplePlayer::enableCustomGlowColor(v30, v58);
}
else
{
SimplePlayer::disableCustomGlowColor(a1->m_player);
}
SimplePlayer::updateColors(a1->m_player);
v33 = (unsigned int)cocos2d::CCDelayTime::create(1.0);
v34 = (unsigned int)cocos2d::CCCallFunc::create(
v21,
(cocos2d::SEL_CallFunc)(unsigned __int64)GJMapObject::playerJump);
v38 = (cocos2d::CCAction *)sub_1003B5760(v33, v34, 0, v35, v36, v37);
cocos2d::CCNode::runAction(v21, v38);
v39 = 10;
do
{
Monster = GJMapObject::createMonster(918);
((void (__fastcall *)(cocos2d::CCNode *, GJMapObject *, _QWORD))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
Monster,
0);
v41 = rand();
v57 = (float)((float)((float)((float)((float)v41 * 4.6566129e-10) + (float)((float)v41 * 4.6566129e-10)) + -1.0)
* 100.0)
+ 600.0;
v42 = rand();
sub_10028CBE0(
v58,
v57,
(float)((float)((float)((float)((float)v42 * 4.6566129e-10) + (float)((float)v42 * 4.6566129e-10)) + -1.0)
* 100.0)
+ 600.0);
Monster->m_objectOffset = 50.0;
v43 = sub_10028CC90();
((void (__fastcall *)(GJMapObject *, cocos2d::ccColor3B *, double))Monster->setPosition)(Monster, v58, v43);
sub_10071FCD0(a1->m_monsters, Monster);
--v39;
}
while ( v39 );
v44 = GJMapObject::createMonster(1327);
((void (__fastcall *)(cocos2d::CCNode *, GJMapObject *, _QWORD))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v44,
0);
sub_10028CBE0(v58, 436.0, 776.0);
v44->m_objectOffset = 50.0;
v45 = sub_10028CC90();
((void (__fastcall *)(GJMapObject *, cocos2d::ccColor3B *, double))v44->setPosition)(v44, v58, v45);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v44->m_shadowSprite->setVisible)(v44->m_shadowSprite, 0);
sub_10071FCD0(a1->m_monsters, v44);
a1->m_editMode = 0;
v46 = GameLevelManager::sharedState();
v52 = 14;
strcpy(v53, "gamemap");
LocalLevelByName = (GJGameLevel *)GameLevelManager::getLocalLevelByName(v46, &v52);
if ( (v52 & 1) != 0 )
operator delete(__p);
if ( !LocalLevelByName )
{
v48 = GameLevelManager::sharedState();
LocalLevelByName = GameLevelManager::createNewLevel(v48);
__str.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)14;
strcpy(__str.__r_.__value_.__s.__data_, "gamemap");
std::string::operator=((std::string *)&LocalLevelByName->m_levelName, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}
v49 = LevelEditorLayer::create(LocalLevelByName, !a1->m_editMode);
a1->m_editorLayer = v49;
LevelEditorLayer::toggleBackground(v49, 0);
LevelEditorLayer::toggleGround(a1->m_editorLayer, 0);
m_editorLayer = a1->m_editorLayer;
if ( a1->m_editMode )
{
((void (__fastcall *)(MapSelectLayer *, LevelEditorLayer *))a1->addChild)(a1, m_editorLayer);
((void (__fastcall *)(LevelEditorLayer *, GJBigSprite *, __int64))a1->m_editorLayer->addChild_0)(
a1->m_editorLayer,
a1->m_bigSprite,
4294967196LL);
}
else
{
m_editorLayer->m_alwaysHideParticleIcons = 1;
LevelEditorLayer::updatePreviewParticles(m_editorLayer);
v51 = a1->m_editorLayer;
v51->m_alwaysPreviewMode = 1;
LevelEditorLayer::updateEditorMode(v51);
((void (__fastcall *)(MapSelectLayer *, GJBigSprite *))a1->addChild)(a1, a1->m_bigSprite);
((void (__fastcall *)(cocos2d::CCNode *, LevelEditorLayer *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
a1->m_editorLayer,
100);
((void (__fastcall *)(MapSelectLayer *, __int64))a1->setKeypadEnabled)(a1, 1);
((void (__fastcall *)(MapSelectLayer *, __int64))a1->setKeyboardEnabled)(a1, 1);
((void (__fastcall *)(MapSelectLayer *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(MapSelectLayer *, __int64))a1->setMouseEnabled)(a1, 1);
}
cocos2d::CCNode::scheduleUpdate(a1);
return v4;
}
return result;
}