//
// ParentalOptionsLayer::addToggle from 0x1404d2330 to 0x1404d290d (1501 bytes)
//
// 5 xrefs:
// > ParentalOptionsLayer::init @ 0x1404d1797
// > ParentalOptionsLayer::init @ 0x1404d17b9
// > ParentalOptionsLayer::init @ 0x1404d17db
// > ParentalOptionsLayer::init @ 0x1404d17fd
// > ??> @ 0x140929798
//
// 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:01 +0000
//
// Hidden C++ exception states: #wind=5
__int64 __fastcall ParentalOptionsLayer::addToggle(__int64 a1, _BYTE *a2, char *a3, __int64 a4, _BYTE *a5)
{
int v8; // ecx
int v9; // eax
__int64 v10; // r13
__int64 v11; // rcx
size_t v12; // rsi
size_t v13; // r8
cocos2d::CCDictionary *v14; // rdi
struct cocos2d::CCObject *v15; // rax
__int64 v16; // rcx
void *v17; // rcx
__int64 v18; // rax
int v19; // edi
const struct cocos2d::CCPoint *v20; // rdx
float v21; // xmm0_4
size_t v22; // r8
cocos2d::CCArray *v23; // rdi
float *v24; // rax
float *v25; // rbx
void *v26; // rbx
__int64 v27; // rax
struct cocos2d::CCObject *ToggleButton; // r12
__int64 result; // rax
cocos2d::CCString *v30; // rax
const char *CString; // rax
size_t v32; // r8
__int64 v33; // rbx
__int64 v34; // rax
void *v35; // rcx
void *v36; // rcx
struct cocos2d::CCSprite *v37; // rax
int v38; // ebx
struct cocos2d::CCObject *v39; // rdi
__int64 v40; // rax
__int64 v41; // rbx
__int64 v42; // rax
float *v43; // [rsp+50h] [rbp-B0h]
bool GameVariable; // [rsp+80h] [rbp-80h]
void *v45; // [rsp+88h] [rbp-78h] BYREF
cocos2d::CCArray *v46; // [rsp+90h] [rbp-70h] BYREF
float v47[2]; // [rsp+98h] [rbp-68h] BYREF
_BYTE v48[4]; // [rsp+A0h] [rbp-60h] BYREF
float v49; // [rsp+A4h] [rbp-5Ch]
__int128 v50; // [rsp+A8h] [rbp-58h] BYREF
__int64 v51; // [rsp+B8h] [rbp-48h]
__int64 v52; // [rsp+C0h] [rbp-40h]
char v53[8]; // [rsp+C8h] [rbp-38h] BYREF
char v54[8]; // [rsp+D0h] [rbp-30h] BYREF
void *Block[2]; // [rsp+D8h] [rbp-28h] BYREF
__int64 v56; // [rsp+E8h] [rbp-18h]
unsigned __int64 v57; // [rsp+F0h] [rbp-10h]
void *v58[2]; // [rsp+F8h] [rbp-8h] BYREF
__int64 v59; // [rsp+108h] [rbp+8h]
unsigned __int64 v60; // [rsp+110h] [rbp+10h]
++*(_DWORD *)(a1 + 668);
v8 = *(_DWORD *)(a1 + 672);
v9 = 1;
if ( v8 > 1 )
v9 = v8;
*(_DWORD *)(a1 + 672) = v9;
v10 = atoi(a3);
v11 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v45 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v45);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v11 = qword_14090BFD0;
}
GameVariable = GameManager::getGameVariable(v11, a3);
*(_OWORD *)Block = 0;
v56 = 0;
v57 = 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 ( v57 > 0xF )
{
v17 = Block[0];
if ( v57 + 1 >= 0x1000 )
{
v17 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v17 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v17);
}
v18 = cocos2d::CCDirector::sharedDirector(v16);
cocos2d::CCDirector::getWinSize(v18, v47);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v46, (float)(v47[0] * 0.5) - 135.0, (float)(v47[1] * 0.5) + 50.0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v45, (float)(v47[0] * 0.5) + 35.0, *((float *)&v46 + 1));
v19 = MoreVideoOptionsLayer::countForPage(a1, 1);
v20 = (const struct cocos2d::CCPoint *)&v46;
if ( (((_BYTE)v19 + 1) & 1) == 0 )
v20 = (const struct cocos2d::CCPoint *)&v45;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v48, v20);
if ( v19 + 1 > 2 )
{
v21 = floorf((float)v19 * 0.5);
v49 = v49 - (float)(48 * (int)v21);
}
v45 = (void *)MoreVideoOptionsLayer::layerForPage(a1, 1);
v46 = (cocos2d::CCArray *)&v50;
v50 = 0;
v51 = 0;
v52 = 0;
v22 = -1;
do
++v22;
while ( a2[v22] );
sub_14003D230(&v50, a2, v22);
v23 = *(cocos2d::CCArray **)(a1 + 728);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v47, 8.0, 0.0);
v25 = v24;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v53, (const struct cocos2d::CCPoint *)v48);
v43 = v25;
v26 = v45;
ToggleButton = GameToolbox::createToggleButton(
(const char *)&v50,
(__int64)ParentalOptionsLayer::onToggle,
GameVariable,
*(_QWORD *)(a1 + 552),
v27,
a1,
(__int64)v45,
0.80000001,
0.5,
110.0,
v43,
(const char *)&qword_140704F78,
0,
0,
v23);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)ToggleButton + 64LL))(
ToggleButton,
(unsigned int)v10);
*(_DWORD *)(*((_QWORD *)ToggleButton + 47) + 372LL) = 1065353216;
*(_DWORD *)(*((_QWORD *)ToggleButton + 48) + 372LL) = 1065353216;
CCMenuItemToggler::toggle((__int64)ToggleButton, *((unsigned __int8 *)ToggleButton + 392));
ParentalOptionsLayer::incrementCountForPage(a1, 1);
v46 = (cocos2d::CCArray *)MoreVideoOptionsLayer::objectsForPage(a1, 1);
cocos2d::CCArray::addObject(v46, ToggleButton);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)ToggleButton + 336LL))(ToggleButton, 0);
result = (*(__int64 (__fastcall **)(void *, _QWORD))(*(_QWORD *)v26 + 336LL))(v26, 0);
if ( a5 )
{
v30 = cocos2d::CCString::createWithFormat("info_%i", v10);
CString = cocos2d::CCString::getCString(v30);
*(_OWORD *)v58 = 0;
v59 = 0;
v60 = 0;
v32 = -1;
do
++v32;
while ( CString[v32] );
sub_14003D230(v58, CString, v32);
*(_OWORD *)Block = 0;
v56 = 0;
v57 = 0;
do
++v12;
while ( a5[v12] );
sub_14003D230(Block, a5, v12);
v33 = *(_QWORD *)(a1 + 680);
v34 = cocos2d::CCString::create(Block);
cocos2d::CCDictionary::setObject(v33, v34, v58);
if ( v57 > 0xF )
{
v35 = Block[0];
if ( v57 + 1 >= 0x1000 )
{
v35 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v35 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v35);
}
v56 = 0;
v57 = 15;
LOBYTE(Block[0]) = 0;
if ( v60 > 0xF )
{
v36 = v58[0];
if ( v60 + 1 >= 0x1000 )
{
v36 = *((void **)v58[0] - 1);
if ( (unsigned __int64)((char *)v58[0] - (char *)v36 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v36);
}
v37 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
v38 = (int)v37;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v37 + 160LL))(v37);
v39 = CCMenuItemSpriteExtra::create(v38, 0, a1, (__int64)ParentalOptionsLayer::onInfo);
*((_DWORD *)v39 + 93) = 0x40000000;
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v39 + 64LL))(v39, (unsigned int)v10);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v39);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v54, -18.0, 16.0);
v41 = v40;
v42 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)ToggleButton + 200LL))(ToggleButton);
cocos2d::CCPoint::operator+(v42, &v45, v41);
(*(void (__fastcall **)(struct cocos2d::CCObject *, void **))(*(_QWORD *)v39 + 184LL))(v39, &v45);
cocos2d::CCArray::addObject(v46, v39);
return (*(__int64 (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v39 + 336LL))(v39, 0);
}
return result;
}