//
// LevelEditorLayer::handleAction from 0x371690 to 0x3719a0 (784 bytes)
//
// 2 xrefs:
// > LevelEditorLayer::redoLastAction @ 0x3719a8
// > LevelEditorLayer::undoLastAction @ 0x3719b4
//
// 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 LevelEditorLayer::handleAction(LevelEditorLayer *a1, bool a2, cocos2d::CCArray *a3)
{
_BOOL4 v4; // r8
int Object; // r5
cocos2d::CCArray *v7; // r0
GameObject *v8; // r6
cocos2d::CCObject *v9; // r1
EditorUI *m_editorUI; // r9
cocos2d::CCArray *v11; // r0
GameObject *v12; // r6
cocos2d::CCArray *v13; // r11
unsigned int v14; // r9
GameObject *v15; // r0
GameObject *v16; // r6
EditorUI *v17; // r0
cocos2d::CCArray *v18; // r0
cocos2d::CCArray *v19; // r11
unsigned int v20; // r9
cocos2d::CCArray *v21; // r10
GameObject *v22; // r6
cocos2d::CCArray *v23; // r9
unsigned int v24; // r6
cocos2d::CCArray *v25; // r11
GameObjectCopy *v26; // r0
GameObjectCopy *v27; // r10
GameObjectCopy *v28; // r0
UndoObject *v29; // r6
int v30; // r2
cocos2d::CCArray *SelectedObjects; // r9
EditorUI *v32; // r0
int v33; // r2
v4 = a2;
if ( cocos2d::CCArray::count(a3) )
{
Object = cocos2d::CCArray::lastObject(a3);
cocos2d::CCObject::retain((cocos2d::CCObject *)Object);
v7 = (cocos2d::CCArray *)cocos2d::CCArray::removeLastObject(a3, 1);
if ( !v4 )
{
switch ( *(_DWORD *)(Object + 56) )
{
case 1:
goto LABEL_8;
case 2:
goto LABEL_5;
case 3:
goto LABEL_12;
case 4:
goto LABEL_9;
default:
switch ( *(_DWORD *)(Object + 56) )
{
case 1:
goto LABEL_5;
case 2:
goto LABEL_8;
case 3:
goto LABEL_9;
case 4:
goto LABEL_12;
case 5:
goto LABEL_19;
case 6:
goto LABEL_29;
default:
v29 = (UndoObject *)Object;
goto LABEL_36;
}
}
}
switch ( *(_DWORD *)(Object + 56) )
{
case 1:
LABEL_5:
v8 = *(GameObject **)(*(_DWORD *)(Object + 52) + 52);
a1->addToSection(a1, v8);
LevelEditorLayer::addSpecial(a1, v8);
if ( v8->m_wasSelected )
{
m_editorUI = a1->m_editorUI;
v11 = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject((cocos2d::CCArray *)v8, v9);
EditorUI::selectObjects(m_editorUI, v11, 1);
}
GameObject::assignUniqueID(v8);
goto LABEL_30;
case 2:
LABEL_8:
v12 = *(GameObject **)(*(_DWORD *)(Object + 52) + 52);
GJBaseGameLayer::removeObjectFromSection(a1, v12);
LevelEditorLayer::removeSpecial(a1, v12);
v12->m_wasSelected = v12->m_isSelected;
EditorUI::deselectObject(a1->m_editorUI);
v12->deactivateObject(v12, 1);
goto LABEL_30;
case 3:
LABEL_9:
v13 = *(cocos2d::CCArray **)(Object + 60);
v14 = 0;
while ( v14 < cocos2d::CCArray::count(v13) )
{
v15 = (GameObject *)cocos2d::CCArray::objectAtIndex(v13, v14++);
v16 = v15;
GJBaseGameLayer::removeObjectFromSection(a1, v15);
LevelEditorLayer::removeSpecial(a1, v16);
v17 = a1->m_editorUI;
v16->m_wasSelected = v16->m_isSelected;
EditorUI::deselectObject(v17);
v16->deactivateObject(v16, 1);
}
goto LABEL_30;
case 4:
LABEL_12:
v18 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
v19 = *(cocos2d::CCArray **)(Object + 60);
v20 = 0;
v21 = v18;
while ( v20 < cocos2d::CCArray::count(v19) )
{
v22 = (GameObject *)cocos2d::CCArray::objectAtIndex(v19, v20);
a1->addToSection(a1, v22);
LevelEditorLayer::addSpecial(a1, v22);
if ( v22->m_wasSelected )
cocos2d::CCArray::addObject(v21, v22);
++v20;
GameObject::assignUniqueID(v22);
}
if ( cocos2d::CCArray::count(v21) )
EditorUI::selectObjects(a1->m_editorUI, v21, 1);
goto LABEL_30;
case 5:
LABEL_19:
v23 = *(cocos2d::CCArray **)(Object + 60);
if ( v23 )
{
v24 = 0;
v25 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
while ( v24 < cocos2d::CCArray::count(v23) )
{
v26 = (GameObjectCopy *)cocos2d::CCArray::objectAtIndex(v23, v24++);
v27 = v26;
v28 = GameObjectCopy::create(v26->m_object);
cocos2d::CCArray::addObject(v25, v28);
GameObjectCopy::resetObject(v27);
GJBaseGameLayer::reorderObjectSection(a1, v27->m_object);
}
v29 = UndoObject::createWithArray(v25, Transform);
}
else
{
v29 = UndoObject::create(*(GameObject **)(*(_DWORD *)(Object + 52) + 52), Transform);
GameObjectCopy::resetObject(*(GameObjectCopy **)(Object + 52));
GJBaseGameLayer::reorderObjectSection(a1, *(GameObject **)(*(_DWORD *)(Object + 52) + 52));
}
if ( *(_BYTE *)(Object + 65)
&& ((int (__fastcall *)(GJTransformControl *))a1->m_editorUI->m_transformControl->isVisible)(a1->m_editorUI->m_transformControl) )
{
GJTransformState::operator=(
(int)&v29->m_transformState,
(PlayerFireBoostSprite **)&a1->m_editorUI->m_transformState,
v30);
v32 = a1->m_editorUI;
v29->m_undoTransform = 1;
GJTransformState::operator=((int)&v32->m_transformState, (PlayerFireBoostSprite **)(Object + 68), v33);
GJTransformControl::loadFromState(a1->m_editorUI->m_transformControl, (GJTransformState *)(Object + 68));
GJTransformControl::refreshControl(a1->m_editorUI->m_transformControl);
}
v29->m_redo = *(_BYTE *)(Object + 64);
goto LABEL_31;
case 6:
LABEL_29:
SelectedObjects = EditorUI::getSelectedObjects(a1->m_editorUI);
EditorUI::changeSelectedObjects(a1->m_editorUI, *(cocos2d::CCArray **)(Object + 60), 1);
UndoObject::setObjects((UndoObject *)Object, SelectedObjects);
LABEL_30:
v29 = (UndoObject *)Object;
LABEL_31:
if ( v4 )
goto LABEL_34;
LABEL_36:
LevelEditorLayer::addToUndoList(a1, v29, 1);
break;
default:
v29 = (UndoObject *)Object;
LABEL_34:
LevelEditorLayer::addToRedoList(a1, v29);
break;
}
if ( cocos2d::CCArray::count(a3) )
{
if ( v4 )
{
if ( *(_BYTE *)(cocos2d::CCArray::lastObject(a3) + 64) )
LevelEditorLayer::undoLastAction(a1);
}
else if ( *(_BYTE *)(Object + 64) )
{
LevelEditorLayer::redoLastAction(a1);
}
}
cocos2d::CCObject::release((cocos2d::CCObject *)Object);
}
}