//
// EditorUI::alignObjects from 0x1402017a0 to 0x140201ce7 (1351 bytes)
//
// 5 xrefs:
// > EditorCommandsPopup::onCommand @ 0x14017dbeb
// > EditorCommandsPopup::onCommand @ 0x14017dc12
// > EditorUI::handleEditorAction @ 0x1401c342e
// > EditorUI::handleEditorAction @ 0x1401c3453
// > ??> @ 0x14091ae40
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:28:13 +0000
//
// Hidden C++ exception states: #wind=1
void __fastcall EditorUI::alignObjects(__int64 a1, cocos2d::CCArray *a2, char a3)
{
unsigned int v5; // eax
cocos2d::CCArray *v6; // rax
cocos2d::CCDictionary *v7; // rsi
unsigned int v8; // r12d
unsigned int v9; // edi
struct cocos2d::CCObject *v10; // rbx
__int64 v11; // rbx
struct cocos2d::CCObject *v12; // rax
cocos2d::CCArray *v13; // r13
unsigned int i; // esi
int v15; // ebx
struct cocos2d::CCObject *v16; // rax
__int64 v17; // rcx
__int64 v18; // r9
cocos2d::CCSprite *v19; // rax
cocos2d::CCSprite *v20; // rdi
__int64 v21; // rbx
__int64 v22; // rax
unsigned int *v23; // rcx
char v24; // si
size_t v25; // rdx
void *v26; // rcx
int (__cdecl *v27)(const void *, const void *); // r9
__int64 v28; // rdx
char v29; // di
unsigned int *v30; // rbx
__int64 v31; // rax
_QWORD *v32; // rbx
_QWORD *j; // rsi
const struct cocos2d::CCPoint *v34; // rax
int *v35; // rbx
const struct cocos2d::CCPoint *v36; // rax
float v37; // xmm1_4
float v38; // xmm2_4
float v39; // xmm1_4
cocos2d::CCPoint *v40; // rcx
__int64 v41; // rax
cocos2d::CCArray *v42; // rax
cocos2d::CCArray *v43; // rsi
unsigned int v44; // edi
struct cocos2d::CCObject *v45; // rbx
__int64 v46; // rax
float v47; // [rsp+20h] [rbp-50h] BYREF
float v48; // [rsp+24h] [rbp-4Ch]
char v49[8]; // [rsp+28h] [rbp-48h] BYREF
float v50[2]; // [rsp+30h] [rbp-40h] BYREF
char v51[8]; // [rsp+38h] [rbp-38h] BYREF
void *v52; // [rsp+40h] [rbp-30h] BYREF
char v53[8]; // [rsp+48h] [rbp-28h] BYREF
char v54; // [rsp+50h] [rbp-20h] BYREF
char v55; // [rsp+58h] [rbp-18h] BYREF
char v56[16]; // [rsp+60h] [rbp-10h] BYREF
float v57; // [rsp+B8h] [rbp+48h] BYREF
float v58; // [rsp+BCh] [rbp+4Ch]
char v59; // [rsp+C0h] [rbp+50h]
float v60; // [rsp+C8h] [rbp+58h] BYREF
float v61; // [rsp+CCh] [rbp+5Ch]
if ( a2 )
{
v59 = a3;
if ( cocos2d::CCArray::count(a2) >= 3 )
{
v5 = cocos2d::CCArray::count(a2);
v6 = cocos2d::CCArray::createWithCapacity(v5);
cocos2d::CCArray::addObjectsFromArray(v6, a2);
v7 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create();
v8 = 1;
if ( *(_BYTE *)(a1 + 915) && !*(_BYTE *)(a1 + 916) )
{
v9 = 0;
while ( v9 < cocos2d::CCArray::count(a2) )
{
v10 = cocos2d::CCArray::objectAtIndex(a2, v9);
if ( *((int *)v10 + 220) <= 0 )
{
++v9;
}
else
{
cocos2d::CCArray::removeObjectAtIndex(a2, v9, 1);
if ( !cocos2d::CCDictionary::objectForKey(v7, *((int *)v10 + 220)) )
{
v11 = *((int *)v10 + 220);
v12 = (struct cocos2d::CCObject *)cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(v7, v12, v11);
}
}
}
v13 = cocos2d::CCDictionary::allKeys(v7);
for ( i = 0; i < cocos2d::CCArray::count(v13); ++i )
{
v15 = *((_DWORD *)cocos2d::CCArray::objectAtIndex(v13, i) + 14);
v16 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(*(_QWORD *)(a1 + 1512) + 4256LL), v15);
if ( v16 )
{
LOBYTE(v18) = 1;
EditorUI::getGroupCenter(v17, v49, v16, v18);
v52 = operator new(0x550u);
v19 = (cocos2d::CCSprite *)GameObject::GameObject(v52);
v20 = v19;
if ( v19 )
{
*((_DWORD *)v19 + 7) = 13;
if ( cocos2d::CCSprite::initWithSpriteFrameName(v19, "checkpoint_01_001.png") )
{
GameObject::commonSetup(v20);
*((_BYTE *)v20 + 313) = 1;
cocos2d::CCObject::autorelease(v20);
}
else
{
(*(void (__fastcall **)(cocos2d::CCSprite *, __int64))(*(_QWORD *)v20 + 8LL))(v20, 1);
v20 = nullptr;
}
}
*((_DWORD *)v20 + 259) = 44;
*((_DWORD *)v20 + 220) = v15;
v21 = *(_QWORD *)v20;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v51, (const struct cocos2d::CCPoint *)v49);
(*(void (__fastcall **)(cocos2d::CCSprite *, __int64))(v21 + 1216))(v20, v22);
cocos2d::CCArray::addObject(a2, v20);
}
}
}
v23 = *((unsigned int **)a2 + 7);
v24 = v59;
v25 = *v23;
v26 = *((void **)v23 + 2);
v27 = (int (__cdecl *)(const void *, const void *))sub_14019F1C0;
if ( !v59 )
v27 = (int (__cdecl *)(const void *, const void *))sub_14019F170;
qsort(v26, v25, 8u, v27);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v57);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v60);
v29 = 1;
v30 = *((unsigned int **)a2 + 7);
v31 = *v30;
if ( (_DWORD)v31 )
{
v32 = *((_QWORD **)v30 + 2);
for ( j = &v32[v31 - 1]; v32 <= j; ++v32 )
{
if ( !*v32 )
break;
v34 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)*v32 + 200LL))(*v32);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v47, v34);
if ( v29 )
{
v29 = 0;
cocos2d::CCPoint::operator=(&v57, &v47);
cocos2d::CCPoint::operator=(&v60, &v47);
}
else
{
if ( v57 > v47 )
v57 = v47;
if ( v47 > v60 )
v60 = v47;
if ( v58 > v48 )
v58 = v48;
if ( v48 > v61 )
v61 = v48;
}
}
v24 = v59;
}
if ( v57 != v60 || v58 != v61 )
{
EditorUI::createUndoObject(a1, v28, 0);
cocos2d::CCPoint::operator-(&v60, v53, &v57);
cocos2d::CCArray::count(a2);
cocos2d::CCPoint::operator*(v53, v50);
if ( cocos2d::CCArray::count(a2) - 1 > 1 )
{
do
{
v35 = (int *)cocos2d::CCArray::objectAtIndex(a2, v8);
v36 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(int *))(*(_QWORD *)v35 + 200LL))(v35);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v47, v36);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v49);
v37 = (float)(int)v8;
if ( v24 )
{
v38 = (float)(v37 * v50[1]) + v58;
v39 = v47;
v40 = (cocos2d::CCPoint *)&v54;
}
else
{
v39 = (float)(v37 * v50[0]) + v57;
v38 = v48;
v40 = (cocos2d::CCPoint *)&v55;
}
cocos2d::CCPoint::CCPoint(v40, v39, v38);
cocos2d::CCPoint::operator=(v49, v41);
cocos2d::CCPoint::operator-(v49, v51, &v47);
if ( v35[259] == 44 )
{
v42 = cocos2d::CCDictionary::objectForKey(
*(cocos2d::CCDictionary **)(*(_QWORD *)(a1 + 1512) + 4256LL),
v35[220]);
v43 = v42;
if ( v42 )
{
v44 = 0;
if ( cocos2d::CCArray::count(v42) )
{
do
{
v45 = cocos2d::CCArray::objectAtIndex(v43, v44);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v56, (const struct cocos2d::CCPoint *)v51);
EditorUI::moveObject(a1, (__int64)v45, v46);
++v44;
}
while ( v44 < cocos2d::CCArray::count(v43) );
}
}
v24 = v59;
}
else
{
cocos2d::CCPoint::operator-(v49, &v52, &v47);
EditorUI::moveObject(a1, (__int64)v35, (__int64)&v52);
}
++v8;
}
while ( v8 < cocos2d::CCArray::count(a2) - 1 );
}
if ( (*(unsigned __int8 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 840) + 344LL))(*(_QWORD *)(a1 + 840)) )
{
EditorUI::deactivateTransformControl(a1);
EditorUI::activateTransformControl(a1, 0);
}
if ( (*(unsigned __int8 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 808) + 344LL))(*(_QWORD *)(a1 + 808)) )
{
*(_BYTE *)(a1 + 824) = 1;
EditorUI::activateRotationControl(a1, 0);
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)(a1 + 432) + 40LL))(a1 + 432);
EditorUI::updateButtons(a1);
}
}
}
}