//
// GauntletSelectLayer::setupGauntlets from 0x91bfb8 to 0x91c480 (1224 bytes)
//
// 3 xrefs:
// > GauntletSelectLayer::init @ 0x91ce18
// > GauntletSelectLayer::loadLevelsFinished @ 0x91d168
// > ??> @ 0x92d78
//
// 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 GauntletSelectLayer::setupGauntlets(GauntletSelectLayer *a1)
{
cocos2d::CCDirector *v2; // x0
cocos2d::CCArray *v3; // x0
cocos2d::CCArray *v4; // x22
cocos2d::CCArray *v5; // x21
cocos2d::CCDictionary *m_savedGauntlets; // x19
cocos2d::CCDictElement *m_pElements; // x19
GJMapPack *m_pObject; // x25
int v9; // w27
_QWORD *next; // x23
unsigned int v11; // w19
__int64 v12; // x7
int v13; // w0
GauntletNode *v14; // x28
cocos2d::CCNode *v15; // x19
float height; // s1
CCMenuItemSpriteExtra *v17; // x0
CCMenuItemSpriteExtra_vtbl *v18; // x2
__int64 m_packID; // x1
cocos2d::CCObject *v20; // x19
_QWORD *v21; // x19
GameManager *v22; // x0
cocos2d::CCLayer *v23; // x28
cocos2d::CCArray *v24; // x0
unsigned int v25; // w19
cocos2d::CCNode *v26; // x25
cocos2d::CCArray *v27; // x28
unsigned int v28; // w1
cocos2d::CCNode *v29; // x23
BoomScrollLayer *v30; // x0
BoomScrollLayer *m_scrollLayer; // x19
cocos2d::CCDirector *v32; // x0
float v33; // s0
__int64 v34; // [xsp+98h] [xbp+98h]
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [xsp+A8h] [xbp+A8h]
float v36; // [xsp+B0h] [xbp+B0h]
cocos2d::CCPoint *setContentSize; // [xsp+C0h] [xbp+C0h]
cocos2d::CCPoint *v38; // [xsp+C0h] [xbp+C0h]
cocos2d::CCArray *v39; // [xsp+C8h] [xbp+C8h]
cocos2d::CCMenu *v40; // [xsp+C8h] [xbp+C8h]
int m_currentGauntlet; // [xsp+D0h] [xbp+D0h]
int v42; // [xsp+D4h] [xbp+D4h]
cocos2d::CCArray *v43; // [xsp+D8h] [xbp+D8h]
float v44; // [xsp+E8h] [xbp+E8h]
float v45; // [xsp+ECh] [xbp+ECh]
cocos2d::CCPoint v46; // [xsp+F0h] [xbp+F0h] BYREF
cocos2d::CCPoint v47; // [xsp+F8h] [xbp+F8h] BYREF
cocos2d::CCPoint v48; // [xsp+100h] [xbp+100h] BYREF
cocos2d::CCPoint v49; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v50; // 0:x2.16
cocos2d::CCPoint v51; // 0:s0.4,4:s1.4
cocos2d::CCPoint v52; // 0:s1.4,4:s2.4
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v2);
v4 = (cocos2d::CCArray *)cocos2d::CCArray::create(v3);
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(v4);
v43 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
cocos2d::CCPoint::CCPoint(&v46, v44 * 0.5, (float)(v45 * 0.5) + -11.0);
m_savedGauntlets = GameLevelManager::sharedState()->m_savedGauntlets;
if ( cocos2d::CCDictionary::count(m_savedGauntlets) )
{
m_currentGauntlet = GameManager::sharedState()->m_currentGauntlet;
if ( m_savedGauntlets && (m_pElements = m_savedGauntlets->m_pElements) != nullptr )
{
m_pObject = (GJMapPack *)m_pElements->m_pObject;
v9 = 1;
v42 = 0;
next = m_pElements->hh.next;
if ( m_pObject->m_packID == 7 )
goto LABEL_15;
LABEL_6:
v11 = (int)(ceilf((float)v9 / 3.0) - 1.0);
if ( (unsigned int)cocos2d::CCArray::count(v4) <= v11 )
{
v23 = cocos2d::CCLayer::create();
cocos2d::CCArray::addObject(v4, v23);
v40 = cocos2d::CCMenu::create();
v23->addChild(v23, v40);
v38 = (cocos2d::CCPoint *)v40;
v24 = (cocos2d::CCArray *)cocos2d::CCArray::addObject(v43, v40);
v39 = (cocos2d::CCArray *)cocos2d::CCArray::create(v24);
cocos2d::CCArray::addObject(v5, v39);
v12 = (__int64)v38;
}
else
{
cocos2d::CCArray::objectAtIndex(v4, v11);
v39 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v5, v11);
v12 = cocos2d::CCArray::objectAtIndex(v43, v11);
}
if ( m_currentGauntlet == m_pObject->m_packID )
{
v13 = v42;
if ( m_currentGauntlet > 1 )
v13 = v11;
v42 = v13;
}
v34 = v12;
++v9;
v14 = GauntletNode::create(m_pObject);
cocos2d::CCDictionary::setObject(a1->m_gauntlets, v14, m_pObject->m_packID);
v15 = cocos2d::CCNode::create();
setContentSize = (cocos2d::CCPoint *)v15->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v48, 110.0, 234.0);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCPoint *))setContentSize)(v15, &v48);
v15->addChild(v15, v14);
setPosition = v14->setPosition;
v36 = v15->getContentSize(v15)->width * 0.5;
height = v15->getContentSize(v15)->height;
cocos2d::CCPoint::CCPoint(&v47, v36, height * 0.5);
v49 = cocos2d::CCNode::convertToNodeSpace(v15, &v47);
((void (__fastcall *)(GauntletNode *, cocos2d::CCPoint *, float, float))setPosition)(v14, &v48, v49.x, v49.y);
v50.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v50.adj = (size_t)GauntletSelectLayer::onPlay;
v17 = CCMenuItemSpriteExtra::create(v15, nullptr, v50);
v18 = v17->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
m_packID = (unsigned int)m_pObject->m_packID;
v20 = v17;
v17->m_scaleMultiplier = 1.05;
v18->setTag(v17, m_packID);
(*(void (__fastcall **)(__int64, cocos2d::CCObject *))(*(_QWORD *)v34 + 440LL))(v34, v20);
cocos2d::CCArray::addObject(v39, v20);
while ( next )
{
v21 = next;
next = (_QWORD *)next[36];
m_pObject = (GJMapPack *)v21[33];
if ( m_pObject->m_packID != 7 )
goto LABEL_6;
LABEL_15:
v22 = GameManager::sharedState();
if ( GameManager::getUGV(v22, "19") )
goto LABEL_6;
}
}
else
{
v42 = 0;
}
v25 = 0;
while ( v25 < (unsigned int)cocos2d::CCArray::count(v5) )
{
v26 = (cocos2d::CCNode *)cocos2d::CCArray::objectAtIndex(v4, v25);
v27 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v5, v25);
v28 = v25++;
v29 = (cocos2d::CCNode *)cocos2d::CCArray::objectAtIndex(v43, v28);
cocos2d::CCNode::convertToWorldSpace(v26, &v46);
LODWORD(v52.x) = COERCE_UNSIGNED_INT(cocos2d::CCNode::convertToNodeSpace(v29, &v47).y);
GameToolbox::alignItemsHorisontally(v27, 112.0, v52, (bool)&v48);
}
v30 = (BoomScrollLayer *)BoomScrollLayer::create(v4, 0, 1, nullptr, nullptr);
a1->m_scrollLayer = v30;
v30->m_delegate = &a1->BoomScrollLayerDelegate;
a1->addChild(a1, a1->m_scrollLayer);
m_scrollLayer = a1->m_scrollLayer;
v32 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenBottom(v32);
cocos2d::CCPoint::CCPoint(&v48, v44 * 0.5, v33 + 15.0);
BoomScrollLayer::setPagesIndicatorPosition(m_scrollLayer, v51);
if ( v42 > 0 )
{
if ( v42 == BoomScrollLayer::getTotalPages(a1->m_scrollLayer) - 1 )
GauntletSelectLayer::goToPage(a1, v42 - 1, 1);
GauntletSelectLayer::goToPage(a1, v42, 1);
}
}
}