//
// ParentalOptionsLayer::addMasterToggle from 0x1404d1b60 to 0x1404d2328 (1992 bytes)
//
// 3 xrefs:
// > ParentalOptionsLayer::init @ 0x1404d174c
// > ParentalOptionsLayer::init @ 0x1404d1775
// > ??> @ 0x14092978c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:33:00 +0000
//
// Hidden C++ exception states: #wind=5
__int64 __fastcall ParentalOptionsLayer::addMasterToggle(__int64 a1, _BYTE *a2, char *a3, __int64 a4, _BYTE *a5)
{
__int64 v8; // rax
int v9; // eax
__int64 v10; // rbx
__int64 v11; // rcx
size_t v12; // rsi
size_t v13; // r8
cocos2d::CCDictionary *v14; // rdi
struct cocos2d::CCObject *v15; // rax
void *v16; // rcx
int v17; // eax
__int64 v18; // rax
__int64 *v19; // rdi
__int64 v20; // rbx
__int64 v21; // rax
__int64 v22; // rbx
__int64 v23; // rax
__int64 v24; // rcx
struct cocos2d::CCArray *v25; // rdi
size_t v26; // r8
float *v27; // rax
float *v28; // rbx
__int64 v29; // rax
struct cocos2d::CCObject *ToggleButton; // r12
size_t v31; // r8
void **v32; // rcx
char *v33; // rbx
size_t v34; // r8
int v35; // edi
char *v36; // rax
__int64 v37; // rax
__int64 v38; // r8
__int64 v39; // rdi
__int64 v40; // rbx
__int64 v41; // rax
__int64 v42; // rbx
__int64 v43; // rax
__int64 result; // rax
unsigned int v45; // r14d
cocos2d::CCString *v46; // rax
const char *CString; // rax
size_t v48; // r8
__int64 v49; // rbx
__int64 v50; // rax
void *v51; // rcx
void *v52; // rcx
struct cocos2d::CCSprite *v53; // rax
int v54; // ebx
struct cocos2d::CCObject *v55; // rdi
__int64 v56; // rax
__int64 v57; // rbx
__int64 v58; // rax
bool GameVariable; // [rsp+80h] [rbp-80h]
__int64 v60; // [rsp+88h] [rbp-78h] BYREF
unsigned int v61; // [rsp+90h] [rbp-70h]
struct cocos2d::CCArray *v62; // [rsp+98h] [rbp-68h] BYREF
float v63[2]; // [rsp+A0h] [rbp-60h] BYREF
__int64 v64; // [rsp+A8h] [rbp-58h]
_BYTE v65[4]; // [rsp+B0h] [rbp-50h] BYREF
float v66; // [rsp+B4h] [rbp-4Ch]
cocos2d::CCArray *v67; // [rsp+B8h] [rbp-48h]
__int128 *v68; // [rsp+C0h] [rbp-40h] BYREF
__int128 v69; // [rsp+C8h] [rbp-38h] BYREF
__int64 v70; // [rsp+D8h] [rbp-28h]
__int64 v71; // [rsp+E0h] [rbp-20h]
char v72[8]; // [rsp+E8h] [rbp-18h] BYREF
_BYTE v73[16]; // [rsp+F0h] [rbp-10h] BYREF
void *Block[2]; // [rsp+100h] [rbp+0h] BYREF
unsigned __int64 v75; // [rsp+110h] [rbp+10h]
unsigned __int64 v76; // [rsp+118h] [rbp+18h]
__int128 Buf2; // [rsp+120h] [rbp+20h] BYREF
__int64 v78; // [rsp+130h] [rbp+30h]
unsigned __int64 v79; // [rsp+138h] [rbp+38h]
v60 = a4;
v8 = cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v8, v63);
v9 = atoi(a3);
v10 = v9;
v61 = v9;
v11 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v62 = (struct cocos2d::CCArray *)operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v62);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v11 = qword_14090BFD0;
}
GameVariable = GameManager::getGameVariable(v11, a3);
*(_OWORD *)Block = 0;
v75 = 0;
v76 = 0;
v12 = -1;
v13 = -1;
do
++v13;
while ( a3[v13] );
sub_14003D230(Block, a3, v13);
v14 = *(cocos2d::CCDictionary **)(a1 + 688);
v15 = (struct cocos2d::CCObject *)cocos2d::CCString::create(Block);
cocos2d::CCDictionary::setObject(v14, v15, v10);
if ( v76 > 0xF )
{
v16 = Block[0];
if ( v76 + 1 >= 0x1000 )
{
v16 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v16 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v16);
}
v64 = MoreVideoOptionsLayer::layerForPage(a1, 0);
v67 = (cocos2d::CCArray *)MoreVideoOptionsLayer::objectsForPage(a1, 0);
v17 = MoreVideoOptionsLayer::countForPage(a1, 0);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v65,
(float)(v63[0] * 0.5) - 120.0,
(float)((float)(v63[1] * 0.5) + 50.0) - (float)(80 * v17));
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v73, 0.0, 0.0, 80.0, 80.0);
v19 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_square05.png", v18);
v20 = *v19;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v62, 340.0, 60.0);
(*(void (__fastcall **)(__int64 *, __int64))(v20 + 312))(v19, v21);
v22 = *v19;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, v63[0] * 0.5, v66);
(*(void (__fastcall **)(__int64 *, __int64))(v22 + 184))(v19, v23);
(*(void (__fastcall **)(__int64, __int64 *, __int64))(*(_QWORD *)v64 + 456LL))(v64, v19, 0xFFFFFFFFLL);
v25 = (struct cocos2d::CCArray *)cocos2d::CCArray::create(v24);
v62 = v25;
v68 = &v69;
v69 = 0;
v70 = 0;
v71 = 0;
v26 = -1;
do
++v26;
while ( a2[v26] );
sub_14003D230(&v69, a2, v26);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v72, 8.0, 0.0);
v28 = v27;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v73, (const struct cocos2d::CCPoint *)v65);
ToggleButton = GameToolbox::createToggleButton(
(const char *)&v69,
(__int64)ParentalOptionsLayer::onMasterToggle,
GameVariable,
*(_QWORD *)(a1 + 552),
v29,
a1,
v64,
0.89999998,
0.55000001,
120.0,
v28,
(const char *)&qword_140704F78,
0,
0,
v25);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)ToggleButton + 64LL))(ToggleButton, v61);
*(_DWORD *)(*((_QWORD *)ToggleButton + 47) + 372LL) = 1067030938;
*(_DWORD *)(*((_QWORD *)ToggleButton + 48) + 372LL) = 1067030938;
CCMenuItemToggler::toggle((__int64)ToggleButton, *((unsigned __int8 *)ToggleButton + 392));
*((_BYTE *)ToggleButton + 393) = 1;
ParentalOptionsLayer::incrementCountForPage(a1, 0);
cocos2d::CCArray::addObject(v67, ToggleButton);
Buf2 = 0;
v78 = 4;
v79 = 15;
strcpy((char *)&Buf2, "0218");
*(_OWORD *)Block = 0;
v75 = 0;
v76 = 0;
v31 = -1;
do
++v31;
while ( a3[v31] );
sub_14003D230(Block, a3, v31);
v32 = Block;
v33 = (char *)Block[0];
if ( v76 > 0xF )
v32 = (void **)Block[0];
v34 = v75;
if ( v75 > 4 )
v34 = 4;
v35 = memcmp(v32, &Buf2, v34);
if ( !v35 )
{
if ( v75 >= 4 )
v35 = v75 > 4;
else
v35 = -1;
}
if ( v76 > 0xF )
{
v36 = v33;
if ( v76 + 1 >= 0x1000 )
{
v33 = *((char **)v33 - 1);
if ( (unsigned __int64)(v36 - v33 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v33);
}
if ( v35 )
{
*(_QWORD *)(a1 + 704) = ToggleButton;
}
else
{
*(_QWORD *)(a1 + 696) = ToggleButton;
cocos2d::CCArray::addObjectsFromArray(*(cocos2d::CCArray **)(a1 + 720), v62);
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v68, (const struct cocos2d::CCPoint *)&unk_14090B3C8);
v39 = cocos2d::CCLabelBMFont::create(v60, "chatFont.fnt", v38, 0, v37);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v39 + 160LL))(v39);
v40 = *(_QWORD *)v39;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v60, 0.0, 0.5);
(*(void (__fastcall **)(__int64, __int64))(v40 + 288))(v39, v41);
v42 = v64;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v64 + 464LL))(v64, v39);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, 155.0, 0.0);
cocos2d::CCPoint::operator+(v65, &v60, v43);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v39 + 184LL))(v39, &v60);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)ToggleButton + 336LL))(ToggleButton, 0);
result = (*(__int64 (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v42 + 336LL))(v42, 0);
if ( a5 )
{
v45 = v61;
v46 = cocos2d::CCString::createWithFormat("info_%i", v61);
CString = cocos2d::CCString::getCString(v46);
Buf2 = 0;
v78 = 0;
v79 = 0;
v48 = -1;
do
++v48;
while ( CString[v48] );
sub_14003D230(&Buf2, CString, v48);
*(_OWORD *)Block = 0;
v75 = 0;
v76 = 0;
do
++v12;
while ( a5[v12] );
sub_14003D230(Block, a5, v12);
v49 = *(_QWORD *)(a1 + 680);
v50 = cocos2d::CCString::create(Block);
cocos2d::CCDictionary::setObject(v49, v50, &Buf2);
if ( v76 > 0xF )
{
v51 = Block[0];
if ( v76 + 1 >= 0x1000 )
{
v51 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v51 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v51);
}
v75 = 0;
v76 = 15;
LOBYTE(Block[0]) = 0;
if ( v79 > 0xF )
{
v52 = (void *)Buf2;
if ( v79 + 1 >= 0x1000 )
{
v52 = *(void **)(Buf2 - 8);
if ( (unsigned __int64)(Buf2 - (_QWORD)v52 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v52);
}
v53 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
v54 = (int)v53;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v53 + 160LL))(v53);
v55 = CCMenuItemSpriteExtra::create(v54, 0, a1, (__int64)ParentalOptionsLayer::onInfo);
*((_DWORD *)v55 + 93) = 0x40000000;
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v55 + 64LL))(v55, v45);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v55);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v68, -27.0, 16.0);
v57 = v56;
v58 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)ToggleButton + 200LL))(ToggleButton);
cocos2d::CCPoint::operator+(v58, &v60, v57);
(*(void (__fastcall **)(struct cocos2d::CCObject *, __int64 *))(*(_QWORD *)v55 + 184LL))(v55, &v60);
cocos2d::CCArray::addObject(v67, v55);
return (*(__int64 (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v55 + 336LL))(v55, 0);
}
return result;
}