//
// CustomSongWidget::onDownload from 0x10061ba70 to 0x10061bcfe (654 bytes)
//
// 5 xrefs:
// > CustomSongWidget::musicActionFinished @ 0x10062133a
// > sub_100621350 @ 0x100621371
// > CustomSongWidget::FLAlert_Clicked @ 0x100621465
// > sub_100621480 @ 0x1006214cc
// > CustomSongWidget::init @ 0x10061ac25
//
// 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 CustomSongWidget::onDownload(CustomSongWidget *a1, cocos2d::CCObject *a2)
{
cocos2d::extension::CCScale9Sprite *m_bgSpr; // rdi
GameManager *v4; // rax
MusicDownloadManager *v5; // rax
unsigned int sizex2; // ecx
MusicDownloadManager *v7; // rax
MusicDownloadManager *v8; // rax
unsigned int v9; // ecx
MusicDownloadManager *v10; // rax
cocos2d::CCSprite *m_sliderBar; // r14
__m128 width_low; // xmm0
__m128 v13; // xmm2
MusicDownloadManager *v14; // rax
MusicDownloadManager *v15; // rax
_BYTE v16[40]; // [rsp+8h] [rbp-28h] BYREF
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))a1->m_errorLabel->setVisible)(a1->m_errorLabel, 0);
m_bgSpr = a1->m_bgSpr;
if ( m_bgSpr )
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, _QWORD))m_bgSpr->setVisible)(m_bgSpr, 0);
v4 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v4, "0016") )
{
v7 = MusicDownloadManager::sharedState();
MusicDownloadManager::showTOS(v7, &a1->FLAlertLayerProtocol);
return;
}
if ( a1->m_hasSFX )
{
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_downloadBtn->setVisible)(a1->m_downloadBtn, 0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))a1->m_cancelDownloadBtn->setVisible)(
a1->m_cancelDownloadBtn,
1);
v5 = MusicDownloadManager::sharedState();
sizex2 = v5->m_customContentURL.m_data.m_short.sizex2;
if ( (sizex2 & 1) == 0 )
{
if ( !(sizex2 >> 1) )
goto LABEL_20;
LABEL_15:
CustomSongWidget::startMultiAssetDownload(a1);
return;
}
if ( v5->m_customContentURL.m_data.m_long.size )
goto LABEL_15;
LABEL_20:
a1->m_hasLibrarySongs = 1;
v14 = MusicDownloadManager::sharedState();
MusicDownloadManager::getCustomContentURL(v14);
return;
}
if ( a1->m_songInfoObject )
{
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_sliderGroove->setVisible)(a1->m_sliderGroove, 1);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_downloadBtn->setVisible)(a1->m_downloadBtn, 0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))a1->m_cancelDownloadBtn->setVisible)(
a1->m_cancelDownloadBtn,
1);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_deleteBtn->setVisible)(a1->m_deleteBtn, 0);
if ( a1->m_customSongID >= 10000000 )
{
v8 = MusicDownloadManager::sharedState();
v9 = v8->m_customContentURL.m_data.m_short.sizex2;
if ( (v9 & 1) != 0 )
{
if ( !v8->m_customContentURL.m_data.m_long.size )
goto LABEL_20;
}
else if ( !(v9 >> 1) )
{
goto LABEL_20;
}
}
if ( a1->m_songInfoObject->m_verified )
{
a1->m_isNotDownloading = 0;
v10 = MusicDownloadManager::sharedState();
MusicDownloadManager::downloadSong(v10, a1->m_customSongID);
m_sliderBar = a1->m_sliderBar;
width_low = (__m128)LODWORD(a1->m_sliderGroove->m_obRect.size.width);
width_low.f32[0] = width_low.f32[0] + -4.0;
v13 = width_low;
v13.f32[0] = fminf(width_low.f32[0] * 0.0, width_low.f32[0]);
sub_10028CC00((__int64)v16, 0.0, 0.0, v13, (__m128)0x41000000u);
((void (__fastcall *)(cocos2d::CCSprite *, _BYTE *))m_sliderBar->setTextureRect)(m_sliderBar, v16);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_sliderGroove->setVisible)(a1->m_sliderGroove, 1);
cocos2d::CCNode::unschedule(a1, (cocos2d::SEL_SCHEDULE)(unsigned __int64)CustomSongWidget::updateDownloadProgress);
cocos2d::CCNode::schedule_1(
a1,
(cocos2d::SEL_SCHEDULE)(unsigned __int64)CustomSongWidget::updateDownloadProgress,
0.033333335);
}
else
{
a1->m_isNotDownloading = 1;
v15 = MusicDownloadManager::sharedState();
MusicDownloadManager::getSongInfo(v15, a1->m_customSongID, 1);
}
}
}