//
// GauntletSelectLayer::init from 0x1001be670 to 0x1001bf044 (2516 bytes)
//
// 1 xrefs:
// > GauntletSelectLayer::create @ 0x1001be624
//
// 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 GauntletSelectLayer::init(GauntletSelectLayer *a1, int a2)
{
_BOOL4 v3; // w19
cocos2d::CCTextureCache *v4; // x0
cocos2d::CCSpriteFrameCache *v5; // x0
cocos2d::CCDirector *v6; // x0
cocos2d::CCDictionary *v7; // x0
cocos2d::CCSprite *v8; // x21
__n128 v9; // q0
__n128 v10; // q1
__n128 v11; // q0
cocos2d::CCSprite *m_backgroundSprite; // x21
__n128 v13; // q1
cocos2d::CCSprite *v14; // x0
cocos2d::CCSprite *v15; // x21
float v16; // s8
cocos2d::CCDirector *v17; // x0
__n128 v18; // q1
__n128 v19; // q0
cocos2d::CCSprite *v20; // x22
__n128 v21; // q0
__n128 v22; // q1
cocos2d::CCDirector *v23; // x0
float v24; // s8
cocos2d::CCDirector *v25; // x0
__n128 v26; // q1
__n128 v27; // q0
cocos2d::CCSprite *v28; // x22
__n128 v29; // q0
__n128 v30; // q1
cocos2d::CCDirector *v31; // x0
float v32; // s8
cocos2d::CCDirector *v33; // x0
__n128 v34; // q1
__n128 v35; // q0
cocos2d::CCSprite *v36; // x22
__n128 v37; // q0
__n128 v38; // q1
cocos2d::CCDirector *v39; // x0
float v40; // s8
cocos2d::CCDirector *v41; // x0
__n128 v42; // q1
__n128 v43; // q0
cocos2d::CCSprite *v44; // x21
__n128 v45; // q0
__n128 v46; // q1
cocos2d::CCDirector *v47; // x0
float v48; // s8
cocos2d::CCDirector *v49; // x0
__n128 v50; // q1
__n128 v51; // q0
unsigned __int32 v52; // s8
float v53; // s11
cocos2d::CCMenu *v54; // x21
_BOOL4 isControllerConnected; // w22
const char *v56; // x0
cocos2d::CCSprite *v57; // x24
const char *v58; // x23
CCMenuItemSpriteExtra *v59; // x0
CCMenuItemSpriteExtra *m_leftButton; // x24
cocos2d::CCDirector *v61; // x0
__n128 v62; // q0
__n128 v63; // q1
cocos2d::CCSprite *v64; // x23
CCMenuItemSpriteExtra *v65; // x0
CCMenuItemSpriteExtra *m_rightButton; // x23
cocos2d::CCDirector *v67; // x0
__n128 v68; // q0
__n128 v69; // q1
cocos2d::CCSprite *v70; // x0
CCMenuItemSpriteExtra *v71; // x23
cocos2d::CCNode *v72; // x21
cocos2d::CCDirector *v73; // x0
float v74; // s8
cocos2d::CCDirector *v75; // x0
__n128 v76; // q1
__n128 v77; // q0
cocos2d::CCSprite *v78; // x0
CCMenuItemSpriteExtra *v79; // x24
cocos2d::CCDirector *v80; // x0
float v81; // s8
cocos2d::CCDirector *v82; // x0
__n128 v83; // q1
__n128 v84; // q0
LoadingCircle *v85; // x0
cocos2d::CCSprite *m_sprite; // x0
__n128 v87; // q0
__n128 v88; // q1
TextArea *m_tryAgainText; // x22
__n128 v90; // q0
__n128 v91; // q1
cocos2d::CCSprite *v92; // x22
CCMenuItemSpriteExtra *v93; // x0
CCMenuItemSpriteExtra *m_refreshButton; // x22
cocos2d::CCDirector *v95; // x0
__n128 v96; // q0
__n128 v97; // q1
GameLevelManager *v98; // x0
GameLevelManager *v99; // x0
void *__p[2]; // [xsp+8h] [xbp-88h] BYREF
char v102; // [xsp+1Fh] [xbp-71h]
cocos2d::CCPoint v103; // [xsp+24h] [xbp-6Ch] BYREF
_WORD v104[2]; // [xsp+2Ch] [xbp-64h] BYREF
__int64 v105; // [xsp+30h] [xbp-60h] BYREF
float v106; // [xsp+38h] [xbp-58h]
float v107; // [xsp+3Ch] [xbp-54h]
cocos2d::CCPoint v108; // 0:kr08_8.8
cocos2d::CCPoint v109; // 0:kr10_8.8
cocos2d::CCPoint v110; // 0:kr18_8.8
cocos2d::CCPoint v111; // 0:kr20_8.8
cocos2d::SEL_MenuHandler v112; // 0:x3.16
cocos2d::SEL_MenuHandler v113; // 0:x3.16
cocos2d::SEL_MenuHandler v114; // 0:x3.16
cocos2d::SEL_MenuHandler v115; // 0:x3.16
cocos2d::SEL_MenuHandler v116; // 0:x3.16
v3 = cocos2d::CCLayer::init(a1);
if ( v3 )
{
v4 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v4, "GauntletSheet.png", 0);
v5 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v5, "GauntletSheet.plist");
((void (__fastcall *)(GauntletSelectLayer *, __int64))a1->setKeypadEnabled)(a1, 1);
((void (__fastcall *)(GauntletSelectLayer *, __int64))a1->setKeyboardEnabled)(a1, 1);
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v6);
v7 = cocos2d::CCDictionary::create();
a1->m_gauntlets = v7;
cocos2d::CCObject::retain(v7);
v8 = cocos2d::CCSprite::create("GJ_gradientBG.png");
a1->m_backgroundSprite = v8;
v9.n128_u32[0] = 0;
v10.n128_u32[0] = 0;
sub_100022980(v9, v10, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v8->setAnchorPoint)(v8, &v105);
((void (__fastcall *)(GauntletSelectLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(
a1,
a1->m_backgroundSprite,
4294967294LL);
((void (__fastcall *)(cocos2d::CCSprite *, float))a1->m_backgroundSprite->setScaleX)(
a1->m_backgroundSprite,
(float)(v106 + 10.0) / a1->m_backgroundSprite->m_obRect.size.width);
v11 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float))a1->m_backgroundSprite->setScaleY)(
a1->m_backgroundSprite,
(float)(v107 + 10.0) / a1->m_backgroundSprite->m_obRect.size.height);
m_backgroundSprite = a1->m_backgroundSprite;
v11.n128_u32[0] = -5.0;
v13.n128_u32[0] = -5.0;
sub_100022980(v11, v13, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))m_backgroundSprite->setPosition)(m_backgroundSprite, &v105);
v14 = a1->m_backgroundSprite;
memset(&v105, 51, 3);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v14->setColor)(v14, &v105);
v15 = cocos2d::CCSprite::createWithSpriteFrameName("theLostGauntletsLabel_001.png");
((void (__fastcall *)(GauntletSelectLayer *, cocos2d::CCSprite *))a1->addChild)(a1, v15);
v16 = v106 * 0.5;
v17 = cocos2d::CCDirector::sharedDirector();
v18.n128_f32[0] = sub_1001768C8((__int64)v17) + -28.0;
v19.n128_f32[0] = v16;
sub_100022980(v19, v18, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v15->setPosition)(v15, &v105);
memset(v104, 76, 3);
v20 = cocos2d::CCSprite::createWithSpriteFrameName("gauntletCorner_001.png");
v21.n128_u32[0] = 0;
v22.n128_u32[0] = 0;
sub_100022980(v21, v22, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v20->setAnchorPoint)(v20, &v105);
v23 = cocos2d::CCDirector::sharedDirector();
v24 = sub_1001768D8((__int64)v23) + -1.0;
v25 = cocos2d::CCDirector::sharedDirector();
v26.n128_f32[0] = sub_1001768D0((__int64)v25) + -1.0;
v27.n128_f32[0] = v24;
sub_100022980(v27, v26, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v20->setPosition)(v20, &v105);
((void (__fastcall *)(GauntletSelectLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v20, 1);
((void (__fastcall *)(cocos2d::CCSprite *, _WORD *))v20->setColor)(v20, v104);
v28 = cocos2d::CCSprite::createWithSpriteFrameName("gauntletCorner_001.png");
v29.n128_u32[0] = 1.0;
v30.n128_u32[0] = 0;
sub_100022980(v29, v30, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v28->setAnchorPoint)(v28, &v105);
v31 = cocos2d::CCDirector::sharedDirector();
v32 = sub_1001768E0((__int64)v31) + 1.0;
v33 = cocos2d::CCDirector::sharedDirector();
v34.n128_f32[0] = sub_1001768D0((__int64)v33) + -1.0;
v35.n128_f32[0] = v32;
sub_100022980(v35, v34, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v28->setPosition)(v28, &v105);
cocos2d::CCSprite::setFlipX(v28, 1);
((void (__fastcall *)(GauntletSelectLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v28, 1);
((void (__fastcall *)(cocos2d::CCSprite *, _WORD *))v28->setColor)(v28, v104);
v36 = cocos2d::CCSprite::createWithSpriteFrameName("gauntletCorner_001.png");
v37.n128_u32[0] = 0;
v38.n128_u32[0] = 1.0;
sub_100022980(v37, v38, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v36->setAnchorPoint)(v36, &v105);
v39 = cocos2d::CCDirector::sharedDirector();
v40 = sub_1001768D8((__int64)v39) + -1.0;
v41 = cocos2d::CCDirector::sharedDirector();
v42.n128_f32[0] = sub_1001768C8((__int64)v41) + 1.0;
v43.n128_f32[0] = v40;
sub_100022980(v43, v42, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v36->setPosition)(v36, &v105);
cocos2d::CCSprite::setFlipY(v36, 1);
((void (__fastcall *)(GauntletSelectLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v36, 1);
((void (__fastcall *)(cocos2d::CCSprite *, _WORD *))v36->setColor)(v36, v104);
v44 = cocos2d::CCSprite::createWithSpriteFrameName("gauntletCorner_001.png");
v45.n128_u32[0] = 1.0;
v46.n128_u32[0] = 1.0;
sub_100022980(v45, v46, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v44->setAnchorPoint)(v44, &v105);
v47 = cocos2d::CCDirector::sharedDirector();
v48 = sub_1001768E0((__int64)v47) + 1.0;
v49 = cocos2d::CCDirector::sharedDirector();
v50.n128_f32[0] = sub_1001768C8((__int64)v49) + 1.0;
v51.n128_f32[0] = v48;
sub_100022980(v51, v50, &v105);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v44->setPosition)(v44, &v105);
cocos2d::CCSprite::setFlipX(v44, 1);
cocos2d::CCSprite::setFlipY(v44, 1);
((void (__fastcall *)(GauntletSelectLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v44, 1);
((void (__fastcall *)(cocos2d::CCSprite *, _WORD *))v44->setColor)(v44, v104);
*(float *)&v52 = v107 * 0.5;
if ( AppDelegate::get()->m_startupScriptFilename.m_data.m_short.shortStorage.__elems_[4] )
v53 = 50.0;
else
v53 = 25.0;
v54 = cocos2d::CCMenu::create();
((void (__fastcall *)(GauntletSelectLayer *, cocos2d::CCMenu *, __int64))a1->addChild_0)(a1, v54, 5);
isControllerConnected = PlatformToolbox::isControllerConnected();
if ( isControllerConnected )
v56 = "controllerBtn_DPad_Left_001.png";
else
v56 = "navArrowBtn_001.png";
v57 = cocos2d::CCSprite::createWithSpriteFrameName(v56);
((void (__fastcall *)(cocos2d::CCSprite *, float))v57->setScale)(v57, 0.8);
if ( isControllerConnected )
{
v58 = "controllerBtn_DPad_Right_001.png";
}
else
{
cocos2d::CCSprite::setFlipX(v57, 1);
v58 = "navArrowBtn_001.png";
}
v112.ptr = (void (__cdecl *)(cocos2d::CCObject *))GauntletSelectLayer::onPrev;
v112.adj = 0;
v59 = CCMenuItemSpriteExtra::create(v57, nullptr, a1, v112);
a1->m_leftButton = v59;
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v54->addChild)(v54, v59);
CCMenuItemSpriteExtra::setSizeMult(a1->m_leftButton, 2.0);
m_leftButton = a1->m_leftButton;
v61 = cocos2d::CCDirector::sharedDirector();
v62.n128_f32[0] = v53 + sub_1001768D8((__int64)v61);
v63.n128_u32[0] = v52;
sub_100022980(v62, v63, &v103);
v108 = cocos2d::CCNode::convertToNodeSpace(v54, &v103);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))m_leftButton->setPosition)(
m_leftButton,
&v105,
v108.x,
v108.y);
v64 = cocos2d::CCSprite::createWithSpriteFrameName(v58);
((void (__fastcall *)(cocos2d::CCSprite *, float))v64->setScale)(v64, 0.8);
v113.ptr = (void (__cdecl *)(cocos2d::CCObject *))GauntletSelectLayer::onNext;
v113.adj = 0;
v65 = CCMenuItemSpriteExtra::create(v64, nullptr, a1, v113);
a1->m_rightButton = v65;
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v54->addChild)(v54, v65);
CCMenuItemSpriteExtra::setSizeMult(a1->m_rightButton, 2.0);
m_rightButton = a1->m_rightButton;
v67 = cocos2d::CCDirector::sharedDirector();
v68.n128_f32[0] = sub_1001768E0((__int64)v67) - v53;
v69.n128_u32[0] = v52;
sub_100022980(v68, v69, &v103);
v109 = cocos2d::CCNode::convertToNodeSpace(v54, &v103);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))m_rightButton->setPosition)(
m_rightButton,
&v105,
v109.x,
v109.y);
v70 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v114.ptr = (void (__cdecl *)(cocos2d::CCObject *))GauntletSelectLayer::onBack;
v114.adj = 0;
v71 = CCMenuItemSpriteExtra::create(v70, nullptr, a1, v114);
CCMenuItemSpriteExtra::setSizeMult(v71, 1.6);
v72 = (cocos2d::CCNode *)sub_1001D7ED0(v71);
((void (__fastcall *)(GauntletSelectLayer *, cocos2d::CCNode *, __int64))a1->addChild_0)(a1, v72, 1);
v73 = cocos2d::CCDirector::sharedDirector();
v74 = sub_1001768D8((__int64)v73) + 25.0;
v75 = cocos2d::CCDirector::sharedDirector();
v76.n128_f32[0] = sub_1001768C8((__int64)v75) + -22.0;
v77.n128_f32[0] = v74;
sub_100022980(v77, v76, &v105);
((void (__fastcall *)(cocos2d::CCNode *, __int64 *))v72->setPosition)(v72, &v105);
v78 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
v115.ptr = (void (__cdecl *)(cocos2d::CCObject *))GauntletSelectLayer::onInfo;
v115.adj = 0;
v79 = CCMenuItemSpriteExtra::create(v78, nullptr, a1, v115);
CCMenuItemSpriteExtra::setSizeMult(v79, 2.0);
((void (__fastcall *)(cocos2d::CCNode *, CCMenuItemSpriteExtra *))v72->addChild)(v72, v79);
v80 = cocos2d::CCDirector::sharedDirector();
v81 = sub_1001768D8((__int64)v80) + 30.0;
v82 = cocos2d::CCDirector::sharedDirector();
v83.n128_f32[0] = sub_1001768D0((__int64)v82) + 30.0;
v84.n128_f32[0] = v81;
sub_100022980(v84, v83, &v103);
v110 = cocos2d::CCNode::convertToNodeSpace(v72, &v103);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))v79->setPosition)(
v79,
&v105,
v110.x,
v110.y);
if ( isControllerConnected )
GameToolbox::addBackButton(a1, v71);
v85 = LoadingCircle::create();
a1->m_loadingCircle = v85;
v85->m_parentLayer = a1;
v85->m_fade = 0;
cocos2d::CCObject::retain(v85);
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(&v105, 100, 3);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))m_sprite->setColor)(m_sprite, &v105);
sub_100009900(__p, "Something went wrong\nplease try again later");
v87.n128_u32[0] = 0.5;
v88.n128_u32[0] = 1.0;
sub_100022980(v87, v88, &v105);
m_tryAgainText = (TextArea *)TextArea::create((__int64)__p, (__int64)"bigFont.fnt", &v105, 0, 1.0, 600.0, 30.0);
a1->m_tryAgainText = m_tryAgainText;
if ( v102 < 0 )
{
operator delete(__p[0]);
m_tryAgainText = a1->m_tryAgainText;
}
v90.n128_f32[0] = v106 * 0.5;
v91.n128_f32[0] = (float)(v107 * 0.5) + 10.0;
sub_100022980(v90, v91, &v105);
((void (__fastcall *)(TextArea *, __int64 *))m_tryAgainText->setPosition)(m_tryAgainText, &v105);
((void (__fastcall *)(TextArea *, float))a1->m_tryAgainText->setScale)(a1->m_tryAgainText, 0.6);
((void (__fastcall *)(GauntletSelectLayer *, TextArea *, __int64))a1->addChild_0)(a1, a1->m_tryAgainText, 10);
((void (__fastcall *)(TextArea *, _QWORD))a1->m_tryAgainText->setVisible)(a1->m_tryAgainText, 0);
v92 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_updateBtn_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v92->setScale)(v92, 0.75);
v116.ptr = (void (__cdecl *)(cocos2d::CCObject *))GauntletSelectLayer::onRefresh;
v116.adj = 0;
v93 = CCMenuItemSpriteExtra::create(v92, nullptr, a1, v116);
a1->m_refreshButton = v93;
((void (__fastcall *)(cocos2d::CCNode *, CCMenuItemSpriteExtra *))v72->addChild)(v72, v93);
m_refreshButton = a1->m_refreshButton;
v95 = cocos2d::CCDirector::sharedDirector();
v96.n128_f32[0] = sub_1001768E0((__int64)v95) + -25.0;
v97.n128_u32[0] = 25.0;
sub_100022980(v96, v97, &v103);
v111 = cocos2d::CCNode::convertToNodeSpace(v72, &v103);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))m_refreshButton->setPosition)(
m_refreshButton,
&v105,
v111.x,
v111.y);
v98 = GameLevelManager::sharedState();
if ( GameLevelManager::areGauntletsLoaded(v98) )
{
GauntletSelectLayer::setupGauntlets(a1);
}
else
{
((void (__fastcall *)(LoadingCircle *, __int64))a1->m_loadingCircle->setVisible)(a1->m_loadingCircle, 1);
GameLevelManager::sharedState()->m_levelManagerDelegate = &a1->LevelManagerDelegate;
v99 = GameLevelManager::sharedState();
GameLevelManager::getGauntlets(v99);
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_leftButton->setVisible)(
a1->m_leftButton,
a1->m_scrollLayer != nullptr);
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_rightButton->setVisible)(
a1->m_rightButton,
a1->m_scrollLayer != nullptr);
}
return v3;
}