//
// EditorUI::onDelete from 0x3a4308 to 0x3a4554 (588 bytes)
//
// 1 xrefs:
// > EditorUI::clickOnPosition @ 0x3a4a66
//
// 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::onDelete(EditorUI *a1, cocos2d::CCObject *a2)
{
LevelEditorLayer *m_editorLayer; // r6
cocos2d::CCPoint v4; // r1
cocos2d::CCArray *v5; // r8
cocos2d::CCDirector *v6; // r0
int v7; // r0
unsigned int v8; // r6
int v9; // r10
_BOOL4 m_stickyControlsEnabled; // r5
GameObject *v11; // r9
int v12; // r6
GameObject *CycledObject; // r5
cocos2d::CCDictionary *v14; // r0
cocos2d::CCArray *m_deleteObjects; // r3
cocos2d::CCDictionary *v16; // r9
unsigned int v17; // r10
cocos2d::CCArray *v18; // r11
cocos2d::ccArray *data; // r2
cocos2d::CCObject **arr; // r6
cocos2d::CCObject **v21; // r8
cocos2d::CCObject *v22; // r10
cocos2d::CCObject *v23; // t1
cocos2d::CCObject *v24; // r9
unsigned int i; // r6
int v26; // r0
cocos2d::CCArray *StickyGroup; // r8
cocos2d::CCArray *v28; // r3
UndoObject *v29; // r0
cocos2d::ccArray *v30; // r3
int v31; // r6
cocos2d::CCObject **v32; // r3
unsigned int v33; // r6
GameObject **v34; // r8
GameObject *v35; // r1
GameObject *v36; // t1
int v37; // r9
intptr_t m_uID; // r1
cocos2d::CCPoint v39; // [sp+4h] [bp-10h] BYREF
m_editorLayer = a1->m_editorLayer;
cocos2d::CCPoint::CCPoint(&v39, &a1->m_clickAtPosition);
LODWORD(v4.x) = &v39;
v5 = LevelEditorLayer::objectsAtPosition(m_editorLayer, v4);
if ( !a1->m_swipeEnabled
|| (v6 = cocos2d::CCDirector::sharedDirector(),
v7 = (int)v6->getKeyboardDispatcher(v6),
v8 = *(unsigned __int8 *)(v7 + 68),
*(_BYTE *)(v7 + 68)) )
{
v12 = 0;
v37 = cocos2d::CCArray::count(v5);
while ( 1 )
{
if ( v12 >= v37 || (CycledObject = EditorUI::getCycledObject(a1, v5, 1)) == nullptr )
{
m_stickyControlsEnabled = 0;
goto LABEL_17;
}
if ( EditorUI::shouldDeleteObject(a1, CycledObject) )
break;
++v12;
}
if ( CycledObject->m_objectID == 747 )
EditorUI::deselectTargetPortals(a1);
cocos2d::CCArray::addObject(a1->m_deleteObjects, CycledObject);
m_stickyControlsEnabled = CycledObject->m_linkedGroup > 0;
}
else
{
v9 = *(unsigned __int8 *)(v7 + 68);
m_stickyControlsEnabled = v9;
while ( v8 < cocos2d::CCArray::count(v5) )
{
v11 = (GameObject *)cocos2d::CCArray::objectAtIndex(v5, v8);
if ( EditorUI::shouldDeleteObject(a1, v11) )
{
if ( !v9 && v11->m_objectID == 747 )
{
v9 = 1;
EditorUI::deselectTargetPortals(a1);
}
cocos2d::CCArray::addObject(a1->m_deleteObjects, v11);
if ( !m_stickyControlsEnabled )
m_stickyControlsEnabled = v11->m_linkedGroup > 0;
}
++v8;
}
}
LABEL_17:
if ( a1->m_stickyControlsEnabled )
{
if ( a1->m_linkControlsDisabled )
{
m_stickyControlsEnabled = 0;
}
else if ( m_stickyControlsEnabled )
{
v14 = cocos2d::CCDictionary::create();
m_deleteObjects = a1->m_deleteObjects;
v16 = v14;
if ( m_deleteObjects )
{
data = m_deleteObjects->data;
if ( data->num )
{
arr = data->arr;
v21 = &arr[data->num] + 0x3FFFFFFF;
while ( arr <= v21 )
{
v23 = *arr++;
v22 = v23;
if ( !v23 )
break;
m_uID = v22[14].m_uID;
if ( m_uID > 0 && !cocos2d::CCDictionary::objectForKey(v16, m_uID) )
cocos2d::CCDictionary::setObject(v16, v22, v22[14].m_uID);
}
}
}
v17 = 0;
v18 = cocos2d::CCDictionary::allKeys(v16);
while ( v17 < cocos2d::CCArray::count(v18) )
{
v26 = cocos2d::CCArray::objectAtIndex(v18, v17);
StickyGroup = GJBaseGameLayer::getStickyGroup(a1->m_editorLayer, *(_DWORD *)(v26 + 52));
if ( StickyGroup )
{
for ( i = 0; i < cocos2d::CCArray::count(StickyGroup); ++i )
{
v24 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(StickyGroup, i);
if ( !cocos2d::CCArray::containsObject(a1->m_deleteObjects, v24) )
cocos2d::CCArray::addObject(a1->m_deleteObjects, v24);
}
}
++v17;
}
}
}
else
{
m_stickyControlsEnabled = a1->m_stickyControlsEnabled;
}
v28 = a1->m_deleteObjects;
if ( v28 )
{
v30 = v28->data;
if ( v30->num )
{
v31 = v30->num + 0x40000000;
v32 = v30->arr;
v33 = (unsigned int)&v32[v31 - 1];
v34 = (GameObject **)v32;
while ( (unsigned int)v34 <= v33 )
{
v36 = *v34++;
v35 = v36;
if ( !v36 )
break;
EditorUI::deleteObject(a1, v35, m_stickyControlsEnabled);
}
}
}
if ( m_stickyControlsEnabled )
{
v29 = UndoObject::createWithArray(a1->m_deleteObjects, DeleteMulti);
LevelEditorLayer::addToUndoList(a1->m_editorLayer, v29, 0);
}
cocos2d::CCArray::removeAllObjects(a1->m_deleteObjects);
EditorUI::updateSpecialUIElements(a1);
EditorUI::tryUpdateTimeMarkers(a1);
}