//
// UILayer::init from 0x100048fe8 to 0x1000494cc (1252 bytes)
//
// 1 xrefs:
// > UILayer::create @ 0x100048f9c
//
// 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)
{
_BOOL8 v4; // x0
bool v5; // w20
cocos2d::CCArray *v6; // x0
GameManager *v7; // x0
unsigned int i; // w23
GameManager *v9; // x0
__int64 v10; // x8
GJUINode *v11; // x21
cocos2d::CCDirector *v12; // x0
cocos2d::CCSprite *v13; // x21
CCMenuItemSpriteExtra *v14; // x0
__int64 v15; // x21
cocos2d::CCDirector *v16; // x0
float v17; // s8
GameManager *v18; // x0
cocos2d::CCDirector *v19; // x0
cocos2d::CCDirector *v20; // x0
double v21; // d0
cocos2d::CCMenu *v22; // x0
__int64 v23; // x0
cocos2d::CCArray *v24; // x0
cocos2d::CCSprite *v25; // x21
CCMenuItemSpriteExtra *v26; // x23
cocos2d::CCSprite *v27; // x22
CCMenuItemSpriteExtra *v28; // x24
__int64 v29; // x0
cocos2d::CCArray *v30; // x25
cocos2d::CCSprite *v31; // x23
float v32; // s8
__n128 v33; // q1
__n128 v34; // q0
cocos2d::CCSprite *v35; // x22
float v36; // s9
__n128 v37; // q1
__n128 v38; // q0
__int64 v40; // [xsp+10h] [xbp-70h] BYREF
cocos2d::ccColor4B v41; // [xsp+18h] [xbp-68h] BYREF
cocos2d::SEL_MenuHandler v42; // 0:x3.16
cocos2d::SEL_MenuHandler v43; // 0:x3.16
cocos2d::SEL_MenuHandler v44; // 0:x3.16
cocos2d::CCPoint v45; // 0:s1.4,4:s2.4
v41 = 0;
v4 = cocos2d::CCLayerColor::initWithColor(a1, &v41);
v5 = v4;
if ( v4 )
{
a1->m_initialized = 1;
a1->m_gameLayer = a2;
v6 = (cocos2d::CCArray *)sub_10024A15C(v4);
a1->m_uiNodes = v6;
cocos2d::CCObject::retain(v6);
v7 = GameManager::sharedState();
GameManager::prepareDPadSettings(v7);
for ( i = 0; i != 4; ++i )
{
v9 = GameManager::sharedState();
if ( i >= 2 )
v10 = 1332;
else
v10 = 1212;
v11 = GJUINode::create((UIButtonConfig *)((char *)v9 + v10));
((void (__fastcall *)(UILayer *, GJUINode *, __int64))a1->addChild_0)(a1, v11, 100);
((void (__fastcall *)(GJUINode *, _QWORD))v11->setVisible)(v11, 0);
sub_10024A2D0(a1->m_uiNodes, v11);
if ( (i & 1) != 0 )
v11->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);
v12 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v12);
v13 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_pauseBtn_clean_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v13->setOpacity)(v13, 75);
v42.ptr = (void (__cdecl *)(cocos2d::CCObject *))UILayer::onPause;
v42.adj = 0;
v14 = CCMenuItemSpriteExtra::create(v13, nullptr, a1, v42);
a1->m_pauseBtn = v14;
v14->m_volume = 0.0;
CCMenuItemSpriteExtra::setSizeMult(v14, 4.0);
v15 = sub_1001D7ED0(a1->m_pauseBtn);
((void (__fastcall *)(UILayer *, __int64, __int64))a1->addChild_0)(a1, v15, 16);
v16 = cocos2d::CCDirector::sharedDirector();
v17 = sub_1001768E0(v16) + -15.0;
if ( AppDelegate::get()->m_startupScriptFilename.m_data.m_short.shortStorage.__elems_[4] )
v17 = v17 + -10.0;
v18 = GameManager::sharedState();
if ( GameManager::getGameVariable(v18, "0015") )
{
v19 = cocos2d::CCDirector::sharedDirector();
v17 = sub_1001768D8(v19) + 15.0;
}
v20 = cocos2d::CCDirector::sharedDirector();
v21 = sub_1001768C8(v20);
(*(void (__fastcall **)(__int64, float, float))(*(_QWORD *)v15 + 200LL))(v15, v17, *(float *)&v21 + -15.0);
v22 = cocos2d::CCMenu::create();
a1->m_checkpointMenu = v22;
v23 = ((__int64 (__fastcall *)(UILayer *, cocos2d::CCMenu *, __int64))a1->addChild_0)(a1, v22, 16);
v24 = (cocos2d::CCArray *)sub_10024A15C(v23);
a1->m_controllerButtons = v24;
cocos2d::CCObject::retain(v24);
v25 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_checkpointBtn_001.png");
sub_10024A2D0(a1->m_controllerButtons, v25);
v43.ptr = (void (__cdecl *)(cocos2d::CCObject *))UILayer::onCheck;
v43.adj = 0;
v26 = CCMenuItemSpriteExtra::create(v25, nullptr, a1, v43);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_checkpointMenu->addChild)(
a1->m_checkpointMenu,
v26);
v26->m_scaleMultiplier = 1.1;
v27 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_removeCheckBtn_001.png");
sub_10024A2D0(a1->m_controllerButtons, v27);
v44.ptr = (void (__cdecl *)(cocos2d::CCObject *))UILayer::onDeleteCheck;
v44.adj = 0;
v28 = CCMenuItemSpriteExtra::create(v27, nullptr, a1, v44);
v29 = ((__int64 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_checkpointMenu->addChild)(
a1->m_checkpointMenu,
v28);
v28->m_scaleMultiplier = 1.1;
v30 = (cocos2d::CCArray *)sub_10024A15C(v29);
sub_10024A2D0(v30, v26);
sub_10024A2D0(v30, v28);
sub_1000229B8(&v40, &qword_10086A7F0);
GameToolbox::alignItemsHorisontally(v30, 10.0, v45, (bool)&v40);
CCMenuItemSpriteExtra::setSizeMult(v26, 1.5);
CCMenuItemSpriteExtra::setSizeMult(v28, 1.5);
((void (__fastcall *)(cocos2d::CCMenu *, __int64))a1->m_checkpointMenu->setEnabled)(a1->m_checkpointMenu, 1);
((void (__fastcall *)(cocos2d::CCMenu *, _QWORD))a1->m_checkpointMenu->setVisible)(a1->m_checkpointMenu, 0);
if ( PlatformToolbox::isControllerConnected() )
{
v31 = cocos2d::CCSprite::createWithSpriteFrameName("controllerBtn_B_001.png");
sub_10024A2D0(a1->m_controllerButtons, v31);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSprite *))v27->addChild)(v27, v31);
v32 = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v27->getContentSize)(v27) * 0.5;
v33.n128_f32[0] = (float)(*(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))v27->getContentSize)(v27) + 4)
* 0.5)
+ -25.0;
v34.n128_f32[0] = v32;
sub_100022980(v34, v33, &v40);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v31->setPosition)(v31, &v40);
((void (__fastcall *)(cocos2d::CCSprite *, float))v31->setScale)(v31, 0.8);
v35 = cocos2d::CCSprite::createWithSpriteFrameName("controllerBtn_X_001.png");
sub_10024A2D0(a1->m_controllerButtons, v35);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSprite *))v25->addChild)(v25, v35);
v36 = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v25->getContentSize)(v25) * 0.5;
v37.n128_f32[0] = (float)(*(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))v25->getContentSize)(v25) + 4)
* 0.5)
+ -25.0;
v38.n128_f32[0] = v36;
sub_100022980(v38, v37, &v40);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v35->setPosition)(v35, &v40);
((void (__fastcall *)(cocos2d::CCSprite *, float))v35->setScale)(v35, 0.8);
}
UILayer::updateCheckState(a1);
a1->m_inPlatformer = 0;
UILayer::refreshDpad(a1);
UILayer::updateUINodeVisibility(a1, a1->m_inPlatformer);
}
return v5;
}