//
// EditorUI::ccTouchEnded from 0x6c2888 to 0x6c3108 (2176 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'EditorUI::ccTouchEnded @ 0x6c310c
// > ??> @ 0xc7860
// > ??> @ 0x1156a30
//
// 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::ccTouchEnded(EditorUI *a1, cocos2d::CCTouch *a2, cocos2d::CCEvent *a3)
{
__int64 v5; // x2
int m_nId; // w0
LevelEditorLayer *m_editorLayer; // x1
GameManager *v9; // x0
_BOOL4 GameVariable; // w25
float v11; // s0
cocos2d::CCPoint *p_m_lastTouchPoint; // x0
float v13; // s0
unsigned int v14; // w2
float v15; // s1
int v16; // w25
_BOOL4 m_snapObjectExists; // w0
GameManager *v18; // x0
bool v19; // w0
GameObject *m_snapObject; // x1
cocos2d::CCPoint *v21; // x0
const cocos2d::CCPoint *v22; // x0
UndoObject *m_undoObject; // x1
UndoObject *v24; // x0
GameObject *v25; // x0
float v26; // s0
float v27; // s1
_BOOL4 m_canActivateControls; // w21
cocos2d::CCArray *m_snapPositions; // x0
float v30; // s0
float v31; // s1
void *m_rotationControl; // x4
cocos2d::CCTouch *v33; // x1
cocos2d::CCLayer *m_objectLayer; // x26
float x; // s0
float y; // s1
LevelEditorLayer *v37; // x21
cocos2d::CCArray *v38; // x0
GameObject *CycledObject; // x21
cocos2d::CCObject *v40; // x1
cocos2d::CCArray *v41; // x0
cocos2d::CCArray *v42; // x0
float v43; // s0
float v44; // s1
const cocos2d::CCPoint *v45; // x0
float v46; // s0
float v47; // s1
unsigned int i; // w21
GameObject *v49; // x28
LevelEditorLayer *v50; // x27
cocos2d::CCArray *v51; // x0
GameObject *v52; // x21
float v53; // s0
float v54; // s1
void *m_scaleControl; // x21
void (__fastcall *v56)(void *, cocos2d::CCRect *); // x28
__int64 v57; // x0
GJTransformControl *m_transformControl; // x21
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x28
__int64 v60; // x0
GameObject *Object; // x0
cocos2d::CCPoint v62; // [xsp+78h] [xbp+78h] BYREF
cocos2d::CCPoint v63; // [xsp+80h] [xbp+80h] BYREF
cocos2d::CCPoint v64; // [xsp+88h] [xbp+88h] BYREF
cocos2d::CCPoint v65; // [xsp+90h] [xbp+90h] BYREF
cocos2d::CCPoint v66; // [xsp+98h] [xbp+98h] BYREF
cocos2d::CCPoint v67; // [xsp+A0h] [xbp+A0h] BYREF
cocos2d::CCRect v68; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCRect v69; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v70; // [xsp+C8h] [xbp+C8h]
cocos2d::CCPoint v71; // 0:kr50_8.8
cocos2d::CCPoint v72; // 0:s0.4,4:s1.4
cocos2d::CCPoint v73; // 0:s0.4,4:s1.4
cocos2d::CCPoint v74; // 0:s0.4,4:s1.4
cocos2d::CCPoint v75; // 0:s0.4,4:s1.4
cocos2d::CCPoint v76; // 0:s0.4,4:s1.4
cocos2d::CCPoint v77; // 0:s0.4,4:s1.4
cocos2d::CCPoint v78; // 0:s2.4,4:s3.4
cocos2d::CCRect v79; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v5 = _stack_chk_guard;
a1->m_canActivateControls = 0;
v70 = v5;
cocos2d::CCNode::stopActionByTag(a1, 123);
m_nId = a2->m_nId;
if ( a1->m_rotationTouchID == m_nId )
{
m_rotationControl = a1->m_rotationControl;
v33 = a2;
a1->m_rotationTouchID = -1;
LABEL_41:
(*(void (__fastcall **)(void *, cocos2d::CCTouch *, cocos2d::CCEvent *))(*(_QWORD *)m_rotationControl + 896LL))(
m_rotationControl,
v33,
a3);
return;
}
if ( m_nId == a1->m_scaleTouchID )
{
m_rotationControl = a1->m_scaleControl;
v33 = a2;
a1->m_scaleTouchID = -1;
goto LABEL_41;
}
if ( m_nId == a1->m_transformTouchID )
{
m_rotationControl = a1->m_transformControl;
v33 = a2;
a1->m_transformTouchID = -1;
goto LABEL_41;
}
m_editorLayer = a1->m_editorLayer;
if ( m_editorLayer->m_playbackMode == Playing )
{
m_editorLayer->m_uiLayer->ccTouchEnded(m_editorLayer->m_uiLayer, a2, a3);
return;
}
if ( m_nId != a1->m_touchID )
return;
v9 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v9, "0059");
EditorUI::getTouchPoint(a1, a2, a3);
v11 = cocos2d::ccpDistance(&a1->m_swipeStart, &v62);
p_m_lastTouchPoint = &a1->m_lastTouchPoint;
if ( v11 < 8.0 && GameVariable )
{
v13 = cocos2d::ccpDistance(p_m_lastTouchPoint, &v62);
v14 = 1;
}
else
{
v13 = cocos2d::ccpDistance(p_m_lastTouchPoint, &v62);
v14 = 0;
if ( !GameVariable )
goto LABEL_10;
}
v15 = 8.0;
v16 = 1;
if ( v13 >= 8.0 )
LABEL_10:
v16 = 0;
m_snapObjectExists = a1->m_snapObjectExists;
a1->m_touchID = -1;
if ( m_snapObjectExists && a1->m_continuousSnap && a1->m_snapObject )
{
cocos2d::CCPoint::CCPoint(&v63, (const cocos2d::CCPoint *)&dword_1242110);
EditorUI::getTouchPoint(a1, a2, a3);
cocos2d::CCNode::convertToNodeSpace(a1->m_editorLayer->m_objectLayer, &v64);
v18 = GameManager::sharedState();
v19 = GameManager::getGameVariable(v18, "0008");
m_snapObject = a1->m_snapObject;
if ( !v19 || !m_snapObject )
goto LABEL_19;
if ( !EditorUI::shouldSnap(a1, m_snapObject) || (unsigned __int8)cocos2d::CCPoint::equals(&v64, &a1->m_swipeStart) )
{
m_snapObject = a1->m_snapObject;
LABEL_19:
v21 = (cocos2d::CCPoint *)m_snapObject->getPosition(m_snapObject);
if ( (unsigned __int8)cocos2d::CCPoint::equals(v21, &a1->m_snapPosition) )
a1->m_noSnapUndo = 1;
v22 = a1->m_snapObject->getPosition(a1->m_snapObject);
cocos2d::CCPoint::operator-(&v69, v22, &a1->m_snapPosition);
if ( !a1->m_noSnapUndo )
{
m_undoObject = a1->m_undoObject;
if ( m_undoObject )
{
LevelEditorLayer::addToUndoList(a1->m_editorLayer, m_undoObject, 0);
v24 = a1->m_undoObject;
if ( v24 )
{
cocos2d::CCObject::release(v24);
a1->m_undoObject = nullptr;
}
}
}
EditorUI::tryUpdateTimeMarkers(a1);
v25 = a1->m_snapObject;
goto LABEL_26;
}
cocos2d::CCPoint::CCPoint(&v69.origin, &v65);
EditorUI::getGridSnappedPos(a1, v74);
EditorUI::getRelativeOffset(a1, a1->m_snapObject);
cocos2d::CCPoint::CCPoint(&v69.origin, &v66);
EditorUI::applySpecialOffset(a1, v75, (GameObject *)&v68, v78);
cocos2d::CCPoint::operator+(&v69, &v66, &v67);
cocos2d::CCPoint::operator=(&v66, v43, v44);
v45 = a1->m_snapObject->getPosition(a1->m_snapObject);
cocos2d::CCPoint::CCPoint(&v68.origin, v45);
a1->m_snapObject->setPosition(a1->m_snapObject, &v66);
cocos2d::CCPoint::operator-(&v69, &v66, &v68);
cocos2d::CCPoint::operator=(&v63, v46, v47);
if ( (unsigned int)cocos2d::CCArray::count(a1->m_selectedObjects) )
{
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(a1->m_selectedObjects); ++i )
{
v49 = (GameObject *)cocos2d::CCArray::objectAtIndex(a1->m_selectedObjects, i);
if ( v49->m_uniqueID != a1->m_snapObject->m_uniqueID )
{
cocos2d::CCPoint::CCPoint(&v69.origin, &v63);
EditorUI::moveObject(a1, v49, v76);
}
}
}
cocos2d::CCPoint::operator+(&v69, &a1->m_pivotPoint, &v63);
cocos2d::CCPoint::operator=(&a1->m_pivotPoint, v53, v54);
if ( a1->m_rotationControl->isVisible(a1->m_rotationControl) )
{
m_scaleControl = a1->m_rotationControl;
}
else
{
if ( !a1->m_scaleControl->isVisible(a1->m_scaleControl) )
{
if ( a1->m_transformControl->isVisible(a1->m_transformControl) )
{
m_transformControl = a1->m_transformControl;
setPosition = m_transformControl->setPosition;
v60 = (__int64)m_transformControl->getPosition(m_transformControl);
cocos2d::CCPoint::operator+(&v69, v60, &v63);
setPosition(m_transformControl, &v69.origin);
GJTransformControl::refreshControl(a1->m_transformControl);
m_snapObject = a1->m_snapObject;
goto LABEL_19;
}
goto LABEL_79;
}
m_scaleControl = a1->m_scaleControl;
}
v56 = *(void (__fastcall **)(void *, cocos2d::CCRect *))(*(_QWORD *)m_scaleControl + 184LL);
v57 = (*(__int64 (__fastcall **)(void *))(*(_QWORD *)m_scaleControl + 192LL))(m_scaleControl);
cocos2d::CCPoint::operator+(&v69, v57, &v63);
v56(m_scaleControl, &v69);
LABEL_79:
m_snapObject = a1->m_snapObject;
goto LABEL_19;
}
if ( a1->m_swipeActive > v14 )
{
m_objectLayer = a1->m_editorLayer->m_objectLayer;
cocos2d::CCNode::convertToNodeSpace(m_objectLayer, &a1->m_swipeStart);
cocos2d::CCNode::convertToNodeSpace(m_objectLayer, &a1->m_swipeEnd);
x = v67.x;
if ( v66.x <= v67.x )
x = v66.x;
y = v67.y;
if ( v66.y <= v67.y )
y = v66.y;
cocos2d::CCRect::CCRect(&v68, x, y, vabds_f32(v66.x, v67.x), vabds_f32(v66.y, v67.y));
EditorUI::getTouchPoint(a1, a2, a3);
if ( cocos2d::ccpDistance(&a1->m_swipeStart, &v69.origin) >= 8.0 )
{
cocos2d::CCRect::CCRect(&v69, &v68);
EditorUI::selectObjectsInRect(a1, v79);
v25 = a1->m_snapObject;
goto LABEL_26;
}
v37 = a1->m_editorLayer;
cocos2d::CCPoint::CCPoint(&v69.origin, &v67);
v38 = LevelEditorLayer::objectsAtPosition(v37, v72);
CycledObject = EditorUI::getCycledObject(a1, v38, 0);
if ( !CycledObject )
goto LABEL_57;
EditorUI::createUndoSelectObject(a1, 0);
v41 = (cocos2d::CCArray *)CycledObject;
goto LABEL_52;
}
if ( !a1->m_isDraggingCamera )
{
EditorUI::getTouchPoint(a1, a2, a3);
v13 = cocos2d::ccpDistance(&a1->m_swipeStart, &v69.origin);
if ( a1->m_swipeSelected )
{
v15 = 20.0;
if ( v13 >= 20.0 )
goto LABEL_57;
}
if ( a1->m_selectedMode != 3 )
{
if ( !a1->m_swipeModeTriggered )
{
cocos2d::CCPoint::CCPoint(&v69.origin, &a1->m_swipeStart);
EditorUI::clickOnPosition(a1, v73);
v25 = a1->m_snapObject;
goto LABEL_26;
}
LABEL_57:
v25 = a1->m_snapObject;
goto LABEL_26;
}
v71 = cocos2d::CCNode::convertToNodeSpace(a1->m_editorLayer->m_objectLayer, &a1->m_swipeStart);
v13 = v71.x;
v15 = v71.y;
v25 = a1->m_snapObject;
if ( v25 && a1->m_editingObject )
goto LABEL_26;
v50 = a1->m_editorLayer;
cocos2d::CCPoint::CCPoint(&v69.origin, &v68.origin);
v51 = LevelEditorLayer::objectsAtPosition(v50, v77);
v52 = EditorUI::getCycledObject(a1, v51, 0);
if ( !v52 )
goto LABEL_57;
EditorUI::createUndoSelectObject(a1, 0);
if ( !a1->m_swipeActive )
{
EditorUI::selectObject(a1, v52, 0);
v25 = a1->m_snapObject;
goto LABEL_26;
}
if ( v16 )
{
if ( a1->m_selectedObject )
{
EditorUI::deselectObject(a1);
}
else
{
Object = (GameObject *)cocos2d::CCArray::lastObject(a1->m_selectedObjects);
if ( Object )
{
GameObject::deselectObject(Object);
cocos2d::CCArray::removeLastObject(a1->m_selectedObjects, 1);
}
}
}
v41 = (cocos2d::CCArray *)v52;
LABEL_52:
v42 = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject(v41, v40);
EditorUI::selectObjects(a1, v42, 0);
v25 = a1->m_snapObject;
goto LABEL_26;
}
a1->m_isDraggingCamera = 0;
v25 = a1->m_snapObject;
LABEL_26:
if ( v25 )
{
if ( a1->m_snapObjectExists && a1->m_continuousSnap )
{
if ( v25->m_isSelected )
((void (__fastcall *)(GameObject *, __int64))v25->selectObject)(v25, 65280);
else
GameObject::deselectObject(v25);
}
a1->m_snapObject = nullptr;
}
a1->m_swipeSelected = 0;
a1->m_swipeActive = 0;
a1->m_snapObjectExists = 0;
a1->m_noSnapUndo = 0;
cocos2d::CCPoint::operator=(&a1->m_createPosition, v13, v15);
a1->m_continuousSnap = 0;
a1->m_editingObject = 0;
cocos2d::CCPoint::operator=(&a1->m_swipePosition, v26, v27);
a1->m_continueSwipe = 0;
m_canActivateControls = a1->m_canActivateControls;
EditorUI::updateButtons(a1);
m_snapPositions = a1->m_snapPositions;
++a1->m_cycledObjectIndex;
cocos2d::CCArray::removeAllObjects(m_snapPositions);
if ( m_canActivateControls )
{
EditorUI::updateSpecialUIElements(a1);
a1->updateTransformControl(a1);
a1->m_canActivateControls = 0;
}
cocos2d::CCPoint::operator=(&a1->m_lastTouchPoint, v30, v31);
}