//
// GJRateLevelLayer::onCustomButton from 0x820a94 to 0x820d14 (640 bytes)
//
// 2 xrefs:
// > ??> @ 0xa7d00
// > ??> @ 0x1187950
//
// 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 GJRateLevelLayer::onCustomButton(GJRateLevelLayer *a1, cocos2d::CCObject *a2)
{
int v3; // w0
FLAlertLayer *v4; // x20
UploadPopupDelegate_vtbl *v5; // x0
GameLevelManager *v6; // x0
UploadActionPopup *m_uploadPopup; // x0
UploadActionPopup *v8; // x0
UploadPopupDelegate_vtbl *v9; // x3
unsigned int *v10; // x2
int v11; // w1
unsigned int *v12; // x2
int onClosePopup; // w0
int v14; // [xsp+38h] [xbp+38h]
UploadPopupDelegate v15; // [xsp+50h] [xbp+50h] BYREF
std::string v16; // 0:x2.8
v3 = a2->getTag(a2);
if ( v3 == -4 )
{
v14 = (int)a1->getValue(a1, -1);
if ( v14 > 0 && a1->m_featureState > 0 )
{
v6 = GameLevelManager::sharedState();
if ( GameLevelManager::updateLevelRankAdmin(v6, a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed, v14) )
{
GameLevelManager::sharedState()->m_uploadActionDelegate = &a1->UploadActionDelegate;
m_uploadPopup = a1->m_uploadPopup;
if ( m_uploadPopup )
m_uploadPopup->m_delegate = nullptr;
sub_D153B8((int)&v15, "Updating rank...");
v8 = (UploadActionPopup *)UploadActionPopup::create((UploadActionPopup *)&a1->UploadPopupDelegate, &v15, v16);
a1->m_uploadPopup = v8;
v9 = v15.__vftable - 3;
if ( (__int64 *)&v15.__vftable[-3] != &qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)&v15.__vftable[-1];
do
onClosePopup = __ldaxr(v12);
while ( __stlxr(onClosePopup - 1, v12) );
}
else
{
onClosePopup = (int)v15.__vftable[-1].onClosePopup;
LODWORD(v15.__vftable[-1].onClosePopup) = onClosePopup - 1;
}
if ( onClosePopup <= 0 )
operator delete(v9);
v8 = a1->m_uploadPopup;
}
v8->show(v8);
}
}
}
else if ( v3 == -2 )
{
sub_D153B8((int)&v15, "Do you want to unrate this level?");
v4 = FLAlertLayer::create((int)a1 + 992, (__int64)"Unrate Level", (__int64)&v15);
v5 = v15.__vftable - 3;
if ( (__int64 *)&v15.__vftable[-3] != &qword_124B6B0 )
{
if ( &pthread_create )
{
v10 = (unsigned int *)&v15.__vftable[-1];
do
v11 = __ldaxr(v10);
while ( __stlxr(v11 - 1, v10) );
}
else
{
v11 = (int)v15.__vftable[-1].onClosePopup;
LODWORD(v15.__vftable[-1].onClosePopup) = v11 - 1;
}
if ( v11 <= 0 )
operator delete(v5);
}
ButtonSprite::updateBGImage(v4->m_button2, "GJ_button_06.png");
v4->setTag(v4, -3);
v4->show(v4);
}
}