//
// SecretRewardsLayer::init from 0x585e70 to 0x587218 (5032 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::create @ 0x5872d8
//
// 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
//
bool SecretRewardsLayer::init(SecretRewardsLayer *a1, bool a2)
{
cocos2d::CCTextureCache *v3; // r0
cocos2d::CCSpriteFrameCache *v4; // r0
cocos2d::CCDirector *v5; // r0
GameManager *v6; // r0
GameManager *v7; // r0
GameManager *v8; // r5
int v9; // r2
int v10; // r3
cocos2d::CCLayer *v11; // r0
SecretRewardsLayer_vtbl *v12; // r3
const char *v13; // r1
cocos2d::CCSprite *v14; // r0
cocos2d::CCSprite_vtbl *v15; // r3
cocos2d::CCSprite *v16; // r5
void (__fastcall *setAnchorPoint)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r6
cocos2d::CCSprite *m_backgroundSprite; // r5
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r6
cocos2d::CCSprite *v20; // r0
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r3
cocos2d::CCSprite *v22; // r6
void (__fastcall *v23)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
void (__fastcall *v24)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
void (__fastcall *v25)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r3
cocos2d::CCSprite *v26; // r6
void (__fastcall *v27)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
void (__fastcall *v28)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
void (__fastcall *v29)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r3
cocos2d::CCSprite *v30; // r0
CCMenuItemSpriteExtra *v31; // r6
cocos2d::CCNode *v32; // r5
void (__fastcall *v33)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
cocos2d::CCDirector *v34; // r0
float v35; // s16
cocos2d::CCDirector *v36; // r0
float v37; // r0
GameStatsManager *v38; // r0
const char *Stat; // r0
cocos2d::CCString *v40; // r0
cocos2d::CCLabelBMFont *v41; // r0
float v42; // r1
float v43; // s15
cocos2d::CCLabelBMFont_vtbl *v44; // r3
cocos2d::CCLabelBMFont *v45; // r8
void (__fastcall *v46)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r5
cocos2d::CCLabelBMFont *m_keysLabel; // r8
void (__fastcall *v48)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // r5
cocos2d::CCSprite *v49; // r0
SecretRewardsLayer_vtbl *v50; // r3
cocos2d::CCSprite *m_keySprite; // r8
void (__fastcall *v52)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r9
const cocos2d::CCPoint *v53; // r11
int v54; // r11
GameStatsManager *v55; // r0
const char *v56; // r0
cocos2d::CCString *v57; // r0
cocos2d::CCLabelBMFont *v58; // r0
cocos2d::CCLabelBMFont *v59; // r6
void (__fastcall *v60)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
const cocos2d::CCPoint *v61; // r0
cocos2d::CCLabelBMFont *m_goldKeysLabel; // r6
void (__fastcall *v63)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // r7
cocos2d::CCSprite *v64; // r0
SecretRewardsLayer_vtbl *v65; // r3
cocos2d::CCSprite *m_goldKeySprite; // r6
void (__fastcall *v67)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
const cocos2d::CCPoint *v68; // r8
cocos2d::CCSprite *v69; // r5
void (__fastcall *v70)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r6
cocos2d::CCSprite *v71; // r5
void (__fastcall *v72)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r6
void (__fastcall *v73)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r6
void (__fastcall *setBlendFunc)(cocos2d::CCSprite *__hidden, cocos2d::ccBlendFunc); // r4
cocos2d::CCArray *v75; // r0
cocos2d::CCDictionary *v76; // r0
unsigned int v77; // s15
cocos2d::CCLayer *v78; // r5
cocos2d::CCMenu *v79; // r6
int v80; // r5
int v81; // r4
float v82; // r0
cocos2d::CCString *v83; // r0
const char *CString; // r0
cocos2d::CCSprite *v85; // r6
void (__fastcall *v86)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
const char *v87; // r3
cocos2d::CCString *v88; // r0
char *v89; // r0
cocos2d::CCString *v90; // r0
char *v91; // r0
int v92; // r6
const char *v93; // r4
cocos2d::CCString *v94; // r0
char *v95; // r0
cocos2d::CCPoint *v96; // r4
GameStatsManager *v97; // r7
stl::StringData::Internal *v98; // r2
stl::StringData::Internal *v99; // r3
int isSpecialChestUnlocked; // r0
GameStatsManager *v101; // r7
stl::StringData::Internal *v102; // r2
stl::StringData::Internal *v103; // r3
GameStatsManager *v104; // r7
stl::StringData::Internal *v105; // r2
stl::StringData::Internal *v106; // r3
int v107; // r7
GJChestSprite *v108; // r8
CCMenuItemSpriteExtra *v109; // r4
float width; // s16
int v111; // r0
void (__fastcall *v112)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9
cocos2d::CCSprite *v113; // r4
void (__fastcall *v114)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r9
cocos2d::CCSprite *v115; // r6
int v116; // r9
GameStatsManager *v117; // r0
const char *v118; // r8
GameStatsManager *v119; // r0
int v120; // r7
cocos2d::CCString *v121; // r0
cocos2d::CCLabelBMFont *v122; // r4
int v123; // r9
char v124; // r1
void (__fastcall *v125)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::ccColor3B *); // r2
char v126; // r3
cocos2d::CCLabelBMFont *v127; // r0
cocos2d::CCLabelBMFont_vtbl *v128; // r3
cocos2d::CCLabelBMFont *m_chestLabel; // r7
void (__fastcall *v130)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // r8
cocos2d::CCSprite *v131; // r4
void (__fastcall *v132)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
cocos2d::CCLayer *v133; // r6
cocos2d::CCMenu *v134; // r7
GJChestSprite *v135; // r8
CCMenuItemSpriteExtra *v136; // r4
void (__fastcall *v137)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // r9
float v138; // s17
float v139; // r0
void (__fastcall *v140)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r9
float v141; // s17
int v142; // r0
void (__fastcall *v143)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r8
GameStatsManager *v144; // r0
cocos2d::CCSprite *v145; // r4
void (__fastcall *v146)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
void (__fastcall *v147)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r3
cocos2d::CCSprite *v148; // r9
void (__fastcall *v149)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
int v150; // r4
cocos2d::CCSprite *v151; // r0
cocos2d::CCSprite_vtbl *v152; // r3
cocos2d::CCSprite *m_goldPriceSprite; // r7
void (__fastcall *v154)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r4
cocos2d::CCLayer *v155; // r4
cocos2d::CCMenu *v156; // r0
void (__fastcall *addChild)(cocos2d::CCNode *__hidden, cocos2d::CCNode *); // r3
cocos2d::CCNode *v158; // r5
cocos2d::CCLayer *v159; // r0
int v160; // r4
char *v161; // r1
cocos2d::CCSprite *v162; // r11
CCMenuItemSpriteExtra *v163; // r6
void (__fastcall *v164)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9
int v165; // r2
bool v166; // r3
float v167; // s14
int i; // r6
cocos2d::CCSprite *v169; // r7
cocos2d::CCSprite *v170; // r0
BoomScrollLayer *v171; // r0
BoomScrollLayer *m_mainScrollLayer; // r5
float v173; // s17
cocos2d::CCDirector *v174; // r0
float v175; // r0
cocos2d::CCPoint v176; // r1
BoomScrollLayer *v177; // r5
cocos2d::CCDirector *v178; // r0
float v179; // r7
cocos2d::CCDirector *v180; // r0
float v181; // r0
cocos2d::CCMenu *v182; // r5
float v183; // s17
cocos2d::CCSprite *v184; // r0
CCMenuItemSpriteExtra *v185; // r0
cocos2d::CCMenu_vtbl *v186; // r3
cocos2d::CCDirector *v187; // r0
float v188; // r0
cocos2d::CCSprite *v189; // r6
CCMenuItemSpriteExtra *v190; // r0
cocos2d::CCMenu_vtbl *v191; // r3
CCMenuItemSpriteExtra *m_rightButton; // r6
void (__fastcall *v193)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r4
cocos2d::CCDirector *v194; // r0
float v195; // r0
int TotalPages; // r4
GJChestSprite *v198; // [sp+Ch] [bp-B0h]
GJChestSprite *v199; // [sp+Ch] [bp-B0h]
GJChestSprite *v200; // [sp+Ch] [bp-B0h]
CCMenuItemSpriteExtra *m_leftButton; // [sp+10h] [bp-ACh]
cocos2d::CCArray *v202; // [sp+14h] [bp-A8h]
cocos2d::CCNode *v203; // [sp+18h] [bp-A4h]
cocos2d::CCPoint *v204; // [sp+18h] [bp-A4h]
cocos2d::CCPoint *v205; // [sp+18h] [bp-A4h]
_BOOL4 v206; // [sp+1Ch] [bp-A0h]
cocos2d::CCArray *v207; // [sp+20h] [bp-9Ch]
char *setContentSize; // [sp+24h] [bp-98h]
char *v209; // [sp+24h] [bp-98h]
_BOOL4 v210; // [sp+28h] [bp-94h]
cocos2d::CCSprite *v211; // [sp+48h] [bp-74h] BYREF
cocos2d::CCSize v212; // [sp+4Ch] [bp-70h] BYREF
_DWORD v213[2]; // [sp+54h] [bp-68h] BYREF
cocos2d::CCPoint v214; // [sp+5Ch] [bp-60h] BYREF
cocos2d::CCPoint v215; // [sp+64h] [bp-58h] BYREF
cocos2d::CCPoint v216; // [sp+6Ch] [bp-50h] BYREF
cocos2d::CCPoint v217; // [sp+74h] [bp-48h] BYREF
void (*v218)(SecretRewardsLayer *, cocos2d::CCObject *); // [sp+7Ch] [bp-40h]
int v219; // [sp+80h] [bp-3Ch]
void (*v220)(SecretRewardsLayer *, cocos2d::CCObject *); // [sp+84h] [bp-38h]
int v221; // [sp+88h] [bp-34h]
cocos2d::CCPoint v222; // [sp+8Ch] [bp-30h] BYREF
cocos2d::CCPoint v223; // [sp+94h] [bp-28h] BYREF
cocos2d::CCPoint v224; // [sp+9Ch] [bp-20h] BYREF
cocos2d::CCRect v225; // [sp+A4h] [bp-18h] BYREF
v210 = a2;
v206 = cocos2d::CCLayer::init(a1);
if ( !v206 )
return v206;
a1->m_inMainLayer = 1;
v3 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v3, "TreasureRoomSheet.png", 0);
v4 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v4, "TreasureRoomSheet.plist");
a1->setKeypadEnabled(a1, 1);
a1->setKeyboardEnabled(a1, 1);
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v212, v5);
v6 = GameManager::sharedState();
if ( GameManager::getUGV(v6, "10") )
a1->m_scratchDialogIndex = 4;
v7 = GameManager::sharedState();
if ( GameManager::getUGV(v7, "21") )
a1->m_potborDialogIndex = 3;
v8 = GameManager::sharedState();
sub_776584((int)&v225, "secretLoop.mp3");
GameManager::fadeInMusic((int)v8, &v225, v9, v10);
sub_774008(&v225);
v11 = cocos2d::CCLayer::create();
v12 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_mainLayer = v11;
v12->addChild_0(a1, v11, 0);
v14 = (cocos2d::CCSprite *)cocos2d::CCSprite::create((cocos2d::CCSprite *)"GJ_gradientBG.png", v13);
v15 = v14->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v16 = v14;
a1->m_backgroundSprite = v14;
setAnchorPoint = v15->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v225.origin, 0.0, 0.0);
setAnchorPoint(v16, &v225.origin);
a1->addChild_0(a1, a1->m_backgroundSprite, -3);
((void (__fastcall *)(cocos2d::CCSprite *, _DWORD))a1->m_backgroundSprite->setScaleX)(
a1->m_backgroundSprite,
(float)(v212.width + 10.0) / a1->m_backgroundSprite->m_obRect.size.width);
((void (__fastcall *)(cocos2d::CCSprite *, _DWORD))a1->m_backgroundSprite->setScaleY)(
a1->m_backgroundSprite,
(float)(v212.height + 10.0) / a1->m_backgroundSprite->m_obRect.size.height);
m_backgroundSprite = a1->m_backgroundSprite;
setPosition = m_backgroundSprite->setPosition;
cocos2d::CCPoint::CCPoint(&v225.origin, -5.0, -5.0);
setPosition(m_backgroundSprite, &v225.origin);
v20 = a1->m_backgroundSprite;
setColor = v20->setColor;
LOWORD(v225.origin.x) = 70;
BYTE2(v225.origin.x) = 75;
setColor(v20, (const cocos2d::ccColor3B *)&v225);
v22 = cocos2d::CCSprite::createWithSpriteFrameName("treasureRoomSpiderweb_001.png");
v23 = v22->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v225.origin, 1.0, 1.0);
v23(v22, &v225.origin);
v24 = v22->setPosition;
cocos2d::CCPoint::CCPoint(&v225.origin, v212.width + 5.0, v212.height + 5.0);
v24(v22, &v225.origin);
v22->setOpacity(v22, 63);
v25 = v22->setColor;
LOWORD(v225.origin.x) = 0;
BYTE2(v225.origin.x) = 0;
v25(v22, (const cocos2d::ccColor3B *)&v225);
a1->addChild_0(a1, v22, -1);
((void (__fastcall *)(cocos2d::CCSprite *, int))v22->setScale)(v22, 1066192077);
v26 = cocos2d::CCSprite::createWithSpriteFrameName("treasureRoomSpiderweb_001.png");
v27 = v26->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v225.origin, 0.0, 1.0);
v27(v26, &v225.origin);
v28 = v26->setPosition;
cocos2d::CCPoint::CCPoint(&v225.origin, -5.0, v212.height + 5.0);
v28(v26, &v225.origin);
v26->setOpacity(v26, 63);
cocos2d::CCSprite::setFlipX(v26, 1);
v29 = v26->setColor;
LOWORD(v225.origin.x) = 0;
BYTE2(v225.origin.x) = 0;
v29(v26, (const cocos2d::ccColor3B *)&v225);
a1->addChild_0(a1, v26, -1);
((void (__fastcall *)(cocos2d::CCSprite *, int))v26->setScale)(v26, 1066192077);
v30 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
a1->m_backSprite = v30;
v219 = 0;
v218 = SecretRewardsLayer::onBack;
v31 = CCMenuItemSpriteExtra::create(
v30,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SecretRewardsLayer::onBack, (unsigned int)a1));
CCMenuItemSpriteExtra::setSizeMult(v31, 1.6);
v32 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v31, nullptr);
a1->addChild_0(a1, v32, 1);
v33 = v32->setPosition;
v34 = cocos2d::CCDirector::sharedDirector();
v35 = COERCE_FLOAT(cocos2d::CCDirector::getScreenLeft(v34));
v36 = cocos2d::CCDirector::sharedDirector();
v37 = COERCE_FLOAT(cocos2d::CCDirector::getScreenTop(v36));
cocos2d::CCPoint::CCPoint(&v225.origin, v35 + 24.0, v37 - 23.0);
v33(v32, &v225.origin);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v31);
v38 = GameStatsManager::sharedState();
Stat = (const char *)GameStatsManager::getStat(v38, "21");
v40 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", Stat);
cocos2d::CCString::getCString(v40);
v41 = cocos2d::CCLabelBMFont::create();
v42 = v212.width - 55.0;
v43 = v212.height - 18.0;
v44 = v41->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v45 = v41;
a1->m_keysLabel = v41;
v46 = v44->setPosition;
cocos2d::CCPoint::CCPoint(&v225.origin, v42, v43);
v46(v45, &v225.origin);
m_keysLabel = a1->m_keysLabel;
v48 = m_keysLabel->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v225.origin, 1.0, 0.5);
v48(m_keysLabel, &v225.origin);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))a1->m_keysLabel->setScale)(a1->m_keysLabel, 1058642330);
a1->addChild(a1, a1->m_keysLabel);
v49 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_bigKey_001.png");
v50 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_keySprite = v49;
v50->addChild_0(a1, v49, 3);
m_keySprite = a1->m_keySprite;
v52 = m_keySprite->setPosition;
v53 = a1->m_keysLabel->getPosition(a1->m_keysLabel);
cocos2d::CCPoint::CCPoint(&v224, 25.0, -0.5);
cocos2d::CCPoint::operator+(&v225, v53, &v224);
v54 = 0;
v52(m_keySprite, &v225.origin);
v55 = GameStatsManager::sharedState();
v56 = (const char *)GameStatsManager::getStat(v55, "43");
v57 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v56);
cocos2d::CCString::getCString(v57);
v58 = cocos2d::CCLabelBMFont::create();
a1->m_goldKeysLabel = v58;
v59 = v58;
v60 = v58->setPosition;
v61 = a1->m_keysLabel->getPosition(a1->m_keysLabel);
v60(v59, v61);
m_goldKeysLabel = a1->m_goldKeysLabel;
v63 = m_goldKeysLabel->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v225.origin, 1.0, 0.5);
v63(m_goldKeysLabel, &v225.origin);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))a1->m_goldKeysLabel->setScale)(a1->m_goldKeysLabel, 1058642330);
a1->addChild(a1, a1->m_goldKeysLabel);
v64 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_bigGoldKey_001.png");
v65 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_goldKeySprite = v64;
v65->addChild_0(a1, v64, 3);
m_goldKeySprite = a1->m_goldKeySprite;
v67 = m_goldKeySprite->setPosition;
v68 = a1->m_goldKeysLabel->getPosition(a1->m_goldKeysLabel);
cocos2d::CCPoint::CCPoint(&v224, 25.0, -0.5);
cocos2d::CCPoint::operator+(&v225, v68, &v224);
v67(m_goldKeySprite, &v225.origin);
a1->m_goldKeysLabel->setVisible(a1->m_goldKeysLabel, 0);
a1->m_goldKeySprite->setVisible(a1->m_goldKeySprite, 0);
v69 = cocos2d::CCSprite::createWithSpriteFrameName("treasureRoomLabel_001.png");
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v69, 2);
v70 = v69->setPosition;
cocos2d::CCPoint::CCPoint(&v225.origin, v212.width * 0.5, v212.height - 42.0);
v70(v69, &v225.origin);
v71 = cocos2d::CCSprite::createWithSpriteFrameName("treasureRoomGround_001.png");
a1->addChild_0(a1, v71, 2);
v72 = v71->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v225.origin, 0.0, 1.0);
v72(v71, &v225.origin);
v73 = v71->setPosition;
cocos2d::CCPoint::CCPoint(&v225.origin, -10.0, 35.0);
v73(v71, &v225.origin);
setBlendFunc = v71->setBlendFunc;
v213[0] = 770;
v213[1] = 1;
((void (__fastcall *)(cocos2d::CCSprite *, int, int, _DWORD *, _DWORD))setBlendFunc)(v71, 770, 1, v213, 0);
((void (__fastcall *)(cocos2d::CCSprite *, _DWORD))v71->setScale)(
v71,
(float)(v212.width + 20.0) / v71->m_obRect.size.width);
v75 = (cocos2d::CCArray *)((int (__fastcall *)(cocos2d::CCSprite *, int))v71->setOpacity)(v71, 150);
v202 = (cocos2d::CCArray *)cocos2d::CCArray::create(v75);
v207 = (cocos2d::CCArray *)cocos2d::CCArray::create(v202);
v76 = cocos2d::CCDictionary::create();
a1->m_chestCounters = v76;
cocos2d::CCObject::retain(v76);
do
{
v77 = (int)floorf((float)v54 / 3.0);
if ( cocos2d::CCArray::count(v202) < v77 + 1 )
{
v78 = cocos2d::CCLayer::create();
v79 = cocos2d::CCMenu::create();
v78->addChild(v78, v79);
cocos2d::CCArray::addObject(v202, v78);
cocos2d::CCArray::addObject(v207, v79);
}
v80 = cocos2d::CCArray::objectAtIndex(v202, v77);
v203 = (cocos2d::CCNode *)cocos2d::CCArray::objectAtIndex(v207, v77);
v81 = v54 % 3;
if ( !(v54 % 3) && v54 <= 5 )
{
v82 = floorf((float)v54 / 3.0);
v83 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"tier%ilabel_001.png",
(const char *)(int)(float)(v82 + 1.0));
CString = cocos2d::CCString::getCString(v83);
v85 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
(*(void (__fastcall **)(int, cocos2d::CCSprite *, int))(*(_DWORD *)v80 + 224))(v80, v85, 2);
v86 = v85->setPosition;
cocos2d::CCPoint::CCPoint(&v225.origin, v212.width * 0.5, (float)(v212.height * 0.5) + 70.0);
v86(v85, &v225.origin);
((void (__fastcall *)(cocos2d::CCSprite *, int))v85->setScale)(v85, 1061997773);
}
cocos2d::CCPoint::CCPoint(
&v222,
(float)((float)(v81 - 1) * 100.0) + (float)(v212.width * 0.5),
(float)(v212.height * 0.5) + 10.0);
if ( v54 > 5 )
v87 = (_BYTE *)(&dword_0 + 2);
else
v87 = (const char *)(v54 + 3);
v198 = (GJChestSprite *)v87;
v88 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"chest_0%i_price_001.png", v87);
v89 = (char *)cocos2d::CCString::getCString(v88);
sub_776584((int)&v215, v89);
v90 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"chest_0%i_02_001.png",
(const char *)v198);
v91 = (char *)cocos2d::CCString::getCString(v90);
sub_776584((int)&v216, v91);
if ( v54 <= 2 )
{
v92 = 0;
LOWORD(v214.x) = 14446;
BYTE2(v214.x) = -126;
LABEL_26:
v107 = 1061997773;
goto LABEL_27;
}
v92 = 0;
memset(&v214, 100, 3);
if ( v54 <= 5 )
goto LABEL_26;
v93 = (const char *)(v81 + 1);
*(_WORD *)((char *)&v214.x + 1) = -19456;
v94 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"chestSpecial_0%i_price_001.png",
v93);
v95 = (char *)cocos2d::CCString::getCString(v94);
sub_7753D4((int)&v215, v95);
if ( v93 == (_BYTE *)&dword_0 + 2 )
{
v96 = &v223;
v101 = GameStatsManager::sharedState();
sub_776584((int)&v223, "0005");
isSpecialChestUnlocked = GameStatsManager::isSpecialChestUnlocked((int)v101, (char **)&v223, v102, v103);
}
else if ( v93 == (_BYTE *)&dword_0 + 3 )
{
v96 = &v224;
v104 = GameStatsManager::sharedState();
sub_776584((int)&v224, "0006");
isSpecialChestUnlocked = GameStatsManager::isSpecialChestUnlocked((int)v104, (char **)&v224, v105, v106);
}
else
{
v96 = &v217;
v97 = GameStatsManager::sharedState();
sub_776584((int)&v217, "0004");
isSpecialChestUnlocked = GameStatsManager::isSpecialChestUnlocked((int)v97, (char **)&v217, v98, v99);
}
v92 = isSpecialChestUnlocked;
sub_774008(v96);
v107 = 1065353216;
LABEL_27:
v108 = GJChestSprite::create((int)v198);
((void (__fastcall *)(GJChestSprite *, int))v108->setScale)(v108, 1058642330);
v221 = 0;
v220 = SecretRewardsLayer::onChestType;
v109 = CCMenuItemSpriteExtra::create(
v108,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SecretRewardsLayer::onChestType, (unsigned int)a1));
sub_776584((int)&v225, "chestClick.ogg");
sub_775D40(&v109->m_selectSound, &v225);
sub_774008(&v225);
setContentSize = (char *)v109->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v225, 60.0, 48.0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *))setContentSize)(v109, &v225);
v209 = (char *)v108->setPosition;
width = v109->getContentSize(v109)->width;
v111 = (int)v109->getContentSize(v109);
cocos2d::CCPoint::CCPoint(&v225.origin, width * 0.5, *(float *)(v111 + 4) * 0.5);
((void (__fastcall *)(GJChestSprite *, cocos2d::CCRect *))v209)(v108, &v225);
v203->addChild(v203, v109);
v109->m_animationEnabled = 0;
v109->m_colorEnabled = 1;
v112 = v109->setPosition;
cocos2d::CCNode::convertToNodeSpace(&v225.origin, v203, &v222);
v112(v109, &v225.origin);
v109->setTag(v109, v54);
if ( v92 )
SecretRewardsLayer::switchToOpenedState(a1, v109);
v113 = cocos2d::CCSprite::createWithSpriteFrameName("chestPlatform_01_001.png");
(*(void (__fastcall **)(int, cocos2d::CCSprite *, int))(*(_DWORD *)v80 + 224))(v80, v113, 2);
v114 = v113->setPosition;
cocos2d::CCPoint::CCPoint(&v224, 0.0, -34.0);
cocos2d::CCPoint::operator+(&v225, &v222, &v224);
v114(v113, &v225.origin);
v113->setColor(v113, (const cocos2d::ccColor3B *)&v214);
v113->setOpacity(v113, 200);
v115 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)LODWORD(v215.x));
(*(void (__fastcall **)(int, cocos2d::CCSprite *, int))(*(_DWORD *)v80 + 224))(v80, v115, 2);
v204 = (cocos2d::CCPoint *)v115->setPosition;
v116 = (int)v113->getPosition(v113);
cocos2d::CCPoint::CCPoint(&v224, 0.0, -20.0);
cocos2d::CCPoint::operator+(&v225, v116, &v224);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCRect *))v204)(v115, &v225);
((void (__fastcall *)(cocos2d::CCSprite *, int))v115->setScale)(v115, v107);
if ( v54 > 5 )
{
if ( v54 == 6 )
{
cocos2d::CCPoint::CCPoint(&v223, (float)(v212.width * 0.5) + 10.0, (float)(v212.height * 0.5) + 72.0);
v127 = cocos2d::CCLabelBMFont::create();
v128 = v127->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_chestLabel = v127;
v128->setPosition(v127, &v223);
m_chestLabel = a1->m_chestLabel;
v130 = m_chestLabel->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v225.origin, 1.0, 0.5);
v130(m_chestLabel, &v225.origin);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))a1->m_chestLabel->setScale)(a1->m_chestLabel, 1056964608);
(*(void (__fastcall **)(int, cocos2d::CCLabelBMFont *))(*(_DWORD *)v80 + 220))(v80, a1->m_chestLabel);
v131 = cocos2d::CCSprite::createWithSpriteFrameName("chest03_small_001.png");
(*(void (__fastcall **)(int, cocos2d::CCSprite *))(*(_DWORD *)v80 + 220))(v80, v131);
v132 = v131->setPosition;
cocos2d::CCPoint::CCPoint(&v224, 22.0, 0.0);
cocos2d::CCPoint::operator+(&v225, &v223, &v224);
v132(v131, &v225.origin);
SecretRewardsLayer::updateUnlockedLabel(a1);
}
}
else
{
v117 = GameStatsManager::sharedState();
v118 = (const char *)GameStatsManager::countUnlockedSecretChests(v117, (GJRewardType)v198);
v119 = GameStatsManager::sharedState();
v120 = GameStatsManager::countSecretChests(v119, (GJRewardType)v198);
v121 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i / %i", v118, v120);
cocos2d::CCString::getCString(v121);
v122 = cocos2d::CCLabelBMFont::create();
(*(void (__fastcall **)(int, cocos2d::CCLabelBMFont *))(*(_DWORD *)v80 + 220))(v80, v122);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v122->setScale)(v122, 1053609165);
v205 = (cocos2d::CCPoint *)v122->setPosition;
v123 = (int)v115->getPosition(v115);
cocos2d::CCPoint::CCPoint(&v224, 0.0, -35.0);
cocos2d::CCPoint::operator+(&v225, v123, &v224);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, cocos2d::CCRect *))v205)(v122, &v225);
if ( (int)v118 >= v120 )
v124 = -1;
v125 = v122->setColor;
if ( (int)v118 >= v120 )
v126 = 0;
else
v126 = -69;
if ( (int)v118 >= v120 )
BYTE1(v225.origin.x) = v124;
else
LOBYTE(v225.origin.x) = v126;
if ( (int)v118 >= v120 )
LOBYTE(v225.origin.x) = v126;
else
v126 = 122;
if ( (int)v118 < v120 )
{
BYTE1(v225.origin.x) = v126;
v126 = 107;
}
BYTE2(v225.origin.x) = v126;
v125(v122, (const cocos2d::ccColor3B *)&v225);
cocos2d::CCDictionary::setObject(a1->m_chestCounters, v122, (intptr_t)v198);
}
++v54;
sub_774008(&v216);
sub_774008(&v215);
}
while ( v54 != 9 );
cocos2d::CCPoint::CCPoint(&v214, v212.width * 0.5, (float)(v212.height * 0.5) + 12.0);
v133 = cocos2d::CCLayer::create();
cocos2d::CCArray::addObject(v202, v133);
v134 = cocos2d::CCMenu::create();
v133->addChild(v133, v134);
v135 = GJChestSprite::create(9);
((void (__fastcall *)(GJChestSprite *, int))v135->setScale)(v135, 1060655596);
v222.y = 0.0;
LODWORD(v222.x) = SecretRewardsLayer::onGoldChest;
v136 = CCMenuItemSpriteExtra::create(
v135,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SecretRewardsLayer::onGoldChest, (unsigned int)a1));
sub_776584((int)&v225, "chestClick.ogg");
sub_775D40(&v136->m_selectSound, &v225);
sub_774008(&v225);
v137 = v136->setContentSize;
v138 = COERCE_FLOAT(((int (__fastcall *)(GJChestSprite *))v135->getScale)(v135));
v139 = v135->getScale(v135);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v225, v138 * 100.0, v139 * 80.0);
v137(v136, (const cocos2d::CCSize *)&v225);
v140 = v135->setPosition;
v141 = v136->getContentSize(v136)->width;
v142 = (int)v136->getContentSize(v136);
cocos2d::CCPoint::CCPoint(&v225.origin, v141 * 0.5, *(float *)(v142 + 4) * 0.5);
v140(v135, &v225.origin);
v134->addChild(v134, v136);
v136->m_animationEnabled = 0;
v136->m_colorEnabled = 1;
v143 = v136->setPosition;
cocos2d::CCNode::convertToNodeSpace(&v225.origin, v134, &v214);
v143(v136, &v225.origin);
v144 = GameStatsManager::sharedState();
if ( !GameStatsManager::getNextGoldChestID(v144) )
SecretRewardsLayer::switchToOpenedState(a1, v136);
v145 = cocos2d::CCSprite::createWithSpriteFrameName("chestPlatform_01_001.png");
v133->addChild_0(v133, v145, 2);
v146 = v145->setPosition;
cocos2d::CCPoint::CCPoint(&v224, 0.0, -40.8);
cocos2d::CCPoint::operator+(&v225, &v214, &v224);
v146(v145, &v225.origin);
v147 = v145->setColor;
qmemcpy(&v225, "\\Pg", 3);
v147(v145, (const cocos2d::ccColor3B *)&v225);
v145->setOpacity(v145, 200);
((void (__fastcall *)(cocos2d::CCSprite *, int))v145->setScale)(v145, 1067030938);
v148 = cocos2d::CCSprite::createWithSpriteFrameName("chest_09_price_001.png");
v133->addChild_0(v133, v148, 2);
v149 = v148->setPosition;
v150 = (int)v145->getPosition(v145);
cocos2d::CCPoint::CCPoint(&v224, 0.0, -24.0);
cocos2d::CCPoint::operator+(&v225, v150, &v224);
v149(v148, &v225.origin);
((void (__fastcall *)(cocos2d::CCSprite *, int))v148->setScale)(v148, 1064682128);
cocos2d::CCPoint::CCPoint(&v215, v212.width * 0.5, (float)(v212.height * 0.5) + 72.0);
v151 = (cocos2d::CCSprite *)cocos2d::CCLabelBMFont::create();
v152 = v151->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_goldPriceSprite = v151;
v152->setPosition(v151, &v215);
m_goldPriceSprite = a1->m_goldPriceSprite;
v154 = m_goldPriceSprite->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v225.origin, 0.5, 0.5);
v154(m_goldPriceSprite, &v225.origin);
((void (__fastcall *)(cocos2d::CCSprite *, int))a1->m_goldPriceSprite->setScale)(a1->m_goldPriceSprite, 1056964608);
v133->addChild(v133, a1->m_goldPriceSprite);
SecretRewardsLayer::updateUnlockedGoldLabel(a1);
v155 = cocos2d::CCLayer::create();
cocos2d::CCArray::addObject(v202, v155);
v156 = cocos2d::CCMenu::create();
addChild = v155->addChild;
v158 = v156;
v159 = v155;
v160 = 1;
addChild(v159, v158);
while ( 2 )
{
sub_776584((int)&v211, "shopRope2_001.png");
sub_776584((int)&v216, "shopRope2_2_001.png");
switch ( v160 )
{
case 3:
sub_7753D4((int)&v211, "shopRope4_001.png");
v161 = "shopRope4_2_001.png";
LABEL_56:
sub_7753D4((int)&v216, v161);
break;
case 4:
sub_7753D4((int)&v211, "shopRope5_001.png");
v161 = "shopRope5_2_001.png";
goto LABEL_56;
case 2:
sub_7753D4((int)&v211, "shopRope3_001.png");
v161 = "shopRope3_2_001.png";
goto LABEL_56;
}
v162 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v211);
v223.y = 0.0;
LODWORD(v223.x) = SecretRewardsLayer::onShop;
v163 = CCMenuItemSpriteExtra::create(
v162,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SecretRewardsLayer::onShop, (unsigned int)a1));
v163->setTag(v163, v160);
v158->addChild(v158, v163);
CCMenuItemSpriteExtra::setSizeMult(v163, 1.5);
v164 = v163->setPosition;
cocos2d::CCPoint::CCPoint(
&v224,
(float)((float)((float)(v160 - 1) * 70.0) - 105.0) + (float)(v212.width * 0.5),
v212.height - 100.0);
cocos2d::CCNode::convertToNodeSpace(&v225.origin, v158, &v224);
v164(v163, &v225.origin);
CCMenuItemSpriteExtra::useAnimationType(v163, Move);
cocos2d::CCPoint::CCPoint(&v225.origin, 0.0, -15.0);
cocos2d::CCPoint::operator=((PlayerObject *)&v163->m_offset, COERCE_FLOAT(&v225), v165, v166);
v163->m_duration = 0.3;
v163->m_unselectedDuration = 0.3;
cocos2d::CCPoint::CCPoint(&v217, 25.0, 76.0);
if ( v160 == 2 )
{
v167 = 2.25;
goto LABEL_59;
}
if ( v160 == 3 )
{
v167 = 3.5;
LABEL_59:
v217.x = v217.x - v167;
}
for ( i = 0; i != 6; ++i )
{
v170 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)LODWORD(v216.x));
v169 = v170;
v162->addChild(v162, v170);
v199 = (GJChestSprite *)v169->setPosition;
cocos2d::CCPoint::CCPoint(&v224, 0.0, (float)i * 20.5);
cocos2d::CCPoint::operator+(&v225, &v217, &v224);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCRect *))v199)(v169, &v225);
}
++v160;
sub_774008(&v216);
sub_774008(&v211);
if ( v160 != 5 )
continue;
break;
}
v171 = BoomScrollLayer::create(v202, 0, 1, nullptr, nullptr);
a1->m_mainScrollLayer = v171;
a1->m_mainLayer->addChild(a1->m_mainLayer, v171);
m_mainScrollLayer = a1->m_mainScrollLayer;
v173 = v212.width;
v174 = cocos2d::CCDirector::sharedDirector();
v175 = COERCE_FLOAT(cocos2d::CCDirector::getScreenBottom(v174));
cocos2d::CCPoint::CCPoint(&v225.origin, v173 * 0.5, v175 + 10.0);
LODWORD(v176.x) = &v225;
BoomScrollLayer::setPagesIndicatorPosition(m_mainScrollLayer, v176);
v177 = a1->m_mainScrollLayer;
v177->m_unkFloat2 = 0.9;
v177->m_doVisit = 1;
v178 = cocos2d::CCDirector::sharedDirector();
v179 = COERCE_FLOAT(cocos2d::CCDirector::getScreenRight(v178));
v180 = cocos2d::CCDirector::sharedDirector();
v181 = COERCE_FLOAT(cocos2d::CCDirector::getScreenTop(v180));
cocos2d::CCRect::CCRect(&v225, 0.0, 0.0, v179, v181);
cocos2d::CCRect::operator=(&v177->m_clippingRect, &v225);
a1->m_mainScrollLayer->m_extendedLayer->m_delegate = &a1->BoomScrollLayerDelegate;
v182 = cocos2d::CCMenu::create();
v182->setTouchPriority(v182, -129);
v183 = (float)(v212.height * 0.5) - 30.0;
v184 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v224.y = 0.0;
LODWORD(v224.x) = SecretRewardsLayer::onSwitchPage;
v185 = CCMenuItemSpriteExtra::create(
v184,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SecretRewardsLayer::onSwitchPage, (unsigned int)a1));
v186 = v182->cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_leftButton = v185;
v186->addChild(v182, v185);
m_leftButton = a1->m_leftButton;
v200 = (GJChestSprite *)m_leftButton->setPosition;
v187 = cocos2d::CCDirector::sharedDirector();
v188 = COERCE_FLOAT(cocos2d::CCDirector::getScreenLeft(v187));
cocos2d::CCPoint::CCPoint(&v217, v188 + 24.0, v183);
cocos2d::CCNode::convertToNodeSpace(&v225.origin, v182, &v217);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *))v200)(m_leftButton, &v225);
a1->m_leftButton->setTag(a1->m_leftButton, 0);
CCMenuItemSpriteExtra::setSizeMult(a1->m_leftButton, 2.0);
v189 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
cocos2d::CCSprite::setFlipX(v189, 1);
v225.origin.y = 0.0;
LODWORD(v225.origin.x) = SecretRewardsLayer::onSwitchPage;
v190 = CCMenuItemSpriteExtra::create(
v189,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SecretRewardsLayer::onSwitchPage, (unsigned int)a1));
v191 = v182->cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_rightButton = v190;
v191->addChild(v182, v190);
m_rightButton = a1->m_rightButton;
v193 = m_rightButton->setPosition;
v194 = cocos2d::CCDirector::sharedDirector();
v195 = COERCE_FLOAT(cocos2d::CCDirector::getScreenRight(v194));
cocos2d::CCPoint::CCPoint(&v216, v195 - 24.0, v183);
cocos2d::CCNode::convertToNodeSpace(&v217, v182, &v216);
v193(m_rightButton, &v217);
a1->m_rightButton->setTag(a1->m_rightButton, 1);
CCMenuItemSpriteExtra::setSizeMult(a1->m_rightButton, 2.0);
a1->addChild_0(a1, v182, 10);
if ( v210 )
{
TotalPages = BoomScrollLayer::getTotalPages(a1->m_mainScrollLayer);
BoomScrollLayer::instantMoveToPage(a1->m_mainScrollLayer, TotalPages - 2);
BoomScrollLayer::instantMoveToPage(a1->m_mainScrollLayer, TotalPages - 1);
}
return v206;
}