//
// EditorUI::ccTouchBegan from 0x10004eeb0 to 0x10004f449 (1433 bytes)
//
// 2 xrefs:
// > sub_10004F4A0 @ 0x10004f4ac
// > ??> @ 0x1008b0478
//
// 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)
{
float v3; // xmm1_4
cocos2d::CCDirector *v7; // rax
_BYTE *UndoObject; // rsi
double v9; // xmm0_8
char v10; // al
LevelEditorLayer *m_editorLayer; // rcx
PlaybackMode m_playbackMode; // edx
UndoObject *m_undoObject; // rdi
cocos2d::CCDirector *v15; // rax
cocos2d::CCDirector *v16; // rax
cocos2d::CCDirector *v17; // rax
cocos2d::CCLayer *m_objectLayer; // rsi
cocos2d::CCDirector *v19; // rax
unsigned __int64 v20; // rsi
LevelEditorLayer *v21; // r12
cocos2d::CCPoint v22; // xmm0_8
cocos2d::CCArray *v23; // r12
unsigned int v24; // r13d
GameObject *m_selectedObject; // rax
cocos2d::CCPoint v26; // xmm0_8
GameObject *m_snapObject; // rdi
double v28; // xmm0_8
cocos2d::CCDirector *v29; // rax
char v30; // al
cocos2d::CCDirector *v31; // rax
GameManager *v32; // rax
unsigned int v33; // r14d
unsigned int v34; // eax
int v35; // ecx
int v36; // r8d
int v37; // r9d
cocos2d::CCAction *v38; // r14
double v39; // xmm0_8
timeb v40; // [rsp+0h] [rbp-40h] BYREF
_BYTE v41[48]; // [rsp+10h] [rbp-30h] BYREF
double v42; // 0:xmm0_8.8
if ( a1->m_rotationTouchID == -1
&& ((unsigned __int8 (__fastcall *)(GJRotationControl *))a1->m_rotationControl->isVisible)(a1->m_rotationControl)
&& ((unsigned __int8 (__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 __int8 (__fastcall *)(GJScaleControl *))a1->m_scaleControl->isVisible)(a1->m_scaleControl)
&& ((unsigned __int8 (__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 __int8 (__fastcall *)(GJTransformControl *))a1->m_transformControl->isVisible)(a1->m_transformControl)
&& ((unsigned __int8 (__fastcall *)(GJTransformControl *, cocos2d::CCTouch *, cocos2d::CCEvent *))a1->m_transformControl->ccTouchBegan)(
a1->m_transformControl,
a2,
a3) )
{
a1->m_transformTouchID = a2->m_nId;
return 1;
}
cocos2d::CCTouch::getLocationInView((cocos2d::CCTouch *)v41);
v7 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::convertToGL((cocos2d::CCDirector *)&v40, (const cocos2d::CCPoint *)v7);
sub_10028CC90();
cocos2d::CCNode::convertToWorldSpace((cocos2d::CCNode *)&v40, (const cocos2d::CCPoint *)a1);
sub_10028CC90();
UndoObject = v41;
v9 = sub_10028CC90();
v10 = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *, _BYTE *, double))a1->m_playbackBtn->isVisible)(
a1->m_playbackBtn,
v41,
v9);
m_editorLayer = a1->m_editorLayer;
m_playbackMode = m_editorLayer->m_playbackMode;
if ( a1->m_toolbarHeight > a1->m_swipeStart.y )
{
if ( v10 & 1 | (m_playbackMode != Playing) )
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_54;
v15 = cocos2d::CCDirector::sharedDirector();
if ( *(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v15->getKeyboardDispatcher)(v15) + 88) )
goto LABEL_54;
if ( !a1->m_freeMoveEnabled )
{
v16 = cocos2d::CCDirector::sharedDirector();
if ( !*(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v16->getKeyboardDispatcher)(v16) + 89) )
{
v17 = cocos2d::CCDirector::sharedDirector();
if ( *(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v17->getKeyboardDispatcher)(v17) + 91) != 1 )
goto LABEL_54;
}
}
if ( a1->m_selectedMode != 3 )
goto LABEL_54;
a1->m_snapSelected = 0;
a1->m_snapObject = nullptr;
m_objectLayer = a1->m_editorLayer->m_objectLayer;
*(cocos2d::CCPoint *)&v42 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)&v40,
(const cocos2d::CCPoint *)m_objectLayer);
v19 = cocos2d::CCDirector::sharedDirector();
if ( *(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *, double))v19->getKeyboardDispatcher)(v19, v42) + 90) == 1
&& (a1->m_selectedObject || (unsigned int)sub_100720070(a1->m_selectedObjects)) )
{
EditorUI::onDuplicate(a1, m_objectLayer);
a1->m_noSnapUndo = 1;
}
a1->m_findSnap = 0;
if ( (unsigned int)sub_100720070(a1->m_selectedObjects) )
{
sub_10028CC60(v41);
v20 = (unsigned __int64)v41;
EditorUI::findSnapObject(a1, 0, v3);
goto LABEL_46;
}
if ( a1->m_selectedObject )
{
v21 = a1->m_editorLayer;
*(double *)&v22 = sub_10028CC60(v41);
v20 = (unsigned __int64)v41;
v23 = LevelEditorLayer::objectsAtPosition(v21, v22);
if ( (unsigned int)sub_100720070(v23) )
{
v24 = 0;
while ( 1 )
{
v20 = v24;
m_selectedObject = (GameObject *)sub_1007200C0(v23, v24);
if ( m_selectedObject->m_uniqueID == a1->m_selectedObject->m_uniqueID )
break;
if ( ++v24 >= (unsigned int)sub_100720070(v23) )
goto LABEL_40;
}
LABEL_45:
a1->m_snapObject = m_selectedObject;
goto LABEL_46;
}
LABEL_40:
if ( a1->m_snapObject || a1->m_selectedObject && a1->m_swipeEnabled )
{
LABEL_46:
if ( a1->m_findSnap )
{
m_snapObject = a1->m_snapObject;
if ( m_snapObject )
{
LABEL_51:
a1->m_snapObjectExists = 1;
((void (__fastcall *)(GameObject *, unsigned __int64))m_snapObject->getPosition)(m_snapObject, v20);
sub_10028CC90();
LABEL_52:
UndoObject = &v40;
v28 = sub_10028CC90();
if ( !a1->m_noSnapUndo )
{
UndoObject = EditorUI::createUndoObject(a1, Transform, 1);
sub_10004F450(a1, UndoObject, v28);
}
LABEL_54:
if ( !a1->m_spaceSwiping )
{
if ( a1->m_swipeEnabled
|| (v29 = cocos2d::CCDirector::sharedDirector(),
*(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v29->getKeyboardDispatcher)(v29) + 88) == 1) )
{
if ( a1->m_selectedMode == 3 )
{
a1->m_swipeActive = 1;
UndoObject = &a1->m_swipeStart;
sub_10028CC90();
}
}
}
v30 = 1;
if ( !a1->m_swipeEnabled )
{
v31 = cocos2d::CCDirector::sharedDirector();
v30 = *(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *, _BYTE *))v31->getKeyboardDispatcher)(
v31,
UndoObject)
+ 88);
}
a1->m_swipeSelected = v30;
a1->m_continuousSnap = 0;
a1->m_touchID = a2->m_nId;
cocos2d::CCNode::stopActionByTag(a1, 123);
if ( !a1->m_swipeSelected )
{
v32 = GameManager::sharedState();
if ( GameManager::getGameVariable(v32, "0057") )
{
v33 = (unsigned int)cocos2d::CCDelayTime::create(0.30000001);
v34 = (unsigned int)cocos2d::CCCallFunc::create(
a1,
(cocos2d::SEL_CallFunc)(unsigned __int64)EditorUI::triggerSwipeMode);
v38 = (cocos2d::CCAction *)sub_1003B5760(v33, v34, 0, v35, v36, v37);
((void (__fastcall *)(cocos2d::CCAction *, __int64))v38->setTag)(v38, 123);
cocos2d::CCNode::runAction(a1, v38);
}
}
ftime(&v40);
v39 = (double)(v40.millitm + 1000 * (v40.time & 0xFFFFF)) / 1000.0;
a1->m_keyTime2 = v39;
a1->m_keyTime = v39;
a1->m_swipeModeTriggered = 0;
return 1;
}
if ( (unsigned int)sub_100720070(a1->m_selectedObjects) )
{
sub_10028CC60(v41);
v20 = (unsigned __int64)v41;
EditorUI::findSnapObject(a1, 0, v3);
}
}
m_snapObject = a1->m_snapObject;
if ( !m_snapObject )
goto LABEL_52;
goto LABEL_51;
}
}
a1->m_editingObject = 1;
*(double *)&v26 = sub_10028CC60(v41);
v20 = (unsigned __int64)v41;
EditorUI::clickOnPosition(a1, v26);
if ( !a1->m_snapSelected )
goto LABEL_46;
m_selectedObject = a1->m_selectedObject;
goto LABEL_45;
}
return 0;
}