//
// GauntletLayer::init from 0x4db090 to 0x4db498 (1032 bytes)
//
// 1 xrefs:
// > GauntletLayer::create @ 0x4db548
//
// 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 GauntletLayer::init(GauntletLayer *a1, GauntletType a2)
{
_BOOL4 v4; // r9
GauntletLayer_vtbl *v5; // r3
cocos2d::CCDirector *v6; // r0
int v7; // r5
GameManager *v8; // r0
cocos2d::CCSprite *BGTexture; // r0
const char *v10; // r1
cocos2d::CCSprite *v11; // r0
cocos2d::CCTexture2D *v12; // r0
cocos2d::CCSprite *m_backgroundSprite; // r7
void (__fastcall *setAnchorPoint)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
cocos2d::CCSprite *v15; // r7
void (__fastcall *setScale)(cocos2d::CCSprite *__hidden, float); // r8
AppDelegate *v17; // r0
float v18; // r0
cocos2d::CCSprite *v19; // r0
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r2
cocos2d::CCSprite *v21; // r7
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
cocos2d::CCLabelBMFont *v23; // r6
void (__fastcall *v24)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
void (__fastcall *v25)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::ccColor3B *); // r2
cocos2d::CCLabelBMFont *v26; // r7
void (__fastcall *v27)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
int v28; // r11
cocos2d::CCSprite *v29; // r0
CCMenuItemSpriteExtra *v30; // r7
cocos2d::CCNode *v31; // r5
void (__fastcall *v32)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCDirector *v33; // r0
float v34; // s17
cocos2d::CCDirector *v35; // r0
float v36; // r0
LoadingCircle *v37; // r0
LoadingCircle *m_loadingCircle; // r0
cocos2d::CCSprite *m_sprite; // r0
void (__fastcall *v40)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r2
TextArea *m_tryAgainText; // r5
void (__fastcall *v42)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
GameLevelManager *v43; // r0
GameLevelManager *v44; // r0
cocos2d::CCArray *StoredOnlineLevels; // r0
GameLevelManager *v46; // r0
cocos2d::CCLabelBMFont *v48; // [sp+1Ch] [bp-38h] BYREF
char v49; // [sp+20h] [bp-34h] BYREF
cocos2d::CCSize v50; // [sp+24h] [bp-30h] BYREF
cocos2d::CCPoint v51; // [sp+2Ch] [bp-28h] BYREF
cocos2d::CCPoint v52; // [sp+34h] [bp-20h] BYREF
cocos2d::ccTexParams v53; // [sp+3Ch] [bp-18h] BYREF
v4 = cocos2d::CCLayer::init(a1);
if ( v4 )
{
v5 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_gauntletType = a2;
v5->setKeypadEnabled(a1, 1);
a1->setKeyboardEnabled(a1, 1);
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v50, v6);
v7 = bgForGauntlet(a1->m_gauntletType);
v8 = GameManager::sharedState();
BGTexture = (cocos2d::CCSprite *)GameManager::getBGTexture(v8, v7);
v11 = (cocos2d::CCSprite *)cocos2d::CCSprite::create(BGTexture, v10);
a1->m_backgroundSprite = v11;
v53.minFilter = 9729;
v53.magFilter = 9729;
v53.wrapS = 10497;
v53.wrapT = 10497;
v12 = v11->getTexture(v11);
cocos2d::CCTexture2D::setTexParameters(v12, &v53);
a1->addChild_0(a1, a1->m_backgroundSprite, -1);
m_backgroundSprite = a1->m_backgroundSprite;
setAnchorPoint = m_backgroundSprite->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v52, 0.0, 0.0);
setAnchorPoint(m_backgroundSprite, &v52);
v15 = a1->m_backgroundSprite;
setScale = v15->setScale;
v17 = AppDelegate::get();
v18 = AppDelegate::bgScale(v17);
((void (__fastcall *)(cocos2d::CCSprite *, _DWORD))setScale)(v15, LODWORD(v18));
v19 = a1->m_backgroundSprite;
setColor = v19->setColor;
memset(&v52, 76, 3);
setColor(v19, (const cocos2d::ccColor3B *)&v52);
v21 = a1->m_backgroundSprite;
setPosition = v21->setPosition;
cocos2d::CCPoint::CCPoint(&v52, 0.0, -20.0);
setPosition(v21, &v52);
GauntletNode::nameForType((int)&v48, a2);
sub_774544((int)&v48, " Gauntlet");
v23 = cocos2d::CCLabelBMFont::create();
a1->addChild_0(a1, v23, 2);
v24 = v23->setPosition;
cocos2d::CCPoint::CCPoint(&v52, v50.width * 0.5, v50.height - 22.0);
v24(v23, &v52);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v23->setScale)(v23, 1065353216);
v25 = v23->setColor;
LOWORD(v52.x) = -1;
BYTE2(v52.x) = 0;
v25(v23, (const cocos2d::ccColor3B *)&v52);
v26 = cocos2d::CCLabelBMFont::create();
a1->addChild_0(a1, v26, 0);
v27 = v26->setPosition;
v28 = (int)v23->getPosition(v23);
cocos2d::CCPoint::CCPoint(&v51, 2.0, -4.0);
cocos2d::CCPoint::operator+(&v52, v28, &v51);
v27(v26, &v52);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v26->setScale)(v26, 1065353216);
v26->setColor(v26, &stru_9AC8B0);
v26->setOpacity(v26, 100);
v29 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v52.y = 0.0;
LODWORD(v52.x) = GauntletLayer::onBack;
v30 = CCMenuItemSpriteExtra::create(
v29,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(GauntletLayer::onBack, (unsigned int)a1));
CCMenuItemSpriteExtra::setSizeMult(v30, 1.6);
v31 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v30, nullptr);
a1->addChild_0(a1, v31, 2);
v32 = v31->setPosition;
v33 = cocos2d::CCDirector::sharedDirector();
v34 = COERCE_FLOAT(cocos2d::CCDirector::getScreenLeft(v33)) + 25.0;
v35 = cocos2d::CCDirector::sharedDirector();
v36 = COERCE_FLOAT(cocos2d::CCDirector::getScreenTop(v35));
cocos2d::CCPoint::CCPoint(&v51, v34, v36 - 22.0);
v32(v31, &v51);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v30);
v37 = LoadingCircle::create();
a1->m_loadingCircle = v37;
v37->m_parentLayer = a1;
m_loadingCircle = a1->m_loadingCircle;
m_loadingCircle->m_fade = 0;
cocos2d::CCObject::retain(m_loadingCircle);
LoadingCircle::show(a1->m_loadingCircle);
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 0);
m_sprite = a1->m_loadingCircle->m_sprite;
v40 = m_sprite->setColor;
memset(&v51, 100, 3);
v40(m_sprite, (const cocos2d::ccColor3B *)&v51);
sub_776584((int)&v49, "Something went wrong\nplease try again later");
cocos2d::CCPoint::CCPoint(&v51, 0.5, 1.0);
a1->m_tryAgainText = (TextArea *)TextArea::create(
(TextArea *)&v49,
(std::string)"bigFont.fnt",
(const char *)0x3F800000,
1142292480,
&v51,
(cocos2d::CCPoint)1101004800LL);
sub_774008(&v49);
m_tryAgainText = a1->m_tryAgainText;
v42 = m_tryAgainText->setPosition;
cocos2d::CCPoint::CCPoint(&v51, v50.width * 0.5, (float)(v50.height * 0.5) + 10.0);
v42(m_tryAgainText, &v51);
((void (__fastcall *)(TextArea *, int))a1->m_tryAgainText->setScale)(a1->m_tryAgainText, 1058642330);
a1->addChild_0(a1, a1->m_tryAgainText, 10);
a1->m_tryAgainText->setVisible(a1->m_tryAgainText, 0);
v43 = GameLevelManager::sharedState();
GameLevelManager::getGauntletSearchKey((GameLevelManager *)&v51, (int)v43, (const char *)a1->m_gauntletType);
v44 = GameLevelManager::sharedState();
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v44, (const char *)LODWORD(v51.x));
if ( StoredOnlineLevels )
{
GauntletLayer::setupGauntlet(a1, StoredOnlineLevels);
}
else
{
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 1);
GameLevelManager::sharedState()->m_levelManagerDelegate = &a1->LevelManagerDelegate;
v46 = GameLevelManager::sharedState();
GameLevelManager::getGauntletLevels(v46, a1->m_gauntletType);
}
sub_774008(&v51);
sub_774008(&v48);
}
return v4;
}