//
// SetupSpawnPopup::updateRemapButtons from 0x4bc0c0 to 0x4bc508 (1096 bytes)
//
// 1 xrefs:
// > SetupSpawnPopup::init @ 0x4bcb80
//
// 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 SetupSpawnPopup::updateRemapButtons(SetupSpawnPopup *a1, float a2)
{
unsigned int v3; // r8
bool v4; // cf
cocos2d::CCArray *m_remapButtons; // r0
unsigned int v6; // r1
cocos2d::CCObject *v7; // r5
cocos2d::CCObject *v8; // r1
EffectGameObject *m_gameObject; // r0
cocos2d::CCArray *m_gameObjects; // r9
float v11; // s16
float v12; // s17
int v13; // r3
float v14; // s18
cocos2d::CCDirector *v15; // r0
cocos2d::ccArray *data; // r3
cocos2d::CCObject **arr; // r6
cocos2d::CCObject **v18; // r5
int v19; // r3
int v20; // t1
float *v21; // r8
float *v22; // r11
cocos2d::CCMenu *m_buttonMenu; // r6
int v24; // r11
_DWORD *v25; // r5
int v26; // r6
const char *v27; // r8
int v28; // r9
char *v29; // r1
cocos2d::CCString *v30; // r0
ButtonSprite *CString; // r0
ButtonSprite *v32; // r0
CCMenuItemSpriteExtra *v33; // r8
float v34; // r0
int *m_finish; // r3
int v36; // r1
signed int v37; // r3
int v38; // r8
unsigned int v39; // r3
int v40; // r8
int *v41; // r9
int *v42; // r12
int *m_start; // lr
_DWORD *v44; // r2
int v45; // r1
int j; // r2
int *v47; // r1
int *v49; // r10
int v50; // r0
int v51; // r1
int *v52; // r10
_BOOL4 v53; // r0
_DWORD **v54; // r3
_DWORD *v55; // r1
_DWORD **v56; // r2
_DWORD *i; // r3
int *v58; // r0
int v59; // r3
float v60; // r3
float v61; // [sp+10h] [bp-7Ch]
int v62; // [sp+14h] [bp-78h]
_DWORD *v63; // [sp+14h] [bp-78h]
_DWORD **v64; // [sp+18h] [bp-74h]
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [sp+1Ch] [bp-70h]
char *v66; // [sp+38h] [bp-54h] BYREF
cocos2d::CCSize v67; // [sp+3Ch] [bp-50h] BYREF
cocos2d::CCPoint v68; // [sp+44h] [bp-48h] BYREF
cocos2d::CCPoint v69; // [sp+4Ch] [bp-40h] BYREF
cocos2d::CCPoint v70; // [sp+54h] [bp-38h] BYREF
void (*v71)(SetupSpawnPopup *, float); // [sp+5Ch] [bp-30h]
int v72; // [sp+60h] [bp-2Ch]
cocos2d::CCPoint v73; // [sp+64h] [bp-28h] BYREF
int v74; // [sp+6Ch] [bp-20h] BYREF
_DWORD *v75[4]; // [sp+70h] [bp-1Ch] BYREF
unsigned int v76; // [sp+80h] [bp-Ch]
v3 = 0;
v72 = 0;
v71 = SetupSpawnPopup::updateRemapButtons;
cocos2d::CCNode::unschedule(a1, (cocos2d::SEL_SCHEDULE)(unsigned int)SetupSpawnPopup::updateRemapButtons);
a1->m_isBusy = 0;
while ( 1 )
{
v4 = v3 >= cocos2d::CCArray::count(a1->m_remapButtons);
m_remapButtons = a1->m_remapButtons;
if ( v4 )
break;
v6 = v3++;
v7 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(m_remapButtons, v6);
SetupTriggerPopup::removeObjectFromPage(a1, v7, 1);
((void (__fastcall *)(cocos2d::CCObject *))v7->__vftable[6].isEqual)(v7);
}
cocos2d::CCArray::removeAllObjects(m_remapButtons);
m_gameObject = a1->m_gameObject;
a1->m_remapGroups.m_finish = a1->m_remapGroups.m_start;
if ( m_gameObject )
m_gameObjects = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject((cocos2d::CCArray *)m_gameObject, v8);
else
m_gameObjects = a1->m_gameObjects;
memset(v75, 0, sizeof(v75));
v75[2] = v75;
v76 = 0;
v75[3] = v75;
if ( m_gameObjects )
{
data = m_gameObjects->data;
if ( data->num )
{
arr = data->arr;
v18 = &arr[data->num] + 0x3FFFFFFF;
while ( arr <= v18 )
{
v20 = (int)*arr++;
v19 = v20;
if ( !v20 )
break;
v21 = *(float **)(v19 + 1636);
v22 = *(float **)(v19 + 1640);
while ( v21 != v22 )
{
v60 = v21[2];
v73.x = *v21;
v56 = v75;
v73.y = v60;
for ( i = v75[1]; i; i = v55 )
{
v64 = v56;
v63 = i;
v53 = std::operator<(i + 4, &v73);
v54 = (_DWORD **)v63;
if ( v53 )
{
v55 = (_DWORD *)v63[3];
v54 = v64;
}
else
{
v55 = (_DWORD *)v63[2];
}
v56 = v54;
}
if ( v56 == v75 || std::operator<(&v73, v56 + 4) )
{
v58 = (int *)std::map,int>::operator[](&v74, &v73);
v59 = 1;
}
else
{
v58 = (int *)std::map,int>::operator[](&v74, &v73);
v59 = *v58 + 1;
}
v21 += 4;
*v58 = v59;
}
}
}
}
v11 = 4.5;
v12 = 35.0;
if ( v76 <= 0xA )
v13 = 5;
else
v13 = 10;
v62 = v13;
v14 = 40.0;
if ( v76 > 0xA )
{
v14 = 15.0;
}
else
{
v12 = 66.0;
v11 = 2.0;
}
v15 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v67, v15);
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(
&v73,
(float)(v67.width * 0.5) - (float)(v11 * v12),
(float)((float)(v67.height * 0.5) + 45.0) - 25.0);
cocos2d::CCNode::convertToNodeSpace(&v68, m_buttonMenu, &v73);
v24 = cocos2d::CCArray::count(m_gameObjects);
v25 = v75[2];
v26 = 0;
while ( v25 != v75 )
{
v27 = (const char *)v25[4];
v28 = v25[5];
if ( v27 == (const char *)a1->m_remapOriginalID && v28 == a1->m_remapNewID )
{
v29 = "GJ_button_03.png";
}
else if ( v24 == v25[6] )
{
v29 = "GJ_button_04.png";
}
else
{
v29 = "GJ_button_05.png";
}
sub_776584((int)&v66, v29);
v30 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i\n%i", v27, v28);
CString = (ButtonSprite *)cocos2d::CCString::getCString(v30);
v32 = ButtonSprite::create(
CString,
(const char *)(int)v14,
0,
0.35,
1,
"bigFont.fnt",
v66,
(const char *)0x41F00000,
v61);
v73.y = 0.0;
LODWORD(v73.x) = SetupSpawnPopup::onSelectRemap;
v33 = CCMenuItemSpriteExtra::create(
v32,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetupSpawnPopup::onSelectRemap, (unsigned int)a1));
v33->setTag(v33, v26);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v33);
SetupTriggerPopup::addObjectToPage(a1, v33, 1);
setPosition = v33->setPosition;
v34 = floorf((float)(v26 / v62));
cocos2d::CCPoint::CCPoint(&v69, v12 * (float)(v26 % v62), v34 * -38.0);
cocos2d::CCPoint::operator+(&v70, &v68, &v69);
setPosition(v33, &v70);
cocos2d::CCArray::addObject(a1->m_remapButtons, v33);
m_finish = a1->m_remapGroups.m_finish;
if ( m_finish != a1->m_remapGroups.m_reserveEnd )
{
if ( m_finish )
{
v36 = v25[5];
*m_finish = v25[4];
m_finish[1] = v36;
}
a1->m_remapGroups.m_finish = m_finish + 2;
goto LABEL_45;
}
v37 = ((char *)m_finish - (char *)a1->m_remapGroups.m_start) >> 3;
if ( v37 )
v38 = v37;
else
v38 = 1;
v4 = __CFADD__(v38, v37);
v39 = v38 + v37;
if ( v4 || v39 >= 0x20000000 )
{
v40 = 0x1FFFFFFF;
}
else
{
v40 = v39;
if ( !v39 )
{
v41 = nullptr;
goto LABEL_35;
}
}
v41 = (int *)operator new(8 * v40);
LABEL_35:
v42 = a1->m_remapGroups.m_finish;
m_start = a1->m_remapGroups.m_start;
v44 = (int *)((char *)v41 + (char *)v42 - (char *)m_start);
if ( v44 )
{
v45 = v25[5];
*v44 = v25[4];
v44[1] = v45;
}
for ( j = 0; ; j += 2 )
{
v47 = &m_start[j];
if ( v42 == &m_start[j] )
break;
v49 = &v41[j];
if ( &v41[j] != nullptr )
{
v50 = *v47;
v51 = v47[1];
*v49 = v50;
v49[1] = v51;
}
}
v52 = (int *)((char *)v41 + (((char *)v42 - (char *)m_start) & 0xFFFFFFF8) + 8);
if ( m_start )
operator delete(m_start);
a1->m_remapGroups.m_start = v41;
a1->m_remapGroups.m_finish = v52;
a1->m_remapGroups.m_reserveEnd = &v41[2 * v40];
LABEL_45:
if ( ++v26 == 20 )
{
sub_774008(&v66);
break;
}
sub_774008(&v66);
v25 = (_DWORD *)sub_761FA8(v25);
}
std::_Rb_tree,std::pair const,int>,std::_Select1st const,int>>,std::less>,std::allocator const,int>>>::_M_erase(
(int)&v74,
v75[1]);
}