//
// SecretLayer4::init from 0x4f19b4 to 0x4f217c (1992 bytes)
//
// 1 xrefs:
// > SecretLayer4::create @ 0x4f02cc
//
// 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 SecretLayer4::init(SecretLayer4 *a1)
{
_BOOL4 v2; // r9
cocos2d::CCTextureCache *v3; // r0
cocos2d::CCSpriteFrameCache *v4; // r0
GameManager *v5; // r6
int v6; // r2
int v7; // r3
cocos2d::CCDirector *v8; // r0
cocos2d::CCDictionary *v9; // r0
AchievementManager *v10; // r0
cocos2d::CCDictionary *m_messageThreads; // r6
cocos2d::CCNode *v12; // r0
AchievementManager *v13; // r0
cocos2d::CCDictionary *v14; // r6
cocos2d::CCNode *v15; // r0
AchievementManager *v16; // r0
cocos2d::CCDictionary *v17; // r6
cocos2d::CCNode *v18; // r0
AchievementManager *v19; // r0
cocos2d::CCDictionary *v20; // r6
cocos2d::CCNode *v21; // r0
AchievementManager *v22; // r0
cocos2d::CCDictionary *v23; // r6
cocos2d::CCNode *v24; // r0
AchievementManager *v25; // r0
cocos2d::CCDictionary *v26; // r6
cocos2d::CCNode *v27; // r0
AchievementManager *v28; // r0
cocos2d::CCDictionary *v29; // r6
cocos2d::CCNode *v30; // r0
GameManager *v31; // r0
const char *v32; // r1
cocos2d::CCDelayTime *v33; // r0
cocos2d::CCSequence *v34; // r11
cocos2d::CCFiniteTimeAction *v35; // r0
cocos2d::CCAction *v36; // r0
cocos2d::CCNode *v37; // r6
void (__fastcall *setAnchorPoint)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r11
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r11
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // r3
cocos2d::CCLabelBMFont *v41; // r6
void (__fastcall *v42)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r11
cocos2d::CCLabelBMFont *v43; // r0
SecretLayer4_vtbl *v44; // r3
cocos2d::CCNode *v45; // r10
CCTextInputNode *v46; // r0
SecretLayer4_vtbl *v47; // r3
CCTextInputNode *m_searchInput; // r6
cocos2d::CCSprite *v49; // r0
CCMenuItemSpriteExtra *v50; // r11
cocos2d::CCNode *v51; // r10
void (__fastcall *v52)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r6
cocos2d::CCDirector *v53; // r0
float v54; // s18
cocos2d::CCDirector *v55; // r0
float v56; // r0
cocos2d::CCNode *v57; // r6
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // r11
cocos2d::CCSprite *v59; // r11
CCMenuItemSpriteExtra *v60; // r0
cocos2d::CCNode_vtbl *v61; // r3
CCMenuItemSpriteExtra *m_submitButton; // r11
GameStatsManager *v63; // r10
stl::StringData::Internal *v64; // r2
stl::StringData::Internal *v65; // r3
int isSpecialChestUnlocked; // r10
cocos2d::CCMenu *v67; // r10
GameStatsManager *v68; // r11
int RewardForSpecialChest; // r11
GJChestSprite *v70; // r11
CCMenuItemSpriteExtra *v71; // r5
void (__fastcall *v72)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // r7
void (__fastcall *v73)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
float width; // s17
int v75; // r0
void (__fastcall *v76)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
float v78; // r2
float v79; // r3
char *v80; // [sp+8h] [bp-74h]
char *v81; // [sp+8h] [bp-74h]
char *v82; // [sp+8h] [bp-74h]
cocos2d::CCLabelBMFont *m_messageLabel; // [sp+Ch] [bp-70h]
cocos2d::CCSize v84; // [sp+14h] [bp-68h] BYREF
cocos2d::CCPoint v85; // [sp+1Ch] [bp-60h] BYREF
cocos2d::CCSize v86; // [sp+24h] [bp-58h] BYREF
cocos2d::CCPoint v87; // [sp+2Ch] [bp-50h] BYREF
cocos2d::CCPoint v88; // [sp+34h] [bp-48h] BYREF
void (*v89)(SecretLayer4 *); // [sp+3Ch] [bp-40h]
int v90; // [sp+40h] [bp-3Ch]
void (*v91)(SecretLayer4 *, cocos2d::CCObject *); // [sp+44h] [bp-38h]
int v92; // [sp+48h] [bp-34h]
cocos2d::CCPoint v93; // [sp+4Ch] [bp-30h] BYREF
cocos2d::CCRect v94; // [sp+54h] [bp-28h] BYREF
cocos2d::CCRect v95; // [sp+64h] [bp-18h] BYREF
cocos2d::CCSize v96; // 0:^0.8
cocos2d::CCRect v97; // 0:kr00_16.16
v2 = cocos2d::CCLayer::init(a1);
if ( v2 )
{
v3 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v3, "SecretSheet.png", 0);
v4 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v4, "SecretSheet.plist");
v5 = GameManager::sharedState();
sub_776584((int)&v95, "secretLoop03.mp3");
GameManager::fadeInMusic((int)v5, &v95, v6, v7);
sub_774008(&v95);
a1->setKeypadEnabled(a1, 1);
a1->setKeyboardEnabled(a1, 1);
v8 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v84, v8);
v9 = cocos2d::CCDictionary::create();
a1->m_messageThreads = v9;
cocos2d::CCObject::retain(v9);
v10 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v10, "geometry.ach.v3.secret01") )
{
m_messageThreads = a1->m_messageThreads;
v12 = SecretLayer4::nodeWithTag(a1, 1);
cocos2d::CCDictionary::setObject(m_messageThreads, v12, 1);
}
v13 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v13, "geometry.ach.v3.secret02") )
{
v14 = a1->m_messageThreads;
v15 = SecretLayer4::nodeWithTag(a1, 2);
cocos2d::CCDictionary::setObject(v14, v15, 2);
}
v16 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v16, "geometry.ach.v3.secret03") )
{
v17 = a1->m_messageThreads;
v18 = SecretLayer4::nodeWithTag(a1, 3);
cocos2d::CCDictionary::setObject(v17, v18, 3);
}
v19 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v19, "geometry.ach.v3.secret04") )
{
v20 = a1->m_messageThreads;
v21 = SecretLayer4::nodeWithTag(a1, 4);
cocos2d::CCDictionary::setObject(v20, v21, 4);
}
v22 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v22, "geometry.ach.v3.secret05") )
{
v23 = a1->m_messageThreads;
v24 = SecretLayer4::nodeWithTag(a1, 5);
cocos2d::CCDictionary::setObject(v23, v24, 5);
}
v25 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v25, "geometry.ach.v3.secret06") )
{
v26 = a1->m_messageThreads;
v27 = SecretLayer4::nodeWithTag(a1, 6);
cocos2d::CCDictionary::setObject(v26, v27, 6);
}
v28 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v28, "geometry.ach.v3.secret07") )
{
v29 = a1->m_messageThreads;
v30 = SecretLayer4::nodeWithTag(a1, 7);
cocos2d::CCDictionary::setObject(v29, v30, 7);
}
v31 = GameManager::sharedState();
if ( !GameManager::getUGV(v31, (const char *)&aO1i2r3e45s7t89[13]) )
{
v33 = cocos2d::CCDelayTime::create(0.8);
v90 = 0;
v89 = SecretLayer4::showFirstDialog;
v34 = (cocos2d::CCSequence *)v33;
v35 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, SecretLayer4::showFirstDialog, 0);
v36 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v34, v35, 0);
cocos2d::CCNode::runAction(a1, v36);
a1->m_basicMessageIndex = 30;
}
v37 = (cocos2d::CCNode *)cocos2d::CCSprite::create((cocos2d::CCSprite *)"GJ_gradientBG.png", v32);
setAnchorPoint = v37->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v95.origin, 0.0, 0.0);
setAnchorPoint(v37, &v95.origin);
a1->addChild_0(a1, v37, -3);
((void (__fastcall *)(cocos2d::CCNode *, _DWORD))v37->setScaleX)(v37, (float)(v84.width + 10.0) / v37[1].m_fSkewX);
((void (__fastcall *)(cocos2d::CCNode *, _DWORD))v37->setScaleY)(v37, (float)(v84.height + 10.0) / v37[1].m_fSkewY);
setPosition = v37->setPosition;
cocos2d::CCPoint::CCPoint(&v95.origin, -5.0, -5.0);
setPosition(v37, &v95.origin);
getTag = v37->__vftable[1].getTag;
strcpy((char *)&v95, "K\n");
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))getTag)(v37, &v95);
cocos2d::CCRect::CCRect(&v94, 0.0, 0.0, 40.0, 40.0);
v41 = cocos2d::CCLabelBMFont::create();
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v41->setScale)(v41, 1065353216);
a1->addChild(a1, v41);
v42 = v41->setPosition;
cocos2d::CCPoint::CCPoint(&v95.origin, v84.width * 0.5, v84.height - 24.0);
v42(v41, &v95.origin);
cocos2d::CCPoint::CCPoint(&v85, v84.width * 0.5, (float)(v84.height * 0.5) + 50.0);
v43 = cocos2d::CCLabelBMFont::create();
v44 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_messageLabel = v43;
v44->addChild(a1, v43);
m_messageLabel = a1->m_messageLabel;
v80 = (char *)m_messageLabel->setPosition;
cocos2d::CCPoint::CCPoint(&v93, 0.0, 43.0);
cocos2d::CCPoint::operator+(&v95, &v85, &v93);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, cocos2d::CCRect *))v80)(m_messageLabel, &v95);
SecretLayer4::getMessage((SecretLayer4 *)&v95, a1);
SecretLayer4::updateMessageLabel((int)a1, &v95);
sub_774008(&v95);
cocos2d::CCRect::CCRect(&v95, &v94);
v97.origin.x = v78;
v97.origin.y = v79;
v97.size = v96;
v45 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"square02b_small.png",
(const char *)&v95,
v97);
((void (__fastcall *)(cocos2d::CCNode *, int))v45->__vftable[1].~CCNode_0)(v45, 100);
cocos2d::CCSize::CCSize(&v86, 200.0, 40.0);
v45->setContentSize(v45, &v86);
a1->addChild_0(a1, v45, -2);
v45->setPosition(v45, &v85);
((void (__fastcall *)(cocos2d::CCNode *, void *))v45->__vftable[1].getTag)(v45, &unk_9ACAB4);
v46 = CCTextInputNode::create(180.0, 50.0, "...", "Thonburi");
v47 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_searchInput = v46;
((void (__fastcall *)(SecretLayer4 *, CCTextInputNode *, int, void (__fastcall *)(cocos2d::CCNode *__hidden, cocos2d::CCNode *, int), int *, const char *))v47->addChild_0)(
a1,
v46,
20,
v47->addChild_0,
&dword_18,
"bigFont.fnt");
a1->m_searchInput->m_delegate = &a1->TextInputDelegate;
a1->m_searchInput->setPosition(a1->m_searchInput, &v85);
CCTextInputNode::setMaxLabelScale(a1->m_searchInput, 0.7);
CCTextInputNode::setMaxLabelWidth(a1->m_searchInput, 180.0);
a1->m_searchInput->m_textField->setVisible(a1->m_searchInput->m_textField, 0);
m_searchInput = a1->m_searchInput;
m_searchInput->m_maxLabelLength = 100;
sub_776584(
(int)&v95,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
CCTextInputNode::setAllowedChars((int)m_searchInput, (int)&v95);
sub_774008(&v95);
SecretLayer4::updateSearchLabel(a1, (const char *)&unk_939830);
v49 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v92 = 0;
v91 = SecretLayer4::onBack;
v50 = CCMenuItemSpriteExtra::create(
v49,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SecretLayer4::onBack, (unsigned int)a1));
CCMenuItemSpriteExtra::setSizeMult(v50, 1.5);
v51 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v50, nullptr);
a1->addChild_0(a1, v51, 1);
v52 = v51->setPosition;
v53 = cocos2d::CCDirector::sharedDirector();
v54 = COERCE_FLOAT(cocos2d::CCDirector::getScreenLeft(v53));
v55 = cocos2d::CCDirector::sharedDirector();
v56 = COERCE_FLOAT(cocos2d::CCDirector::getScreenTop(v55));
cocos2d::CCPoint::CCPoint(&v95.origin, v54 + 24.0, v56 - 23.0);
v52(v51, &v95.origin);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v50);
v57 = cocos2d::CCNode::create();
setContentSize = v57->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v95, 80.0, 80.0);
setContentSize(v57, (const cocos2d::CCSize *)&v95);
v59 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_secretLock3_001.png");
v57->addChild(v57, v59);
v81 = (char *)v59->setPosition;
cocos2d::CCPoint::CCPoint(&v95.origin, 40.0, 40.0);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCRect *))v81)(v59, &v95);
v93.y = 0.0;
LODWORD(v93.x) = SecretLayer4::onSubmit;
v60 = CCMenuItemSpriteExtra::create(
v57,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SecretLayer4::onSubmit, (unsigned int)a1));
v61 = v51->__vftable;
a1->m_submitButton = v60;
v61->addChild(v51, v60);
m_submitButton = a1->m_submitButton;
v82 = (char *)m_submitButton->setPosition;
cocos2d::CCPoint::CCPoint(&v88, v84.width * 0.5, (float)(v84.height * 0.5) - 20.0);
cocos2d::CCNode::convertToNodeSpace(&v95.origin, v51, &v88);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *))v82)(m_submitButton, &v95);
CCMenuItemSpriteExtra::setSizeMult(a1->m_submitButton, 1.0);
v63 = GameStatsManager::sharedState();
sub_776584((int)&v95, "0003");
isSpecialChestUnlocked = GameStatsManager::isSpecialChestUnlocked((int)v63, (char **)&v95, v64, v65);
sub_774008(&v95);
if ( isSpecialChestUnlocked )
{
LOBYTE(v2) = isSpecialChestUnlocked;
}
else
{
v67 = cocos2d::CCMenu::create();
a1->addChild_0(a1, v67, 10);
v68 = GameStatsManager::sharedState();
sub_776584((int)&v95, "0003");
RewardForSpecialChest = GameStatsManager::getRewardForSpecialChest((int)v68, (const std::string *)&v95);
sub_774008(&v95);
v70 = GJChestSprite::create(*(_DWORD *)(RewardForSpecialChest + 60));
GJChestSprite::switchToState(v70, Closed, 0);
((void (__fastcall *)(GJChestSprite *, int))v70->setScale)(v70, 1058642330);
v95.origin.y = 0.0;
LODWORD(v95.origin.x) = SecretLayer4::onChest01;
v71 = CCMenuItemSpriteExtra::create(
v70,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SecretLayer4::onChest01, (unsigned int)a1));
sub_776584((int)&v88, "chestClick.ogg");
sub_775D40(&v71->m_selectSound, &v88);
sub_774008(&v88);
v72 = v71->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v88, 60.0, 48.0);
v72(v71, (const cocos2d::CCSize *)&v88);
v73 = v70->setPosition;
width = v71->getContentSize(v71)->width;
v75 = (int)v71->getContentSize(v71);
cocos2d::CCPoint::CCPoint(&v88, width * 0.5, *(float *)(v75 + 4) * 0.5);
v73(v70, &v88);
v67->addChild(v67, v71);
v76 = v71->setPosition;
cocos2d::CCPoint::CCPoint(&v87, v84.width - 60.0, 60.0);
cocos2d::CCNode::convertToNodeSpace(&v88, v67, &v87);
v76(v71, &v88);
}
}
return v2;
}