//
// SecretRewardsLayer::updateUnlockedLabel from 0x585a80 to 0x585b9e (286 bytes)
//
// 3 xrefs:
// > SecretRewardsLayer::onSelectItem @ 0x585d22
// > SecretRewardsLayer::init @ 0x586aba
// > SecretRewardsLayer::createSecondaryLayer @ 0x58a0ee
//
// 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 SecretRewardsLayer::updateUnlockedLabel(SecretRewardsLayer *a1)
{
GameStatsManager *v2; // r0
const char *v3; // r9
GameStatsManager *v4; // r0
int v5; // r0
cocos2d::CCLabelBMFont *m_chestLabel; // r7
void (__fastcall *setString)(cocos2d::CCLabelBMFont *__hidden, const unsigned __int8 *); // r8
cocos2d::CCString *v8; // r0
const char *CString; // r0
GameStatsManager *v10; // r0
const char *v11; // r9
GameStatsManager *v12; // r0
int v13; // r10
cocos2d::CCString *v14; // r0
char *v15; // r0
cocos2d::CCLabelBMFont *m_chestCounter; // r0
cocos2d::CCObject *v17; // r0
cocos2d::CCObject *v18; // r5
cocos2d::CCLabelBMFont *v19; // r0
void (__fastcall *setColor)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::ccColor3B *); // r2
void (__fastcall *v21)(cocos2d::CCObject *__hidden); // r2
int v23; // [sp+4h] [bp-Ch] BYREF
unsigned __int8 *v24; // [sp+8h] [bp-8h] BYREF
v2 = GameStatsManager::sharedState();
v3 = (const char *)GameStatsManager::countUnlockedSecretChests(v2, (GJRewardType)0);
v4 = GameStatsManager::sharedState();
v5 = GameStatsManager::countSecretChests(v4, (GJRewardType)0);
m_chestLabel = a1->m_chestLabel;
setString = m_chestLabel->setString;
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i/%i",
v3,
v5,
m_chestLabel->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable,
a1,
v23);
CString = cocos2d::CCString::getCString(v8);
setString(m_chestLabel, (const unsigned __int8 *)CString);
if ( !a1->m_inMainLayer )
{
v10 = GameStatsManager::sharedState();
v11 = (const char *)GameStatsManager::countUnlockedSecretChests(v10, a1->m_rewardType);
v12 = GameStatsManager::sharedState();
v13 = GameStatsManager::countSecretChests(v12, a1->m_rewardType);
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i/%i", v11, v13);
v15 = (char *)cocos2d::CCString::getCString(v14);
sub_776584((int)&v24, v15);
m_chestCounter = a1->m_chestCounter;
if ( m_chestCounter )
m_chestCounter->setString(m_chestCounter, v24);
v17 = cocos2d::CCDictionary::objectForKey(a1->m_chestCounters, a1->m_rewardType);
v18 = v17;
if ( v17 )
v17->__vftable[11].acceptVisitor(v17, (cocos2d::CCDataVisitor *)v24);
if ( (int)v11 >= v13 )
{
v19 = a1->m_chestCounter;
if ( v19 )
{
setColor = v19->setColor;
LOWORD(v23) = -256;
BYTE2(v23) = -1;
setColor(v19, (const cocos2d::ccColor3B *)&v23);
}
if ( v18 )
{
v21 = v18->__vftable[13].~CCObject_0;
LOWORD(v23) = -206;
BYTE2(v23) = 50;
((void (__fastcall *)(cocos2d::CCObject *, int *))v21)(v18, &v23);
}
}
sub_774008(&v24);
}
}