//
// SetGroupIDLayer::updateGroupIDButtons from 0x1403fc120 to 0x1403fc7dd (1725 bytes)
//
// 6 xrefs:
// > SetGroupIDLayer::init @ 0x1403f9e5f
// > SetGroupIDLayer::onPaste @ 0x1403fb85f
// > SetGroupIDLayer::callRemoveFromGroup @ 0x1403fc99c
// > SetGroupIDLayer::onAddGroup @ 0x1403fcbf8
// > SetGroupIDLayer::onAddGroupParent @ 0x1403fccec
// > ??> @ 0x1406d84a4
//
// 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=4
void SetGroupIDLayer::updateGroupIDButtons(SetGroupIDLayer *a1)
{
signed int v2; // r15d
unsigned int i; // ebx
struct cocos2d::CCObject *v4; // rax
__int64 v5; // rcx
__int64 v6; // rdx
cocos2d::CCDictionary *v7; // r13
int v8; // ebx
GameObject *m_targetObject; // rcx
int v10; // r14d
__int64 v11; // rdi
unsigned __int64 v12; // rsi
std::array *m_groups; // rax
int v14; // ebx
struct cocos2d::CCObject *v15; // r15
__int64 v16; // rcx
int v17; // r12d
float v18; // xmm6_4
int v19; // eax
float v20; // xmm9_4
int v21; // eax
float v22; // xmm8_4
cocos2d::CCDirector *v23; // rax
struct cocos2d::CCArray *v24; // rbx
__int64 v25; // r14
struct cocos2d::CCObject *v26; // rdi
unsigned int v27; // ebx
bool v28; // di
unsigned int v29; // edi
struct cocos2d::CCObject *v30; // rsi
int v31; // ecx
int v32; // r12d
__int64 v33; // r15
unsigned __int64 v34; // r14
__int64 v35; // rax
__int64 v36; // rbx
struct cocos2d::CCObject *v37; // rdi
__int64 v38; // rdx
__int64 v39; // rcx
__int64 v40; // rcx
cocos2d::CCObject_vtbl *v41; // rbx
int v42; // eax
const char *v43; // rbx
cocos2d::CCString *v44; // rax
const char *CString; // rsi
ButtonSprite *v46; // rdi
CCMenuItemSpriteExtra *v47; // rbx
float v48; // xmm0_4
void *v49; // [rsp+50h] [rbp-A8h]
ButtonSprite *v50; // [rsp+50h] [rbp-A8h]
CCMenuItemSpriteExtra *v51; // [rsp+58h] [rbp-A0h]
void *v52; // [rsp+100h] [rbp+8h] BYREF
cocos2d::CCArray *v53; // [rsp+108h] [rbp+10h]
float v54; // [rsp+110h] [rbp+18h]
struct cocos2d::CCPoint v55; // [rsp+118h] [rbp+20h] BYREF
v2 = 0;
for ( i = 0; i < cocos2d::CCArray::count(a1->m_groupIDObjects); ++i )
{
v4 = cocos2d::CCArray::objectAtIndex(a1->m_groupIDObjects, i);
((void (__fastcall *)(struct cocos2d::CCObject *))v4->__vftable[6].setTag)(v4);
}
cocos2d::CCArray::removeAllObjects(a1->m_groupIDObjects);
cocos2d::CCDictionary::removeAllObjects(a1->m_parentGroups);
v7 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v5);
v8 = 0;
LODWORD(v52) = 0;
m_targetObject = a1->m_targetObject;
if ( m_targetObject )
{
v10 = 0;
if ( m_targetObject->m_groupCount > 0 )
{
v11 = 0;
v12 = 0;
do
{
if ( v12 <= 9 && (m_groups = m_targetObject->m_groups) != nullptr )
v14 = m_groups->_Elems[v11];
else
v14 = 0;
v15 = (struct cocos2d::CCObject *)cocos2d::CCNode::create(m_targetObject, v6);
cocos2d::CCDictionary::setObject(v7, v15, v14);
if ( a1->m_targetObject->m_hasGroupParentsString )
{
v16 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v52 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v52);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v16 = qword_1406C2ED8;
}
if ( a1->m_targetObject == cocos2d::CCDictionary::objectForKey(
*(cocos2d::CCDictionary **)(*(_QWORD *)(v16 + 528) + 3936LL),
v14) )
cocos2d::CCDictionary::setObject(a1->m_parentGroups, v15, v14);
}
++v10;
++v12;
++v11;
m_targetObject = a1->m_targetObject;
v2 = 0;
}
while ( v10 < m_targetObject->m_groupCount );
}
LOBYTE(m_targetObject) = 0;
v17 = 5;
LABEL_17:
v18 = 2.0;
goto LABEL_18;
}
v29 = 0;
LODWORD(v53) = 0;
if ( cocos2d::CCArray::count(a1->m_targetObjects) )
{
do
{
v30 = cocos2d::CCArray::objectAtIndex(a1->m_targetObjects, v29);
v31 = 0;
v32 = 0;
if ( SLOWORD(v30[21].__vftable) > 0 )
{
v33 = 0;
v34 = 0;
do
{
if ( v34 <= 9 )
{
v35 = *(_QWORD *)&v30[20].m_uOrderOfArrival;
if ( v35 )
v31 = *(__int16 *)(v35 + v33);
}
v36 = v31;
v37 = cocos2d::CCDictionary::objectForKey(v7, v31);
if ( !cocos2d::CCDictionary::objectForKey(v7, v36) )
{
v37 = (struct cocos2d::CCObject *)cocos2d::CCNode::create(v39, v38);
v37->setTag(v37, 0);
cocos2d::CCDictionary::setObject(v7, v37, v36);
LODWORD(v52) = (_DWORD)v52 + 1;
}
if ( BYTE2(v30[21].__vftable) )
{
v40 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v49 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v49);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v40 = qword_1406C2ED8;
}
if ( v30 == cocos2d::CCDictionary::objectForKey(
*(cocos2d::CCDictionary **)(*(_QWORD *)(v40 + 528) + 3936LL),
v36) )
cocos2d::CCDictionary::setObject(a1->m_parentGroups, v37, v36);
}
v41 = v37->__vftable;
v42 = v37->getTag(v37);
v41->setTag(v37, v42 + 1);
++v32;
++v34;
v33 += 2;
v31 = 0;
}
while ( v32 < SLOWORD(v30[21].__vftable) );
v29 = (unsigned int)v53;
}
LODWORD(v53) = ++v29;
}
while ( v29 < cocos2d::CCArray::count(a1->m_targetObjects) );
v8 = (int)v52;
v2 = 0;
}
LOBYTE(m_targetObject) = v8 > 10;
v17 = 5;
if ( v8 <= 10 )
goto LABEL_17;
v17 = 10;
v18 = 4.5;
LABEL_18:
v19 = 58;
if ( (_BYTE)m_targetObject )
v19 = 35;
v20 = (float)v19;
v21 = 30;
if ( (_BYTE)m_targetObject )
v21 = 15;
v22 = (float)v21;
v23 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(m_targetObject);
cocos2d::CCDirector::getWinSize(v23);
cocos2d::CCPoint::CCPoint(v20 * v18, (float)(v54 * 0.5) - (float)(v20 * v18));
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v55);
v24 = cocos2d::CCDictionary::allKeys(v7);
v53 = v24;
qsort(v24->data->arr, v24->data->num, 8u, (_CoreCrtNonSecureSearchSortCompareFunction)sub_1403F85C0);
if ( cocos2d::CCArray::count(v24) )
{
while ( 1 )
{
if ( v2 >= 20 )
return;
v25 = SLODWORD(cocos2d::CCArray::objectAtIndex(v24, v2)[1].__vftable);
v26 = cocos2d::CCDictionary::objectForKey(v7, v25);
v28 = true;
if ( !a1->m_targetObject )
{
v27 = cocos2d::CCArray::count(a1->m_targetObjects);
if ( v26->getTag(v26) < v27 )
v28 = false;
}
if ( cocos2d::CCDictionary::objectForKey(a1->m_parentGroups, v25) )
{
v43 = "GJ_button_03.png";
}
else
{
v43 = "GJ_button_05.png";
if ( v28 )
v43 = "GJ_button_04.png";
}
v44 = cocos2d::CCString::createWithFormat("%i", v25);
CString = cocos2d::CCString::getCString(v44);
v50 = (ButtonSprite *)operator new(0x2C0u);
v46 = ButtonSprite::ButtonSprite(v50);
if ( v46 )
{
if ( ButtonSprite::init_1(v46, CString, (int)v22, 0, 0.5, 1, "goldFont.fnt", v43, 20.0) )
{
cocos2d::CCObject::autorelease(v46);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v46->~ButtonSprite)(v46, 1);
v46 = nullptr;
}
}
v51 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v47 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v51);
if ( !v47 )
goto LABEL_59;
if ( !CCMenuItemSpriteExtra::init(
v47,
v46,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetGroupIDLayer::onRemoveFromGroup) )
break;
cocos2d::CCObject::autorelease(v47);
LABEL_60:
v47->setTag(v47, v25);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v47);
v48 = floorf((float)(v2 / v17));
cocos2d::CCPoint::CCPoint(v48, (float)(v2 % v17) * v20);
cocos2d::CCPoint::operator+(&v55, &v52);
v47->setPosition_0(v47, (const cocos2d::CCPoint *)&v52);
cocos2d::CCArray::addObject(a1->m_groupIDObjects, v47);
++v2;
v24 = v53;
if ( v2 >= cocos2d::CCArray::count(v53) )
return;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v47->~CCMenuItemSpriteExtra)(v47, 1);
LABEL_59:
v47 = nullptr;
goto LABEL_60;
}
}