//
// SetGroupIDLayer::updateGroupIDButtons from 0x1003161c0 to 0x1003166da (1306 bytes)
//
// 6 xrefs:
// > SetGroupIDLayer::init @ 0x100313ced
// > SetGroupIDLayer::onAddGroupParent @ 0x100315368
// > SetGroupIDLayer::onPaste @ 0x1003167e2
// > SetGroupIDLayer::callRemoveFromGroup @ 0x1003179d0
// > SetGroupIDLayer::removeGroupID @ 0x100317acb
// > SetGroupIDLayer::addGroupID @ 0x100317bb4
//
// 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 SetGroupIDLayer::updateGroupIDButtons(SetGroupIDLayer *a1)
{
SetGroupIDLayer *v1; // r12
unsigned int v2; // ebx
__int64 v3; // rax
GameObject *m_targetObject; // rdi
int v5; // esi
int v6; // r13d
int GroupID; // r15d
cocos2d::CCNode *v8; // rbx
GameManager *v9; // rax
GameObject *GroupParent; // rax
int v11; // eax
unsigned int v12; // ebx
cocos2d::CCArray *m_targetObjects; // rdi
__int64 v14; // rax
GameObject *v15; // r13
int v16; // r12d
int v17; // eax
int v18; // r14d
cocos2d::CCNode *v19; // rbx
GameManager *v20; // rax
char v21; // r15
const cocos2d::CCPoint *m_buttonMenu; // rbx
float v23; // xmm0_4
cocos2d::CCArray *v24; // rbx
int v25; // ecx
unsigned int v26; // r13d
SetGroupIDLayer *v27; // r14
intptr_t v28; // r15
cocos2d::CCObject *v29; // rax
const char *v30; // rbx
unsigned int v31; // ebx
bool v32; // cf
cocos2d::CCString *v33; // rax
const char *CString; // rax
ButtonSprite *v35; // rax
CCMenuItemSpriteExtra *v36; // rbx
unsigned int v37; // eax
char v38; // [rsp+0h] [rbp-80h]
unsigned __int64 v39; // [rsp+Ch] [rbp-74h] BYREF
unsigned __int64 v40; // [rsp+14h] [rbp-6Ch] BYREF
double v41; // [rsp+1Ch] [rbp-64h] BYREF
float v42[2]; // [rsp+24h] [rbp-5Ch] BYREF
unsigned int v43; // [rsp+2Ch] [rbp-54h]
GameObject *v44; // [rsp+30h] [rbp-50h]
SetGroupIDLayer *v45; // [rsp+38h] [rbp-48h]
cocos2d::CCDictionary *v46; // [rsp+40h] [rbp-40h]
cocos2d::CCArray *v47; // [rsp+48h] [rbp-38h]
unsigned int v48; // [rsp+50h] [rbp-30h]
float v49; // [rsp+54h] [rbp-2Ch]
double v50; // 0:xmm0_8.8
v1 = a1;
if ( (unsigned int)sub_100720070(a1->m_groupIDObjects) )
{
v2 = 0;
do
{
v3 = sub_1007200C0(a1->m_groupIDObjects, v2);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v3 + 504LL))(v3);
++v2;
}
while ( v2 < (unsigned int)sub_100720070(a1->m_groupIDObjects) );
}
sub_100720270(a1->m_groupIDObjects);
cocos2d::CCDictionary::removeAllObjects(a1->m_parentGroups);
v46 = cocos2d::CCDictionary::create();
m_targetObject = a1->m_targetObject;
v45 = v1;
if ( m_targetObject )
{
v49 = 58.0;
v48 = 5;
v5 = 0;
if ( m_targetObject->m_groupCount > 0 )
{
do
{
v6 = v5;
GroupID = GameObject::getGroupID(m_targetObject, v5);
v8 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(v46, v8, GroupID);
m_targetObject = v1->m_targetObject;
if ( m_targetObject->m_hasGroupParentsString )
{
v9 = GameManager::sharedState();
GroupParent = GJBaseGameLayer::getGroupParent(v9->m_levelEditorLayer, GroupID);
m_targetObject = v1->m_targetObject;
if ( m_targetObject == GroupParent )
{
cocos2d::CCDictionary::setObject(v1->m_parentGroups, v8, GroupID);
m_targetObject = v1->m_targetObject;
}
}
++v5;
}
while ( v6 + 1 < m_targetObject->m_groupCount );
}
goto LABEL_25;
}
v11 = sub_100720070(v1->m_targetObjects);
v49 = 58.0;
v48 = 5;
if ( v11 )
{
LODWORD(v47) = 0;
v12 = 0;
while ( 1 )
{
m_targetObjects = v1->m_targetObjects;
v43 = v12;
v14 = sub_1007200C0(m_targetObjects, v12);
if ( *(__int16 *)(v14 + 1168) > 0 )
break;
LABEL_13:
v12 = v43 + 1;
v1 = v45;
if ( v43 + 1 >= (unsigned int)sub_100720070(v45->m_targetObjects) )
{
if ( (int)v47 >= 11 )
{
v49 = 35.0;
v21 = 1;
v48 = 10;
goto LABEL_26;
}
goto LABEL_25;
}
}
v15 = (GameObject *)v14;
v16 = 0;
v44 = (GameObject *)v14;
while ( 1 )
{
v18 = GameObject::getGroupID(v15, v16);
v19 = (cocos2d::CCNode *)cocos2d::CCDictionary::objectForKey(v46, v18);
if ( cocos2d::CCDictionary::objectForKey(v46, v18) )
{
v15 = v44;
if ( v44->m_hasGroupParentsString )
goto LABEL_21;
}
else
{
v19 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, _QWORD))v19->setTag)(v19, 0);
cocos2d::CCDictionary::setObject(v46, v19, v18);
LODWORD(v47) = (_DWORD)v47 + 1;
v15 = v44;
if ( v44->m_hasGroupParentsString )
{
LABEL_21:
v20 = GameManager::sharedState();
if ( v15 == GJBaseGameLayer::getGroupParent(v20->m_levelEditorLayer, v18) )
cocos2d::CCDictionary::setObject(v45->m_parentGroups, v19, v18);
}
}
v17 = ((__int64 (__fastcall *)(cocos2d::CCNode *))v19->getTag)(v19);
((void (__fastcall *)(cocos2d::CCNode *, _QWORD))v19->setTag)(v19, (unsigned int)(v17 + 1));
if ( ++v16 >= v15->m_groupCount )
goto LABEL_13;
}
}
LABEL_25:
v21 = 0;
LABEL_26:
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v42);
m_buttonMenu = (const cocos2d::CCPoint *)v1->m_buttonMenu;
if ( v21 )
v23 = -4.5;
else
v23 = -2.0;
sub_10028CBE0((float *)&v41, (float)(v23 * v49) + (float)(v42[0] * 0.5), (float)(0.5 * v42[1]) + -1.0);
*(cocos2d::CCPoint *)&v50 = cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)&v40, m_buttonMenu);
v24 = cocos2d::CCDictionary::allKeys(v46);
qsort(v24->data->arr, v24->data->num, 8u, (int (__cdecl *)(const void *, const void *))sub_1003121D0);
if ( (unsigned int)sub_100720070(v24) )
{
v25 = 30;
if ( v21 )
v25 = 15;
LODWORD(v44) = v25;
v26 = 0;
v47 = v24;
v27 = v45;
do
{
v28 = *(int *)(sub_1007200C0(v24, v26) + 56);
v29 = cocos2d::CCDictionary::objectForKey(v46, v28);
v30 = "GJ_button_04.png";
if ( !v27->m_targetObject )
{
v31 = ((__int64 (__fastcall *)(cocos2d::CCObject *, double))v29->getTag)(v29, v50);
v32 = v31 < (unsigned int)sub_100720070(v27->m_targetObjects);
v30 = "GJ_button_04.png";
if ( v32 )
v30 = "GJ_button_05.png";
}
if ( cocos2d::CCDictionary::objectForKey(v27->m_parentGroups, v28) )
v30 = "GJ_button_03.png";
v33 = (cocos2d::CCString *)sub_1007AB580("%i", v38);
CString = cocos2d::CCString::getCString(v33);
v35 = ButtonSprite::create_1(CString, (int)v44, 0, 0.5, 1, "goldFont.fnt", v30, 20.0);
v36 = CCMenuItemSpriteExtra::create(
v35,
nullptr,
v27,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetGroupIDLayer::onRemoveFromGroup);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v36->setTag)(v36, (unsigned int)v28);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v27->m_buttonMenu->addChild)(
v27->m_buttonMenu,
v36);
HIDWORD(v50) = 0;
*(float *)&v50 = (float)(int)(v26 % v48) * v49;
sub_10028CBE0((float *)&v39, *(float *)&v50, (float)(int)(-30 * (v26 / v48)));
sub_10028CCE0(&v41, &v40, &v39);
((void (__fastcall *)(CCMenuItemSpriteExtra *, double *))v36->setPosition)(v36, &v41);
sub_10071FCD0(v27->m_groupIDObjects, v36);
v24 = v47;
v37 = sub_100720070(v47);
if ( v26 > 0x12 )
break;
++v26;
}
while ( v26 < v37 );
}
}