//
// EditorUI::onNewCustomItem from 0x100187c6c to 0x100187ed4 (616 bytes)
//
// 2 xrefs:
// > EditorUI::handleEditorAction @ 0x1001635f4
// > EditorUI::createCustomItems @ 0x100184a7c
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 10:59:51 +0000
//
void __fastcall EditorUI::onNewCustomItem(__int64 a1)
{
__int64 v2; // x0
__int64 v3; // x0
char *CString; // x0
char *v5; // x1
__int64 v6; // x19
__int64 v7; // x0
__int64 v8; // x0
char *v9; // x0
char *v10; // x1
__int64 v11; // x19
__int64 v12; // x8
__int64 v13; // x0
__n128 v14; // q0
__int64 v15; // x20
__int64 v16; // x8
__int64 v17; // x0
__int64 v18; // x20
void *__dst[2]; // [xsp+10h] [xbp-70h] BYREF
__int64 v20; // [xsp+20h] [xbp-60h]
void *v21[2]; // [xsp+28h] [xbp-58h] BYREF
char v22; // [xsp+3Fh] [xbp-41h]
void *__p[2]; // [xsp+40h] [xbp-40h] BYREF
char v24; // [xsp+57h] [xbp-29h]
__int128 v25; // [xsp+58h] [xbp-28h] BYREF
__int64 v26; // [xsp+68h] [xbp-18h]
v2 = *(_QWORD *)(a1 + 896);
if ( v2 && (v2 = sub_1002E757C(v2), (unsigned int)v2 >= 0x3E9) )
{
v3 = sub_1003065B0("A custom object cannot contain more than %i objects.", 1000);
CString = (char *)cocos2d::CCString::getCString(v3);
sub_100009900(&v25, CString);
if ( v26 >= 0 )
v5 = (char *)&v25;
else
v5 = (char *)v25;
sub_100009900(__p, v5);
v6 = FLAlertLayer::create_1(0, "Max Limit", __p, "OK", 0, 340.0);
if ( v24 < 0 )
operator delete(__p[0]);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v6 + 1312LL))(v6);
}
else
{
v7 = GameManager::sharedState(v2);
if ( (unsigned int)cocos2d::CCDictionary::count(*(_QWORD *)(v7 + 456)) < 0xC8 )
{
v12 = *(_QWORD *)(a1 + 1496);
if ( v12 )
goto LABEL_19;
if ( !(unsigned int)sub_1002E757C(*(_QWORD *)(a1 + 896)) )
return;
v12 = *(_QWORD *)(a1 + 1496);
if ( v12 )
{
LABEL_19:
if ( *(_DWORD *)(v12 + 1028) == 749 )
return;
}
v13 = sub_1002E757C(*(_QWORD *)(a1 + 896));
if ( (_DWORD)v13 )
{
v15 = *(_QWORD *)(a1 + 896);
}
else
{
v15 = sub_1002E736C(v13);
v14 = sub_1002E74E0(v15, *(_QWORD *)(a1 + 1496));
}
EditorUI::copyObjects(&v25, a1, v15, 0, 0, v14);
v16 = HIBYTE(v26);
if ( v26 < 0 )
v16 = *((_QWORD *)&v25 + 1);
if ( v16 )
{
v17 = sub_1002E757C(*(_QWORD *)(a1 + 896));
if ( (unsigned int)v17 <= 0x3E8 )
{
v18 = GameManager::sharedState(v17);
if ( SHIBYTE(v26) < 0 )
{
sub_1000097D0(__dst, (void *)v25, *((unsigned __int64 *)&v25 + 1));
}
else
{
*(_OWORD *)__dst = v25;
v20 = v26;
}
GameManager::addNewCustomObject(v18, __dst);
if ( SHIBYTE(v20) < 0 )
operator delete(__dst[0]);
*(_DWORD *)(a1 + 1344) = 0;
EditorUI::reloadCustomItems(a1);
}
}
}
else
{
v8 = sub_1003065B0("You cannot create more than %i custom objects.", 200);
v9 = (char *)cocos2d::CCString::getCString(v8);
sub_100009900(&v25, v9);
if ( v26 >= 0 )
v10 = (char *)&v25;
else
v10 = (char *)v25;
sub_100009900(v21, v10);
v11 = FLAlertLayer::create_1(0, "Max Custom Objects", v21, "OK", 0, 340.0);
if ( v22 < 0 )
operator delete(v21[0]);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v11 + 1312LL))(v11);
}
}
if ( SHIBYTE(v26) < 0 )
operator delete((void *)v25);
}