//
// EditorUI::ccTouchBegan from 0x140123810 to 0x140123e8a (1658 bytes)
//
// 2 xrefs:
// > ??> @ 0x140552668
// > ??> @ 0x1406c99c0
//
// 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=1
bool EditorUI::ccTouchBegan(EditorUI *a1, cocos2d::CCTouch *a2, cocos2d::CCEvent *a3)
{
float v3; // xmm3_4
__int64 v7; // rcx
cocos2d::CCDirector *v8; // rax
struct cocos2d::CCPoint v9; // rax
struct cocos2d::CCPoint v10; // rax
char v11; // al
__m128d Myhead_low; // xmm0
CCMenuItemSpriteExtra *m_unlinkBtn; // rax
cocos2d::CCObject *v15; // rcx
unsigned int v16; // ebx
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
_BYTE *v20; // rsi
cocos2d::CCObject **p_m_unk3F0; // r14
__int64 v22; // rcx
__int64 v23; // rax
cocos2d::CCPoint v24; // rax
cocos2d::CCPoint v25; // rax
cocos2d::CCPoint v26; // rax
cocos2d::CCArray *v27; // rsi
struct cocos2d::CCObject *v28; // rax
cocos2d::CCPoint v29; // rax
cocos2d::CCPoint v30; // rax
cocos2d::CCObject *m_unk3F0; // rcx
__int64 v32; // rax
UndoCommand v33; // edx
UndoObject *UndoObject; // rax
cocos2d::CCKeypadDelegate_vtbl *v35; // rbx
__int64 v36; // rax
__int64 v37; // rax
bool v38; // al
GameManager *v39; // rcx
__int64 v40; // rbx
struct cocos2d::CCDelayTime *v41; // rax
struct cocos2d::CCSequence *v42; // rbx
cocos2d::ccColor3B *v43; // r8
struct cocos2d::CCPoint v44; // [rsp+20h] [rbp-28h] BYREF
struct cocos2d::CCPoint v45; // [rsp+50h] [rbp+8h] BYREF
cocos2d::CCPoint v46; // [rsp+68h] [rbp+20h] BYREF
if ( LODWORD(a1->cocos2d::CCLayer::cocos2d::CCMouseDelegate::__vftable) != -1
|| !((unsigned __int8 (__fastcall *)(cocos2d::CCScriptHandlerEntry *))a1->m_pScriptKeypadHandlerEntry->cocos2d::CCLayer::__vftable[4].encodeWithCoder)(a1->m_pScriptKeypadHandlerEntry)
|| !((unsigned __int8 (__fastcall *)(cocos2d::CCScriptHandlerEntry *, cocos2d::CCTouch *, cocos2d::CCEvent *))a1->m_pScriptKeypadHandlerEntry[5].~CCScriptHandlerEntry)(
&a1->m_pScriptKeypadHandlerEntry[5],
a2,
a3) )
{
if ( HIDWORD(a1->cocos2d::CCLayer::cocos2d::CCMouseDelegate::__vftable) == -1
&& (*(unsigned __int8 (__fastcall **)(_QWORD))(**(_QWORD **)&a1->m_uPreviousPriority + 328LL))(*(_QWORD *)&a1->m_uPreviousPriority)
&& (*(unsigned __int8 (__fastcall **)(__int64, cocos2d::CCTouch *, cocos2d::CCEvent *))(*(_QWORD *)(*(_QWORD *)&a1->m_uPreviousPriority + 320LL)
+ 8LL))(
*(_QWORD *)&a1->m_uPreviousPriority + 320LL,
a2,
a3) )
{
HIDWORD(a1->cocos2d::CCLayer::cocos2d::CCMouseDelegate::__vftable) = a2->m_nId;
return 1;
}
if ( *(_DWORD *)&a1->m_bMouseEnabled == -1
&& (*((unsigned __int8 (__fastcall **)(FLAlertLayerProtocol_vtbl *))a1->FLAlert_Clicked + 41))(a1->FLAlertLayerProtocol::__vftable)
&& (*((unsigned __int8 (__fastcall **)(FLAlertLayerProtocol_vtbl *, cocos2d::CCTouch *, cocos2d::CCEvent *))a1->FLAlertLayerProtocol::__vftable[40].FLAlert_Clicked
+ 1))(
a1->FLAlertLayerProtocol::__vftable + 40,
a2,
a3) )
{
*(_DWORD *)&a1->m_bMouseEnabled = a2->m_nId;
return 1;
}
cocos2d::CCTouch::getLocationInView(a2);
v8 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v7);
v9 = cocos2d::CCDirector::convertToGL(v8, &v46);
((void (__fastcall *)(_QWORD, _QWORD))cocos2d::CCPoint::operator=)(&v45, v9);
v10 = cocos2d::CCNode::convertToWorldSpace((EditorUI *)((char *)a1 - 320), &v44);
((void (__fastcall *)(_QWORD, _QWORD))cocos2d::CCPoint::operator=)(&v45, v10);
cocos2d::CCPoint::operator=(&a1->m_enableLinkBtn, &v45);
v11 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)&a1->m_isPlayingMusic + 328LL))(*(_QWORD *)&a1->m_isPlayingMusic);
Myhead_low = (__m128d)LODWORD(a1->m_objectEditorStates._List._Mypair._Myval2._Myhead);
if ( *(float *)Myhead_low.m128d_f64 > *((float *)&a1->m_enableLinkBtn + 1) )
{
if ( LODWORD(a1->m_unlinkBtn[4].m_fScaleX) == 1 && !v11 )
{
m_unlinkBtn = a1->m_unlinkBtn;
LABEL_18:
(*(void (__fastcall **)(__int64, cocos2d::CCTouch *, cocos2d::CCEvent *))(*(_QWORD *)(*((_QWORD *)&m_unlinkBtn[25].m_activateSound.m_data.m_bigStorage
+ 1)
+ 320LL)
+ 8LL))(
*((_QWORD *)&m_unlinkBtn[25].m_activateSound.m_data.m_bigStorage + 1) + 320LL,
a2,
a3);
return 1;
}
return 0;
}
m_unlinkBtn = a1->m_unlinkBtn;
if ( LODWORD(m_unlinkBtn[4].m_fScaleX) == 1 )
goto LABEL_18;
if ( *(_DWORD *)&a1->m_bTouchEnabled != -1 )
return 0;
v15 = (cocos2d::CCObject *)a1->cocos2d::CCLayer::cocos2d::CCKeypadDelegate::__vftable;
v16 = 0;
if ( v15 )
{
cocos2d::CCObject::release(v15);
a1->cocos2d::CCLayer::cocos2d::CCKeypadDelegate::__vftable = nullptr;
}
if ( LOBYTE(a1->cocos2d::CCLayer::cocos2d::CCKeyboardDelegate::__vftable)
|| (v17 = cocos2d::CCDirector::sharedDirector(v15),
*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v17 + 176LL))(v17) + 88))
|| !LOBYTE(a1->m_objectEditorStates._List._Mypair._Myval2._Mysize)
&& (v18 = cocos2d::CCDirector::sharedDirector(v15),
!*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v18 + 176LL))(v18) + 89))
&& (v19 = cocos2d::CCDirector::sharedDirector(v15),
!*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v19 + 176LL))(v19) + 91))
|| LODWORD(a1->m_linkBtn) != 3 )
{
LABEL_62:
if ( !LOBYTE(a1->cocos2d::CCLayer::cocos2d::CCKeyboardDelegate::__vftable) )
{
if ( BYTE4(a1->m_objectEditorStates._List._Mypair._Myval2._Myhead)
|| (v36 = cocos2d::CCDirector::sharedDirector(v15),
*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v36 + 176LL))(v36) + 88)) )
{
if ( LODWORD(a1->m_linkBtn) == 3 )
{
BYTE5(a1->m_objectEditorStates._List._Mypair._Myval2._Myhead) = 1;
cocos2d::CCPoint::operator=(&a1->m_undoBtn, &a1->m_enableLinkBtn);
}
}
}
v38 = true;
if ( !BYTE4(a1->m_objectEditorStates._List._Mypair._Myval2._Myhead) )
{
v37 = cocos2d::CCDirector::sharedDirector(v15);
if ( !*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v37 + 176LL))(v37) + 88) )
v38 = false;
}
BYTE6(a1->m_objectEditorStates._List._Mypair._Myval2._Myhead) = v38;
HIBYTE(a1->m_objectEditorStates._List._Mypair._Myval2._Myhead) = 0;
*(_DWORD *)&a1->m_bTouchEnabled = a2->m_nId;
cocos2d::CCNode::stopActionByTag((EditorUI *)((char *)a1 - 320), 123);
if ( !BYTE6(a1->m_objectEditorStates._List._Mypair._Myval2._Myhead) )
{
v39 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v45 = (struct cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v45);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v39 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getGameVariable(v39, "0057") )
{
v40 = cocos2d::CCCallFunc::create(&a1[-1].m_deleteButton, EditorUI::triggerSwipeMode);
Myhead_low = (__m128d)0x3E99999Au;
v41 = cocos2d::CCDelayTime::create(0.30000001);
v42 = cocos2d::CCSequence::create(v41, v40, 0);
v42->setTag(v42, 123);
cocos2d::CCNode::runAction((CCLightFlash *)&a1[-1].m_deleteButton, (cocos2d::CCPoint)v42, v43, v3, v44.x);
}
}
Myhead_low.m128d_f64[0] = sub_14003CF30();
*(__m128d *)&a1->m_pasteColorBtn = _mm_unpacklo_pd(Myhead_low, Myhead_low);
LOBYTE(a1->m_createButtonBars) = 0;
return 1;
}
v20 = (char *)&a1->m_objectEditorStates._List._Mypair._Myval2._Mysize + 2;
BYTE2(a1->m_objectEditorStates._List._Mypair._Myval2._Mysize) = 0;
p_m_unk3F0 = &a1->m_unk3F0;
a1->m_unk3F0 = nullptr;
cocos2d::CCNode::convertToNodeSpace(*(cocos2d::CCNode **)&a1->m_unlinkBtn[7].m_nScriptTapHandler, &v45);
v23 = cocos2d::CCDirector::sharedDirector(v22);
if ( *(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v23 + 176LL))(v23) + 90) )
{
if ( a1->m_editSpecialBtn )
{
LABEL_33:
EditorUI::onDuplicate((EditorUI *)((char *)a1 - 320), nullptr);
BYTE1(a1->cocos2d::CCLayer::cocos2d::CCKeyboardDelegate::__vftable) = 1;
p_m_unk3F0 = &a1->m_unk3F0;
goto LABEL_34;
}
if ( cocos2d::CCArray::count((cocos2d::CCArray *)a1->m_objectEditorStates._Mask) )
{
v20 = (char *)&a1->m_objectEditorStates._List._Mypair._Myval2._Mysize + 2;
goto LABEL_33;
}
}
LABEL_34:
BYTE2(a1->m_copyPasteBtn) = 0;
if ( cocos2d::CCArray::count((cocos2d::CCArray *)a1->m_objectEditorStates._Mask) )
{
cocos2d::CCPoint::CCPoint(&v46);
EditorUI::findSnapObject((EditorUI *)((char *)a1 - 320), v24, 0.0);
}
else if ( a1->m_editSpecialBtn )
{
cocos2d::CCPoint::CCPoint(&v46);
v27 = LevelEditorLayer::objectsAtPosition((LevelEditorLayer *)a1->m_unlinkBtn, v26);
if ( cocos2d::CCArray::count(v27) )
{
while ( 1 )
{
v28 = cocos2d::CCArray::objectAtIndex(v27, v16);
if ( v28[16].m_eObjType == HIDWORD(a1->m_editSpecialBtn[1].m_pSelectedImage) )
break;
if ( ++v16 >= cocos2d::CCArray::count(v27) )
goto LABEL_44;
}
a1->m_unk3F0 = v28;
}
LABEL_44:
if ( !a1->m_unk3F0 && (!a1->m_editSpecialBtn || !BYTE4(a1->m_objectEditorStates._List._Mypair._Myval2._Myhead)) )
{
BYTE2(a1->cocos2d::CCLayer::cocos2d::CCKeyboardDelegate::__vftable) = 1;
cocos2d::CCPoint::CCPoint(&v46);
EditorUI::clickOnPosition((EditorUI *)((char *)a1 - 320), v29);
if ( BYTE2(a1->m_objectEditorStates._List._Mypair._Myval2._Mysize) )
a1->m_unk3F0 = a1->m_editSpecialBtn;
}
}
else
{
BYTE2(a1->cocos2d::CCLayer::cocos2d::CCKeyboardDelegate::__vftable) = 1;
cocos2d::CCPoint::CCPoint(&v46);
EditorUI::clickOnPosition((EditorUI *)((char *)a1 - 320), v25);
if ( *v20 )
*p_m_unk3F0 = a1->m_editSpecialBtn;
}
if ( BYTE2(a1->m_copyPasteBtn)
&& !a1->m_unk3F0
&& cocos2d::CCArray::count((cocos2d::CCArray *)a1->m_objectEditorStates._Mask) )
{
cocos2d::CCPoint::CCPoint(&v46);
EditorUI::findSnapObject((EditorUI *)((char *)a1 - 320), v30, 0.0);
}
m_unk3F0 = a1->m_unk3F0;
if ( m_unk3F0 )
{
BYTE1(a1->m_objectEditorStates._List._Mypair._Myval2._Mysize) = 1;
v32 = ((__int64 (__fastcall *)(cocos2d::CCObject *))m_unk3F0->__vftable[2].getTag)(m_unk3F0);
cocos2d::CCPoint::operator=(&a1->m_objectEditorStates._Vec._Mypair._Myval2._Myend, v32);
}
cocos2d::CCPoint::operator=(&a1->m_editGroupBtn, &v45);
if ( !BYTE1(a1->cocos2d::CCLayer::cocos2d::CCKeyboardDelegate::__vftable) )
{
UndoObject = EditorUI::createUndoObject((EditorUI *)((char *)a1 - 320), v33, 1);
v35 = (cocos2d::CCKeypadDelegate_vtbl *)UndoObject;
if ( (UndoObject *)a1->cocos2d::CCLayer::cocos2d::CCKeypadDelegate::__vftable != UndoObject )
{
if ( UndoObject )
cocos2d::CCObject::retain(UndoObject);
v15 = (cocos2d::CCObject *)a1->cocos2d::CCLayer::cocos2d::CCKeypadDelegate::__vftable;
if ( v15 )
cocos2d::CCObject::release(v15);
a1->cocos2d::CCLayer::cocos2d::CCKeypadDelegate::__vftable = v35;
}
}
goto LABEL_62;
}
LODWORD(a1->cocos2d::CCLayer::cocos2d::CCMouseDelegate::__vftable) = a2->m_nId;
return 1;
}