//
// LevelBrowserLayer::onDeleteSelected from 0x6e7a70 to 0x6e7da0 (816 bytes)
//
// 3 xrefs:
// > ??> @ 0x59aa8
// > LevelBrowserLayer::init @ 0x6ebb8c
// > ??> @ 0x122ae18
//
// 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 LevelBrowserLayer::onDeleteSelected(LevelBrowserLayer *a1, cocos2d::CCObject *a2)
{
cocos2d::CCArray *m_levels; // x0
cocos2d::CCArray *v4; // x0
cocos2d::ccArray *data; // x0
unsigned int num; // w1
cocos2d::CCObject **arr; // x0
cocos2d::CCObject **v8; // x3
cocos2d::CCObject *v9; // x2
unsigned __int64 v10; // x1
cocos2d::CCString *v11; // x0
char *CString; // x0
FLAlertLayer *v13; // x20
void *v14; // x0
char *v15; // x0
unsigned int *v16; // x20
int v17; // w1
FLAlertLayer *v18; // x20
void *v19; // x0
unsigned int *v20; // x1
int v21; // w2
unsigned int *v22; // x2
int v23; // w1
char *v24; // [xsp+48h] [xbp+48h] BYREF
__int64 v25; // [xsp+50h] [xbp+50h] BYREF
m_levels = a1->m_levels;
if ( m_levels && (unsigned int)cocos2d::CCArray::count(m_levels) )
{
v4 = a1->m_levels;
if ( !v4 )
goto LABEL_21;
data = v4->data;
num = data->num;
if ( !data->num )
goto LABEL_21;
arr = data->arr;
v8 = &arr[num - 1];
if ( arr > v8 )
goto LABEL_21;
v9 = *arr;
LODWORD(v10) = 0;
if ( !*arr )
goto LABEL_21;
do
{
++arr;
if ( HIBYTE(v9[9].__vftable) )
v10 = (unsigned int)(v10 + 1);
else
v10 = (unsigned int)v10;
if ( v8 < arr )
break;
v9 = *arr;
}
while ( *arr );
if ( (_DWORD)v10 )
{
v11 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Are you sure you want to delete the %i selected levels?",
(const char *)v10);
CString = (char *)cocos2d::CCString::getCString(v11);
sub_D153B8((int)&v24, CString);
sub_D153B8((int)&v25, v24);
v13 = FLAlertLayer::create((int)a1 + 552, (__int64)"Delete", (__int64)&v25);
v14 = (void *)(v25 - 24);
if ( (__int64 *)(v25 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(v25 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *(_DWORD *)(v25 - 8);
*(_DWORD *)(v25 - 8) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v14);
}
ButtonSprite::updateBGImage(v13->m_button2, "GJ_button_06.png");
v13->setTag(v13, 5);
v13->show(v13);
v15 = v24 - 24;
if ( v24 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v24 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v24 - 2);
*((_DWORD *)v24 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v15);
}
}
else
{
LABEL_21:
sub_D153B8((int)&v25, "No levels selected.");
v18 = FLAlertLayer::create(0, (__int64)"Nothing here...", (__int64)&v25);
v19 = (void *)(v25 - 24);
if ( (__int64 *)(v25 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v25 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(_DWORD *)(v25 - 8);
*(_DWORD *)(v25 - 8) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v19);
}
v18->show(v18);
}
}
}