//
// EditorUI::onDeleteSelected from 0x1400e6430 to 0x1400e686b (1083 bytes)
//
// 4 xrefs:
// > EditorUI::keyDown @ 0x1401266f1
// > EditorUI::init @ 0x1400e02fa
// > EditorUI::setupDeleteMenu @ 0x1400e5093
// > ??> @ 0x1406c8d00
//
// 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
//
// Hidden C++ exception states: #wind=6
void EditorUI::onDeleteSelected(EditorUI *a1, cocos2d::CCObject *a2)
{
EditorUI *v3; // rcx
char v4; // r15
cocos2d::CCArray *v5; // r14
unsigned int i; // edi
GameObject *v7; // rsi
EditorUI *v8; // rcx
unsigned int j; // ebp
GameObject *v10; // rax
GameObject *v11; // rsi
LevelEditorLayer *m_editorLayer; // rdi
void *v13; // rdi
__int64 v14; // rcx
cocos2d::CCArray *v15; // rax
LevelEditorLayer *v16; // rsi
unsigned int v17; // ebp
GameObject *m_selectedObject; // rdx
GameObject *v19; // rdi
LevelEditorLayer *v20; // rsi
cocos2d::CCObject *v21; // r14
GameObjectCopy *v22; // rax
unsigned int v23; // ebp
_BOOL8 v24; // rdx
if ( cocos2d::CCArray::count(a1->m_selectedObjects) )
{
v4 = 0;
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(v3);
for ( i = 0; i < cocos2d::CCArray::count(a1->m_selectedObjects); ++i )
{
v7 = (GameObject *)cocos2d::CCArray::objectAtIndex(a1->m_selectedObjects, i);
if ( EditorUI::shouldDeleteObject(v8, v7) )
cocos2d::CCArray::addObject(v5, v7);
}
for ( j = 0; j < cocos2d::CCArray::count(v5); ++j )
{
v10 = (GameObject *)cocos2d::CCArray::objectAtIndex(v5, j);
v11 = v10;
if ( v10->m_objectID == 747 )
v4 = 1;
v10->m_wasSelected = v10->m_isSelected;
EditorUI::deselectObject(a1, v10);
m_editorLayer = a1->m_editorLayer;
v11->deactivateObject(v11, 1);
GJBaseGameLayer::removeObjectFromSection(m_editorLayer, v11);
LevelEditorLayer::removeSpecial(m_editorLayer, v11);
m_editorLayer->m_unk3b22 = 1;
a1->m_rotationTouchID = -1;
if ( a1->m_rotationControl->isVisible(a1->m_rotationControl) )
{
a1->m_rotationControl->setVisible(a1->m_rotationControl, 0);
GJRotationControl::finishTouch(a1->m_rotationControl);
}
EditorUI::deactivateScaleControl(a1);
EditorUI::deactivateTransformControl(a1);
}
v13 = operator new(0xA0u);
cocos2d::CCObject::CCObject((cocos2d::CCObject *)v13);
*(_QWORD *)v13 = &UndoObject::`vftable';
*((_QWORD *)v13 + 7) = 0;
*((_DWORD *)v13 + 16) = 0;
*((_QWORD *)v13 + 9) = 0;
*((_WORD *)v13 + 40) = 0;
sub_1400DE960((__int64)v13 + 84);
if ( v5 )
{
v15 = (cocos2d::CCArray *)cocos2d::CCArray::create(v14);
*((_QWORD *)v13 + 9) = v15;
cocos2d::CCArray::addObjectsFromArray(v15, v5);
cocos2d::CCObject::retain(*((cocos2d::CCObject **)v13 + 9));
}
*((_DWORD *)v13 + 16) = 4;
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v13);
v16 = a1->m_editorLayer;
cocos2d::CCArray::removeAllObjects(v16->m_redoObjects);
v17 = 1000;
if ( !v16->m_increaseMaxUndoRedo )
v17 = 200;
if ( cocos2d::CCArray::count(v16->m_undoObjects) >= v17 )
cocos2d::CCArray::removeObjectAtIndex(v16->m_undoObjects, 0, 1);
cocos2d::CCArray::addObject(v16->m_undoObjects, (struct cocos2d::CCObject *)v13);
if ( v4 )
EditorUI::deselectTargetPortals(a1);
}
else
{
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
{
if ( EditorUI::shouldDeleteObject(v3, m_selectedObject) )
{
v19 = a1->m_selectedObject;
if ( v19 )
{
v19->m_wasSelected = v19->m_isSelected;
EditorUI::deselectObject(a1, v19);
v20 = a1->m_editorLayer;
cocos2d::CCArray::removeAllObjects(v20->m_redoObjects);
v21 = (cocos2d::CCObject *)operator new(0xA0u);
cocos2d::CCObject::CCObject(v21);
v21->__vftable = (cocos2d::CCObject_vtbl *)&UndoObject::`vftable';
v21[1].__vftable = nullptr;
v21[1].m_uID = 0;
*(_QWORD *)&v21[1].m_nTag = 0;
LOWORD(v21[1].m_uAutoReleaseCount) = 0;
sub_1400DE960((__int64)&v21[1].m_eObjType);
v22 = GameObjectCopy::create(v19);
v21[1].__vftable = (cocos2d::CCObject_vtbl *)v22;
cocos2d::CCObject::retain(v22);
v21[1].m_uID = 1;
cocos2d::CCObject::autorelease(v21);
cocos2d::CCArray::removeAllObjects(v20->m_redoObjects);
v23 = 1000;
if ( !v20->m_increaseMaxUndoRedo )
v23 = 200;
if ( cocos2d::CCArray::count(v20->m_undoObjects) >= v23 )
cocos2d::CCArray::removeObjectAtIndex(v20->m_undoObjects, 0, 1);
cocos2d::CCArray::addObject(v20->m_undoObjects, v21);
LOBYTE(v24) = 1;
v19->deactivateObject(v19, v24);
GJBaseGameLayer::removeObjectFromSection(v20, v19);
LevelEditorLayer::removeSpecial(v20, v19);
v20->m_unk3b22 = 1;
a1->m_rotationTouchID = -1;
if ( a1->m_rotationControl->isVisible(a1->m_rotationControl) )
{
a1->m_rotationControl->setVisible(a1->m_rotationControl, 0);
GJRotationControl::finishTouch(a1->m_rotationControl);
}
EditorUI::deactivateScaleControl(a1);
EditorUI::deactivateTransformControl(a1);
}
}
}
}
EditorUI::updateObjectInfoLabel(a1);
a1->updateScaleControl(&a1->GJScaleControlDelegate);
EditorUI::updateButtons(a1);
}