//
// EditorUI::alignObjects from 0x6b5c9c to 0x6b619c (1280 bytes)
//
// 3 xrefs:
// > EditorPauseLayer::onAlignX @ 0x78ac18
// > EditorPauseLayer::onAlignY @ 0x78ac4c
// > ??> @ 0x8cdc0
//
// 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 EditorUI::alignObjects(EditorUI *a1, cocos2d::CCArray *a2, bool a3)
{
unsigned int v5; // w19
cocos2d::CCArray *v6; // x0
unsigned int v7; // w1
cocos2d::CCArray *v8; // x0
cocos2d::CCDictionary *v9; // x23
__int64 v10; // x21
cocos2d::CCNode *v11; // x0
unsigned int v12; // w19
cocos2d::CCArray *v13; // x23
int v14; // w21
cocos2d::CCArray *StickyGroup; // x0
GameObject *v16; // x28
GameObject_vtbl *v17; // x2
void (__fastcall *setStartPos)(GameObject *__hidden, cocos2d::CCPoint); // x21
cocos2d::ccArray *data; // x1
cocos2d::ccArray *v20; // x1
cocos2d::CCObject **arr; // x19
cocos2d::CCObject **v22; // x23
cocos2d::CCObject *v23; // x0
int v24; // w24
const cocos2d::CCPoint *v25; // x0
float v26; // s0
float v27; // s1
signed int v28; // w24
int v29; // w0
GameObject *v30; // x23
const cocos2d::CCPoint *v31; // x0
float v32; // s0
float v33; // s1
float v34; // s0
float v35; // s1
unsigned int v36; // w19
cocos2d::CCArray *v37; // x23
unsigned int v38; // w1
GameObject *v39; // x27
float v40; // s0
float v41; // s1
_BOOL4 v42; // [xsp+74h] [xbp+74h]
cocos2d::CCPoint v43; // [xsp+88h] [xbp+88h] BYREF
cocos2d::CCPoint v44; // [xsp+90h] [xbp+90h] BYREF
__int64 v45; // [xsp+98h] [xbp+98h] BYREF
float v46; // [xsp+A0h] [xbp+A0h]
float v47; // [xsp+A4h] [xbp+A4h]
cocos2d::CCPoint v48; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCPoint v49; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCPoint v50; // [xsp+B8h] [xbp+B8h] BYREF
cocos2d::CCPoint v51; // [xsp+C0h] [xbp+C0h] BYREF
cocos2d::CCPoint v52; // 0:s0.4,4:s1.4
cocos2d::CCPoint v53; // 0:s0.4,4:s1.4
v42 = a3;
if ( a2 && (unsigned int)cocos2d::CCArray::count(a2) > 2 )
{
v5 = 0;
v6 = (cocos2d::CCArray *)cocos2d::CCArray::count(a2);
v8 = (cocos2d::CCArray *)cocos2d::CCArray::createWithCapacity(v6, v7);
cocos2d::CCArray::addObjectsFromArray(v8, a2);
v9 = cocos2d::CCDictionary::create();
LABEL_4:
while ( v5 < (unsigned int)cocos2d::CCArray::count(a2) )
{
while ( 1 )
{
v10 = cocos2d::CCArray::objectAtIndex(a2, v5);
if ( *(int *)(v10 + 856) <= 0 )
break;
cocos2d::CCArray::removeObjectAtIndex(a2, v5, 1);
if ( cocos2d::CCDictionary::objectForKey(v9, *(int *)(v10 + 856)) )
goto LABEL_4;
v11 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(v9, v11, *(int *)(v10 + 856));
if ( v5 >= (unsigned int)cocos2d::CCArray::count(a2) )
goto LABEL_8;
}
++v5;
}
LABEL_8:
v12 = 0;
v13 = cocos2d::CCDictionary::allKeys(v9);
if ( (unsigned int)cocos2d::CCArray::count(v13) )
{
do
{
v14 = *(_DWORD *)(cocos2d::CCArray::objectAtIndex(v13, v12) + 56);
StickyGroup = GJBaseGameLayer::getStickyGroup(a1->m_editorLayer, v14);
if ( StickyGroup )
{
EditorUI::getGroupCenter(a1, StickyGroup, 1);
v16 = GameObject::createWithFrame("checkpoint_01_001.png");
v17 = v16->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v16->m_linkedGroup = v14;
v16->m_objectID = 44;
setStartPos = v17->setStartPos;
cocos2d::CCPoint::CCPoint(&v51, &v50);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))setStartPos)(v16, &v51);
cocos2d::CCArray::addObject(a2, v16);
}
++v12;
}
while ( v12 < (unsigned int)cocos2d::CCArray::count(v13) );
}
data = a2->data;
if ( v42 )
qsort(data->arr, data->num, 8u, (int (*)(const void *, const void *))alignYSort);
else
qsort(data->arr, data->num, 8u, (int (*)(const void *, const void *))alignXSort);
cocos2d::CCPoint::CCPoint(&v43);
cocos2d::CCPoint::CCPoint(&v44);
v20 = a2->data;
if ( v20->num )
{
arr = v20->arr;
v22 = &arr[v20->num - 1];
if ( arr <= v22 )
{
v23 = *arr;
if ( *arr )
{
v24 = 1;
do
{
v25 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(cocos2d::CCObject *))v23->__vftable[2].acceptVisitor)(v23);
cocos2d::CCPoint::CCPoint(&v51, v25);
if ( v24 )
{
cocos2d::CCPoint::operator=(&v43, v26, v27);
cocos2d::CCPoint::operator=(&v44, v40, v41);
}
else
{
if ( v51.x < v43.x )
v43.x = v51.x;
if ( v51.x > v44.x )
v44.x = v51.x;
if ( v51.y < v43.y )
v43.y = v51.y;
if ( v51.y > v44.y )
v44.y = v51.y;
}
if ( v22 < ++arr )
break;
v23 = *arr;
v24 = 0;
}
while ( *arr );
}
}
}
if ( v43.x != v44.x || v43.y != v44.y )
{
EditorUI::createUndoObject(a1, Transform, 0);
v28 = 1;
cocos2d::CCPoint::operator-(&v45, &v44, &v43);
v29 = cocos2d::CCArray::count(a2);
cocos2d::CCPoint::operator*(&v45, 1.0 / (float)(unsigned int)(v29 - 1));
if ( (unsigned int)cocos2d::CCArray::count(a2) - 1 > 1 )
{
do
{
v30 = (GameObject *)cocos2d::CCArray::objectAtIndex(a2, v28);
v31 = v30->getPosition(v30);
cocos2d::CCPoint::CCPoint(&v48, v31);
cocos2d::CCPoint::CCPoint(&v49);
if ( v42 )
{
cocos2d::CCPoint::CCPoint(&v51, v48.x, v43.y + (float)((float)v28 * v47));
cocos2d::CCPoint::operator=(&v49, v32, v33);
cocos2d::CCPoint::operator-(&v50, &v49, &v48);
if ( v30->m_objectID != 44 )
goto LABEL_34;
}
else
{
cocos2d::CCPoint::CCPoint(&v51, v43.x + (float)((float)v28 * v46), v48.y);
cocos2d::CCPoint::operator=(&v49, v34, v35);
cocos2d::CCPoint::operator-(&v50, &v49, &v48);
if ( v30->m_objectID != 44 )
{
LABEL_34:
cocos2d::CCPoint::operator-(&v51, &v49, &v48);
EditorUI::moveObject(a1, v30, v52);
goto LABEL_35;
}
}
v36 = 0;
v37 = GJBaseGameLayer::getStickyGroup(a1->m_editorLayer, v30->m_linkedGroup);
if ( v37 )
{
while ( v36 < (unsigned int)cocos2d::CCArray::count(v37) )
{
v38 = v36++;
v39 = (GameObject *)cocos2d::CCArray::objectAtIndex(v37, v38);
cocos2d::CCPoint::CCPoint(&v51, &v50);
EditorUI::moveObject(a1, v39, v53);
}
++v28;
continue;
}
LABEL_35:
++v28;
}
while ( v28 < (unsigned int)cocos2d::CCArray::count(a2) - 1 );
}
}
}
}