//
// LevelInfoLayer::levelDownloadFinished from 0x6dd920 to 0x6ddcb4 (916 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'LevelInfoLayer::levelDownloadFinished @ 0x6ddcb8
// > ??> @ 0x63498
// > ??> @ 0x115b6b0
//
// 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 LevelInfoLayer::levelDownloadFinished(LevelInfoLayer *a1, GJGameLevel *a2)
{
GJGameLevel *m_level; // x0
GJGameLevel *v5; // x0
CCMenuItemSpriteExtra *m_cloneBtn; // x1
cocos2d::CCNode *v7; // x21
void (__fastcall *setSkewY)(cocos2d::CCNode *__hidden, float); // x22
cocos2d::CCSpriteFrameCache *v9; // x0
cocos2d::CCSpriteFrame *v10; // x0
char *v11; // x0
CCMenuItemSpriteExtra *v12; // x22
void (__fastcall *setEnabled)(cocos2d::CCMenuItemSprite *__hidden, bool); // x25
int v14; // w0
CustomSongWidget *m_songWidget; // x22
char *v16; // x0
void *v17; // x0
unsigned int *v18; // x19
int v19; // w1
unsigned int *v20; // x1
int v21; // w2
unsigned int *v22; // x1
int v23; // w2
__int64 v24; // [xsp+58h] [xbp+58h] BYREF
char *v25; // [xsp+60h] [xbp+60h] BYREF
m_level = a1->m_level;
if ( !m_level || m_level->m_levelID.random - m_level->m_levelID.seed == a2->m_levelID.random - a2->m_levelID.seed )
{
a1->m_circle->setVisible(a1->m_circle, 0);
v5 = a1->m_level;
if ( v5 )
cocos2d::CCObject::release(v5);
a1->m_level = a2;
cocos2d::CCObject::retain(a2);
a1->m_playBtnMenu->setVisible(a1->m_playBtnMenu, 1);
LevelInfoLayer::updateLabelValues(a1);
m_cloneBtn = a1->m_cloneBtn;
if ( m_cloneBtn )
{
m_cloneBtn->setVisible(a1->m_cloneBtn, a1->m_level->m_password.random != a1->m_level->m_password.seed);
if ( a1->m_cloneBtn->isVisible(a1->m_cloneBtn) )
{
sub_D153B8((int)&v25, "GJ_duplicateBtn_001.png");
if ( a1->m_level->m_password.random - a1->m_level->m_password.seed != 1 )
sub_D1798C(&v25, "GJ_duplicateLockedBtn_001.png", 29);
v7 = a1->m_cloneBtn->getNormalImage(a1->m_cloneBtn);
setSkewY = v7->__vftable[1].setSkewY;
v9 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v10 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v9, v25);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSpriteFrame *))setSkewY)(v7, v10);
v11 = v25 - 24;
if ( v25 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(v25 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v11);
}
}
v12 = a1->m_cloneBtn;
setEnabled = v12->setEnabled;
v14 = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))v12->isVisible)(v12);
setEnabled(v12, v14);
}
m_songWidget = a1->m_songWidget;
sub_D18D28(&v24, &a1->m_level->m_songIDs);
sub_D18D28(&v25, &a1->m_level->m_sfxIDs);
CustomSongWidget::updateWithMultiAssets(m_songWidget, (std::string)&v24, (std::string)&v25, a1->m_level->m_songSize);
v16 = v25 - 24;
if ( v25 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v25 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v16);
}
v17 = (void *)(v24 - 24);
if ( (__int64 *)(v24 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v24 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v24 - 8);
*(_DWORD *)(v24 - 8) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v17);
}
}
}