//
// UILayer::init from 0x1004c7c00 to 0x1004c8344 (1860 bytes)
//
// 1 xrefs:
// > UILayer::create @ 0x1004c7bbe
//
// 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 UILayer::init(UILayer *a1, GJBaseGameLayer *a2)
{
bool result; // al
GameManager *v4; // rdi
cocos2d::CCArray *v5; // rax
GameManager *v6; // rax
GameManager *v7; // rax
GJUINode *v8; // r15
GameManager *v9; // rax
GJUINode *v10; // r15
GameManager *v11; // rax
GJUINode *v12; // r15
GameManager *v13; // rax
GJUINode *v14; // r15
cocos2d::CCSprite *v15; // r15
CCMenuItemSpriteExtra *v16; // rax
cocos2d::CCSize WinSize; // xmm0_8
int v18; // edx
int v19; // ecx
int v20; // r8d
int v21; // r9d
__int64 v22; // r15
GameManager *v23; // rax
cocos2d::CCDirector *v24; // rax
GameManager *v25; // rax
cocos2d::CCDirector *v26; // rax
cocos2d::CCDirector *v27; // rax
cocos2d::CCMenu *v28; // rax
cocos2d::CCMenu *v29; // rsi
cocos2d::CCArray *v30; // rax
cocos2d::CCSprite *v31; // r14
CCMenuItemSpriteExtra *v32; // r13
cocos2d::CCSprite *v33; // r14
CCMenuItemSpriteExtra *v34; // r12
cocos2d::CCMenu *m_checkpointMenu; // rdi
cocos2d::CCArray *v36; // r14
GameManager *v37; // rax
bool GameVariable; // al
bool v39; // cl
cocos2d::CCMenu *v40; // r12
GameManager *v41; // rax
GameManager *v42; // rax
cocos2d::CCSprite *v43; // r12
cocos2d::CCSprite *v44; // r14
__int64 v45; // rax
void *v46; // rax
cocos2d::CCLabelBMFont *v47; // r13
cocos2d::CCSprite *v48; // r14
__int64 v49; // rax
void *v50; // r15
cocos2d::CCSprite *v51; // r14
__int64 v52; // rax
unsigned int v53; // r14d
__int64 v54; // rax
cocos2d::ccColor4B v55; // [rsp+8h] [rbp-58h] BYREF
__int64 v56; // [rsp+10h] [rbp-50h] BYREF
cocos2d::CCSprite *v57; // [rsp+18h] [rbp-48h]
float v58; // [rsp+24h] [rbp-3Ch]
cocos2d::CCSprite *v59; // [rsp+28h] [rbp-38h]
bool v60; // [rsp+37h] [rbp-29h]
cocos2d::CCPoint v61; // 0:xmm1_8.8
v55 = 0;
result = cocos2d::CCLayerColor::initWithColor(a1, &v55);
if ( result )
{
v60 = result;
v4 = GameManager::sharedState();
a1->m_initialized = GameManager::getGameVariable(v4, "0024");
a1->m_gameLayer = a2;
v5 = (cocos2d::CCArray *)sub_10071F9E0(v4, "0024");
a1->m_uiNodes = v5;
cocos2d::CCObject::retain(v5);
v6 = GameManager::sharedState();
GameManager::prepareDPadSettings(v6);
v7 = GameManager::sharedState();
v8 = GJUINode::create(&v7->m_dpad1);
((void (__fastcall *)(UILayer *, GJUINode *, __int64))a1->addChild_0)(a1, v8, 100);
((void (__fastcall *)(GJUINode *, _QWORD))v8->setVisible)(v8, 0);
sub_10071FCD0(a1->m_uiNodes, v8);
v9 = GameManager::sharedState();
v10 = GJUINode::create(&v9->m_dpad1);
((void (__fastcall *)(UILayer *, GJUINode *, __int64))a1->addChild_0)(a1, v10, 100);
((void (__fastcall *)(GJUINode *, _QWORD))v10->setVisible)(v10, 0);
sub_10071FCD0(a1->m_uiNodes, v10);
v10->m_player2 = 1;
v11 = GameManager::sharedState();
v12 = GJUINode::create(&v11->m_dpad4);
((void (__fastcall *)(UILayer *, GJUINode *, __int64))a1->addChild_0)(a1, v12, 100);
((void (__fastcall *)(GJUINode *, _QWORD))v12->setVisible)(v12, 0);
sub_10071FCD0(a1->m_uiNodes, v12);
v13 = GameManager::sharedState();
v14 = GJUINode::create(&v13->m_dpad4);
((void (__fastcall *)(UILayer *, GJUINode *, __int64))a1->addChild_0)(a1, v14, 100);
((void (__fastcall *)(GJUINode *, _QWORD))v14->setVisible)(v14, 0);
sub_10071FCD0(a1->m_uiNodes, v14);
v14->m_player2 = 1;
((void (__fastcall *)(UILayer *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(UILayer *, __int64))a1->setKeypadEnabled)(a1, 1);
((void (__fastcall *)(UILayer *, __int64))a1->setKeyboardEnabled)(a1, 1);
cocos2d::CCDirector::sharedDirector();
WinSize = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v55);
v15 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_pauseBtn_clean_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, __int64, double))v15->setOpacity)(v15, 75, *(double *)&WinSize);
v16 = CCMenuItemSpriteExtra::create(v15, nullptr, a1, (cocos2d::SEL_MenuHandler)(unsigned __int64)UILayer::onPause);
a1->m_pauseBtn = v16;
v16->m_volume = 0.0;
WinSize.height = 0.0;
CCMenuItemSpriteExtra::setSizeMult(v16, 4.0);
v22 = sub_100792C50(a1->m_pauseBtn, 0, v18, v19, v20, v21);
((void (__fastcall *)(UILayer *, __int64, __int64))a1->addChild_0)(a1, v22, 16);
v23 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v23, "0024") )
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_pauseBtn->setVisible)(a1->m_pauseBtn, 0);
v24 = cocos2d::CCDirector::sharedDirector();
LODWORD(v59) = sub_100484DA0((__int64)v24);
v25 = GameManager::sharedState();
if ( GameManager::getGameVariable(v25, "0015") )
{
v26 = cocos2d::CCDirector::sharedDirector();
WinSize.width = sub_100484D90((__int64)v26) + 15.0;
}
else
{
WinSize = (cocos2d::CCSize)(unsigned int)v59;
WinSize.width = *(float *)&v59 + -15.0;
}
*(float *)&v59 = WinSize.width;
v27 = cocos2d::CCDirector::sharedDirector();
v61.y = WinSize.height;
v61.x = sub_100484D70((__int64)v27) + -15.0;
(*(void (__fastcall **)(__int64, float, float))(*(_QWORD *)v22 + 200LL))(v22, *(float *)&v59, v61.x);
v28 = cocos2d::CCMenu::create();
a1->m_checkpointMenu = v28;
v29 = v28;
((void (__fastcall *)(UILayer *, cocos2d::CCMenu *, __int64))a1->addChild_0)(a1, v28, 16);
v30 = (cocos2d::CCArray *)sub_10071F9E0(a1, v29);
a1->m_controllerButtons = v30;
cocos2d::CCObject::retain(v30);
v31 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_checkpointBtn_001.png");
sub_10071FCD0(a1->m_controllerButtons, v31);
v59 = v31;
v32 = CCMenuItemSpriteExtra::create(v31, nullptr, a1, (cocos2d::SEL_MenuHandler)(unsigned __int64)UILayer::onCheck);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_checkpointMenu->addChild)(
a1->m_checkpointMenu,
v32);
v32->m_scaleMultiplier = 1.1;
v33 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_removeCheckBtn_001.png");
sub_10071FCD0(a1->m_controllerButtons, v33);
v57 = v33;
v34 = CCMenuItemSpriteExtra::create(
v33,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)UILayer::onDeleteCheck);
m_checkpointMenu = a1->m_checkpointMenu;
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))m_checkpointMenu->addChild)(m_checkpointMenu, v34);
v34->m_scaleMultiplier = 1.1;
v36 = (cocos2d::CCArray *)sub_10071F9E0(m_checkpointMenu, v34);
sub_10071FCD0(v36, v32);
sub_10071FCD0(v36, v34);
sub_10028CC60(&v56, &dbl_1009A2038);
GameToolbox::alignItemsHorisontally(v36, 10.0, v61, (bool)&v56);
CCMenuItemSpriteExtra::setSizeMult(v32, 1.5);
CCMenuItemSpriteExtra::setSizeMult(v34, 1.5);
v37 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v37, "0071");
v39 = 0;
v40 = a1->m_checkpointMenu;
if ( !GameVariable )
{
v41 = GameManager::sharedState();
v39 = GameManager::getGameVariable(v41, "0024");
}
((void (__fastcall *)(cocos2d::CCMenu *, bool))v40->setEnabled)(v40, v39);
v42 = GameManager::sharedState();
GameManager::getGameVariable(v42, "0071");
((void (__fastcall *)(cocos2d::CCMenu *, _QWORD))a1->m_checkpointMenu->setVisible)(a1->m_checkpointMenu, 0);
if ( PlatformToolbox::isControllerConnected() )
{
v43 = cocos2d::CCSprite::createWithSpriteFrameName("controllerBtn_B_001.png");
sub_10071FCD0(a1->m_controllerButtons, v43);
v44 = v57;
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSprite *))v57->addChild)(v57, v43);
v58 = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v44->getContentSize)(v44) * 0.5;
v45 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v44->getContentSize)(v44);
sub_10028CBE0((float *)&v56, v58, (float)(*(float *)(v45 + 4) * 0.5) + -25.0);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v43->setPosition)(v43, &v56);
((void (__fastcall *)(cocos2d::CCSprite *, float))v43->setScale)(v43, 0.80000001);
v46 = cocos2d::CCSprite::createWithSpriteFrameName("controllerBtn_X_001.png");
}
else
{
v47 = cocos2d::CCLabelBMFont::create_3("X", "bigFont.fnt");
sub_10071FCD0(a1->m_controllerButtons, v47);
v48 = v57;
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCLabelBMFont *))v57->addChild)(v57, v47);
v58 = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v48->getContentSize)(v48) * 0.5;
v49 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v48->getContentSize)(v48);
sub_10028CBE0((float *)&v56, v58, (float)(*(float *)(v49 + 4) * 0.5) + -25.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int64 *))v47->setPosition)(v47, &v56);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v47->setScale)(v47, 0.80000001);
v46 = cocos2d::CCLabelBMFont::create_3("Z", "bigFont.fnt");
}
v50 = v46;
sub_10071FCD0(a1->m_controllerButtons, v46);
v51 = v59;
((void (__fastcall *)(cocos2d::CCSprite *, void *))v59->addChild)(v59, v50);
*(float *)&v57 = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v51->getContentSize)(v51) * 0.5;
v52 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v51->getContentSize)(v51);
sub_10028CBE0((float *)&v56, *(float *)&v57, (float)(0.5 * *(float *)(v52 + 4)) + -25.0);
(*(void (__fastcall **)(void *, __int64 *))(*(_QWORD *)v50 + 184LL))(v50, &v56);
(*(void (__fastcall **)(void *, float))(*(_QWORD *)v50 + 160LL))(v50, 0.80000001);
UILayer::updateCheckState(a1);
a1->m_inPlatformer = 0;
if ( (unsigned int)sub_100720070(a1->m_uiNodes) )
{
v53 = 0;
do
{
v54 = sub_1007200C0(a1->m_uiNodes, v53);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v54 + 328LL))(v54, 0);
++v53;
}
while ( v53 < (unsigned int)sub_100720070(a1->m_uiNodes) );
}
return v60;
}
return result;
}