//
// CustomSongWidget::onDownload from 0x1400cabc0 to 0x1400cad9f (479 bytes)
//
// 4 xrefs:
// > CustomSongWidget::musicActionFinished @ 0x1400cd64e
// > CustomSongWidget::FLAlert_Clicked @ 0x1400cda65
// > CustomSongWidget::init @ 0x1400c87f6
// > ??> @ 0x1406c82f8
//
// 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
//
// Hidden C++ exception states: #wind=1
void CustomSongWidget::onDownload(CustomSongWidget *a1, cocos2d::CCObject *a2)
{
cocos2d::extension::CCScale9Sprite *m_bgSpr; // rcx
GameManager *v4; // rcx
_BOOL8 v5; // rdx
MusicDownloadManager *v6; // rcx
_BOOL8 v7; // rdx
_BOOL8 v8; // rdx
MusicDownloadManager *v9; // rax
int m_customSongID; // edi
MusicDownloadManager *v11; // rax
MusicDownloadManager *v12; // rax
void *v13; // [rsp+30h] [rbp+8h]
a1->m_errorLabel->setVisible(a1->m_errorLabel, 0);
m_bgSpr = a1->m_bgSpr;
if ( m_bgSpr )
m_bgSpr->setVisible(m_bgSpr, 0);
v4 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v13 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v13);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v4 = (GameManager *)qword_1406C2ED8;
}
if ( !GameManager::getGameVariable(v4, "0016") )
{
MusicDownloadManager::sharedState();
MusicDownloadManager::showTOS(v6, &a1->FLAlertLayerProtocol);
return;
}
if ( a1->m_hasSFX )
{
a1->m_downloadBtn->setVisible(a1->m_downloadBtn, 0);
LOBYTE(v7) = 1;
a1->m_cancelDownloadBtn->setVisible(a1->m_cancelDownloadBtn, v7);
if ( MusicDownloadManager::sharedState()->m_customContentURL.m_data.m_size )
{
CustomSongWidget::startMultiAssetDownload(a1);
return;
}
LABEL_13:
a1->m_hasLibrarySongs = 1;
v9 = MusicDownloadManager::sharedState();
MusicDownloadManager::getCustomContentURL(v9);
return;
}
if ( !a1->m_songInfoObject )
return;
LOBYTE(v5) = 1;
a1->m_sliderGroove->setVisible(a1->m_sliderGroove, v5);
a1->m_downloadBtn->setVisible(a1->m_downloadBtn, 0);
LOBYTE(v8) = 1;
a1->m_cancelDownloadBtn->setVisible(a1->m_cancelDownloadBtn, v8);
a1->m_deleteBtn->setVisible(a1->m_deleteBtn, 0);
if ( a1->m_customSongID >= 10000000 && !MusicDownloadManager::sharedState()->m_customContentURL.m_data.m_size )
goto LABEL_13;
m_customSongID = a1->m_customSongID;
if ( a1->m_songInfoObject->m_verified )
{
a1->m_isNotDownloading = 0;
v11 = MusicDownloadManager::sharedState();
MusicDownloadManager::downloadSong(v11, m_customSongID);
CustomSongWidget::startDownload(a1);
}
else
{
a1->m_isNotDownloading = 1;
v12 = MusicDownloadManager::sharedState();
MusicDownloadManager::getSongInfo(v12, m_customSongID, 1);
}
}