//
// GauntletLayer::init from 0x100232338 to 0x100232898 (1376 bytes)
//
// 1 xrefs:
// > GauntletLayer::create @ 0x1002322ec
//
// 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 GauntletLayer::init(GauntletLayer *a1, GauntletType a2)
{
_BOOL4 v4; // w19
cocos2d::CCDirector *v5; // x0
int v6; // w22
GameManager *v7; // x0
const char *BGTexture; // x0
cocos2d::CCSprite *v9; // x0
cocos2d::CCTexture2D *v10; // x0
__n128 v11; // q0
cocos2d::CCSprite *m_backgroundSprite; // x22
__n128 v13; // q1
cocos2d::CCSprite *v14; // x22
AppDelegate *v15; // x0
float v16; // s0
cocos2d::CCSprite *v17; // x0
__n128 v18; // q0
cocos2d::CCSprite *v19; // x22
__n128 v20; // q1
std::string *v21; // x0
cocos2d::CCLabelBMFont *v22; // x21
__n128 v23; // q0
__n128 v24; // q1
std::string *v25; // x0
cocos2d::CCLabelBMFont *v26; // x22
float32x2_t *v27; // x21
__n128 v28; // q0
__n128 v29; // q1
double v30; // d0
cocos2d::CCSprite *v31; // x0
CCMenuItemSpriteExtra *v32; // x21
__int64 v33; // x1
__int64 v34; // x2
__int64 v35; // x3
__int64 v36; // x4
__int64 v37; // x5
__int64 v38; // x6
__int64 v39; // x7
cocos2d::CCMenu *v40; // x22
cocos2d::CCDirector *v41; // x0
float v42; // s8
cocos2d::CCDirector *v43; // x0
__n128 v44; // q1
__n128 v45; // q0
LoadingCircle *v46; // x0
cocos2d::CCSprite *m_sprite; // x0
__n128 v48; // q0
__n128 v49; // q1
TextArea *m_tryAgainText; // x21
__n128 v51; // q0
__n128 v52; // q1
GameLevelManager *v53; // x0
void **v54; // x1
cocos2d::CCArray *StoredOnlineLevels; // x1
GameLevelManager *v56; // x0
void *v58[2]; // [xsp+10h] [xbp-A0h] BYREF
char v59; // [xsp+27h] [xbp-89h]
void *__p[2]; // [xsp+28h] [xbp-88h] BYREF
char v61; // [xsp+3Fh] [xbp-71h]
float32x2_t v62; // [xsp+40h] [xbp-70h] BYREF
std::string v63; // [xsp+48h] [xbp-68h] BYREF
cocos2d::ccTexParams v64; // [xsp+60h] [xbp-50h] BYREF
float v65; // [xsp+78h] [xbp-38h]
float v66; // [xsp+7Ch] [xbp-34h]
cocos2d::CCSize WinSize; // 0:kr00_8.8
cocos2d::SEL_MenuHandler v68; // 0:x3.16
v4 = cocos2d::CCLayer::init(a1);
if ( v4 )
{
a1->m_gauntletType = a2;
((void (__fastcall *)(GauntletLayer *, __int64))a1->setKeypadEnabled)(a1, 1);
((void (__fastcall *)(GauntletLayer *, __int64))a1->setKeyboardEnabled)(a1, 1);
v5 = cocos2d::CCDirector::sharedDirector();
WinSize = cocos2d::CCDirector::getWinSize(v5);
v6 = sub_100232914((unsigned int)a1->m_gauntletType, WinSize.width, WinSize.height);
v7 = GameManager::sharedState();
BGTexture = GameManager::getBGTexture(v7, v6);
v9 = cocos2d::CCSprite::create(BGTexture);
a1->m_backgroundSprite = v9;
v64 = (cocos2d::ccTexParams)xmmword_100636BB0;
v10 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v9->getTexture)(v9);
cocos2d::CCTexture2D::setTexParameters(v10, &v64);
v11 = ((__n128 (__fastcall *)(GauntletLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(
a1,
a1->m_backgroundSprite,
0xFFFFFFFFLL);
m_backgroundSprite = a1->m_backgroundSprite;
v11.n128_u32[0] = 0;
v13.n128_u32[0] = 0;
sub_100022980(v11, v13, &v63);
((void (__fastcall *)(cocos2d::CCSprite *, std::string *))m_backgroundSprite->setAnchorPoint)(
m_backgroundSprite,
&v63);
v14 = a1->m_backgroundSprite;
v15 = AppDelegate::get();
v16 = AppDelegate::bgScale(v15);
((void (__fastcall *)(cocos2d::CCSprite *, float))v14->setScale)(v14, v16);
v17 = a1->m_backgroundSprite;
memset(&v63, 76, 3);
v18 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, std::string *))v17->setColor)(v17, &v63);
v19 = a1->m_backgroundSprite;
v18.n128_u32[0] = 0;
v20.n128_u32[0] = -20.0;
sub_100022980(v18, v20, &v63);
((void (__fastcall *)(cocos2d::CCSprite *, std::string *))v19->setPosition)(v19, &v63);
GauntletNode::nameForType(a2, &v63);
std::string::append(&v63, " Gauntlet");
if ( (v63.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v21 = &v63;
else
v21 = (std::string *)v63.__r_.__value_.__r.__words[0];
v22 = cocos2d::CCLabelBMFont::create_1((const char *)v21, "goldFont.fnt");
v23 = ((__n128 (__fastcall *)(GauntletLayer *, cocos2d::CCLabelBMFont *, __int64))a1->addChild_0)(a1, v22, 2);
v23.n128_f32[0] = v65 * 0.5;
v24.n128_f32[0] = v66 + -22.0;
sub_100022980(v23, v24, v58);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, void **))v22->setPosition)(v22, v58);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v22->setScale)(v22, 1.0);
BYTE2(v58[0]) = 0;
LOWORD(v58[0]) = -1;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, void **))v22->setColor)(v22, v58);
if ( (v63.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v25 = &v63;
else
v25 = (std::string *)v63.__r_.__value_.__r.__words[0];
v26 = cocos2d::CCLabelBMFont::create_1((const char *)v25, "goldFont.fnt");
((void (__fastcall *)(GauntletLayer *, cocos2d::CCLabelBMFont *, _QWORD))a1->addChild_0)(a1, v26, 0);
v27 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v22->getPosition)(v22);
v28.n128_u32[0] = 2.0;
v29.n128_u32[0] = -4.0;
sub_100022980(v28, v29, &v62);
*(float32x2_t *)&v30 = sub_1000229DC(v27, &v62, (float32x2_t *)v58);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, void **, double))v26->setPosition)(v26, v58, v30);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v26->setScale)(v26, 1.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, void *))v26->setColor)(v26, &unk_10063A9EC);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))v26->setOpacity)(v26, 100);
v31 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v68.ptr = (void (__cdecl *)(cocos2d::CCObject *))GauntletLayer::onBack;
v68.adj = 0;
v32 = CCMenuItemSpriteExtra::create(v31, nullptr, a1, v68);
CCMenuItemSpriteExtra::setSizeMult(v32, 1.6);
v40 = sub_1001D7ED0(v32, v33, v34, v35, v36, v37, v38, v39, 0);
((void (__fastcall *)(GauntletLayer *, cocos2d::CCMenu *, __int64))a1->addChild_0)(a1, v40, 2);
v41 = cocos2d::CCDirector::sharedDirector();
v42 = sub_1001768D8((__int64)v41);
v43 = cocos2d::CCDirector::sharedDirector();
v44.n128_f32[0] = sub_1001768C8((__int64)v43) + -22.0;
v45.n128_f32[0] = v42 + 25.0;
sub_100022980(v45, v44, v58);
((void (__fastcall *)(cocos2d::CCMenu *, void **))v40->setPosition)(v40, v58);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v32);
v46 = LoadingCircle::create();
a1->m_loadingCircle = v46;
v46->m_parentLayer = a1;
v46->m_fade = 0;
cocos2d::CCObject::retain(v46);
LoadingCircle::show(a1->m_loadingCircle);
((void (__fastcall *)(LoadingCircle *, _QWORD))a1->m_loadingCircle->setVisible)(a1->m_loadingCircle, 0);
m_sprite = a1->m_loadingCircle->m_sprite;
memset(v58, 100, 3);
((void (__fastcall *)(cocos2d::CCSprite *, void **))m_sprite->setColor)(m_sprite, v58);
sub_100009900(__p, "Something went wrong\nplease try again later");
v48.n128_u32[0] = 0.5;
v49.n128_u32[0] = 1.0;
sub_100022980(v48, v49, v58);
m_tryAgainText = (TextArea *)TextArea::create(
(__int64)__p,
(__int64)"bigFont.fnt",
(__int64 *)v58,
0,
1.0,
600.0,
20.0);
a1->m_tryAgainText = m_tryAgainText;
if ( v61 < 0 )
{
operator delete(__p[0]);
m_tryAgainText = a1->m_tryAgainText;
}
v51.n128_f32[0] = v65 * 0.5;
v52.n128_f32[0] = (float)(v66 * 0.5) + 10.0;
sub_100022980(v51, v52, v58);
((void (__fastcall *)(TextArea *, void **))m_tryAgainText->setPosition)(m_tryAgainText, v58);
((void (__fastcall *)(TextArea *, float))a1->m_tryAgainText->setScale)(a1->m_tryAgainText, 0.6);
((void (__fastcall *)(GauntletLayer *, TextArea *, __int64))a1->addChild_0)(a1, a1->m_tryAgainText, 10);
((void (__fastcall *)(TextArea *, _QWORD))a1->m_tryAgainText->setVisible)(a1->m_tryAgainText, 0);
GameLevelManager::sharedState();
GameLevelManager::getGauntletSearchKey(a1->m_gauntletType, v58);
v53 = GameLevelManager::sharedState();
if ( v59 >= 0 )
v54 = v58;
else
v54 = (void **)v58[0];
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v53, (const char *)v54);
if ( StoredOnlineLevels )
{
GauntletLayer::setupGauntlet(a1, StoredOnlineLevels);
}
else
{
((void (__fastcall *)(LoadingCircle *, __int64))a1->m_loadingCircle->setVisible)(a1->m_loadingCircle, 1);
GameLevelManager::sharedState()->m_levelManagerDelegate = &a1->LevelManagerDelegate;
v56 = GameLevelManager::sharedState();
GameLevelManager::getGauntletLevels(v56, a1->m_gauntletType);
}
if ( v59 < 0 )
operator delete(v58[0]);
if ( SHIBYTE(v63.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v63.__r_.__value_.__l.__data_);
}
return v4;
}