//
// EditorUI::alignObjects from 0x1003f7930 to 0x1003f7d64 (1076 bytes)
//
// 2 xrefs:
// > EditorPauseLayer::onAlignX @ 0x10039e05c
// > EditorPauseLayer::onAlignY @ 0x10039e090
//
// 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)
{
_BOOL4 v3; // w19
__int64 v6; // x0
cocos2d::CCObject *v7; // x0
cocos2d::CCDictionary *v8; // x22
__int64 v9; // x23
__int64 v10; // x0
__int64 v11; // x24
cocos2d::CCNode *v12; // x0
cocos2d::CCArray *v13; // x22
unsigned int v14; // w23
int v15; // w25
cocos2d::CCArray *StickyGroup; // x0
GameObject *v17; // x26
float v18; // s0
int (__cdecl *v19)(const void *, const void *); // x3
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x22
unsigned __int64 v23; // x23
char v24; // w24
__int64 *v25; // x0
int v26; // w0
unsigned int v27; // w22
GameObject *v28; // x23
__int64 *v29; // x0
__n128 v30; // q0
__n128 v31; // q1
cocos2d::CCArray *v32; // x0
__int64 v33; // x23
unsigned int v34; // w24
GameObject *v35; // x25
float32x2_t v36; // [xsp+0h] [xbp-90h] BYREF
float32x2_t v37; // [xsp+8h] [xbp-88h] BYREF
float32x2_t v38; // [xsp+10h] [xbp-80h] BYREF
float32x2_t v39; // [xsp+18h] [xbp-78h] BYREF
float32x2_t v40; // [xsp+20h] [xbp-70h] BYREF
float32x2_t v41; // [xsp+28h] [xbp-68h] BYREF
float32x2_t v42; // [xsp+30h] [xbp-60h] BYREF
float32x2_t v43; // [xsp+38h] [xbp-58h] BYREF
cocos2d::CCPoint v44; // 0:s0.4,4:s1.4
cocos2d::CCPoint v45; // 0:s0.4,4:s1.4
if ( a2 )
{
v3 = a3;
if ( (unsigned int)sub_10024A36C((__int64)a2) >= 3 )
{
v6 = sub_10024A36C((__int64)a2);
v7 = sub_10024A300(v6);
sub_10024A360((__int64)v7, (__int64)a2);
v8 = cocos2d::CCDictionary::create();
if ( (unsigned int)sub_10024A36C((__int64)a2) )
{
v9 = 0;
do
{
v10 = sub_10024A388((__int64)a2, v9);
if ( *(int *)(v10 + 872) < 1 )
{
v9 = (unsigned int)(v9 + 1);
}
else
{
v11 = v10;
sub_10024A44C((__int64)a2, v9, 1);
if ( !cocos2d::CCDictionary::objectForKey(v8, *(int *)(v11 + 872)) )
{
v12 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(v8, v12, *(int *)(v11 + 872));
}
}
}
while ( (unsigned int)v9 < (unsigned int)sub_10024A36C((__int64)a2) );
}
v13 = cocos2d::CCDictionary::allKeys(v8);
if ( (unsigned int)sub_10024A36C((__int64)v13) )
{
v14 = 0;
do
{
v15 = *(_DWORD *)(sub_10024A388((__int64)v13, v14) + 56);
StickyGroup = GJBaseGameLayer::getStickyGroup(a1->m_editorLayer, v15);
if ( StickyGroup )
{
EditorUI::getGroupCenter((EditorUI *)StickyGroup, StickyGroup, 1);
v17 = GameObject::createWithFrame("checkpoint_01_001.png");
v17->m_objectID = 44;
v17->m_linkedGroup = v15;
v18 = sub_1000229B8((__int64 *)&v42, (__int64 *)&v43);
((void (__fastcall *)(GameObject *, float32x2_t *, float))v17->setStartPos)(v17, &v42, v18);
sub_10024A2D0((__int64)a2);
}
++v14;
}
while ( v14 < (unsigned int)sub_10024A36C((__int64)v13) );
}
if ( v3 )
v19 = (int (__cdecl *)(const void *, const void *))sub_1003C4ADC;
else
v19 = (int (__cdecl *)(const void *, const void *))sub_1003C4A78;
qsort(a2->data->arr, a2->data->num, 8u, v19);
sub_1000229B0(&v43);
sub_1000229B0(&v42);
data = a2->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v23 = (unsigned __int64)&arr[num - 1];
v24 = 1;
do
{
if ( !*arr )
break;
v25 = (__int64 *)((__int64 (__fastcall *)(cocos2d::CCObject *))(*arr)->__vftable[2].acceptVisitor)(*arr);
sub_1000229B8((__int64 *)&v41, v25);
if ( (v24 & 1) != 0 )
{
sub_1000229D0(&v43, (double *)&v41);
sub_1000229D0(&v42, (double *)&v41);
}
else
{
if ( v41.f32[0] < v43.f32[0] )
v43.i32[0] = v41.i32[0];
if ( v41.f32[0] > v42.f32[0] )
v42.i32[0] = v41.i32[0];
if ( v41.f32[1] < v43.f32[1] )
v43.i32[1] = v41.i32[1];
if ( v41.f32[1] > v42.f32[1] )
v42.i32[1] = v41.i32[1];
}
v24 = 0;
++arr;
}
while ( (unsigned __int64)arr <= v23 );
}
if ( v43.f32[0] != v42.f32[0] || v43.f32[1] != v42.f32[1] )
{
EditorUI::createUndoObject(a1, Transform, 0);
sub_1000229F0(&v42, &v43, &v41);
v26 = sub_10024A36C((__int64)a2);
sub_100022A14(&v41, &v40, 1.0 / (float)(unsigned int)(v26 - 1));
if ( (unsigned int)sub_10024A36C((__int64)a2) - 3 <= 0xFFFFFFFD )
{
v27 = 1;
do
{
v28 = (GameObject *)sub_10024A388((__int64)a2, v27);
v29 = (__int64 *)((__int64 (__fastcall *)(GameObject *))v28->getPosition)(v28);
sub_1000229B8((__int64 *)&v39, v29);
sub_1000229B0(&v38);
if ( v3 )
{
v30.n128_u32[0] = v39.i32[0];
v31.n128_f32[0] = v43.f32[1] + (float)((float)v27 * v40.f32[1]);
}
else
{
v30.n128_f32[0] = v43.f32[0] + (float)((float)v27 * v40.f32[0]);
v31.n128_u32[0] = v39.u32[1];
}
sub_100022980(v30, v31, &v37);
sub_1000229D0(&v38, (double *)&v37);
sub_1000229F0(&v38, &v39, &v37);
if ( v28->m_objectID == 44 )
{
v32 = GJBaseGameLayer::getStickyGroup(a1->m_editorLayer, v28->m_linkedGroup);
if ( v32 )
{
v33 = (__int64)v32;
if ( (unsigned int)sub_10024A36C((__int64)v32) )
{
v34 = 0;
do
{
v35 = (GameObject *)sub_10024A388(v33, v34);
v44.x = sub_1000229B8((__int64 *)&v36, (__int64 *)&v37);
EditorUI::moveObject(a1, v35, v44);
++v34;
}
while ( v34 < (unsigned int)sub_10024A36C(v33) );
}
}
}
else
{
v45.x = sub_1000229F0(&v38, &v39, &v36).f32[0];
EditorUI::moveObject(a1, v28, v45);
}
++v27;
}
while ( v27 < (unsigned int)sub_10024A36C((__int64)a2) - 1 );
}
}
}
}
}