//
// SecretLayer4::init from 0x1003b0c80 to 0x1003b182f (2991 bytes)
//
// 2 xrefs:
// > SecretLayer4::create @ 0x1003b0c45
// > ??> @ 0x100929278
//
// 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 __fastcall SecretLayer4::init(SecretLayer4 *a1)
{
bool result; // al
cocos2d::CCTextureCache *v3; // rax
cocos2d::CCSpriteFrameCache *v4; // rax
GameManager *v5; // rax
cocos2d::CCDictionary *v6; // rax
AchievementManager *v7; // rax
cocos2d::CCDictionary *m_messageThreads; // r14
cocos2d::CCNode *v9; // r15
AchievementManager *v10; // rax
cocos2d::CCDictionary *v11; // r14
cocos2d::CCNode *v12; // r15
AchievementManager *v13; // rax
cocos2d::CCDictionary *v14; // r14
cocos2d::CCNode *v15; // r15
AchievementManager *v16; // rax
cocos2d::CCDictionary *v17; // r14
cocos2d::CCNode *v18; // r15
AchievementManager *v19; // rax
cocos2d::CCDictionary *v20; // r14
cocos2d::CCNode *v21; // r15
AchievementManager *v22; // rax
cocos2d::CCDictionary *v23; // r14
cocos2d::CCNode *v24; // r15
AchievementManager *v25; // rax
cocos2d::CCDictionary *v26; // r14
cocos2d::CCNode *v27; // r15
GameManager *v28; // rax
unsigned int v29; // r14d
unsigned int v30; // eax
int v31; // ecx
int v32; // r8d
int v33; // r9d
cocos2d::CCAction *v34; // rax
cocos2d::CCSprite *v35; // r14
cocos2d::CCLabelBMFont *v36; // r14
cocos2d::CCLabelBMFont *v37; // rax
cocos2d::CCLabelBMFont *m_messageLabel; // r15
cocos2d::CCLabelBMFont *v39; // rdi
std::string::pointer data; // rsi
cocos2d::extension::CCScale9Sprite *v41; // r15
CCTextInputNode *v42; // rax
CCTextInputNode *m_searchInput; // rdi
CCTextInputNode *v44; // r14
cocos2d::CCSprite *v45; // rax
CCMenuItemSpriteExtra *v46; // r15
int v47; // edx
int v48; // ecx
int v49; // r8d
int v50; // r9d
const cocos2d::CCPoint *v51; // r14
cocos2d::CCDirector *v52; // rax
cocos2d::CCDirector *v53; // rax
double v54; // xmm0_8
cocos2d::CCNode *v55; // r15
cocos2d::CCSprite *v56; // r12
CCMenuItemSpriteExtra *v57; // rax
CCMenuItemSpriteExtra *m_submitButton; // r15
GameStatsManager *v59; // rax
bool isSpecialChestUnlocked; // r14
cocos2d::CCMenu *v61; // r14
GameStatsManager *v62; // rax
__int64 RewardForSpecialChest; // r15
GJChestSprite *v64; // r15
CCMenuItemSpriteExtra *v65; // rbx
__int64 v66; // rax
unsigned __int64 v67; // [rsp+0h] [rbp-100h] BYREF
__m128 v68; // [rsp+8h] [rbp-F8h] BYREF
float v69; // [rsp+18h] [rbp-E8h] BYREF
void *v70[3]; // [rsp+20h] [rbp-E0h] BYREF
std::string v71; // [rsp+38h] [rbp-C8h] BYREF
char v72; // [rsp+50h] [rbp-B0h] BYREF
char v73[15]; // [rsp+51h] [rbp-AFh] BYREF
void *v74; // [rsp+60h] [rbp-A0h]
char v75; // [rsp+68h] [rbp-98h] BYREF
char v76[15]; // [rsp+69h] [rbp-97h] BYREF
void *v77; // [rsp+78h] [rbp-88h]
std::string v78; // [rsp+80h] [rbp-80h] BYREF
std::string __str; // [rsp+98h] [rbp-68h] BYREF
unsigned __int64 v80[2]; // [rsp+B0h] [rbp-50h] BYREF
unsigned __int64 v81; // [rsp+C0h] [rbp-40h] BYREF
float v82; // [rsp+C8h] [rbp-38h] BYREF
float v83; // [rsp+CCh] [rbp-34h]
float v84; // [rsp+D0h] [rbp-30h]
bool v85; // [rsp+D7h] [rbp-29h]
double v86; // 0:xmm0_8.8
double v87; // 0:xmm0_8.8
double v88; // 0:xmm0_8.8
cocos2d::CCRect v89; // 0:xmm0_8.8,8:xmm1_8.8
result = cocos2d::CCLayer::init(a1);
if ( !result )
return result;
v85 = result;
v3 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v3, "SecretSheet.png", 0);
v4 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile_2(v4, "SecretSheet.plist");
v5 = GameManager::sharedState();
strcpy((char *)v70, " secretLoop03.mp3");
GameManager::fadeInMusic(*(__m128 *)"secretLoop03.mp3", (__int64)v5, (unsigned __int8 *)v70);
if ( ((__int64)v70[0] & 1) != 0 )
operator delete(v70[2]);
((void (__fastcall *)(SecretLayer4 *, __int64))a1->setKeypadEnabled)(a1, 1);
((void (__fastcall *)(SecretLayer4 *, __int64))a1->setKeyboardEnabled)(a1, 1);
cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v86 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v82);
v6 = cocos2d::CCDictionary::create();
a1->m_messageThreads = v6;
cocos2d::CCObject::retain(v6);
v7 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v7, "geometry.ach.v3.secret01") )
{
m_messageThreads = a1->m_messageThreads;
v9 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, __int64, double))v9->setTag)(v9, 1, v86);
cocos2d::CCDictionary::setObject(m_messageThreads, v9, 1);
}
v10 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v10, "geometry.ach.v3.secret02") )
{
v11 = a1->m_messageThreads;
v12 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, __int64, double))v12->setTag)(v12, 2, v86);
cocos2d::CCDictionary::setObject(v11, v12, 2);
}
v13 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v13, "geometry.ach.v3.secret03") )
{
v14 = a1->m_messageThreads;
v15 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, __int64, double))v15->setTag)(v15, 3, v86);
cocos2d::CCDictionary::setObject(v14, v15, 3);
}
v16 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v16, "geometry.ach.v3.secret04") )
{
v17 = a1->m_messageThreads;
v18 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, __int64, double))v18->setTag)(v18, 4, v86);
cocos2d::CCDictionary::setObject(v17, v18, 4);
}
v19 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v19, "geometry.ach.v3.secret05") )
{
v20 = a1->m_messageThreads;
v21 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, __int64, double))v21->setTag)(v21, 5, v86);
cocos2d::CCDictionary::setObject(v20, v21, 5);
}
v22 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v22, "geometry.ach.v3.secret06") )
{
v23 = a1->m_messageThreads;
v24 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, __int64, double))v24->setTag)(v24, 6, v86);
cocos2d::CCDictionary::setObject(v23, v24, 6);
}
v25 = AchievementManager::sharedState();
if ( !AchievementManager::isAchievementEarned(v25, "geometry.ach.v3.secret07") )
{
v26 = a1->m_messageThreads;
v27 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, __int64, double))v27->setTag)(v27, 7, v86);
cocos2d::CCDictionary::setObject(v26, v27, 7);
}
v28 = GameManager::sharedState();
if ( !GameManager::getUGV(v28, "9") )
{
v29 = (unsigned int)cocos2d::CCDelayTime::create(0.80000001);
v30 = (unsigned int)cocos2d::CCCallFunc::create(
a1,
(cocos2d::SEL_CallFunc)(unsigned __int64)SecretLayer4::showFirstDialog);
v34 = (cocos2d::CCAction *)sub_1003B5760(v29, v30, 0, v31, v32, v33);
cocos2d::CCNode::runAction(a1, v34);
a1->m_basicMessageIndex = 30;
}
v35 = cocos2d::CCSprite::create_1("GJ_gradientBG.png");
sub_10028CBE0((float *)v80, 0.0, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *))v35->setAnchorPoint)(v35, v80);
((void (__fastcall *)(SecretLayer4 *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v35, 4294967293LL);
((void (__fastcall *)(cocos2d::CCSprite *, float))v35->setScaleX)(v35, (float)(v82 + 10.0) / v35->m_obRect.size.width);
((void (__fastcall *)(cocos2d::CCSprite *, float))v35->setScaleY)(
v35,
(float)(v83 + 10.0) / v35->m_obRect.size.height);
sub_10028CBE0((float *)v80, -5.0, -5.0);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *))v35->setPosition)(v35, v80);
strcpy((char *)v80, "K\n");
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *))v35->setColor)(v35, v80);
sub_10028CC00((__int64)v80, 0.0, 0.0, (__m128)0x42200000u, (__m128)0x42200000u);
v36 = cocos2d::CCLabelBMFont::create_3("Chamber of Time", "goldFont.fnt");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v36->setScale)(v36, 1.0);
((void (__fastcall *)(SecretLayer4 *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v36);
sub_10028CBE0(v68.f32, v82 * 0.5, v83 + -24.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __m128 *))v36->setPosition)(v36, &v68);
sub_10028CBE0((float *)&v67, v82 * 0.5, (float)(v83 * 0.5) + 50.0);
v37 = cocos2d::CCLabelBMFont::create_3(" ", "bigFont.fnt");
a1->m_messageLabel = v37;
((void (__fastcall *)(SecretLayer4 *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v37);
m_messageLabel = a1->m_messageLabel;
sub_10028CBE0((float *)&v81, 0.0, 43.0);
sub_10028CCE0((double *)v68.i64, &v67, &v81);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __m128 *))m_messageLabel->setPosition)(m_messageLabel, &v68);
if ( !a1->m_selectedThread )
{
v84 = (float)((float)a1->m_basicMessageCount * -0.050000001) + 1.0;
if ( (float)((float)rand() * 4.6566129e-10) > v84 )
SecretLayer4::selectAThread(a1);
if ( !a1->m_selectedThread )
{
SecretLayer4::getBasicMessage(&v78, a1);
v39 = a1->m_messageLabel;
if ( (*(_BYTE *)&v78.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_25;
LABEL_27:
data = v78.__r_.__value_.__s.__data_;
goto LABEL_28;
}
}
SecretLayer4::getThreadMessage(&v78);
v39 = a1->m_messageLabel;
if ( (*(_BYTE *)&v78.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_27;
LABEL_25:
data = v78.__r_.__value_.__l.__data_;
LABEL_28:
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string::pointer))v39->setString)(v39, data);
v89.size = (cocos2d::CCSize)1058642330LL;
cocos2d::CCLabelBMFont::limitLabelWidth(a1->m_messageLabel, 320.0, 0.60000002, 0.0);
if ( (*(_BYTE *)&v78.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v78.__r_.__value_.__l.__data_);
*(double *)&v89.origin = sub_10028D180(&v68, v80);
v41 = cocos2d::extension::CCScale9Sprite::create_2("square02b_small.png", v89);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v41->setOpacity)(v41, 100);
sub_10028CBF0(v68.f32, 200.0, 40.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __m128 *))v41->setContentSize)(v41, &v68);
((void (__fastcall *)(SecretLayer4 *, cocos2d::extension::CCScale9Sprite *, __int64))a1->addChild_0)(
a1,
v41,
4294967294LL);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, unsigned __int64 *))v41->setPosition)(v41, &v67);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, void *))v41->setColor)(v41, &unk_10081A9D8);
v42 = CCTextInputNode::create(180.0, 50.0, "...", "Thonburi", 24, "bigFont.fnt");
a1->m_searchInput = v42;
((void (__fastcall *)(SecretLayer4 *, CCTextInputNode *, __int64))a1->addChild_0)(a1, v42, 20);
m_searchInput = a1->m_searchInput;
m_searchInput->m_delegate = &a1->TextInputDelegate;
((void (__fastcall *)(CCTextInputNode *, unsigned __int64 *))m_searchInput->setPosition)(m_searchInput, &v67);
CCTextInputNode::setMaxLabelScale(a1->m_searchInput, 0.69999999);
CCTextInputNode::setMaxLabelWidth(a1->m_searchInput, 180.0);
((void (__fastcall *)(cocos2d::CCTextFieldTTF *, _QWORD))a1->m_searchInput->m_textField->setVisible)(
a1->m_searchInput->m_textField,
0);
v44 = a1->m_searchInput;
v44->m_maxLabelLength = 100;
v71.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x68u);
v71.__r_.__value_.__r.__words[0] = 105;
v71.__r_.__value_.__l.__size_ = 97;
strcpy(
v71.__r_.__value_.__l.__data_,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
CCTextInputNode::setAllowedChars((std::string *)v44, &v71);
if ( (*(_BYTE *)&v71.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v71.__r_.__value_.__l.__data_);
SecretLayer4::updateSearchLabel(a1, "");
v45 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v46 = CCMenuItemSpriteExtra::create(
v45,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SecretLayer4::onBack);
CCMenuItemSpriteExtra::setSizeMult(v46, 1.5);
v51 = (const cocos2d::CCPoint *)sub_100792C50((_DWORD)v46, 0, v47, v48, v49, v50);
((void (__fastcall *)(SecretLayer4 *, const cocos2d::CCPoint *, __int64))a1->addChild_0)(a1, v51, 1);
v52 = cocos2d::CCDirector::sharedDirector();
v84 = sub_100484D90(v52) + 24.0;
v53 = cocos2d::CCDirector::sharedDirector();
v54 = sub_100484D70(v53);
sub_10028CBE0((float *)&v81, v84, *(float *)&v54 + -23.0);
(*(void (__fastcall **)(const cocos2d::CCPoint *, unsigned __int64 *))(*(_QWORD *)v51 + 184LL))(v51, &v81);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v46);
v55 = cocos2d::CCNode::create();
sub_10028CBF0((float *)&v81, 80.0, 80.0);
((void (__fastcall *)(cocos2d::CCNode *, unsigned __int64 *))v55->setContentSize)(v55, &v81);
v56 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_secretLock3_001.png");
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSprite *))v55->addChild)(v55, v56);
sub_10028CBE0((float *)&v81, 40.0, 40.0);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *))v56->setPosition)(v56, &v81);
v57 = CCMenuItemSpriteExtra::create(
v55,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SecretLayer4::onSubmit);
a1->m_submitButton = v57;
(*(void (__fastcall **)(const cocos2d::CCPoint *, CCMenuItemSpriteExtra *))(*(_QWORD *)v51 + 440LL))(v51, v57);
m_submitButton = a1->m_submitButton;
sub_10028CBE0(&v69, v82 * 0.5, (float)(v83 * 0.5) + -20.0);
*(cocos2d::CCPoint *)&v87 = cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)&v81, v51);
((void (__fastcall *)(CCMenuItemSpriteExtra *, unsigned __int64 *, double))m_submitButton->setPosition)(
m_submitButton,
&v81,
v87);
CCMenuItemSpriteExtra::setSizeMult(a1->m_submitButton, 1.0);
v59 = GameStatsManager::sharedState();
v72 = 8;
strcpy(v73, "0003");
isSpecialChestUnlocked = GameStatsManager::isSpecialChestUnlocked(
(__int64)v59,
(__int64)&v72,
COERCE_DOUBLE(1065353216));
if ( (v72 & 1) != 0 )
operator delete(v74);
if ( !isSpecialChestUnlocked )
{
v61 = cocos2d::CCMenu::create();
((void (__fastcall *)(SecretLayer4 *, cocos2d::CCMenu *, __int64))a1->addChild_0)(a1, v61, 10);
v62 = GameStatsManager::sharedState();
v75 = 8;
strcpy(v76, "0003");
RewardForSpecialChest = GameStatsManager::getRewardForSpecialChest((__int64)v62, (__int64)&v75);
if ( (v75 & 1) != 0 )
operator delete(v77);
v64 = GJChestSprite::create(*(_DWORD *)(RewardForSpecialChest + 64));
GJChestSprite::switchToState(v64, Closed, 0);
((void (__fastcall *)(GJChestSprite *, float))v64->setScale)(v64, 0.60000002);
v65 = CCMenuItemSpriteExtra::create(
v64,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SecretLayer4::onChest01);
__str.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)28;
strcpy(__str.__r_.__value_.__s.__data_, "chestClick.ogg");
std::string::operator=((std::string *)&v65->m_selectSound, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
sub_10028CBF0((float *)&v81, 60.000004, 48.0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, unsigned __int64 *))v65->setContentSize)(v65, &v81);
v84 = *(float *)((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))v65->getContentSize)(v65) * 0.5;
v66 = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))v65->getContentSize)(v65);
sub_10028CBE0((float *)&v81, v84, 0.5 * *(float *)(v66 + 4));
((void (__fastcall *)(GJChestSprite *, unsigned __int64 *))v64->setPosition)(v64, &v81);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v61->addChild)(v61, v65);
sub_10028CBE0(&v69, v82 + -60.0, 60.0);
*(cocos2d::CCPoint *)&v88 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)&v81,
(const cocos2d::CCPoint *)v61);
((void (__fastcall *)(CCMenuItemSpriteExtra *, unsigned __int64 *, double))v65->setPosition)(v65, &v81, v88);
}
return v85;
}