//
// EditorUI::updateCreateMenu from 0x10002e270 to 0x10002e73e (1230 bytes)
//
// 6 xrefs:
// > EditorUI::setupCreateMenu @ 0x10002a526
// > EditorUI::resetUI @ 0x10002a696
// > EditorUI::clickOnPosition @ 0x10002db48
// > EditorUI::orderUpCustomItem @ 0x1000315ca
// > EditorUI::orderDownCustomItem @ 0x100031687
// > EditorUI::onCreateButton @ 0x1000347f2
//
// 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 __fastcall EditorUI::updateCreateMenu(EditorUI *a1, bool a2)
{
bool v3; // zf
EditButtonBar *m_createButtonBar; // rdi
void (__cdecl *setVisible)(cocos2d::CCNode *__hidden, bool); // rax
cocos2d::CCArray *m_createButtonArray; // r15
unsigned int i; // r12d
int *v8; // r14
__int64 v9; // rax
__int64 v10; // rbx
__int64 v11; // rdi
__int64 v12; // r14
int v13; // eax
cocos2d::CCArray *m_customObjectButtonArray; // r15
unsigned int j; // r12d
int *v16; // r13
__int64 v17; // rax
__int64 v18; // rbx
__int64 v19; // rdi
__int64 v20; // r13
int v21; // eax
cocos2d::CCArray *v22; // r14
unsigned int v23; // ebx
_DWORD *v24; // rax
cocos2d::CCArray *v25; // r14
unsigned int v26; // ebx
_DWORD *v27; // rbx
__int64 v28; // rax
__int64 v29; // r14
__int64 v30; // rdi
_DWORD *v31; // rax
__int64 v32; // r14
_DWORD *v33; // rbx
EditorUI *v34; // [rsp+0h] [rbp-40h]
__int16 v35; // [rsp+10h] [rbp-30h] BYREF
char v36; // [rsp+12h] [rbp-2Eh]
__int16 v37; // [rsp+14h] [rbp-2Ch] BYREF
char v38; // [rsp+16h] [rbp-2Ah]
v3 = a1->m_selectedMode == 2;
m_createButtonBar = a1->m_createButtonBar;
setVisible = m_createButtonBar->setVisible;
if ( !v3 )
{
((void (__fastcall *)(EditButtonBar *, _QWORD))setVisible)(m_createButtonBar, 0);
((void (__fastcall *)(cocos2d::CCMenu *, _QWORD))a1->m_tabsMenu->setVisible)(a1->m_tabsMenu, 0);
return;
}
((void (__fastcall *)(EditButtonBar *, __int64))setVisible)(m_createButtonBar, 1);
((void (__fastcall *)(cocos2d::CCMenu *, __int64))a1->m_tabsMenu->setVisible)(a1->m_tabsMenu, 1);
v34 = a1;
m_createButtonArray = a1->m_createButtonArray;
if ( (unsigned int)sub_100720070(m_createButtonArray) )
{
for ( i = 0; i < (unsigned int)sub_100720070(m_createButtonArray); ++i )
{
v8 = (int *)sub_1007200C0(m_createButtonArray, i);
v9 = (*(__int64 (__fastcall **)(int *))(*(_QWORD *)v8 + 1056LL))(v8);
v10 = v9;
v11 = *(_QWORD *)(v9 + 640);
if ( v11 || (v11 = *(_QWORD *)(v9 + 648)) != 0 )
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v11 + 944LL))(v11, &unk_100815540);
if ( v8[132] < 0 )
continue;
v12 = *(_QWORD *)(v10 + 632);
v38 = -1;
v37 = -1;
if ( *(_DWORD *)(v12 + 1248) == 1 && GameObject::isColorObject((GameObject *)v12) && *(_BYTE *)(v12 + 1768) == 1 )
{
v38 = -1;
v37 = -14136;
goto LABEL_5;
}
v13 = *(_DWORD *)(v12 + 1028);
if ( v13 > 1583 )
{
if ( v13 != 2012 && v13 != 1584 )
{
LABEL_21:
if ( GameObject::getMainColorMode((GameObject *)v12) != 1010 )
goto LABEL_5;
}
}
else if ( (unsigned int)(v13 - 918) >= 2 && (unsigned int)(v13 - 1327) >= 2 )
{
goto LABEL_21;
}
v38 = 0;
v37 = 0;
LABEL_5:
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v12 + 1480LL))(v12, &v37);
v36 = -1;
v35 = -14136;
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v12 + 1080LL))(v12, &v35);
}
}
m_customObjectButtonArray = v34->m_customObjectButtonArray;
if ( (unsigned int)sub_100720070(m_customObjectButtonArray) )
{
for ( j = 0; j < (unsigned int)sub_100720070(m_customObjectButtonArray); ++j )
{
v16 = (int *)sub_1007200C0(m_customObjectButtonArray, j);
v17 = (*(__int64 (__fastcall **)(int *))(*(_QWORD *)v16 + 1056LL))(v16);
v18 = v17;
v19 = *(_QWORD *)(v17 + 640);
if ( v19 || (v19 = *(_QWORD *)(v17 + 648)) != 0 )
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v19 + 944LL))(v19, &unk_100815540);
if ( v16[132] < 0 )
continue;
v20 = *(_QWORD *)(v18 + 632);
v38 = -1;
v37 = -1;
if ( *(_DWORD *)(v20 + 1248) == 1 && GameObject::isColorObject((GameObject *)v20) && *(_BYTE *)(v20 + 1768) )
{
v38 = -1;
v37 = -14136;
goto LABEL_27;
}
v21 = *(_DWORD *)(v20 + 1028);
if ( v21 > 1583 )
{
if ( v21 != 2012 && v21 != 1584 )
{
LABEL_43:
if ( GameObject::getMainColorMode((GameObject *)v20) != 1010 )
goto LABEL_27;
}
}
else if ( (unsigned int)(v21 - 918) >= 2 && (unsigned int)(v21 - 1327) >= 2 )
{
goto LABEL_43;
}
v38 = 0;
v37 = 0;
LABEL_27:
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v20 + 1480LL))(v20, &v37);
v36 = -1;
v35 = -14136;
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v20 + 1080LL))(v20, &v35);
}
}
v22 = v34->m_createButtonArray;
if ( (unsigned int)sub_100720070(v22) )
{
v23 = 0;
while ( 1 )
{
v24 = (_DWORD *)sub_1007200C0(v22, v23);
if ( v24[132] == v34->m_selectedObjectIndex )
break;
if ( ++v23 >= (unsigned int)sub_100720070(v22) )
goto LABEL_49;
}
}
else
{
LABEL_49:
v25 = v34->m_customObjectButtonArray;
if ( !(unsigned int)sub_100720070(v25) )
return;
v26 = 0;
while ( 1 )
{
v24 = (_DWORD *)sub_1007200C0(v25, v26);
if ( v24[132] == v34->m_selectedObjectIndex )
break;
if ( ++v26 >= (unsigned int)sub_100720070(v25) )
return;
}
}
v27 = v24;
v28 = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)v24 + 1056LL))(v24);
v29 = v28;
v30 = *(_QWORD *)(v28 + 640);
if ( v30 || (v30 = *(_QWORD *)(v28 + 648)) != 0 )
{
v38 = 127;
v37 = 32639;
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v30 + 944LL))(v30, &v37);
}
v31 = v27;
if ( (int)v27[132] >= 0 )
{
v32 = *(_QWORD *)(v29 + 632);
v38 = 127;
v37 = 32639;
v36 = 127;
v35 = 25700;
if ( *(_DWORD *)(v32 + 1248) == 1 && GameObject::isColorObject((GameObject *)v32) && *(_BYTE *)(v32 + 1768) == 1 )
{
v38 = v36;
v37 = v35;
}
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v32 + 1480LL))(v32, &v37);
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v32 + 1080LL))(v32, &v35);
v31 = v27;
}
if ( a2 )
{
v33 = v31;
EditorUI::selectBuildTab(v34, v31[134]);
EditButtonBar::goToPage(v34->m_createButtonBar, v33[133]);
}
}