//
// GauntletSelectLayer::setupGauntlets from 0x1001bf244 to 0x1001bf684 (1088 bytes)
//
// 2 xrefs:
// > GauntletSelectLayer::init @ 0x1001befbc
// > GauntletSelectLayer::loadLevelsFinished @ 0x1001bf70c
//
// 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
//
void __fastcall GauntletSelectLayer::setupGauntlets(GauntletSelectLayer *a1)
{
cocos2d::CCDirector *v2; // x0
__int64 v3; // x0
cocos2d::CCArray *v4; // x21
__int64 v5; // x22
__n128 v6; // q0
__n128 v7; // q1
cocos2d::CCDictionary *m_savedGauntlets; // x20
GameManager *v9; // x0
cocos2d::CCDictElement *next; // x19
int v11; // w23
int v12; // w20
GJMapPack *m_pObject; // x26
GameManager *v14; // x0
__int64 v15; // x24
__int64 v16; // x28
cocos2d::CCMenu *v17; // x27
cocos2d::CCLayer *v18; // x25
__int64 v19; // x0
int v21; // w21
GauntletNode *v22; // x24
cocos2d::CCNode *v23; // x25
float v24; // s8
__n128 v25; // q1
__n128 v26; // q0
CCMenuItemSpriteExtra *v27; // x24
__int64 v28; // x24
cocos2d::CCNode *v29; // x25
cocos2d::CCArray *v30; // x26
cocos2d::CCNode *v31; // x27
BoomScrollLayer *v32; // x0
BoomScrollLayer *m_scrollLayer; // x21
float v34; // s8
cocos2d::CCDirector *v35; // x0
__n128 v36; // q1
__n128 v37; // q0
int m_currentGauntlet; // [xsp+4h] [xbp-ACh]
cocos2d::CCArray *v39; // [xsp+8h] [xbp-A8h]
GauntletSelectLayer *v40; // [xsp+10h] [xbp-A0h]
__int64 v41; // [xsp+18h] [xbp-98h]
cocos2d::CCPoint v42; // [xsp+20h] [xbp-90h] BYREF
int v43; // [xsp+28h] [xbp-88h] BYREF
cocos2d::CCPoint v44; // [xsp+30h] [xbp-80h] BYREF
float v45; // [xsp+38h] [xbp-78h]
float v46; // [xsp+3Ch] [xbp-74h]
cocos2d::CCPoint v47; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v48; // 0:x3.16
cocos2d::CCPoint v49; // 0:s0.4,4:s1.4
cocos2d::CCPoint v50; // 0:s1.4,4:s2.4
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v2);
v4 = (cocos2d::CCArray *)sub_10024A15C(v3);
v5 = sub_10024A15C(v4);
v41 = sub_10024A15C(v5);
v6.n128_f32[0] = v45 * 0.5;
v7.n128_f32[0] = (float)(v46 * 0.5) + -11.0;
sub_100022980(v6, v7, &v44);
m_savedGauntlets = GameLevelManager::sharedState()->m_savedGauntlets;
if ( cocos2d::CCDictionary::count(m_savedGauntlets) )
{
v40 = a1;
v9 = GameManager::sharedState();
if ( m_savedGauntlets && (next = m_savedGauntlets->m_pElements) != nullptr )
{
v11 = 0;
m_currentGauntlet = v9->m_currentGauntlet;
v12 = 1;
v39 = v4;
do
{
m_pObject = (GJMapPack *)next->m_pObject;
next = (cocos2d::CCDictElement *)next->hh.next;
if ( m_pObject->m_packID == 7 )
{
v14 = GameManager::sharedState();
if ( !GameManager::getUGV(v14, "19") )
continue;
}
v15 = (unsigned int)(int)(float)(ceilf((float)v12 / 3.0) + -1.0);
if ( (unsigned int)sub_10024A36C(v4) <= (unsigned int)v15 )
{
v18 = cocos2d::CCLayer::create();
sub_10024A2D0(v4, v18);
v17 = cocos2d::CCMenu::create();
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *))v18->addChild)(v18, v17);
sub_10024A2D0(v41, v17);
v16 = sub_10024A15C(v19);
sub_10024A2D0(v5, v16);
}
else
{
sub_10024A388(v4, v15);
v16 = sub_10024A388(v5, v15);
v17 = (cocos2d::CCMenu *)sub_10024A388(v41, v15);
}
if ( m_pObject->m_packID != m_currentGauntlet || m_currentGauntlet <= 1 )
v21 = v11;
else
v21 = v15;
v22 = GauntletNode::create(m_pObject);
cocos2d::CCDictionary::setObject(v40->m_gauntlets, v22, m_pObject->m_packID);
v23 = cocos2d::CCNode::create();
sub_100022988((float *)&v43, 110.0, 234.0);
((void (__fastcall *)(cocos2d::CCNode *, int *))v23->setContentSize)(v23, &v43);
((void (__fastcall *)(cocos2d::CCNode *, GauntletNode *))v23->addChild)(v23, v22);
v24 = *(float *)((__int64 (__fastcall *)(cocos2d::CCNode *))v23->getContentSize)(v23) * 0.5;
v25.n128_f32[0] = *(float *)(((__int64 (__fastcall *)(cocos2d::CCNode *))v23->getContentSize)(v23) + 4) * 0.5;
v26.n128_f32[0] = v24;
sub_100022980(v26, v25, &v42);
v47 = cocos2d::CCNode::convertToNodeSpace(v23, &v42);
((void (__fastcall *)(GauntletNode *, int *, float, float))v22->setPosition)(v22, &v43, v47.x, v47.y);
v11 = v21;
v48.ptr = (void (__cdecl *)(cocos2d::CCObject *))GauntletSelectLayer::onPlay;
v48.adj = 0;
v27 = CCMenuItemSpriteExtra::create(v23, nullptr, v40, v48);
v27->m_scaleMultiplier = 1.05;
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v27->setTag)(v27, (unsigned int)m_pObject->m_packID);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v17->addChild)(v17, v27);
sub_10024A2D0(v16, v27);
++v12;
v4 = v39;
}
while ( next );
}
else
{
v11 = 0;
}
if ( (unsigned int)sub_10024A36C(v5) )
{
v28 = 0;
do
{
v29 = (cocos2d::CCNode *)sub_10024A388(v4, v28);
v30 = (cocos2d::CCArray *)sub_10024A388(v5, v28);
v31 = (cocos2d::CCNode *)sub_10024A388(v41, v28);
cocos2d::CCNode::convertToWorldSpace(v29, &v44);
LODWORD(v50.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(v31, &v42).y);
GameToolbox::alignItemsHorisontally(v30, 112.0, v50, (bool)&v43);
v28 = (unsigned int)(v28 + 1);
}
while ( (unsigned int)v28 < (unsigned int)sub_10024A36C(v5) );
}
v32 = BoomScrollLayer::create(v4, 0, 1, nullptr, nullptr);
v40->m_scrollLayer = v32;
v32->m_delegate = &v40->BoomScrollLayerDelegate;
((void (__fastcall *)(GauntletSelectLayer *, BoomScrollLayer *))v40->addChild)(v40, v32);
m_scrollLayer = v40->m_scrollLayer;
v34 = v45 * 0.5;
v35 = cocos2d::CCDirector::sharedDirector();
v36.n128_f32[0] = sub_1001768D0((__int64)v35) + 15.0;
v37.n128_f32[0] = v34;
sub_100022980(v37, v36, &v43);
BoomScrollLayer::setPagesIndicatorPosition(m_scrollLayer, v49);
if ( v11 > 0 )
{
if ( v11 == BoomScrollLayer::getTotalPages(v40->m_scrollLayer) - 1 )
GauntletSelectLayer::goToPage(v40, v11 - 1, 1);
GauntletSelectLayer::goToPage(v40, v11, 1);
}
}
}