//
// EditorUI::onNewCustomItem from 0x6c47f0 to 0x6c4c3c (1100 bytes)
//
// 3 xrefs:
// > ??> @ 0x6f8b8
// > EditorUI::createCustomItems @ 0x6977f4
// > ??> @ 0x122bab8
//
// 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 EditorUI::onNewCustomItem(EditorUI *a1, cocos2d::CCObject *a2)
{
cocos2d::CCArray *m_selectedObjects; // x0
cocos2d::CCString *v4; // x0
char *CString; // x0
FLAlertLayer *v6; // x21
void *v7; // x0
char *v8; // x1
char *v9; // x0
GameManager *v10; // x0
GameObject *m_selectedObject; // x0
cocos2d::CCArray *v12; // x0
cocos2d::CCArray *v13; // x20
char *v14; // x1
unsigned int *v15; // x1
int v16; // w2
cocos2d::CCString *v17; // x0
char *v18; // x0
FLAlertLayer *v19; // x21
void *v20; // x0
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
GameManager *v26; // x24
unsigned int *v27; // x1
int v28; // w2
char *v29; // [xsp+58h] [xbp+58h] BYREF
__int64 v30; // [xsp+60h] [xbp+60h] BYREF
m_selectedObjects = a1->m_selectedObjects;
if ( m_selectedObjects && (unsigned int)cocos2d::CCArray::count(m_selectedObjects) > 0x3E8 )
{
v4 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"A custom object cannot contain more than %i objects.",
(const char *)&elf_hash_bucket[124]);
CString = (char *)cocos2d::CCString::getCString(v4);
sub_D153B8((int)&v29, CString);
sub_D153B8((int)&v30, v29);
v6 = FLAlertLayer::create(0, (__int64)"Max Limit", (__int64)&v30);
v7 = (void *)(v30 - 24);
if ( (__int64 *)(v30 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v30 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(_DWORD *)(v30 - 8);
*(_DWORD *)(v30 - 8) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v7);
}
v6->show(v6);
v8 = v29;
v9 = v29 - 24;
if ( v29 - 24 == (char *)&qword_124B6B0 )
return;
if ( &pthread_create )
{
v25 = (unsigned int *)(v29 - 8);
do
v22 = __ldaxr(v25);
while ( __stlxr(v22 - 1, v25) );
goto LABEL_32;
}
goto LABEL_34;
}
v10 = GameManager::sharedState();
if ( cocos2d::CCDictionary::count(v10->m_customObjectDict) > 0xC7 )
{
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"You cannot create more than %i custom objects.",
(const char *)&qword_C8);
v18 = (char *)cocos2d::CCString::getCString(v17);
sub_D153B8((int)&v29, v18);
sub_D153B8((int)&v30, v29);
v19 = FLAlertLayer::create(0, (__int64)"Max Custom Objects", (__int64)&v30);
v20 = (void *)(v30 - 24);
if ( (__int64 *)(v30 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v30 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *(_DWORD *)(v30 - 8);
*(_DWORD *)(v30 - 8) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v20);
}
v19->show(v19);
v8 = v29;
v9 = v29 - 24;
if ( v29 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v29 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
LABEL_32:
if ( v22 > 0 )
return;
goto LABEL_17;
}
LABEL_34:
v22 = *((_DWORD *)v8 - 2);
*((_DWORD *)v8 - 2) = v22 - 1;
goto LABEL_32;
}
}
else
{
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
goto LABEL_8;
if ( !(unsigned int)cocos2d::CCArray::count(a1->m_selectedObjects) )
return;
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
{
LABEL_8:
if ( m_selectedObject->m_objectID == 749 )
return;
}
v12 = (cocos2d::CCArray *)cocos2d::CCArray::count(a1->m_selectedObjects);
if ( (_DWORD)v12 )
{
v13 = a1->m_selectedObjects;
}
else
{
v13 = (cocos2d::CCArray *)cocos2d::CCArray::create(v12);
cocos2d::CCArray::addObject(v13, a1->m_selectedObject);
}
EditorUI::copyObjects((__int64 *)&v29, a1, v13, 0, 0);
v14 = v29;
if ( *((_QWORD *)v29 - 3) )
{
if ( (unsigned int)cocos2d::CCArray::count(a1->m_selectedObjects) <= 0x3E8 )
{
v26 = GameManager::sharedState();
sub_D18D28(&v30, &v29);
GameManager::addNewCustomObject(v26, (cocos2d::CCString *)&v30);
if ( (__int64 *)(v30 - 24) != &qword_124B6B0 )
sub_6865FC((void *)(v30 - 24));
a1->m_selectedObjectIndex = 0;
EditorUI::reloadCustomItems(a1);
v14 = v29;
}
else
{
v14 = v29;
}
}
v9 = v14 - 24;
if ( v14 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v14 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v14 - 2);
*((_DWORD *)v14 - 2) = v16 - 1;
}
if ( v16 <= 0 )
LABEL_17:
operator delete(v9);
}
}
}