//
// EditorSoundBrowserLayer::setTextPopupClosed from 0x1004cdedc to 0x1004ce0d4 (504 bytes)
//
// 2 xrefs:
// > sub_1004CE108 @ 0x1004ce10c
// > ??> @ 0x100988168
//
// 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 11:06:27 +0000
//
void __fastcall EditorSoundBrowserLayer::setTextPopupClosed(__int64 a1, int a2, std::string *__str)
{
int v5; // w21
int v6; // w8
__int64 v7; // x10
std::string::size_type v8; // x8
std::string *v9; // x10
std::string::size_type size; // x11
int v11; // w9
__int64 v12; // x0
__int64 v13; // x0
void *v14; // x0
__int64 v15; // x0
_QWORD v16[2]; // [xsp+0h] [xbp-50h] BYREF
char v17; // [xsp+17h] [xbp-39h]
void *__p[2]; // [xsp+18h] [xbp-38h] BYREF
char v19; // [xsp+2Fh] [xbp-21h]
v5 = *(_DWORD *)(a1 + 1184);
*(_DWORD *)(a1 + 1184) = 0;
while ( 1 )
{
v6 = HIBYTE(__str->__r_.__value_.__r.__words[2]);
if ( SHIBYTE(__str->__r_.__value_.__r.__words[2]) < 0 )
break;
if ( !*((_BYTE *)&__str->__r_.__value_.__s + 23) )
goto LABEL_11;
v7 = HIBYTE(__str->__r_.__value_.__r.__words[2]);
if ( *((_BYTE *)&__str[-1].__r_.__value_.__r.__words[2] + v7 + 7) != 32 )
goto LABEL_11;
v8 = v7 - 1;
*((_BYTE *)&__str->__r_.__value_.__s + 23) = v7 - 1;
v9 = __str;
LABEL_9:
v9->__r_.__value_.__s.__data_[v8] = 0;
}
size = __str->__r_.__value_.__l.__size_;
if ( size )
{
v9 = (std::string *)__str->__r_.__value_.__r.__words[0];
if ( *(_BYTE *)(__str->__r_.__value_.__r.__words[0] + size - 1) == 32 )
{
v8 = size - 1;
__str->__r_.__value_.__l.__size_ = size - 1;
goto LABEL_9;
}
}
while ( 1 )
{
LABEL_11:
if ( (v6 & 0x80) != 0 )
{
if ( !__str->__r_.__value_.__l.__size_ )
break;
v11 = *(unsigned __int8 *)__str->__r_.__value_.__l.__data_;
}
else
{
if ( !v6 )
break;
v11 = (unsigned __int8)__str->__r_.__value_.__s.__data_[0];
}
if ( v11 != 32 )
break;
std::string::erase(__str, 0, 1u);
v6 = HIBYTE(__str->__r_.__value_.__r.__words[2]);
}
if ( v5 == 2 )
{
if ( (v6 & 0x80) != 0 )
{
if ( !__str->__r_.__value_.__l.__size_ )
return;
}
else if ( !v6 )
{
return;
}
std::string::operator=((std::string *)(a1 + 1120), __str);
sub_1004CD3FC(a1, 9);
return;
}
if ( v5 != 1 )
return;
if ( (v6 & 0x80) != 0 )
{
if ( __str->__r_.__value_.__l.__size_ )
goto LABEL_21;
}
else if ( v6 )
{
LABEL_21:
if ( EditorSFXManager::sharedState() )
{
v12 = EditorSFXManager::sharedState();
if ( sub_1004CB1A0(v12, (__int64)__str) )
{
sub_1004CD3FC(a1, 1);
return;
}
}
sub_100009900(v16, "You already have 50 sound packs. Delete some first.");
v13 = sub_10034A8F8(0, (__int64)"Limit Reached", (__int64)v16, (__int64)"OK", 0);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v13 + 1312LL))(v13);
if ( v17 < 0 )
{
v14 = (void *)v16[0];
goto LABEL_32;
}
return;
}
sub_100009900(__p, "Please enter a name.");
v15 = sub_10034A8F8(0, (__int64)"Error", (__int64)__p, (__int64)"OK", 0);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v15 + 1312LL))(v15);
if ( v19 < 0 )
{
v14 = __p[0];
LABEL_32:
operator delete(v14);
}
}