//
// CustomSongWidget::deleteSong from 0x7474c8 to 0x74768c (452 bytes)
//
// 2 xrefs:
// > CustomSongWidget::FLAlert_Clicked @ 0x748320
// > ??> @ 0x536a0
//
// 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 CustomSongWidget::deleteSong(CustomSongWidget *a1)
{
FMODAudioEngine *v2; // x22
MusicDownloadManager *v3; // x0
_BOOL4 isMusicPlaying; // w22
void *v5; // x0
MusicDownloadManager *v6; // x0
cocos2d::CCLabelBMFont *m_errorLabel; // x0
void (__fastcall *setColor)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::ccColor3B *); // x2
FMODAudioEngine *v9; // x0
unsigned int *v10; // x2
int v11; // w1
__int64 v12; // [xsp+0h] [xbp+0h] BYREF
__int64 v13; // [xsp+40h] [xbp+40h] BYREF
if ( a1->m_songInfoObject )
{
v2 = FMODAudioEngine::sharedEngine();
v3 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSong(&v13, v3, a1->m_songInfoObject->m_songID);
isMusicPlaying = FMODAudioEngine::isMusicPlaying(v2, (unsigned int)&v12 + 64);
v5 = (void *)(v13 - 24);
if ( (__int64 *)(v13 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v10 = (unsigned int *)(v13 - 8);
do
v11 = __ldaxr(v10);
while ( __stlxr(v11 - 1, v10) );
}
else
{
v11 = *(_DWORD *)(v13 - 8);
*(_DWORD *)(v13 - 8) = v11 - 1;
}
if ( v11 <= 0 )
operator delete(v5);
}
if ( isMusicPlaying )
{
v9 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopAllMusic(v9, 1);
}
v6 = MusicDownloadManager::sharedState();
MusicDownloadManager::deleteSong(v6, a1->m_songInfoObject->m_songID);
CustomSongWidget::updateSongInfo(a1);
m_errorLabel = a1->m_errorLabel;
setColor = m_errorLabel->setColor;
LOBYTE(v13) = -1;
*(_WORD *)((char *)&v13 + 1) = 100;
setColor(m_errorLabel, (const cocos2d::ccColor3B *)&v13);
a1->m_errorLabel->setString(a1->m_errorLabel, "Song Deleted");
if ( a1->m_isMusicLibrary )
cocos2d::CCLabelBMFont::limitLabelWidth(a1->m_errorLabel, 140.0, 0.35, 0.0);
else
cocos2d::CCLabelBMFont::limitLabelWidth(a1->m_errorLabel, 230.0, 0.4, 0.0);
CustomSongWidget::showError(a1, 1);
}
}