//
// EditorUI::onNewCustomItem from 0xbdff6c to 0xbe02d4 (872 bytes)
//
// 4 xrefs:
// > EditorUI::handleEditorAction @ 0xbd7588
// > ??> @ 0x964c0
// > EditorUI::createCustomItems @ 0xbdfd1c
// > ??> @ 0x1544140
//
// 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 13:03:45 +0000
//
__int64 __fastcall EditorUI::onNewCustomItem(EditorUI *this, cocos2d::CCObject *a2)
{
cocos2d::CCArray *v3; // x0
cocos2d::CCString *v4; // x0
size_t v5; // x0
const char *v6; // x1
size_t v7; // x0
__int64 v8; // x20
__int64 v10; // x0
__int64 v11; // x0
cocos2d::CCArray *v12; // x0
cocos2d::CCArray *v13; // x21
GameManager *v14; // x0
__int64 v15; // x23
char *v16; // x20
cocos2d::CCString *v17; // x0
const char *v18; // x0
size_t v19; // x0
size_t v20; // x0
char *CString; // [xsp+48h] [xbp+48h]
char *v22; // [xsp+48h] [xbp+48h]
char *v23; // [xsp+48h] [xbp+48h]
__int64 v24; // [xsp+58h] [xbp+58h] BYREF
size_t v25; // [xsp+60h] [xbp+60h]
void *v26; // [xsp+68h] [xbp+68h]
__int64 v27; // [xsp+70h] [xbp+70h] BYREF
size_t v28; // [xsp+78h] [xbp+78h]
void *v29; // [xsp+80h] [xbp+80h]
v3 = *((cocos2d::CCArray **)this + 112);
if ( v3 )
{
v3 = (cocos2d::CCArray *)cocos2d::CCArray::count(v3);
if ( (unsigned int)v3 > 0x3E8 )
{
v4 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"A custom object cannot contain more than %i objects.",
(const char *)&elf_hash_bucket[124]);
v24 = 0;
CString = (char *)cocos2d::CCString::getCString(v4);
v25 = 0;
v26 = nullptr;
v5 = strlen(CString);
std::string::__init(&v24, CString, v5);
v6 = (char *)&v24 + 1;
if ( (v24 & 1) != 0 )
v6 = (const char *)v26;
v22 = (char *)v6;
v27 = 0;
v28 = 0;
v29 = nullptr;
v7 = strlen(v6);
std::string::__init(&v27, v22, v7);
v8 = FLAlertLayer::create(
0,
(cocos2d::CCLabelBMFont *)"Max Limit",
(char *)&v27,
(ButtonSprite *)"OK",
nullptr,
340.0);
if ( (v27 & 1) != 0 )
operator delete(v29);
LABEL_7:
(*(void (__fastcall **)(__int64))(*(_QWORD *)v8 + 1312LL))(v8);
goto LABEL_8;
}
}
v10 = GameManager::sharedState(v3);
if ( (unsigned int)cocos2d::CCDictionary::count(*(cocos2d::CCDictionary **)(v10 + 456)) > 0xC7 )
{
v16 = (char *)&v24 + 1;
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"You cannot create more than %i custom objects.",
(const char *)&qword_C8);
v18 = (const char *)cocos2d::CCString::getCString(v17);
v24 = 0;
v23 = (char *)v18;
v25 = 0;
v26 = nullptr;
v19 = strlen(v18);
std::string::__init(&v24, v23, v19);
if ( (v24 & 1) != 0 )
v16 = (char *)v26;
v27 = 0;
v28 = 0;
v29 = nullptr;
v20 = strlen(v16);
std::string::__init(&v27, v16, v20);
v8 = FLAlertLayer::create(
0,
(cocos2d::CCLabelBMFont *)"Max Custom Objects",
(char *)&v27,
(ButtonSprite *)"OK",
nullptr,
340.0);
if ( (v27 & 1) != 0 )
operator delete(v29);
goto LABEL_7;
}
v11 = *((_QWORD *)this + 187);
if ( !v11 )
{
if ( !(unsigned int)cocos2d::CCArray::count(*((cocos2d::CCArray **)this + 112)) )
return _stack_chk_guard;
v11 = *((_QWORD *)this + 187);
if ( !v11 )
goto LABEL_13;
}
if ( *(_DWORD *)(v11 + 1028) != 749 )
{
LABEL_13:
v12 = (cocos2d::CCArray *)cocos2d::CCArray::count(*((cocos2d::CCArray **)this + 112));
if ( (_DWORD)v12 )
{
v13 = *((cocos2d::CCArray **)this + 112);
}
else
{
v13 = (cocos2d::CCArray *)cocos2d::CCArray::create(v12);
cocos2d::CCArray::addObject(v13, *((cocos2d::CCObject **)this + 187));
}
EditorUI::copyObjects(&v24, this, v13, 0, 0);
if ( (v24 & 1) != 0 )
{
if ( !v25 )
goto LABEL_24;
}
else if ( !((int)(unsigned __int8)v24 >> 1) )
{
return _stack_chk_guard;
}
v14 = (GameManager *)cocos2d::CCArray::count(*((cocos2d::CCArray **)this + 112));
if ( (unsigned int)v14 <= 0x3E8 )
{
v15 = GameManager::sharedState(v14);
v27 = 0;
v28 = 0;
v29 = nullptr;
if ( (v24 & 1) != 0 )
{
std::string::__init(&v27, v26, v25);
}
else
{
v29 = v26;
v27 = v24;
v28 = v25;
}
GameManager::addNewCustomObject(v15, (__int64)&v27);
if ( (v27 & 1) != 0 )
operator delete(v29);
*((_DWORD *)this + 336) = 0;
EditorUI::reloadCustomItems((EditButtonBar **)this);
}
LABEL_8:
if ( (v24 & 1) == 0 )
return _stack_chk_guard;
LABEL_24:
operator delete(v26);
}
return _stack_chk_guard;
}