//
// EditorUI::onNewCustomItem from 0x1003e849c to 0x1003e8704 (616 bytes)
//
// 1 xrefs:
// > EditorUI::createCustomItems @ 0x1003e8de4
//
// 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::onNewCustomItem(EditorUI *a1, cocos2d::CCObject *a2)
{
cocos2d::CCArray *m_selectedObjects; // x0
cocos2d::CCString *v4; // x0
char *CString; // x0
char *v6; // x1
FLAlertLayer *v7; // x19
GameManager *v8; // x0
cocos2d::CCString *v9; // x0
char *v10; // x0
char *v11; // x1
FLAlertLayer *v12; // x19
GameObject *m_selectedObject; // x8
cocos2d::CCArray *v14; // x20
__int64 v15; // x8
GameManager *v16; // x20
void *__dst[2]; // [xsp+10h] [xbp-70h] BYREF
__int64 v18; // [xsp+20h] [xbp-60h]
void *v19[2]; // [xsp+28h] [xbp-58h] BYREF
char v20; // [xsp+3Fh] [xbp-41h]
void *__p[2]; // [xsp+40h] [xbp-40h] BYREF
char v22; // [xsp+57h] [xbp-29h]
__int128 v23; // [xsp+58h] [xbp-28h] BYREF
__int64 v24; // [xsp+68h] [xbp-18h]
m_selectedObjects = a1->m_selectedObjects;
if ( m_selectedObjects && (unsigned int)sub_10024A36C((__int64)m_selectedObjects) >= 0x3E9 )
{
v4 = (cocos2d::CCString *)sub_100268F4C("A custom object cannot contain more than %i objects.", 1000);
CString = (char *)cocos2d::CCString::getCString(v4);
sub_100009900(&v23, CString);
if ( v24 >= 0 )
v6 = (char *)&v23;
else
v6 = (char *)v23;
sub_100009900(__p, v6);
v7 = FLAlertLayer::create_1(0, (__int64)"Max Limit", (__int64)__p, (__int64)"OK", 0, 340.0);
if ( v22 < 0 )
operator delete(__p[0]);
((void (__fastcall *)(FLAlertLayer *))v7->show)(v7);
}
else
{
v8 = GameManager::sharedState();
if ( cocos2d::CCDictionary::count(v8->m_customObjectDict) < 0xC8 )
{
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
goto LABEL_19;
if ( !(unsigned int)sub_10024A36C((__int64)a1->m_selectedObjects) )
return;
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
{
LABEL_19:
if ( m_selectedObject->m_objectID == 749 )
return;
}
if ( (unsigned int)sub_10024A36C((__int64)a1->m_selectedObjects) )
{
v14 = a1->m_selectedObjects;
}
else
{
v14 = (cocos2d::CCArray *)sub_10024A15C();
sub_10024A2D0((__int64)v14);
}
EditorUI::copyObjects(&v23, a1, v14, 0, 0);
v15 = HIBYTE(v24);
if ( v24 < 0 )
v15 = *((_QWORD *)&v23 + 1);
if ( v15 && (unsigned int)sub_10024A36C((__int64)a1->m_selectedObjects) <= 0x3E8 )
{
v16 = GameManager::sharedState();
if ( SHIBYTE(v24) < 0 )
{
sub_1000097D0(__dst, (void *)v23, *((unsigned __int64 *)&v23 + 1));
}
else
{
*(_OWORD *)__dst = v23;
v18 = v24;
}
GameManager::addNewCustomObject(v16, (__int128 *)__dst);
if ( SHIBYTE(v18) < 0 )
operator delete(__dst[0]);
a1->m_selectedObjectIndex = 0;
EditorUI::reloadCustomItems(a1);
}
}
else
{
v9 = (cocos2d::CCString *)sub_100268F4C("You cannot create more than %i custom objects.", 200);
v10 = (char *)cocos2d::CCString::getCString(v9);
sub_100009900(&v23, v10);
if ( v24 >= 0 )
v11 = (char *)&v23;
else
v11 = (char *)v23;
sub_100009900(v19, v11);
v12 = FLAlertLayer::create_1(0, (__int64)"Max Custom Objects", (__int64)v19, (__int64)"OK", 0, 340.0);
if ( v20 < 0 )
operator delete(v19[0]);
((void (__fastcall *)(FLAlertLayer *))v12->show)(v12);
}
}
if ( SHIBYTE(v24) < 0 )
operator delete((void *)v23);
}