//
// SetGroupIDLayer::updateGroupIDButtons from 0x976390 to 0x976848 (1208 bytes)
//
// 9 xrefs:
// > SetGroupIDLayer::onAddGroupParent @ 0x976890
// > SetGroupIDLayer::onAddGroupParent @ 0x9768d8
// > SetGroupIDLayer::addGroupID @ 0x976a04
// > SetGroupIDLayer::removeGroupID @ 0x976b04
// > SetGroupIDLayer::removeGroupID @ 0x976b74
// > SetGroupIDLayer::callRemoveFromGroup @ 0x976bc0
// > SetGroupIDLayer::onPaste @ 0x9775b0
// > SetGroupIDLayer::init @ 0x978eb0
// > ??> @ 0x7e438
//
// 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 SetGroupIDLayer::updateGroupIDButtons(SetGroupIDLayer *a1)
{
unsigned int i; // w20
unsigned int v3; // w1
__int64 v4; // x0
bool v5; // cf
cocos2d::CCArray *m_groupIDObjects; // x0
cocos2d::CCDictionary *v7; // x21
GameObject *m_targetObject; // x2
int v9; // w20
intptr_t GroupID; // x23
cocos2d::CCNode *v11; // x24
GameManager *v12; // x0
GameObject *GroupParent; // x0
float v14; // s8
int v15; // w25
float v16; // s10
float v17; // s9
cocos2d::CCDirector *v18; // x0
cocos2d::CCMenu *m_buttonMenu; // x22
signed int v20; // w20
cocos2d::CCArray *v21; // x23
_BOOL4 v22; // w27
int v23; // w22
cocos2d::CCObject *v24; // x0
const char *v25; // x28
cocos2d::CCString *v26; // x0
ButtonSprite *CString; // x0
const char *v28; // x6
cocos2d::CCNode *v29; // x0
CCMenuItemSpriteExtra *v30; // x27
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
float v32; // s1
int v33; // w2
unsigned int v34; // w27
unsigned int v35; // w25
int j; // w26
GameObject *v37; // x23
int v38; // w22
void (__fastcall *setTag)(cocos2d::CCObject *__hidden, int); // x24
int v40; // w0
intptr_t v41; // x24
cocos2d::CCNode *v42; // x20
GameManager *v43; // x0
float v44; // [xsp+A8h] [xbp+A8h]
float v45; // [xsp+ACh] [xbp+ACh]
_BYTE v46[8]; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCPoint v47; // [xsp+B8h] [xbp+B8h] BYREF
cocos2d::CCPoint v48; // [xsp+C0h] [xbp+C0h] BYREF
cocos2d::SEL_MenuHandler v49; // 0:x2.16
for ( i = 0; ; ++i )
{
v5 = i >= (unsigned int)cocos2d::CCArray::count(a1->m_groupIDObjects);
m_groupIDObjects = a1->m_groupIDObjects;
if ( v5 )
break;
v3 = i;
v4 = cocos2d::CCArray::objectAtIndex(m_groupIDObjects, v3);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v4 + 504LL))(v4);
}
cocos2d::CCArray::removeAllObjects(m_groupIDObjects);
cocos2d::CCDictionary::removeAllObjects(a1->m_parentGroups);
v7 = cocos2d::CCDictionary::create();
m_targetObject = a1->m_targetObject;
if ( m_targetObject )
{
if ( m_targetObject->m_groupCount > 0 )
{
v9 = 0;
do
{
while ( 1 )
{
GroupID = GameObject::getGroupID(m_targetObject, v9);
v11 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(v7, v11, GroupID);
m_targetObject = a1->m_targetObject;
if ( m_targetObject->m_hasGroupParentsString )
{
v12 = GameManager::sharedState();
GroupParent = GJBaseGameLayer::getGroupParent(v12->m_levelEditorLayer, GroupID);
m_targetObject = a1->m_targetObject;
if ( m_targetObject == GroupParent )
break;
}
if ( m_targetObject->m_groupCount <= ++v9 )
goto LABEL_11;
}
++v9;
cocos2d::CCDictionary::setObject(a1->m_parentGroups, v11, GroupID);
m_targetObject = a1->m_targetObject;
}
while ( m_targetObject->m_groupCount > v9 );
}
}
else
{
v35 = 0;
for ( j = 0; v35 < (unsigned int)cocos2d::CCArray::count(a1->m_targetObjects); ++v35 )
{
v37 = (GameObject *)cocos2d::CCArray::objectAtIndex(a1->m_targetObjects, v35);
if ( v37->m_groupCount > 0 )
{
v38 = 0;
do
{
v41 = GameObject::getGroupID(v37, v38);
v42 = (cocos2d::CCNode *)cocos2d::CCDictionary::objectForKey(v7, v41);
if ( !cocos2d::CCDictionary::objectForKey(v7, v41) )
{
v42 = cocos2d::CCNode::create();
++j;
v42->setTag(v42, 0);
cocos2d::CCDictionary::setObject(v7, v42, v41);
}
if ( v37->m_hasGroupParentsString )
{
v43 = GameManager::sharedState();
if ( v37 == GJBaseGameLayer::getGroupParent(v43->m_levelEditorLayer, v41) )
cocos2d::CCDictionary::setObject(a1->m_parentGroups, v42, v41);
}
++v38;
setTag = v42->setTag;
v40 = v42->getTag(v42);
setTag(v42, v40 + 1);
}
while ( v37->m_groupCount > v38 );
}
}
if ( j > 10 )
{
v14 = 35.0;
v15 = 10;
v16 = 4.5;
v17 = 15.0;
goto LABEL_12;
}
}
LABEL_11:
v14 = 58.0;
v15 = 5;
v16 = 2.0;
v17 = 30.0;
LABEL_12:
v18 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v18);
m_buttonMenu = a1->m_buttonMenu;
v20 = 0;
cocos2d::CCPoint::CCPoint(&v48, -(float)((float)(v16 * v14) - (float)(v44 * 0.5)), (float)(v45 * 0.5) + -1.0);
cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v48);
v21 = cocos2d::CCDictionary::allKeys(v7);
qsort(v21->data->arr, v21->data->num, 8u, (int (*)(const void *, const void *))groupIDCompare);
while ( v20 < (unsigned int)cocos2d::CCArray::count(v21) && v20 <= 19 )
{
v22 = 1;
v23 = *(_DWORD *)(cocos2d::CCArray::objectAtIndex(v21, v20) + 56);
v24 = cocos2d::CCDictionary::objectForKey(v7, v23);
if ( !a1->m_targetObject )
{
v34 = v24->getTag(v24);
v22 = v34 >= (unsigned int)cocos2d::CCArray::count(a1->m_targetObjects);
}
v25 = "GJ_button_03.png";
if ( !cocos2d::CCDictionary::objectForKey(a1->m_parentGroups, v23) )
{
v25 = "GJ_button_04.png";
if ( !v22 )
v25 = "GJ_button_05.png";
}
v26 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)v23);
CString = (ButtonSprite *)cocos2d::CCString::getCString(v26);
v29 = (cocos2d::CCNode *)ButtonSprite::create(
CString,
(const char *)(unsigned int)(int)v17,
0,
1,
0.5,
"goldFont.fnt",
v25,
v28,
20.0);
v49.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v49.adj = (size_t)SetGroupIDLayer::onRemoveFromGroup;
v30 = CCMenuItemSpriteExtra::create(v29, nullptr, v49);
v30->setTag(v30, v23);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v30);
setPosition = v30->setPosition;
v32 = (float)(v20 / v15);
v33 = v20 % v15;
++v20;
cocos2d::CCPoint::CCPoint(&v47, v14 * (float)v33, (float)(int)(-30 * vcvtms_s32_f32(v32)));
cocos2d::CCPoint::operator+(&v48, v46, &v47);
setPosition(v30, &v48);
cocos2d::CCArray::addObject(a1->m_groupIDObjects, v30);
}
}