//
// EditorUI::toggleSpecialEditButtons from 0x14011a9f0 to 0x14011ad2f (831 bytes)
//
// 3 xrefs:
// > EditorUI::updateButtons @ 0x1400e1f70
// > EditorUI::toggleEnableRotate @ 0x140110300
// > ??> @ 0x1406c948c
//
// 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=2
void EditorUI::toggleSpecialEditButtons(EditorUI *a1)
{
unsigned __int8 v2; // r14
unsigned int v3; // ebx
int v4; // edi
struct cocos2d::CCObject *v5; // rax
unsigned int m_uIndexInArray; // ecx
GameObject *m_selectedObject; // rax
unsigned int m_objectType; // ecx
int v9; // edi
int i; // ebp
int v11; // edx
cocos2d::CCString *v12; // rax
const char *CString; // rax
size_t v14; // r8
__int64 v15; // rdi
void *v16; // rcx
__int64 v17; // rax
_QWORD *v18; // rbx
__int16 *v19; // rdx
__int64 v20; // rcx
__int64 v21; // rcx
__int64 v22; // rcx
GameManager *v23; // rcx
__int16 v24; // [rsp+20h] [rbp-68h] BYREF
char v25; // [rsp+22h] [rbp-66h]
void *v26; // [rsp+30h] [rbp-58h]
__int128 v27; // [rsp+38h] [rbp-50h] BYREF
__int64 v28; // [rsp+48h] [rbp-40h]
unsigned __int64 v29; // [rsp+50h] [rbp-38h]
v2 = 0;
if ( cocos2d::CCArray::count(a1->m_selectedObjects) )
{
v2 = 1;
v3 = 0;
if ( cocos2d::CCArray::count(a1->m_selectedObjects) )
{
v4 = 35651585;
while ( 1 )
{
v5 = cocos2d::CCArray::objectAtIndex(a1->m_selectedObjects, v3);
m_uIndexInArray = v5[16].m_uIndexInArray;
if ( m_uIndexInArray <= 0x19 && _bittest(&v4, m_uIndexInArray) && !BYTE2(v5[21].m_nZOrder) )
break;
if ( ++v3 >= cocos2d::CCArray::count(a1->m_selectedObjects) )
goto LABEL_15;
}
v2 = 0;
}
}
else
{
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
{
m_objectType = m_selectedObject->m_objectType;
if ( m_objectType > 0x19 || (v9 = 35651585, !_bittest(&v9, m_objectType)) || m_selectedObject->m_isNoTouch )
v2 = 1;
}
}
LABEL_15:
for ( i = 0; i < 4; ++i )
{
switch ( i )
{
case 1:
v11 = 28;
break;
case 2:
v11 = 25;
break;
case 3:
v11 = 26;
break;
default:
v11 = 27;
break;
}
v12 = cocos2d::CCString::createWithFormat("%i", v11);
CString = cocos2d::CCString::getCString(v12);
v27 = 0;
v28 = 0;
v29 = 0;
v14 = -1;
do
++v14;
while ( CString[v14] );
sub_14003A930(&v27, CString, v14);
v15 = cocos2d::CCDictionary::objectForKey(a1->m_editButtonDict, &v27);
if ( v29 > 0xF )
{
v16 = (void *)v27;
if ( v29 + 1 >= 0x1000 )
{
v16 = *(void **)(v27 - 8);
if ( (unsigned __int64)(v27 - (_QWORD)v16 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v16);
}
v28 = 0;
v29 = 15;
LOBYTE(v27) = 0;
if ( v15 )
{
v17 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v15 + 936LL))(v15);
v18 = (_QWORD *)v17;
v19 = &word_140529A48;
if ( !v2 )
v19 = &word_140529A40;
v24 = *v19;
v25 = *((_BYTE *)v19 + 2);
v20 = *(_QWORD *)(v17 + 624);
if ( v20 )
(**(void (__fastcall ***)(__int64, __int16 *))(v20 + 368))(v20 + 368, &v24);
v21 = v18[79];
if ( v21 )
(**(void (__fastcall ***)(__int64, __int16 *))(v21 + 320))(v21 + 320, &v24);
v22 = v18[81];
if ( v22 || (v22 = v18[80]) != 0 )
(**(void (__fastcall ***)(__int64, __int16 *))(v22 + 320))(v22 + 320, &v24);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v15 + 920LL))(v15, v2);
}
}
if ( v2 )
{
v23 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v26 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v23 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getGameVariable(v23, "0007") )
EditorUI::activateRotationControl(a1, nullptr);
}
else
{
a1->m_rotationTouchID = -1;
if ( a1->m_rotationControl->isVisible(a1->m_rotationControl) )
{
a1->m_rotationControl->setVisible(a1->m_rotationControl, 0);
GJRotationControl::finishTouch(a1->m_rotationControl);
}
}
EditorUI::updateGridNodeSize(a1);
}