//
// GauntletSelectLayer::setupGauntlets from 0x100572070 to 0x100572500 (1168 bytes)
//
// 2 xrefs:
// > GauntletSelectLayer::init @ 0x100571da3
// > GauntletSelectLayer::loadLevelsFinished @ 0x10057267c
//
// 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 *v1; // rsi
__int64 v2; // r12
__int64 v3; // r15
cocos2d::CCPoint v4; // xmm1_8
cocos2d::CCDictionary *m_savedGauntlets; // rbx
GameManager *v6; // rax
__int64 v7; // r13
cocos2d::CCDictElement *m_pElements; // r15
cocos2d::CCArray *v9; // r14
cocos2d::CCLayer *v10; // r12
cocos2d::CCMenu *v11; // r14
__int64 v12; // rdi
unsigned int v13; // r15d
GauntletNode *v14; // r15
cocos2d::CCNode *v15; // r12
CCMenuItemSpriteExtra *v16; // r15
GJMapPack *m_pObject; // rbx
GameManager *v18; // rax
__m128 v19; // xmm0
unsigned int v20; // ebx
const cocos2d::CCPoint *v21; // r13
__int64 v22; // r14
const cocos2d::CCPoint *v23; // rsi
BoomScrollLayer *v24; // rax
GauntletSelectLayer *v25; // r15
BoomScrollLayer *m_scrollLayer; // rbx
cocos2d::CCDirector *v27; // rax
float v28; // xmm1_4
cocos2d::CCPoint v29; // xmm0_8
int v30; // ebx
float v31; // [rsp+8h] [rbp-98h] BYREF
float v32; // [rsp+10h] [rbp-90h] BYREF
cocos2d::CCDictElement *v33; // [rsp+18h] [rbp-88h]
float v34; // [rsp+20h] [rbp-80h] BYREF
__int64 v35; // [rsp+28h] [rbp-78h]
__int64 v36; // [rsp+30h] [rbp-70h]
__int64 v37; // [rsp+38h] [rbp-68h]
float v38; // [rsp+40h] [rbp-60h] BYREF
float v39; // [rsp+44h] [rbp-5Ch]
float v40; // [rsp+48h] [rbp-58h]
int m_currentGauntlet; // [rsp+4Ch] [rbp-54h]
__int64 v42; // [rsp+50h] [rbp-50h]
GauntletSelectLayer *v43; // [rsp+58h] [rbp-48h]
__int64 v44; // [rsp+60h] [rbp-40h]
__int64 v45; // [rsp+68h] [rbp-38h]
cocos2d::CCArray *v46; // [rsp+70h] [rbp-30h]
double v47; // 0:xmm0_8.8
v1 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v38);
v45 = sub_10071F9E0(&v38, v1);
v2 = sub_10071F9E0(&v38, v1);
v3 = sub_10071F9E0(&v38, v1);
v4 = (cocos2d::CCPoint)LODWORD(v39);
v4.x = (float)(v39 * 0.5) + -11.0;
sub_10028CBE0(&v31, v38 * 0.5, v4.x);
m_savedGauntlets = GameLevelManager::sharedState()->m_savedGauntlets;
if ( cocos2d::CCDictionary::count(m_savedGauntlets) )
{
v42 = v3;
v43 = a1;
v6 = GameManager::sharedState();
v7 = 0;
if ( m_savedGauntlets )
{
m_pElements = m_savedGauntlets->m_pElements;
v9 = (cocos2d::CCArray *)v45;
if ( m_pElements )
{
m_currentGauntlet = v6->m_currentGauntlet;
LODWORD(v46) = 1;
v7 = 0;
v37 = v2;
do
{
m_pObject = (GJMapPack *)m_pElements->m_pObject;
m_pElements = (cocos2d::CCDictElement *)m_pElements->hh.next;
if ( m_pObject->m_packID == 7 )
{
v18 = GameManager::sharedState();
if ( !GameManager::getUGV(v18, "19") )
continue;
}
v33 = m_pElements;
v19 = 0;
v19.f32[0] = (float)(int)v46 / 3.0;
v13 = (int)(float)(_mm_round_ss(v19, v19, 10).f32[0] + -1.0);
if ( (unsigned int)sub_100720070(v9) <= v13 )
{
v10 = cocos2d::CCLayer::create();
sub_10071FCD0(v9, v10);
v11 = cocos2d::CCMenu::create();
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *))v10->addChild)(v10, v11);
v12 = v42;
v35 = (__int64)v11;
sub_10071FCD0(v42, v11);
v36 = sub_10071F9E0(v12, v11);
sub_10071FCD0(v37, v36);
}
else
{
sub_1007200C0(v9, v13);
v36 = sub_1007200C0(v2, v13);
v35 = sub_1007200C0(v42, v13);
}
if ( m_pObject->m_packID != m_currentGauntlet )
v13 = v7;
if ( m_currentGauntlet >= 2 )
v7 = v13;
v44 = v7;
v14 = GauntletNode::create(m_pObject);
cocos2d::CCDictionary::setObject(v43->m_gauntlets, v14, m_pObject->m_packID);
v15 = cocos2d::CCNode::create();
sub_10028CBF0(&v34, 110.0, 234.0);
((void (__fastcall *)(cocos2d::CCNode *, float *))v15->setContentSize)(v15, &v34);
((void (__fastcall *)(cocos2d::CCNode *, GauntletNode *))v15->addChild)(v15, v14);
v40 = *(float *)((__int64 (__fastcall *)(cocos2d::CCNode *))v15->getContentSize)(v15) * 0.5;
v4 = (cocos2d::CCPoint)*(unsigned int *)(((__int64 (__fastcall *)(cocos2d::CCNode *))v15->getContentSize)(v15)
+ 4);
v4.x = v4.x * 0.5;
sub_10028CBE0(&v32, v40, v4.x);
*(cocos2d::CCPoint *)&v47 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)&v34,
(const cocos2d::CCPoint *)v15);
((void (__fastcall *)(GauntletNode *, float *, double))v14->setPosition)(v14, &v34, v47);
v7 = v44;
v16 = CCMenuItemSpriteExtra::create(
v15,
nullptr,
v43,
(cocos2d::SEL_MenuHandler)(unsigned __int64)GauntletSelectLayer::onPlay);
v16->m_scaleMultiplier = 1.05;
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v16->setTag)(v16, (unsigned int)m_pObject->m_packID);
(*(void (__fastcall **)(__int64, CCMenuItemSpriteExtra *))(*(_QWORD *)v35 + 440LL))(v35, v16);
sub_10071FCD0(v36, v16);
LODWORD(v46) = (_DWORD)v46 + 1;
v9 = (cocos2d::CCArray *)v45;
v2 = v37;
m_pElements = v33;
}
while ( m_pElements );
}
}
else
{
v9 = (cocos2d::CCArray *)v45;
}
v44 = v7;
if ( (unsigned int)sub_100720070(v2) )
{
v20 = 0;
do
{
v21 = (const cocos2d::CCPoint *)sub_1007200C0(v9, v20);
v46 = (cocos2d::CCArray *)sub_1007200C0(v2, v20);
v22 = sub_1007200C0(v42, v20);
cocos2d::CCNode::convertToWorldSpace((cocos2d::CCNode *)&v32, v21);
v23 = (const cocos2d::CCPoint *)v22;
v9 = (cocos2d::CCArray *)v45;
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)&v34, v23);
GameToolbox::alignItemsHorisontally(v46, 112.0, v4, (bool)&v34);
++v20;
}
while ( v20 < (unsigned int)sub_100720070(v2) );
}
v24 = BoomScrollLayer::create(v9, 0, 1, nullptr, nullptr);
v25 = v43;
v43->m_scrollLayer = v24;
v24->m_delegate = &v25->BoomScrollLayerDelegate;
((void (__fastcall *)(GauntletSelectLayer *, BoomScrollLayer *))v25->addChild)(v25, v24);
m_scrollLayer = v25->m_scrollLayer;
*(float *)&v46 = v38 * 0.5;
v27 = cocos2d::CCDirector::sharedDirector();
v28 = sub_100484D80((__int64)v27) + 15.0;
v29 = (cocos2d::CCPoint)(unsigned int)v46;
sub_10028CBE0(&v34, *(float *)&v46, v28);
BoomScrollLayer::setPagesIndicatorPosition(m_scrollLayer, v29);
v30 = v44;
if ( (int)v44 > 0 )
{
if ( v30 == BoomScrollLayer::getTotalPages(v25->m_scrollLayer) - 1 )
GauntletSelectLayer::goToPage(v25, v30 - 1, 1);
GauntletSelectLayer::goToPage(v25, v30, 1);
}
}
}