//
// SecretLayer4::init from 0x94a77c to 0x94b4b4 (3384 bytes)
//
// 3 xrefs:
// > SecretLayer4::create @ 0x94b580
// > ??> @ 0x55428
// > ??> @ 0x11b3f10
//
// 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)
{
bool v2; // w23
cocos2d::CCTextureCache *v4; // x0
cocos2d::CCSpriteFrameCache *v5; // x0
GameManager *v6; // x21
void *v7; // x0
cocos2d::CCDirector *v8; // x0
cocos2d::CCDictionary *v9; // x0
AchievementManager *v10; // x0
AchievementManager *v11; // x0
AchievementManager *v12; // x0
AchievementManager *v13; // x0
AchievementManager *v14; // x0
AchievementManager *v15; // x0
AchievementManager *v16; // x0
GameManager *v17; // x0
const char *v18; // x1
cocos2d::CCNode *v19; // x21
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // x2
cocos2d::CCLabelBMFont *v21; // x21
cocos2d::CCLabelBMFont *v22; // x0
SecretLayer4_vtbl *v23; // x2
cocos2d::CCLabelBMFont *m_messageLabel; // x21
void *v25; // x0
cocos2d::CCNode *v26; // x21
CCTextInputNode *v27; // x0
CCTextInputNode *m_searchInput; // x21
void *v29; // x0
cocos2d::CCSprite *v30; // x0
CCMenuItemSpriteExtra *v31; // x26
cocos2d::CCNode *v32; // x21
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
cocos2d::CCDirector *v34; // x0
float v35; // s0
float v36; // s9
cocos2d::CCDirector *v37; // x0
float v38; // s0
cocos2d::CCNode *v39; // x26
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x27
cocos2d::CCSprite *v41; // x27
CCMenuItemSpriteExtra *v42; // x0
cocos2d::CCNode_vtbl *v43; // x2
CCMenuItemSpriteExtra *m_submitButton; // x26
GameStatsManager *v45; // x21
int isSpecialChestUnlocked; // w21
void *v47; // x0
cocos2d::CCMenu *v48; // x26
GameStatsManager *v49; // x21
__int64 RewardForSpecialChest; // x21
void *v51; // x0
GJChestSprite *v52; // x27
CCMenuItemSpriteExtra *v53; // x21
void *v54; // x0
void (__fastcall *v55)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x19
void (__fastcall *v56)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x19
__int128 v57; // q0
const cocos2d::CCSize *(__fastcall *getContentSize)(const cocos2d::CCNode *__hidden); // x1
__int64 v59; // x0
void (__fastcall *v60)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x19
cocos2d::CCDictionary *v61; // x21
cocos2d::CCNode *v62; // x0
AchievementManager *v63; // x0
cocos2d::CCDictionary *v64; // x21
cocos2d::CCNode *v65; // x0
AchievementManager *v66; // x0
cocos2d::CCDictionary *v67; // x21
cocos2d::CCNode *v68; // x0
AchievementManager *v69; // x0
cocos2d::CCDictionary *v70; // x21
cocos2d::CCNode *v71; // x0
GameManager *v72; // x0
cocos2d::CCSequence *v73; // x21
cocos2d::CCFiniteTimeAction *v74; // x0
cocos2d::CCAction *v75; // x0
cocos2d::CCDictionary *v76; // x21
cocos2d::CCNode *v77; // x0
cocos2d::CCDictionary *v78; // x21
cocos2d::CCNode *v79; // x0
cocos2d::CCDictionary *m_messageThreads; // x21
cocos2d::CCNode *v81; // x0
unsigned int *v82; // x1
int v83; // w2
unsigned int *v84; // x1
int v85; // w2
unsigned int *v86; // x1
int v87; // w2
unsigned int *v88; // x1
int v89; // w2
unsigned int *v90; // x19
int v91; // w1
unsigned int *v92; // x1
int v93; // w2
cocos2d::CCSize *v94[2]; // [xsp+0h] [xbp+0h] BYREF
cocos2d::CCSize *v95[2]; // [xsp+80h] [xbp+80h]
float v96; // [xsp+98h] [xbp+98h]
float v97; // [xsp+9Ch] [xbp+9Ch]
cocos2d::CCPoint v98; // [xsp+A0h] [xbp+A0h] BYREF
char v99; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCPoint v100; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCRect v101; // [xsp+B8h] [xbp+B8h] BYREF
cocos2d::CCRect v102; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCPoint v103; // 0:kr08_8.8
cocos2d::CCPoint v104; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v105; // 0:x2.16
cocos2d::SEL_MenuHandler v106; // 0:x2.16
cocos2d::SEL_MenuHandler v107; // 0:x2.16
cocos2d::CCRect v108; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v2 = cocos2d::CCLayer::init(a1);
if ( !v2 )
return v2;
v4 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v4, "SecretSheet.png", 0);
v5 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v5, "SecretSheet.plist");
v6 = GameManager::sharedState();
sub_D153B8((unsigned int)v94 + 200, "secretLoop03.mp3");
GameManager::fadeInMusic((__int64)v6, &v102);
v7 = (void *)(*(_QWORD *)&v102.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v102.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v88 = (unsigned int *)(*(_QWORD *)&v102.origin - 8LL);
do
v89 = __ldaxr(v88);
while ( __stlxr(v89 - 1, v88) );
}
else
{
v89 = *(_DWORD *)(*(_QWORD *)&v102.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v102.origin - 8LL) = v89 - 1;
}
if ( v89 <= 0 )
operator delete(v7);
}
a1->setKeypadEnabled(a1, 1);
a1->setKeyboardEnabled(a1, 1);
v8 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(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;
v81 = SecretLayer4::nodeWithTag(a1, 1);
cocos2d::CCDictionary::setObject(m_messageThreads, v81, 1);
}
v11 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v11, "geometry.ach.v3.secret02") )
{
v78 = a1->m_messageThreads;
v79 = SecretLayer4::nodeWithTag(a1, 2);
cocos2d::CCDictionary::setObject(v78, v79, 2);
}
v12 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v12, "geometry.ach.v3.secret03") )
{
v76 = a1->m_messageThreads;
v77 = SecretLayer4::nodeWithTag(a1, 3);
cocos2d::CCDictionary::setObject(v76, v77, 3);
}
v13 = AchievementManager::sharedState();
if ( AchievementManager::isAchievementEarned(v13, "geometry.ach.v3.secret04") )
{
v14 = AchievementManager::sharedState();
if ( AchievementManager::isAchievementEarned(v14, "geometry.ach.v3.secret05") )
goto LABEL_12;
}
else
{
v61 = a1->m_messageThreads;
v62 = SecretLayer4::nodeWithTag(a1, 4);
cocos2d::CCDictionary::setObject(v61, v62, 4);
v63 = AchievementManager::sharedState();
if ( AchievementManager::isAchievementEarned(v63, "geometry.ach.v3.secret05") )
{
LABEL_12:
v15 = AchievementManager::sharedState();
if ( AchievementManager::isAchievementEarned(v15, "geometry.ach.v3.secret06") )
goto LABEL_13;
goto LABEL_27;
}
}
v64 = a1->m_messageThreads;
v65 = SecretLayer4::nodeWithTag(a1, 5);
cocos2d::CCDictionary::setObject(v64, v65, 5);
v66 = AchievementManager::sharedState();
if ( AchievementManager::isAchievementEarned(v66, "geometry.ach.v3.secret06") )
{
LABEL_13:
v16 = AchievementManager::sharedState();
if ( AchievementManager::isAchievementEarned(v16, "geometry.ach.v3.secret07") )
goto LABEL_14;
LABEL_28:
v70 = a1->m_messageThreads;
v71 = SecretLayer4::nodeWithTag(a1, 7);
cocos2d::CCDictionary::setObject(v70, v71, 7);
v72 = GameManager::sharedState();
if ( GameManager::getUGV(v72, "9") )
goto LABEL_15;
goto LABEL_29;
}
LABEL_27:
v67 = a1->m_messageThreads;
v68 = SecretLayer4::nodeWithTag(a1, 6);
cocos2d::CCDictionary::setObject(v67, v68, 6);
v69 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v69, "geometry.ach.v3.secret07") )
goto LABEL_28;
LABEL_14:
v17 = GameManager::sharedState();
if ( GameManager::getUGV(v17, "9") )
goto LABEL_15;
LABEL_29:
v73 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(0.8);
v74 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, SecretLayer4::showFirstDialog, 0);
v75 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v73, v74, 0);
cocos2d::CCNode::runAction(a1, v75);
a1->m_basicMessageIndex = 30;
LABEL_15:
v19 = (cocos2d::CCNode *)cocos2d::CCSprite::create((cocos2d::CCSprite *)"GJ_gradientBG.png", v18);
v95[0] = (cocos2d::CCSize *)v19->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v102.origin, 0.0, 0.0);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))v95[0])(v19, &v102);
a1->addChild_0(a1, v19, -3);
v19->setScaleX(v19, (float)(v96 + 10.0) / v19[1].m_obContentSize.height);
v19->setScaleY(v19, (float)(v97 + 10.0) / v19[1].m_sAdditionalTransform.a);
v95[0] = (cocos2d::CCSize *)v19->setPosition;
cocos2d::CCPoint::CCPoint(&v102.origin, -5.0, -5.0);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))v95[0])(v19, &v102);
getTag = v19->__vftable[1].getTag;
strcpy((char *)&v102, "K\n");
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCRect *))getTag)(v19, &v102);
cocos2d::CCRect::CCRect(&v101, 0.0, 0.0, 40.0, 40.0);
v21 = cocos2d::CCLabelBMFont::create();
v21->setScale(v21, 1.0);
a1->addChild(a1, v21);
v95[0] = (cocos2d::CCSize *)v21->setPosition;
cocos2d::CCPoint::CCPoint(&v102.origin, v96 * 0.5, v97 - 24.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, cocos2d::CCRect *))v95[0])(v21, &v102);
cocos2d::CCPoint::CCPoint(&v98, v96 * 0.5, (float)(v97 * 0.5) + 50.0);
v22 = cocos2d::CCLabelBMFont::create();
v23 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_messageLabel = v22;
((void (__fastcall *)(SecretLayer4 *))v23->addChild)(a1);
m_messageLabel = a1->m_messageLabel;
v95[0] = (cocos2d::CCSize *)m_messageLabel->setPosition;
cocos2d::CCPoint::CCPoint(&v100, 0.0, 43.0);
cocos2d::CCPoint::operator+(&v102, &v98, &v100);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, cocos2d::CCRect *))v95[0])(m_messageLabel, &v102);
SecretLayer4::getMessage(a1, (__int64)&v102);
SecretLayer4::updateMessageLabel((__int64)a1, &v102);
v25 = (void *)(*(_QWORD *)&v102.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v102.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v84 = (unsigned int *)(*(_QWORD *)&v102.origin - 8LL);
do
v85 = __ldaxr(v84);
while ( __stlxr(v85 - 1, v84) );
}
else
{
v85 = *(_DWORD *)(*(_QWORD *)&v102.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v102.origin - 8LL) = v85 - 1;
}
if ( v85 <= 0 )
operator delete(v25);
}
v95[0] = (cocos2d::CCSize *)&v99;
cocos2d::CCRect::CCRect(&v102, &v101);
v26 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"square02b_small.png",
(const char *)&v102,
v108);
((void (__fastcall *)(cocos2d::CCNode *, __int64))v26->__vftable[1].~CCNode_0)(v26, 100);
cocos2d::CCSize::CCSize(v95[0], 200.0, 40.0);
v26->setContentSize(v26, v95[0]);
a1->addChild_0(a1, v26, -2);
v26->setPosition(v26, &v98);
((void (__fastcall *)(cocos2d::CCNode *, void *))v26->__vftable[1].getTag)(v26, &unk_EF8250);
v27 = CCTextInputNode::create(180.0, 50.0, "...", "Thonburi");
a1->m_searchInput = v27;
a1->addChild_0(a1, v27, 20);
a1->m_searchInput->m_delegate = &a1->TextInputDelegate;
a1->m_searchInput->setPosition(a1->m_searchInput, &v98);
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_D153B8(
(unsigned int)v94 + 200,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
CCTextInputNode::setAllowedChars((__int64)m_searchInput, (__int64)&v102);
v29 = (void *)(*(_QWORD *)&v102.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v102.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v86 = (unsigned int *)(*(_QWORD *)&v102.origin - 8LL);
do
v87 = __ldaxr(v86);
while ( __stlxr(v87 - 1, v86) );
}
else
{
v87 = *(_DWORD *)(*(_QWORD *)&v102.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v102.origin - 8LL) = v87 - 1;
}
if ( v87 <= 0 )
operator delete(v29);
}
SecretLayer4::updateSearchLabel(a1, &byte_F288A0);
v30 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v105.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v105.adj = (size_t)SecretLayer4::onBack;
v31 = CCMenuItemSpriteExtra::create(v30, nullptr, v105);
CCMenuItemSpriteExtra::setSizeMult(v31, 1.5);
v32 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v31, nullptr);
a1->addChild_0(a1, v32, 1);
setPosition = v32->setPosition;
v34 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenLeft(v34);
v36 = v35;
v37 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenTop(v37);
cocos2d::CCPoint::CCPoint(&v102.origin, v36 + 24.0, v38 - 23.0);
setPosition(v32, &v102.origin);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v31);
v39 = cocos2d::CCNode::create();
setContentSize = v39->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v102, 80.0, 80.0);
setContentSize(v39, (const cocos2d::CCSize *)&v102);
v41 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_secretLock3_001.png");
v39->addChild(v39, v41);
v95[0] = (cocos2d::CCSize *)v41->setPosition;
cocos2d::CCPoint::CCPoint(&v102.origin, 40.0, 40.0);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCRect *))v95[0])(v41, &v102);
v106.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v106.adj = (size_t)SecretLayer4::onSubmit;
v42 = CCMenuItemSpriteExtra::create(v39, nullptr, v106);
v43 = v32->__vftable;
a1->m_submitButton = v42;
((void (__fastcall *)(cocos2d::CCNode *))v43->addChild)(v32);
m_submitButton = a1->m_submitButton;
v95[0] = (cocos2d::CCSize *)m_submitButton->setPosition;
cocos2d::CCPoint::CCPoint(&v100, v96 * 0.5, (float)(v97 * 0.5) + -20.0);
v103 = cocos2d::CCNode::convertToNodeSpace(v32, &v100);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v95[0])(
m_submitButton,
&v102,
v103.x,
v103.y);
CCMenuItemSpriteExtra::setSizeMult(a1->m_submitButton, 1.0);
v45 = GameStatsManager::sharedState();
sub_D153B8((unsigned int)v94 + 200, "0003");
isSpecialChestUnlocked = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)v45, (char **)&v102);
v47 = (void *)(*(_QWORD *)&v102.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v102.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v82 = (unsigned int *)(*(_QWORD *)&v102.origin - 8LL);
do
v83 = __ldaxr(v82);
while ( __stlxr(v83 - 1, v82) );
}
else
{
v83 = *(_DWORD *)(*(_QWORD *)&v102.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v102.origin - 8LL) = v83 - 1;
}
if ( v83 <= 0 )
operator delete(v47);
}
if ( isSpecialChestUnlocked )
return isSpecialChestUnlocked;
v48 = cocos2d::CCMenu::create();
a1->addChild_0(a1, v48, 10);
v49 = GameStatsManager::sharedState();
sub_D153B8((unsigned int)v94 + 200, "0003");
RewardForSpecialChest = GameStatsManager::getRewardForSpecialChest((__int64)v49, (const std::string *)&v102);
v51 = (void *)(*(_QWORD *)&v102.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v102.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v92 = (unsigned int *)(*(_QWORD *)&v102.origin - 8LL);
do
v93 = __ldaxr(v92);
while ( __stlxr(v93 - 1, v92) );
}
else
{
v93 = *(_DWORD *)(*(_QWORD *)&v102.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v102.origin - 8LL) = v93 - 1;
}
if ( v93 <= 0 )
operator delete(v51);
}
v52 = GJChestSprite::create(*(_DWORD *)(RewardForSpecialChest + 64));
GJChestSprite::switchToState(v52, Closed, 0);
v52->setScale(v52, 0.6);
v107.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v107.adj = (size_t)SecretLayer4::onChest01;
v53 = CCMenuItemSpriteExtra::create(v52, nullptr, v107);
sub_D153B8((unsigned int)v94 + 200, "chestClick.ogg");
sub_D18EA8(&v53->m_selectSound, &v102);
v54 = (void *)(*(_QWORD *)&v102.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v102.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v90 = (unsigned int *)(*(_QWORD *)&v102.origin - 8LL);
do
v91 = __ldaxr(v90);
while ( __stlxr(v91 - 1, v90) );
}
else
{
v91 = *(_DWORD *)(*(_QWORD *)&v102.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v102.origin - 8LL) = v91 - 1;
}
if ( v91 <= 0 )
operator delete(v54);
}
v55 = v53->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v102, 60.0, 48.0);
v55(v53, (const cocos2d::CCSize *)&v102);
v56 = v52->setPosition;
*(float *)&v57 = v53->getContentSize(v53)->width * 0.5;
getContentSize = v53->getContentSize;
*(_OWORD *)v95 = v57;
v59 = (__int64)getContentSize(v53);
cocos2d::CCPoint::CCPoint(&v102.origin, *(float *)v95, *(float *)(v59 + 4) * 0.5);
v56(v52, &v102.origin);
v48->addChild(v48, v53);
v60 = v53->setPosition;
cocos2d::CCPoint::CCPoint(&v100, v96 - 60.0, 60.0);
v104 = cocos2d::CCNode::convertToNodeSpace(v48, &v100);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCRect *, float, float))v60)(v53, &v102, v104.x, v104.y);
return v2;
}