//
// EditLevelLayer::textInputClosed from 0x1001fd5f0 to 0x1001fd88f (671 bytes)
//
// 2 xrefs:
// > sub_1001FD940 @ 0x1001fd94c
// > ??> @ 0x1008da808
//
// 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 EditLevelLayer::textInputClosed(EditLevelLayer *a1, CCTextInputNode *a2)
{
double v2; // xmm0_8
int v3; // eax
GJGameLevel *v4; // r14
GJGameLevel *m_level; // rbx
GameManager *v6; // rbx
std::string::pointer data; // rdi
char *v8; // r14
size_t v9; // rax
std::string::size_type v10; // r15
char *v11; // r12
size_t v12; // r13
std::string __str; // [rsp+0h] [rbp-E0h] BYREF
char *v14[2]; // [rsp+18h] [rbp-C8h] BYREF
char *__s; // [rsp+28h] [rbp-B8h]
std::string v16; // [rsp+30h] [rbp-B0h] BYREF
__int128 v17; // [rsp+50h] [rbp-90h] BYREF
char *v18; // [rsp+60h] [rbp-80h]
std::string v19; // [rsp+70h] [rbp-70h] BYREF
std::string __dst; // [rsp+88h] [rbp-58h] BYREF
__int128 v21; // [rsp+A0h] [rbp-40h] BYREF
void *v22; // [rsp+B0h] [rbp-30h]
v3 = ((__int64 (__fastcall *)(CCTextInputNode *))a2->getTag)(a2);
switch ( v3 )
{
case 3:
CCTextInputNode::getString(&v21, (__int64)a2, v2);
v6 = GameManager::sharedState();
if ( (v21 & 1) != 0 )
{
sub_100006B70(&v19, v22, *((unsigned __int64 *)&v21 + 1), v2);
}
else
{
v19.__r_.__value_.__r.__words[2] = (std::string::size_type)v22;
*(_OWORD *)&v19.__r_.__value_.__l.0 = v21;
}
std::string::operator=((std::string *)&v6->m_playerName, &v19);
if ( (*(_BYTE *)&v19.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_37;
data = v19.__r_.__value_.__l.__data_;
break;
case 2:
CCTextInputNode::getString(&v21, (__int64)a2, v2);
m_level = a1->m_level;
if ( (v21 & 1) != 0 )
{
sub_100006B70(&v17, v22, *((unsigned __int64 *)&v21 + 1), v2);
}
else
{
v18 = (char *)v22;
v17 = v21;
}
LevelTools::base64EncodeString(&__str, &v17);
std::string::operator=((std::string *)&m_level->m_levelDesc, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( (v17 & 1) == 0 )
goto LABEL_37;
data = v18;
break;
case 1:
CCTextInputNode::getString(&v21, (__int64)a2, v2);
v4 = a1->m_level;
if ( (v21 & 1) != 0 )
{
sub_100006B70(&v16, v22, *((unsigned __int64 *)&v21 + 1), v2);
}
else
{
v16.__r_.__value_.__r.__words[2] = (std::string::size_type)v22;
v2 = *(double *)&v21;
*(_OWORD *)&v16.__r_.__value_.__l.0 = v21;
}
std::string::operator=((std::string *)&v4->m_levelName, &v16);
if ( (*(_BYTE *)&v16.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v16.__r_.__value_.__l.__data_);
CCTextInputNode::getString(v14, (__int64)a2, v2);
if ( ((__int64)v14[0] & 1) != 0 )
v8 = __s;
else
v8 = (char *)v14 + 1;
v9 = strlen(v8);
if ( v9 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v10 = v9;
if ( v9 >= 0x17 )
{
v12 = 26;
if ( (v9 | 7) != 0x17 )
v12 = (v9 | 7) + 1;
v11 = (char *)operator new(v12);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)v11;
__dst.__r_.__value_.__r.__words[0] = v12 | 1;
__dst.__r_.__value_.__l.__size_ = v10;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v9);
v11 = __dst.__r_.__value_.__s.__data_;
if ( !v9 )
goto LABEL_32;
}
memmove(v11, v8, v10);
LABEL_32:
v11[v10] = 0;
CCTextInputNode::updateLabel(a2, &__dst, v2);
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
if ( ((__int64)v14[0] & 1) == 0 )
goto LABEL_37;
data = __s;
break;
default:
return;
}
operator delete(data);
LABEL_37:
if ( (v21 & 1) != 0 )
operator delete(v22);
}