//
// EditorUI::alignObjects from 0x10004da20 to 0x10004df18 (1272 bytes)
//
// 2 xrefs:
// > EditorPauseLayer::onAlignX @ 0x100293f2a
// > EditorPauseLayer::onAlignY @ 0x100293f5d
//
// 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 EditorUI::alignObjects(EditorUI *a1, cocos2d::CCArray *a2, bool a3)
{
unsigned int v3; // eax
__int64 v4; // rax
cocos2d::CCDictionary *v5; // rbx
unsigned int v6; // r15d
__int64 v7; // rax
__int64 v8; // r14
cocos2d::CCNode *v9; // rax
cocos2d::CCArray *v10; // rbx
EditorUI *v11; // r12
unsigned int v12; // r15d
unsigned int v13; // r14d
cocos2d::CCArray *StickyGroup; // rax
GameObject *v15; // r12
double v16; // xmm0_8
GameObject *v17; // rsi
cocos2d::CCArray *v18; // r13
int (__cdecl *v19)(const void *, const void *); // rcx
cocos2d::ccArray *data; // rax
__int64 num; // r15
cocos2d::CCObject **arr; // r14
float *v23; // rsi
double v24; // xmm0_8
int v25; // eax
unsigned int v26; // r12d
GameObject *v27; // r15
float v28; // xmm0_4
float v29; // xmm1_4
cocos2d::CCPoint v30; // xmm0_8
EditorUI *v31; // rbx
cocos2d::CCArray *v32; // rax
cocos2d::CCArray *v33; // r15
unsigned int v34; // r14d
GameObject *v35; // r13
cocos2d::CCPoint v36; // xmm0_8
unsigned __int64 v37; // r15
_QWORD *i; // r14
char v39[8]; // [rsp+Ch] [rbp-84h] BYREF
char v40[8]; // [rsp+14h] [rbp-7Ch] BYREF
float v41[2]; // [rsp+1Ch] [rbp-74h] BYREF
char v42[8]; // [rsp+24h] [rbp-6Ch] BYREF
_DWORD v43[2]; // [rsp+2Ch] [rbp-64h] BYREF
unsigned int v44; // [rsp+34h] [rbp-5Ch]
cocos2d::CCArray *v45; // [rsp+38h] [rbp-58h]
float v46; // [rsp+40h] [rbp-50h] BYREF
float v47; // [rsp+44h] [rbp-4Ch]
EditorUI *v48; // [rsp+48h] [rbp-48h]
_BOOL4 v49; // [rsp+54h] [rbp-3Ch]
float v50; // [rsp+58h] [rbp-38h] BYREF
float v51; // [rsp+5Ch] [rbp-34h]
float v52; // [rsp+60h] [rbp-30h] BYREF
float v53; // [rsp+64h] [rbp-2Ch]
v49 = a3;
v48 = a1;
if ( !a2 || (unsigned int)sub_100720070(a2) < 3 )
return;
v3 = sub_100720070(a2);
v4 = sub_10071FD00(v3);
sub_100720050(v4, a2);
v5 = cocos2d::CCDictionary::create();
if ( (unsigned int)sub_100720070(a2) )
{
v6 = 0;
do
{
v7 = sub_1007200C0(a2, v6);
if ( *(int *)(v7 + 872) <= 0 )
{
++v6;
}
else
{
v8 = v7;
sub_100720230(a2, v6, 1);
if ( !cocos2d::CCDictionary::objectForKey(v5, *(int *)(v8 + 872)) )
{
v9 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(v5, v9, *(int *)(v8 + 872));
}
}
}
while ( v6 < (unsigned int)sub_100720070(a2) );
}
v45 = a2;
v10 = cocos2d::CCDictionary::allKeys(v5);
v11 = v48;
if ( (unsigned int)sub_100720070(v10) )
{
v12 = 0;
do
{
v13 = *(_DWORD *)(sub_1007200C0(v10, v12) + 56);
StickyGroup = GJBaseGameLayer::getStickyGroup(v11->m_editorLayer, v13);
if ( StickyGroup )
{
EditorUI::getGroupCenter((EditorUI *)&v52, (cocos2d::CCArray *)v13, (bool)StickyGroup);
v15 = GameObject::createWithFrame("checkpoint_01_001.png");
v15->m_objectID = 44;
v15->m_linkedGroup = v13;
v16 = sub_10028CC60(&v50);
((void (__fastcall *)(GameObject *, float *, double))v15->setStartPos)(v15, &v50, v16);
v17 = v15;
v11 = v48;
sub_10071FCD0(v45, v17);
}
++v12;
}
while ( v12 < (unsigned int)sub_100720070(v10) );
}
v18 = v45;
v19 = (int (__cdecl *)(const void *, const void *))sub_100008B30;
if ( v49 )
v19 = (int (__cdecl *)(const void *, const void *))sub_100008B80;
qsort(v45->data->arr, v45->data->num, 8u, v19);
sub_10028CC30(&v52);
sub_10028CC30(&v50);
data = v45->data;
num = data->num;
if ( data->num )
{
arr = data->arr;
if ( *arr )
{
((void (__fastcall *)(cocos2d::CCObject *))(*arr)->__vftable[2].acceptVisitor)(*arr);
sub_10028CC60(&v46);
sub_10028CC90();
v23 = &v46;
v24 = sub_10028CC90();
if ( (_DWORD)num != 1 )
{
v37 = (unsigned __int64)&arr[num - 1];
for ( i = arr + 1; (unsigned __int64)i <= v37; ++i )
{
if ( !*i )
break;
v23 = (float *)(*(__int64 (__fastcall **)(_QWORD, float *, double))(*(_QWORD *)*i + 192LL))(*i, v23, v24);
sub_10028CC60(&v46);
if ( v52 > v46 )
{
v52 = v46;
if ( v46 <= v50 )
{
LABEL_41:
*(_QWORD *)&v24 = LODWORD(v47);
if ( v53 <= v47 )
goto LABEL_42;
goto LABEL_46;
}
}
else if ( v46 <= v50 )
{
goto LABEL_41;
}
v50 = v46;
*(_QWORD *)&v24 = LODWORD(v47);
if ( v53 <= v47 )
{
LABEL_42:
if ( *(float *)&v24 > v51 )
goto LABEL_47;
continue;
}
LABEL_46:
v53 = *(float *)&v24;
if ( *(float *)&v24 > v51 )
LABEL_47:
v51 = *(float *)&v24;
}
}
}
}
if ( v52 != v50 || v53 != v51 )
{
EditorUI::createUndoObject(v11, Transform, 0);
sub_10028CD00(&v46, &v50, &v52);
v25 = sub_100720070(v45);
sub_10028CD40(v41, &v46, 1.0 / (float)(v25 - 1));
if ( (unsigned int)sub_100720070(v18) - 3 <= 0xFFFFFFFD )
{
v26 = 1;
do
{
v27 = (GameObject *)sub_1007200C0(v18, v26);
((void (__fastcall *)(GameObject *))v27->getPosition)(v27);
sub_10028CC60(v43);
sub_10028CC30(v39);
if ( v49 )
{
v28 = *(float *)v43;
v29 = (float)((float)(int)v26 * v41[1]) + v53;
}
else
{
v28 = (float)((float)(int)v26 * v41[0]) + v52;
v29 = *(float *)&v43[1];
}
sub_10028CBE0(v42, v28, v29);
*(double *)&v30 = sub_10028CC90();
v44 = v26;
sub_10028CD00(v42, v39, v43);
if ( v27->m_objectID == 44 )
{
v31 = v48;
v32 = GJBaseGameLayer::getStickyGroup(v48->m_editorLayer, v27->m_linkedGroup);
if ( v32 )
{
v33 = v32;
if ( (unsigned int)sub_100720070(v32) )
{
v34 = 0;
do
{
v35 = (GameObject *)sub_1007200C0(v33, v34);
*(double *)&v36 = sub_10028CC60(v40);
EditorUI::moveObject(v31, v35, v36);
++v34;
}
while ( v34 < (unsigned int)sub_100720070(v33) );
}
}
}
else
{
sub_10028CD00(v40, v39, v43);
EditorUI::moveObject(v48, v27, v30);
}
v26 = v44 + 1;
v18 = v45;
}
while ( v26 < (unsigned int)sub_100720070(v45) - 1 );
}
}
}