//
// cocos2d::CCTextFieldTTF::deleteBackward from 0x1001cb698 to 0x1001cb8a0 (520 bytes)
//
// 2 xrefs:
// > sub_1001CB8C0 @ 0x1001cb8c4
// > ??> @ 0x1007ba0c8
//
// 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 cocos2d::CCTextFieldTTF::deleteBackward(cocos2d::CCTextFieldTTF *a1)
{
std::string *m_pInputText; // x8
std::size_t size; // x23
__int64 v4; // x21
__int64 v5; // x20
cocos2d::CCTextFieldDelegate *m_pDelegate; // x0
std::string *capacitym1; // x8
int m_uCursorPos; // w8
std::string *v9; // x1
std::string *p_dst; // x1
std::string *v11; // x20
std::string *v12; // x0
std::string *m_pPlaceHolder; // x1
cocos2d::CCTextFieldDelegate *v14; // x0
std::string *v15; // x1
std::string __dst; // [xsp+8h] [xbp-48h] BYREF
m_pInputText = a1->m_pInputText;
size = m_pInputText->m_data.m_short.shortStorage.__elems_[22];
if ( (size & 0x8000000000000000LL) != 0 )
{
size = m_pInputText->m_data.m_long.size;
if ( !(_DWORD)size )
return;
}
else if ( !m_pInputText->m_data.m_short.shortStorage.__elems_[22] )
{
return;
}
if ( a1->m_uCursorPos )
{
v4 = 0;
do
--v4;
while ( (*std::string::at((std::string *)a1->m_pInputText, v4 + (int)size) & 0xC0) == 0x80 );
v5 = -v4;
m_pDelegate = a1->m_pDelegate;
if ( !m_pDelegate )
goto LABEL_12;
capacitym1 = a1->m_pInputText;
if ( capacitym1->m_data.m_short.shortStorage.__elems_[22] < 0 )
capacitym1 = (std::string *)capacitym1->m_data.m_long.capacitym1;
if ( (((__int64 (__fastcall *)(cocos2d::CCTextFieldDelegate *, cocos2d::CCTextFieldTTF *, char *, __int64))m_pDelegate->onTextFieldDeleteBackward)(
m_pDelegate,
a1,
(char *)capacitym1 + (int)size - (unsigned int)v5,
-v4)
& 1) == 0 )
{
LABEL_12:
if ( (int)v5 >= (int)size )
{
v11 = a1->m_pInputText;
if ( v11 )
{
if ( v11->m_data.m_short.shortStorage.__elems_[22] < 0 )
operator delete((void *)v11->m_data.m_long.capacitym1);
operator delete(v11);
a1->m_pInputText = nullptr;
}
v12 = (std::string *)operator new(0x18u);
v12->m_data.m_long.size = 0;
v12->m_data.m_long.longStorage = nullptr;
v12->m_data.m_long.capacitym1 = 0;
a1->m_pInputText = v12;
a1->m_nCharCount = 0;
m_pPlaceHolder = a1->m_pPlaceHolder;
if ( m_pPlaceHolder->m_data.m_short.shortStorage.__elems_[22] < 0 )
m_pPlaceHolder = (std::string *)m_pPlaceHolder->m_data.m_long.capacitym1;
cocos2d::CCLabelTTF::setString(a1, (const char *)m_pPlaceHolder);
v14 = a1->m_pDelegate;
if ( v14 )
((void (__fastcall *)(cocos2d::CCTextFieldDelegate *))v14->textChanged)(v14);
}
else
{
m_uCursorPos = a1->m_uCursorPos;
if ( m_uCursorPos >= 1 && m_uCursorPos <= a1->m_nCharCount )
{
v15 = a1->m_pInputText;
if ( v15->m_data.m_short.shortStorage.__elems_[22] < 0 )
v15 = (std::string *)v15->m_data.m_long.capacitym1;
sub_100009900(&__dst, (char *)v15);
std::string::erase(&__dst, a1->m_uCursorPos - 1LL, (unsigned int)v5);
--a1->m_uCursorPos;
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_dst = &__dst;
else
p_dst = (std::string *)__dst.__r_.__value_.__r.__words[0];
}
else
{
v9 = a1->m_pInputText;
if ( v9->m_data.m_short.shortStorage.__elems_[22] < 0 )
v9 = (std::string *)v9->m_data.m_long.capacitym1;
sub_100085F6C(&__dst, v9, (int)size + v4);
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_dst = &__dst;
else
p_dst = (std::string *)__dst.__r_.__value_.__r.__words[0];
}
((void (__fastcall *)(cocos2d::CCTextFieldTTF *, std::string *))a1->setString)(a1, p_dst);
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
}
}
}
}