//
// PlayLayer::updateProgressbar from 0x5cefd8 to 0x5cf208 (560 bytes)
//
// 5 xrefs:
// > PlayLayer::toggleProgressbar @ 0x5cf33c
// > PlayLayer::postUpdate @ 0x5dc1fc
// > PlayLayer::setupHasCompleted @ 0x5dc954
// > PlayLayer::resetLevel @ 0x5e56c0
// > ??> @ 0x3fb88
//
// 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 PlayLayer::updateProgressbar(PlayLayer *a1)
{
float *v2; // x21
float CurrentPercent; // s0
float v4; // s8
float m_progressWidth; // s2
float v6; // s0
cocos2d::CCSprite *m_progressFill; // x23
void (__fastcall *setTextureRect)(cocos2d::CCSprite *__hidden, const cocos2d::CCRect *); // x24
double v9; // d0
const char **m_percentageLabel; // x20
void (__fastcall *v11)(const char **, const char *); // x21
cocos2d::CCString *v12; // x0
const char *CString; // x0
int v14; // w1
unsigned __int64 v15; // x0
void *v16; // x0
unsigned int *v17; // x2
int v18; // w1
cocos2d::CCRect v19; // [xsp+58h] [xbp+58h] BYREF
v2 = &a1->m_varianceValues.__elems_[1975];
if ( a1->m_isPlatformer )
return;
CurrentPercent = PlayLayer::getCurrentPercent(a1);
v4 = CurrentPercent;
m_progressWidth = a1->m_progressWidth;
if ( CurrentPercent > 0.01 )
{
v6 = m_progressWidth * (float)(CurrentPercent / 100.0);
if ( m_progressWidth <= v6 )
goto LABEL_6;
goto LABEL_5;
}
v6 = m_progressWidth * 0.0001;
if ( m_progressWidth > (float)(m_progressWidth * 0.0001) )
{
if ( v4 <= 0.01 )
{
LABEL_5:
m_progressWidth = v6;
goto LABEL_6;
}
m_progressWidth = m_progressWidth * (float)(v4 / 100.0);
}
LABEL_6:
m_progressFill = a1->m_progressFill;
setTextureRect = m_progressFill->setTextureRect;
cocos2d::CCRect::CCRect(&v19, 0.0, 0.0, m_progressWidth, a1->m_progressHeight);
setTextureRect(m_progressFill, &v19);
if ( *((_BYTE *)v2 + 2248) )
{
if ( v4 < 0.0 )
{
v9 = 0.0;
}
else if ( v4 >= 100.0 )
{
v9 = 100.0;
}
else
{
v9 = 0.0;
if ( v4 >= 0.0 )
v9 = v4;
}
m_percentageLabel = (const char **)a1->m_percentageLabel;
v11 = *((void (__fastcall **)(const char **, const char *))*m_percentageLabel + 114);
v12 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%.2f%%",
*m_percentageLabel,
v9);
CString = cocos2d::CCString::getCString(v12);
v11(m_percentageLabel, CString);
}
else
{
v14 = (int)v4;
v15 = 100;
if ( (int)v4 <= 99 )
{
if ( v14 < 0 )
v15 = 0;
else
v15 = (unsigned int)v14;
}
GameToolbox::intToString((__int64 *)&v19, (GameToolbox *)v15);
sub_D15FD4(&v19, "%", 1);
a1->m_percentageLabel->setString(a1->m_percentageLabel, *(const unsigned __int8 **)&v19.origin);
v16 = (void *)(*(_QWORD *)&v19.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v19.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(*(_QWORD *)&v19.origin - 8LL);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *(_DWORD *)(*(_QWORD *)&v19.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v19.origin - 8LL) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v16);
}
}
}