//
// SetGroupIDLayer::updateGroupIDButtons from 0x509720 to 0x509aa2 (898 bytes)
//
// 6 xrefs:
// > SetGroupIDLayer::onAddGroupParent @ 0x509b22
// > SetGroupIDLayer::addGroupID @ 0x509c18
// > SetGroupIDLayer::removeGroupID @ 0x509c98
// > SetGroupIDLayer::callRemoveFromGroup @ 0x509cda
// > SetGroupIDLayer::onPaste @ 0x50a15a
// > SetGroupIDLayer::init @ 0x50b0da
//
// 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 v2; // r8
bool v3; // cf
cocos2d::CCArray *m_groupIDObjects; // r0
unsigned int v5; // r1
int v6; // r0
cocos2d::CCDictionary *v7; // r0
GameObject *m_targetObject; // r5
cocos2d::CCDictionary *v9; // r6
int v10; // r11
int i; // r5
GameObject *v12; // r0
intptr_t GroupID; // r7
cocos2d::CCNode *v14; // r8
GameManager *v15; // r0
float v16; // s17
int v17; // r10
float v18; // s16
float v19; // s18
intptr_t v20; // r8
cocos2d::CCNode *v21; // r7
int v22; // r9
void (__fastcall *setTag)(cocos2d::CCObject *__hidden, int); // r8
int v24; // r0
GameObject *v25; // r10
GameManager *v26; // r0
cocos2d::CCDirector *v27; // r0
cocos2d::CCMenu *m_buttonMenu; // r7
unsigned int v29; // r5
cocos2d::CCArray *v30; // r9
const char *v31; // r8
cocos2d::CCObject *v32; // r0
unsigned int v33; // r7
_BOOL4 v34; // r7
const char *v35; // r2
const char *v36; // r3
char *v37; // r7
cocos2d::CCString *v38; // r0
ButtonSprite *CString; // r0
ButtonSprite *v40; // r0
CCMenuItemSpriteExtra *v41; // r7
float v42; // r0
float v43; // s15
signed int v44; // r0
int v45; // [sp+0h] [bp-64h]
void *v46; // [sp+10h] [bp-54h]
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [sp+2Ch] [bp-38h]
cocos2d::CCSize v48; // [sp+34h] [bp-30h] BYREF
cocos2d::CCPoint v49; // [sp+3Ch] [bp-28h] BYREF
cocos2d::CCPoint v50; // [sp+44h] [bp-20h] BYREF
cocos2d::CCPoint v51; // [sp+4Ch] [bp-18h] BYREF
cocos2d::CCPoint v52; // [sp+54h] [bp-10h] BYREF
v2 = 0;
v46 = &_stack_chk_guard;
while ( 1 )
{
v3 = v2 >= cocos2d::CCArray::count(a1->m_groupIDObjects);
m_groupIDObjects = a1->m_groupIDObjects;
if ( v3 )
break;
v5 = v2++;
v6 = cocos2d::CCArray::objectAtIndex(m_groupIDObjects, v5);
(*(void (__fastcall **)(int))(*(_DWORD *)v6 + 252))(v6);
}
cocos2d::CCArray::removeAllObjects(m_groupIDObjects);
cocos2d::CCDictionary::removeAllObjects(a1->m_parentGroups);
v7 = cocos2d::CCDictionary::create();
m_targetObject = a1->m_targetObject;
v9 = v7;
if ( m_targetObject )
{
for ( i = 0; ; ++i )
{
v12 = a1->m_targetObject;
if ( i >= v12->m_groupCount )
break;
GroupID = GameObject::getGroupID(v12, i);
v14 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(v9, v14, GroupID);
if ( a1->m_targetObject->m_hasGroupParentsString )
{
v15 = GameManager::sharedState();
if ( a1->m_targetObject == GJBaseGameLayer::getGroupParent(v15->m_levelEditorLayer, GroupID) )
cocos2d::CCDictionary::setObject(a1->m_parentGroups, v14, GroupID);
}
}
v16 = 58.0;
v17 = 5;
v18 = 2.0;
v19 = 30.0;
}
else
{
v10 = 0;
while ( (unsigned int)m_targetObject < cocos2d::CCArray::count(a1->m_targetObjects) )
{
v22 = 0;
v25 = (GameObject *)cocos2d::CCArray::objectAtIndex(a1->m_targetObjects, (unsigned int)m_targetObject);
while ( v22 < v25->m_groupCount )
{
v20 = GameObject::getGroupID(v25, v22);
v21 = (cocos2d::CCNode *)cocos2d::CCDictionary::objectForKey(v9, v20);
if ( !cocos2d::CCDictionary::objectForKey(v9, v20) )
{
++v10;
v21 = cocos2d::CCNode::create();
v21->setTag(v21, 0);
cocos2d::CCDictionary::setObject(v9, v21, v20);
}
if ( v25->m_hasGroupParentsString )
{
v26 = GameManager::sharedState();
if ( v25 == GJBaseGameLayer::getGroupParent(v26->m_levelEditorLayer, v20) )
cocos2d::CCDictionary::setObject(a1->m_parentGroups, v21, v20);
}
++v22;
setTag = v21->setTag;
v24 = v21->getTag(v21);
setTag(v21, v24 + 1);
}
m_targetObject = (GameObject *)((char *)m_targetObject + 1);
}
if ( v10 <= 10 )
v17 = 5;
else
v17 = 10;
v16 = 58.0;
v18 = 4.5;
if ( v10 > 10 )
v16 = 35.0;
v19 = 30.0;
if ( v10 > 10 )
v19 = 15.0;
else
v18 = 2.0;
}
v27 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v48, v27);
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v52, (float)(v48.width * 0.5) - (float)(v18 * v16), (float)(v48.height * 0.5) - 1.0);
cocos2d::CCNode::convertToNodeSpace(&v49, m_buttonMenu, &v52);
v29 = 0;
v30 = cocos2d::CCDictionary::allKeys(v9);
qsort(v30->data->arr, v30->data->num, 4u, groupIDCompare);
while ( v29 < cocos2d::CCArray::count(v30) && v29 != 20 )
{
v31 = *(const char **)(cocos2d::CCArray::objectAtIndex(v30, v29) + 52);
v32 = cocos2d::CCDictionary::objectForKey(v9, (intptr_t)v31);
if ( a1->m_targetObject )
{
v34 = 1;
}
else
{
v33 = v32->getTag(v32);
v34 = v33 >= cocos2d::CCArray::count(a1->m_targetObjects);
}
if ( cocos2d::CCDictionary::objectForKey(a1->m_parentGroups, (intptr_t)v31) )
{
v37 = "GJ_button_03.png";
}
else
{
v36 = "GJ_button_04.png";
v35 = "GJ_button_05.png";
if ( v34 )
v37 = "GJ_button_04.png";
else
v37 = "GJ_button_05.png";
}
v38 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v31, v35, v36, v45);
CString = (ButtonSprite *)cocos2d::CCString::getCString(v38);
v40 = ButtonSprite::create(
CString,
(const char *)(int)v19,
0,
0.5,
1,
"goldFont.fnt",
v37,
(const char *)0x41A00000,
*(float *)&v46);
v45 = 0;
LODWORD(v52.x) = SetGroupIDLayer::onRemoveFromGroup;
v52.y = 0.0;
v41 = CCMenuItemSpriteExtra::create(
v40,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetGroupIDLayer::onRemoveFromGroup, (unsigned int)a1));
v41->setTag(v41, (int)v31);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v41);
v42 = floorf((float)((int)v29 / v17));
setPosition = v41->setPosition;
v43 = v42;
v44 = v29++;
cocos2d::CCPoint::CCPoint(&v50, v16 * (float)(v44 % v17), (float)(-30 * (int)v43));
cocos2d::CCPoint::operator+(&v51, &v49, &v50);
setPosition(v41, &v51);
cocos2d::CCArray::addObject(a1->m_groupIDObjects, v41);
}
}