//
// IDNameBrowserPopup::onFormAdd from 0xce3c1c to 0xce3f08 (748 bytes)
//
// 3 xrefs:
// > ??> @ 0xde088
// > IDNameBrowserPopup::init @ 0xce3580
// > ??> @ 0x1546a80
//
// 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:06:38 +0000
//
__int64 __fastcall IDNameBrowserPopup::onFormAdd(IDNameBrowserPopup *this, cocos2d::CCObject *a2)
{
GameManager *v3; // x0
int FormID; // w22
CCTextInputNode *v5; // x0
GameManager *v6; // x1
__int64 v7; // x0
_BYTE *v8; // x21
__int64 v9; // x20
_BYTE *v10; // x20
_BYTE *v11; // x1
const char *v12; // x1
LevelSettingsObject *v14; // x21
int IDByName; // w0
_QWORD *v16; // x21
__int64 v17; // [xsp+40h] [xbp+40h] BYREF
__int64 v18; // [xsp+48h] [xbp+48h]
void *v19; // [xsp+50h] [xbp+50h]
GameManager *v20[3]; // [xsp+58h] [xbp+58h] BYREF
__int64 v21[2]; // [xsp+70h] [xbp+70h] BYREF
void *v22; // [xsp+80h] [xbp+80h]
char s[64]; // [xsp+88h] [xbp+88h] BYREF
v3 = *(GameManager **)(GameManager::sharedState(_stack_chk_guard) + 552);
if ( !v3 || !*(_QWORD *)(*(_QWORD *)(GameManager::sharedState(v3) + 552) + 3272LL) )
return _stack_chk_guard;
FormID = IDNameBrowserPopup::getFormID(this);
if ( FormID <= 0 )
{
(*(void (__fastcall **)(_QWORD, const char *))(**((_QWORD **)this + 91) + 928LL))(
*((_QWORD *)this + 91),
"Enter a valid ID");
return _stack_chk_guard;
}
v5 = *((CCTextInputNode **)this + 90);
if ( v5 )
{
CCTextInputNode::getString(v5, &v17);
}
else
{
v17 = 0;
v18 = 0;
v19 = nullptr;
std::string::__init(&v17, &byte_11B8890, 0);
}
LevelSettingsObject::sanitizeIDName((char *)&v17, (__int64 *)v20);
v6 = (GameManager *)(LOBYTE(v20[0]) >> 1);
if ( ((__int64)v20[0] & 1) != 0 )
v6 = v20[1];
if ( v6 )
{
v14 = *(LevelSettingsObject **)(*(_QWORD *)(GameManager::sharedState((GameManager *)LOBYTE(v20[0])) + 552) + 3272LL);
IDByName = LevelSettingsObject::findIDByName(v14, (__int64)v20, *((_DWORD *)this + 169));
if ( FormID == IDByName || IDByName <= 0 )
{
LevelSettingsObject::setIDName((unsigned __int64)v14, FormID, (char *)v20, *((_DWORD *)this + 169));
LevelSettingsObject::touchIDUsage(v14, FormID, *((_DWORD *)this + 169));
v16 = *((_QWORD **)this + 90);
if ( v16 )
{
v21[0] = 0;
v21[1] = 0;
v22 = nullptr;
std::string::__init(v21, &byte_11B8890, 0);
CCTextInputNode::setString(v16, (char *)v21);
if ( (v21[0] & 1) != 0 )
operator delete(v22);
}
IDNameBrowserPopup::setFormID(this, 0);
IDNameBrowserPopup::rebuildList(this);
IDNameBrowserPopup::updateConflictLabel(this);
}
else
{
snprintf(s, 0x40u, "Name used by ID %d", IDByName);
(*(void (__fastcall **)(_QWORD, char *))(**((_QWORD **)this + 91) + 928LL))(*((_QWORD *)this + 91), s);
}
goto LABEL_19;
}
v7 = *((_QWORD *)this + 91);
if ( (v17 & 1) != 0 )
{
v8 = v19;
v9 = v18;
}
else
{
v9 = (unsigned __int8)v17 >> 1;
v8 = (char *)&v17 + 1;
}
if ( v9 )
{
v10 = &v8[v9];
if ( v10 != v8 )
{
v11 = v8;
if ( *v8 != 32 )
{
LABEL_34:
v12 = "Name needs a letter";
goto LABEL_18;
}
while ( v10 != ++v11 )
{
if ( *v11 != 32 )
{
if ( v11 - v8 == -1 )
break;
goto LABEL_34;
}
}
}
}
v12 = "Enter a name";
LABEL_18:
(*(void (__fastcall **)(__int64, const char *))(*(_QWORD *)v7 + 928LL))(v7, v12);
LABEL_19:
if ( ((__int64)v20[0] & 1) != 0 )
operator delete(v20[2]);
if ( (v17 & 1) != 0 )
operator delete(v19);
return _stack_chk_guard;
}