//
// SetupSpawnPopup::updateRemapButtons from 0x14045f230 to 0x14045fa4e (2078 bytes)
//
// 6 xrefs:
// > SetupSpawnPopup::init @ 0x14045edb9
// > SetupSpawnPopup::addRemap @ 0x14045efc4
// > SetupSpawnPopup::onDeleteRemap @ 0x14045f15b
// > SetupSpawnPopup::updateRemapButtons @ 0x14045f280
// > SetupSpawnPopup::queueUpdateButtons @ 0x14045fb4f
// > ??> @ 0x1406dada8
//
// 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
//
// Hidden C++ exception states: #wind=6
void SetupSpawnPopup::updateRemapButtons(SetupSpawnPopup *a1, float a2)
{
SetupSpawnPopup *v2; // r14
unsigned int i; // edi
struct cocos2d::CCObject *v4; // rbx
cocos2d::CCArray *PageContainer; // rax
std::_Simple_types::value_type *Myfirst; // rax
struct cocos2d::CCObject *m_gameObject; // rcx
struct cocos2d::CCArray *m_gameObjects; // rdi
int v9; // esi
__int64 num; // rcx
_QWORD *v11; // rbx
cocos2d::ccArray *data; // rax
cocos2d::CCObject **arr; // r15
cocos2d::CCObject **v14; // r12
cocos2d::CCObject *v15; // rax
unsigned int *v16; // rdi
unsigned int *j; // r14
__int64 v18; // rdx
__int64 v19; // r8
__int64 v20; // rax
_QWORD *v21; // r10
__int64 v22; // r9
char *v23; // rax
char *v24; // rax
int v25; // r13d
float v26; // xmm6_4
int v27; // eax
float v28; // xmm9_4
float v29; // xmm8_4
cocos2d::CCDirector *v30; // rax
unsigned int v31; // eax
int v32; // r12d
__int64 *v33; // rbx
unsigned int v34; // r15d
unsigned int v35; // edi
const char *v36; // rdx
size_t v37; // r8
void **v38; // rsi
cocos2d::CCString *v39; // rax
const char *CString; // r15
ButtonSprite *v41; // rdi
CCMenuItemSpriteExtra *v42; // rsi
SetupSpawnPopup *v43; // r15
cocos2d::CCArray *v44; // rax
float v45; // xmm0_4
_BYTE *Mylast; // rdx
void *v47; // rcx
__int64 **v48; // rax
__int64 *k; // rax
__int64 *m; // rax
void *v51; // rcx
struct cocos2d::CCArray *v52; // [rsp+58h] [rbp-B0h] BYREF
_QWORD *v53; // [rsp+60h] [rbp-A8h] BYREF
unsigned __int64 v54; // [rsp+68h] [rbp-A0h]
__int64 v55; // [rsp+70h] [rbp-98h]
SetupSpawnPopup *v56; // [rsp+78h] [rbp-90h]
ButtonSprite *v57; // [rsp+88h] [rbp-80h] BYREF
int v58; // [rsp+90h] [rbp-78h]
float v59; // [rsp+A8h] [rbp-60h]
struct cocos2d::CCPoint v60; // [rsp+B0h] [rbp-58h] BYREF
CCMenuItemSpriteExtra *v61; // [rsp+B8h] [rbp-50h]
__int64 v62; // [rsp+C0h] [rbp-48h]
void **v63; // [rsp+C8h] [rbp-40h]
__int64 v64; // [rsp+D0h] [rbp-38h]
void *Block[2]; // [rsp+D8h] [rbp-30h] BYREF
__int64 v66; // [rsp+E8h] [rbp-20h]
unsigned __int64 v67; // [rsp+F0h] [rbp-18h]
v2 = a1;
v56 = a1;
cocos2d::CCNode::unschedule(a1, SetupSpawnPopup::updateRemapButtons);
v2->m_isBusy = 0;
for ( i = 0; i < cocos2d::CCArray::count(v2->m_remapButtons); ++i )
{
v4 = cocos2d::CCArray::objectAtIndex(v2->m_remapButtons, i);
PageContainer = SetupTriggerPopup::getPageContainer(v2, 1);
cocos2d::CCArray::removeObject(PageContainer, v4, 1);
((void (__fastcall *)(struct cocos2d::CCObject *))v4->__vftable[6].setTag)(v4);
}
cocos2d::CCArray::removeAllObjects(v2->m_remapButtons);
Myfirst = v2->m_remapGroups._Mypair._Myval2._Myfirst;
if ( Myfirst != v2->m_remapGroups._Mypair._Myval2._Mylast )
v2->m_remapGroups._Mypair._Myval2._Mylast = Myfirst;
m_gameObject = v2->m_gameObject;
if ( m_gameObject )
m_gameObjects = cocos2d::CCArray::createWithObject(m_gameObject);
else
m_gameObjects = v2->m_gameObjects;
v52 = m_gameObjects;
v54 = 0;
v9 = 40;
v11 = operator new(0x28u);
*v11 = v11;
v11[1] = v11;
v11[2] = v11;
*((_WORD *)v11 + 12) = 257;
v53 = v11;
if ( m_gameObjects )
{
data = m_gameObjects->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v14 = &arr[num - 1];
if ( arr <= v14 )
{
do
{
v15 = *arr;
if ( !*arr )
break;
v16 = *(unsigned int **)&v15[33].m_uID;
for ( j = *(unsigned int **)&v15[33].m_nTag; v16 != j; v11 = v53 )
{
v18 = *v16;
LODWORD(v55) = *v16;
v19 = v16[2];
HIDWORD(v55) = v16[2];
v20 = v11[1];
v21 = v11;
num = v20;
while ( !*(_BYTE *)(num + 25) )
{
if ( *(_DWORD *)(num + 28) < (int)v18
|| *(_DWORD *)(num + 28) <= (int)v18 && *(_DWORD *)(num + 32) < (int)v19 )
{
num = *(_QWORD *)(num + 16);
}
else
{
v21 = (_QWORD *)num;
num = *(_QWORD *)num;
}
}
LOBYTE(num) = !*((_BYTE *)v21 + 25)
&& (int)v18 >= *((_DWORD *)v21 + 7)
&& ((int)v18 > *((_DWORD *)v21 + 7) || (int)v19 >= *((_DWORD *)v21 + 8));
v57 = (ButtonSprite *)v11[1];
v58 = 0;
v22 = (__int64)v11;
if ( (_BYTE)num )
{
while ( !*(_BYTE *)(v20 + 25) )
{
v57 = (ButtonSprite *)v20;
if ( *(_DWORD *)(v20 + 28) < (int)v18
|| *(_DWORD *)(v20 + 28) <= (int)v18 && *(_DWORD *)(v20 + 32) < (int)v19 )
{
v58 = 0;
v20 = *(_QWORD *)(v20 + 16);
}
else
{
v58 = 1;
v22 = v20;
v20 = *(_QWORD *)v20;
}
}
if ( *(_BYTE *)(v22 + 25)
|| (int)v18 < *(_DWORD *)(v22 + 28)
|| (int)v18 <= *(_DWORD *)(v22 + 28) && (int)v19 < *(_DWORD *)(v22 + 32) )
{
if ( v54 == 0x666666666666666LL )
LABEL_106:
sub_140052E40(num, v18, v19);
v61 = (CCMenuItemSpriteExtra *)&v53;
v62 = 0;
v24 = (char *)operator new(0x28u);
*(_QWORD *)(v24 + 28) = v55;
*((_DWORD *)v24 + 9) = 0;
*(_QWORD *)v24 = v11;
*((_QWORD *)v24 + 1) = v11;
*((_QWORD *)v24 + 2) = v11;
*((_WORD *)v24 + 12) = 0;
v62 = 0;
v22 = sub_1400636D0(&v53, (__int64)&v57, (__int64)v24);
}
++*(_DWORD *)(v22 + 36);
}
else
{
while ( !*(_BYTE *)(v20 + 25) )
{
v57 = (ButtonSprite *)v20;
if ( *(_DWORD *)(v20 + 28) < (int)v18
|| *(_DWORD *)(v20 + 28) <= (int)v18 && *(_DWORD *)(v20 + 32) < (int)v19 )
{
v58 = 0;
v20 = *(_QWORD *)(v20 + 16);
}
else
{
v58 = 1;
v22 = v20;
v20 = *(_QWORD *)v20;
}
}
if ( *(_BYTE *)(v22 + 25)
|| (int)v18 < *(_DWORD *)(v22 + 28)
|| (int)v18 <= *(_DWORD *)(v22 + 28) && (int)v19 < *(_DWORD *)(v22 + 32) )
{
if ( v54 == 0x666666666666666LL )
goto LABEL_106;
v63 = (void **)&v53;
v64 = 0;
v23 = (char *)operator new(0x28u);
*(_QWORD *)(v23 + 28) = v55;
*((_DWORD *)v23 + 9) = 0;
*(_QWORD *)v23 = v11;
*((_QWORD *)v23 + 1) = v11;
*((_QWORD *)v23 + 2) = v11;
*((_WORD *)v23 + 12) = 0;
v64 = 0;
v22 = sub_1400636D0(&v53, (__int64)&v57, (__int64)v23);
}
*(_DWORD *)(v22 + 36) = 1;
}
v16 += 4;
}
++arr;
}
while ( arr <= v14 );
m_gameObjects = v52;
v2 = v56;
}
}
}
v25 = 5;
if ( v54 <= 0xA )
{
v26 = 2.0;
}
else
{
v25 = 10;
v26 = 4.5;
}
v27 = 66;
if ( v54 > 0xA )
v27 = 35;
v28 = (float)v27;
if ( v54 > 0xA )
v9 = 15;
v29 = (float)v9;
LOBYTE(num) = v54 > 0xA;
v30 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(num);
cocos2d::CCDirector::getWinSize(v30);
cocos2d::CCPoint::CCPoint(v28 * v26, (float)(v59 * 0.5) - (float)(v28 * v26));
cocos2d::CCNode::convertToNodeSpace(v2->m_buttonMenu, &v60);
v31 = cocos2d::CCArray::count(m_gameObjects);
LODWORD(v55) = v31;
v32 = 0;
v33 = (__int64 *)*v53;
if ( *(_BYTE *)(*v53 + 25LL) )
goto LABEL_105;
while ( 1 )
{
v34 = *((_DWORD *)v33 + 7);
v35 = *((_DWORD *)v33 + 8);
if ( __PAIR64__(v35, v34) == *(_QWORD *)&v56->m_remapOriginalID )
{
v36 = "GJ_button_03.png";
}
else
{
v36 = "GJ_button_05.png";
if ( v31 == *((_DWORD *)v33 + 9) )
v36 = "GJ_button_04.png";
}
*(_OWORD *)Block = 0;
v66 = 0;
v67 = 0;
v37 = -1;
do
++v37;
while ( v36[v37] );
sub_14003A930(Block, v36, v37);
v38 = Block;
if ( v67 > 0xF )
v38 = (void **)Block[0];
v39 = cocos2d::CCString::createWithFormat("%i\n%i", v34, v35);
CString = cocos2d::CCString::getCString(v39);
v57 = (ButtonSprite *)operator new(0x2C0u);
v41 = ButtonSprite::ButtonSprite(v57);
if ( v41 )
{
if ( ButtonSprite::init_1(
v41,
CString,
(int)v29,
0,
0.34999999,
1,
(const char *)&qword_14052A4D8,
(const char *)v38,
30.0) )
{
cocos2d::CCObject::autorelease(v41);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v41->~ButtonSprite)(v41, 1);
v41 = nullptr;
}
}
v61 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v42 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v61);
v43 = v56;
if ( v42 )
{
if ( CCMenuItemSpriteExtra::init(
v42,
v41,
nullptr,
v56,
(cocos2d::SEL_MenuHandler *)SetupSpawnPopup::onSelectRemap) )
{
cocos2d::CCObject::autorelease(v42);
goto LABEL_83;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v42->~CCMenuItemSpriteExtra)(v42, 1);
}
v42 = nullptr;
LABEL_83:
v42->setTag(v42, v32);
v43->m_buttonMenu->addChild_1(v43->m_buttonMenu, v42);
v44 = SetupTriggerPopup::getPageContainer(v43, 1);
cocos2d::CCArray::addObject(v44, v42);
v45 = floorf((float)(v32 / v25)) * -38.0;
cocos2d::CCPoint::CCPoint(v45, (float)(v32 % v25) * v28);
cocos2d::CCPoint::operator+(&v60, &v52);
v42->setPosition_0(v42, (const cocos2d::CCPoint *)&v52);
cocos2d::CCArray::addObject(v43->m_remapButtons, v42);
Mylast = v43->m_remapGroups._Mypair._Myval2._Mylast;
if ( Mylast == (_BYTE *)v43->m_remapGroups._Mypair._Myval2._Myend )
{
sub_14012D2A0((const void **)&v43->m_remapGroups._Mypair._Myval2._Myfirst, Mylast, (__int64 *)((char *)v33 + 28));
}
else
{
*(_QWORD *)Mylast = *(__int64 *)((char *)v33 + 28);
v43->m_remapGroups._Mypair._Myval2._Mylast += 2;
}
if ( ++v32 >= 20 )
break;
if ( v67 > 0xF )
{
v47 = Block[0];
if ( v67 + 1 >= 0x1000 )
{
v47 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v47 - 8) > 0x1F )
goto LABEL_103;
}
j_j_free(v47);
}
v48 = (__int64 **)v33[2];
if ( *((_BYTE *)v48 + 25) )
{
for ( k = (__int64 *)v33[1]; !*((_BYTE *)k + 25); k = (__int64 *)k[1] )
{
if ( v33 != (__int64 *)k[2] )
break;
v33 = k;
}
v33 = k;
}
else
{
v33 = (__int64 *)v33[2];
for ( m = *v48; !*((_BYTE *)m + 25); m = (__int64 *)*m )
v33 = m;
}
v31 = v55;
if ( *((_BYTE *)v33 + 25) )
goto LABEL_105;
}
if ( v67 > 0xF )
{
v51 = Block[0];
if ( v67 + 1 >= 0x1000 )
{
v51 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v51 - 8) > 0x1F )
LABEL_103:
invalid_parameter_noinfo_noreturn();
}
j_j_free(v51);
}
LABEL_105:
sub_140093D70((void **)&v53);
}