//
// EditorUI::onNewCustomItem from 0x10063c3d0 to 0x10063c89a (1226 bytes)
//
// 2 xrefs:
// > EditorUI::handleEditorAction @ 0x10060cc80
// > EditorUI::createCustomItems @ 0x100638774
//
// This function is hookable on this platform (idp: pc, 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 12:34:41 +0000
//
void __fastcall EditorUI::onNewCustomItem(__int64 a1, double a2)
{
__int64 v3; // rdi
__int64 v4; // rax
const char *CString; // r14
size_t v6; // rax
std::string::size_type v7; // rbx
char *data; // r15
const char *v9; // rbx
__int64 v10; // rax
__int64 v11; // rax
const char *v12; // r14
size_t v13; // rax
std::string::size_type v14; // rbx
char *v15; // r15
const char *v16; // rbx
__int64 v17; // rax
__int64 v18; // rdi
__int64 v19; // r14
size_t v20; // r12
size_t v21; // rax
size_t v22; // r14
char *v23; // r15
size_t v24; // r12
char *v25; // rbx
size_t v26; // r12
size_t v27; // rax
size_t v28; // r14
char *v29; // r15
size_t v30; // r12
char *v31; // rbx
__int64 v32; // r14
__int64 v33; // rax
unsigned int IntGameVariable; // r14d
__int64 v35; // rax
unsigned int v36; // r15d
__int64 v37; // r12
__int64 CustomItems; // rax
__int128 v39; // [rsp+0h] [rbp-80h] BYREF
void *v40; // [rsp+10h] [rbp-70h]
_QWORD v41[2]; // [rsp+18h] [rbp-68h] BYREF
void *v42; // [rsp+28h] [rbp-58h]
_QWORD v43[2]; // [rsp+30h] [rbp-50h] BYREF
void *__p; // [rsp+40h] [rbp-40h]
std::string __dst[2]; // [rsp+48h] [rbp-38h] BYREF
v3 = *(_QWORD *)(a1 + 896);
if ( v3 && (unsigned int)sub_1007FEF90(v3) >= 0x3E9 )
{
v4 = sub_10088E820("A custom object cannot contain more than %i objects.", v39);
CString = (const char *)cocos2d::CCString::getCString(v4);
v6 = strlen(CString);
if ( v6 < 0xFFFFFFFFFFFFFFF8LL )
{
v7 = v6;
if ( v6 >= 0x17 )
{
v26 = 26;
if ( (v6 | 7) != 0x17 )
v26 = (v6 | 7) + 1;
data = (char *)operator new(v26);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst[0].__r_.__value_.__r.__words[0] = v26 + 1;
__dst[0].__r_.__value_.__l.__size_ = v7;
}
else
{
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v6);
data = __dst[0].__r_.__value_.__s.__data_;
if ( !v6 )
{
__dst[0].__r_.__value_.__s.__data_[0] = 0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
{
LABEL_7:
v9 = __dst[0].__r_.__value_.__l.__data_;
goto LABEL_39;
}
LABEL_38:
v9 = __dst[0].__r_.__value_.__s.__data_;
LABEL_39:
v27 = strlen(v9);
if ( v27 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v28 = v27;
if ( v27 >= 0x17 )
{
v30 = 26;
if ( (v27 | 7) != 0x17 )
v30 = (v27 | 7) + 1;
v29 = (char *)operator new(v30);
v42 = v29;
v41[0] = v30 | 1;
v41[1] = v28;
}
else
{
LOBYTE(v41[0]) = 2 * v27;
v29 = (char *)v41 + 1;
if ( !v27 )
goto LABEL_47;
}
memmove(v29, v9, v28);
LABEL_47:
v29[v28] = 0;
v31 = FLAlertLayer::create_1(0, (int)"Max Limit", (__int64)v41, (int)"OK", 0, 340.0);
if ( (v41[0] & 1) != 0 )
operator delete(v42);
(*(void (__fastcall **)(char *))(*(_QWORD *)v31 + 1312LL))(v31);
goto LABEL_50;
}
}
memmove(data, CString, v7);
data[v7] = 0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_7;
goto LABEL_38;
}
LABEL_68:
sub_100003630();
}
v10 = GameManager::sharedState();
if ( (unsigned int)cocos2d::CCDictionary::count(*(_QWORD *)(v10 + 456)) >= 0xC8 )
{
v11 = sub_10088E820("You cannot create more than %i custom objects.", v39);
v12 = (const char *)cocos2d::CCString::getCString(v11);
v13 = strlen(v12);
if ( v13 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_68;
v14 = v13;
if ( v13 >= 0x17 )
{
v20 = 26;
if ( (v13 | 7) != 0x17 )
v20 = (v13 | 7) + 1;
v15 = (char *)operator new(v20);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)v15;
__dst[0].__r_.__value_.__r.__words[0] = v20 + 1;
__dst[0].__r_.__value_.__l.__size_ = v14;
}
else
{
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v13);
v15 = __dst[0].__r_.__value_.__s.__data_;
if ( !v13 )
{
__dst[0].__r_.__value_.__s.__data_[0] = 0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
{
LABEL_13:
v16 = __dst[0].__r_.__value_.__l.__data_;
goto LABEL_23;
}
LABEL_22:
v16 = __dst[0].__r_.__value_.__s.__data_;
LABEL_23:
v21 = strlen(v16);
if ( v21 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v22 = v21;
if ( v21 >= 0x17 )
{
v24 = 26;
if ( (v21 | 7) != 0x17 )
v24 = (v21 | 7) + 1;
v23 = (char *)operator new(v24);
__p = v23;
v43[0] = v24 | 1;
v43[1] = v22;
}
else
{
LOBYTE(v43[0]) = 2 * v21;
v23 = (char *)v43 + 1;
if ( !v21 )
goto LABEL_31;
}
memmove(v23, v16, v22);
LABEL_31:
v23[v22] = 0;
v25 = FLAlertLayer::create_1(0, (int)"Max Custom Objects", (__int64)v43, (int)"OK", 0, 340.0);
if ( (v43[0] & 1) != 0 )
operator delete(__p);
(*(void (__fastcall **)(char *))(*(_QWORD *)v25 + 1312LL))(v25);
goto LABEL_50;
}
}
memmove(v15, v12, v14);
v15[v14] = 0;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_13;
goto LABEL_22;
}
v17 = *(_QWORD *)(a1 + 1496);
if ( v17 )
goto LABEL_15;
if ( !(unsigned int)sub_1007FEF90(*(_QWORD *)(a1 + 896)) )
return;
v17 = *(_QWORD *)(a1 + 1496);
if ( v17 )
{
LABEL_15:
if ( *(_DWORD *)(v17 + 1028) == 749 )
return;
}
v18 = *(_QWORD *)(a1 + 896);
if ( (unsigned int)sub_1007FEF90(v18) )
{
v19 = *(_QWORD *)(a1 + 896);
}
else
{
v19 = sub_1007FE900(v18);
sub_1007FEBF0(v19, *(_QWORD *)(a1 + 1496));
}
EditorUI::copyObjects(__dst, a1, v19, 0, 0);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
{
if ( !(*(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1) )
goto LABEL_50;
LABEL_61:
if ( (unsigned int)sub_1007FEF90(*(_QWORD *)(a1 + 896)) <= 0x3E8 )
{
v32 = GameManager::sharedState();
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
{
sub_10001AD30(&v39, __dst[0].__r_.__value_.__l.__data_, __dst[0].__r_.__value_.__l.__size_);
}
else
{
v40 = __dst[0].__r_.__value_.__l.__data_;
a2 = *(double *)__dst[0].__r_.__value_.__r.__words;
v39 = *(_OWORD *)&__dst[0].__r_.__value_.__l.0;
}
GameManager::addNewCustomObject(v32, (__int64)&v39);
if ( (v39 & 1) != 0 )
operator delete(v40);
*(_DWORD *)(a1 + 1344) = 0;
v33 = GameManager::sharedState();
IntGameVariable = GameManager::getIntGameVariable(v33, "0049");
v35 = GameManager::sharedState();
v36 = GameManager::getIntGameVariable(v35, "0050");
v37 = *(_QWORD *)(a1 + 624);
CustomItems = EditorUI::createCustomItems(a1, a2);
EditButtonBar::loadFromItems(v37, CustomItems, IntGameVariable, v36, 1);
}
goto LABEL_50;
}
if ( __dst[0].__r_.__value_.__l.__size_ )
goto LABEL_61;
LABEL_50:
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
}