//
// EditorUI::ccTouchBegan from 0x1003f86b4 to 0x1003f8bdc (1320 bytes)
//
// 2 xrefs:
// > sub_1003F8BDC @ 0x1003f8be0
// > ??> @ 0x100813eb8
//
// 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
//
bool __fastcall EditorUI::ccTouchBegan(EditorUI *a1, cocos2d::CCTouch *a2, cocos2d::CCEvent *a3)
{
double v6; // d0
char v7; // w0
LevelEditorLayer *m_editorLayer; // x8
PlaybackMode m_playbackMode; // w9
UndoObject *m_undoObject; // x0
cocos2d::CCDirector *v12; // x0
cocos2d::CCDirector *v13; // x0
cocos2d::CCDirector *v14; // x0
cocos2d::CCDirector *v15; // x0
cocos2d::CCObject *v16; // x1
float v17; // s2
GameObject *m_snapObject; // x0
float v19; // s2
double *v20; // x0
UndoObject *UndoObject; // x0
cocos2d::CCDirector *v22; // x0
char v23; // w8
cocos2d::CCDirector *v24; // x0
GameManager *v25; // x0
cocos2d::CCDelayTime *v26; // x20
char v27; // w0
__int64 v28; // x1
__int64 v29; // x2
__int64 v30; // x3
__int64 v31; // x4
__int64 v32; // x5
__int64 v33; // x6
__int64 v34; // x7
cocos2d::CCSequence *v35; // x20
double v36; // d0
LevelEditorLayer *v37; // x21
cocos2d::CCArray *v38; // x21
unsigned int v39; // w22
GameObject *v40; // x0
__int64 v41; // [xsp+18h] [xbp-38h] BYREF
timeb v42; // [xsp+20h] [xbp-30h] BYREF
cocos2d::SEL_CallFunc v43; // 0:x1.16
cocos2d::CCPoint v44; // 0:s0.4,4:s1.4
cocos2d::CCPoint v45; // 0:s0.4,4:s1.4
cocos2d::CCPoint v46; // 0:s0.4,4:s1.4
cocos2d::CCPoint v47; // 0:s0.4,4:s1.4
if ( a1->m_rotationTouchID == -1
&& ((unsigned int (__fastcall *)(GJRotationControl *))a1->m_rotationControl->isVisible)(a1->m_rotationControl)
&& ((unsigned int (__fastcall *)(GJRotationControl *, cocos2d::CCTouch *, cocos2d::CCEvent *))a1->m_rotationControl->ccTouchBegan)(
a1->m_rotationControl,
a2,
a3) )
{
a1->m_rotationTouchID = a2->m_nId;
return 1;
}
if ( a1->m_scaleTouchID == -1
&& ((unsigned int (__fastcall *)(GJScaleControl *))a1->m_scaleControl->isVisible)(a1->m_scaleControl)
&& ((unsigned int (__fastcall *)(GJScaleControl *, cocos2d::CCTouch *, cocos2d::CCEvent *))a1->m_scaleControl->ccTouchBegan)(
a1->m_scaleControl,
a2,
a3) )
{
a1->m_scaleTouchID = a2->m_nId;
return 1;
}
if ( a1->m_transformTouchID == -1
&& ((unsigned int (__fastcall *)(GJTransformControl *))a1->m_transformControl->isVisible)(a1->m_transformControl)
&& ((unsigned int (__fastcall *)(GJTransformControl *, cocos2d::CCTouch *, cocos2d::CCEvent *))a1->m_transformControl->ccTouchBegan)(
a1->m_transformControl,
a2,
a3) )
{
a1->m_transformTouchID = a2->m_nId;
return 1;
}
EditorUI::getTouchPoint(a1, a2, a3);
v6 = sub_1000229D0(&a1->m_swipeStart, (double *)&v42.time);
v7 = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *, double))a1->m_playbackBtn->isVisible)(a1->m_playbackBtn, v6);
m_editorLayer = a1->m_editorLayer;
m_playbackMode = m_editorLayer->m_playbackMode;
if ( a1->m_swipeStart.y < a1->m_toolbarHeight )
{
if ( (m_playbackMode != Playing) | v7 & 1 )
return 0;
LABEL_17:
((void (__fastcall *)(UILayer *, cocos2d::CCTouch *, cocos2d::CCEvent *))m_editorLayer->m_uiLayer->ccTouchBegan)(
m_editorLayer->m_uiLayer,
a2,
a3);
return 1;
}
if ( m_playbackMode == Playing )
goto LABEL_17;
if ( a1->m_touchID == -1 )
{
m_undoObject = a1->m_undoObject;
if ( m_undoObject )
{
cocos2d::CCObject::release(m_undoObject);
a1->m_undoObject = nullptr;
}
if ( a1->m_spaceSwiping )
goto LABEL_43;
v12 = cocos2d::CCDirector::sharedDirector();
if ( (*(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v12->getKeyboardDispatcher)(v12) + 88) & 1) != 0 )
goto LABEL_43;
if ( !a1->m_freeMoveEnabled )
{
v13 = cocos2d::CCDirector::sharedDirector();
if ( (*(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v13->getKeyboardDispatcher)(v13) + 89) & 1) == 0 )
{
v14 = cocos2d::CCDirector::sharedDirector();
if ( *(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v14->getKeyboardDispatcher)(v14) + 91) != 1 )
goto LABEL_43;
}
}
if ( a1->m_selectedMode != 3 )
goto LABEL_43;
a1->m_snapSelected = 0;
a1->m_snapObject = nullptr;
cocos2d::CCNode::convertToNodeSpace(a1->m_editorLayer->m_objectLayer, &a1->m_swipeStart);
v15 = cocos2d::CCDirector::sharedDirector();
if ( *(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v15->getKeyboardDispatcher)(v15) + 90) == 1
&& (a1->m_selectedObject || (unsigned int)sub_10024A36C((__int64)a1->m_selectedObjects)) )
{
EditorUI::onDuplicate(a1, v16);
a1->m_noSnapUndo = 1;
}
a1->m_findSnap = 0;
if ( (unsigned int)sub_10024A36C((__int64)a1->m_selectedObjects) )
{
sub_1000229B8(&v41, &v42.time);
v44.x = 0.0;
EditorUI::findSnapObject(a1, v44, v17);
goto LABEL_35;
}
if ( a1->m_selectedObject )
{
v37 = a1->m_editorLayer;
v46.x = sub_1000229B8(&v41, &v42.time);
v38 = LevelEditorLayer::objectsAtPosition(v37, v46);
if ( (unsigned int)sub_10024A36C((__int64)v38) )
{
v39 = 0;
while ( 1 )
{
v40 = (GameObject *)sub_10024A388((__int64)v38, v39);
if ( v40->m_uniqueID == a1->m_selectedObject->m_uniqueID )
break;
if ( ++v39 >= (unsigned int)sub_10024A36C((__int64)v38) )
goto LABEL_60;
}
a1->m_snapObject = v40;
LABEL_35:
if ( a1->m_findSnap )
{
m_snapObject = a1->m_snapObject;
if ( m_snapObject )
{
LABEL_40:
a1->m_snapObjectExists = 1;
v20 = (double *)((__int64 (__fastcall *)(GameObject *))m_snapObject->getPosition)(m_snapObject);
sub_1000229D0(&a1->m_snapPosition, v20);
LABEL_41:
sub_1000229D0(&a1->m_cameraTest, (double *)&v42.time);
if ( !a1->m_noSnapUndo )
{
UndoObject = EditorUI::createUndoObject(a1, Transform, 1);
sub_10033E710((__int64)a1, UndoObject);
}
LABEL_43:
if ( !a1->m_spaceSwiping )
{
if ( a1->m_swipeEnabled
|| (v22 = cocos2d::CCDirector::sharedDirector(),
*(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v22->getKeyboardDispatcher)(v22) + 88) == 1) )
{
if ( a1->m_selectedMode == 3 )
{
a1->m_swipeActive = 1;
sub_1000229D0(&a1->m_swipeEnd, (double *)&a1->m_swipeStart);
}
}
}
if ( a1->m_swipeEnabled )
{
v23 = 1;
}
else
{
v24 = cocos2d::CCDirector::sharedDirector();
v23 = *(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v24->getKeyboardDispatcher)(v24) + 88);
}
a1->m_swipeSelected = v23 & 1;
a1->m_continuousSnap = 0;
a1->m_touchID = a2->m_nId;
cocos2d::CCNode::stopActionByTag(a1, 123);
if ( !a1->m_swipeSelected )
{
v25 = GameManager::sharedState();
if ( GameManager::getGameVariable(v25, "0057") )
{
v26 = cocos2d::CCDelayTime::create(0.3);
v43.ptr = (void (*)(void))EditorUI::triggerSwipeMode;
v43.adj = 0;
v27 = (unsigned __int8)cocos2d::CCCallFunc::create(a1, v43);
v35 = sub_10018A494(v26, v28, v29, v30, v31, v32, v33, v34, v27);
((void (__fastcall *)(cocos2d::CCSequence *, __int64))v35->setTag)(v35, 123);
cocos2d::CCNode::runAction(a1, v35);
}
}
ftime(&v42);
v36 = (double)(v42.millitm + 1000 * (unsigned __int64)(v42.time & 0xFFFFF)) / 1000.0;
a1->m_keyTime2 = v36;
a1->m_keyTime = v36;
a1->m_swipeModeTriggered = 0;
return 1;
}
if ( (unsigned int)sub_10024A36C((__int64)a1->m_selectedObjects) )
{
sub_1000229B8(&v41, &v42.time);
v45.x = 0.0;
EditorUI::findSnapObject(a1, v45, v19);
}
}
m_snapObject = a1->m_snapObject;
if ( !m_snapObject )
goto LABEL_41;
goto LABEL_40;
}
LABEL_60:
if ( a1->m_snapObject || a1->m_selectedObject && a1->m_swipeEnabled )
goto LABEL_35;
}
a1->m_editingObject = 1;
v47.x = sub_1000229B8(&v41, (__int64 *)&a1->m_swipeStart);
EditorUI::clickOnPosition(a1, v47);
if ( a1->m_snapSelected )
a1->m_snapObject = a1->m_selectedObject;
goto LABEL_35;
}
return 0;
}