//
// MoreVideoOptionsLayer::addToggle from 0x1404cf450 to 0x1404cfaff (1711 bytes)
//
// 5 xrefs:
// > MoreVideoOptionsLayer::init @ 0x1404cec40
// > MoreVideoOptionsLayer::init @ 0x1404cec5d
// > MoreVideoOptionsLayer::init @ 0x1404cec7a
// > MoreVideoOptionsLayer::init @ 0x1404cec97
// > ??> @ 0x1409296f0
//
// 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:32:59 +0000
//
// Hidden C++ exception states: #wind=5
__int64 __fastcall MoreVideoOptionsLayer::addToggle(__int64 a1, _BYTE *a2, char *a3, _BYTE *a4)
{
int v8; // ecx
unsigned int v9; // r13d
signed int v10; // eax
__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
__int64 v22; // rdi
size_t v23; // r8
float *v24; // rax
float *v25; // rbx
__int64 v26; // rax
struct cocos2d::CCObject *ToggleButton; // r12
cocos2d::CCString *v28; // rax
const char *CString; // rax
size_t v30; // r8
struct cocos2d::CCString *v31; // rax
void *v32; // rcx
cocos2d::CCArray *v33; // r13
__int64 result; // rax
cocos2d::CCString *v35; // rax
const char *v36; // rax
size_t v37; // r8
__int64 v38; // rbx
__int64 v39; // rax
void *v40; // rcx
void *v41; // rcx
struct cocos2d::CCSprite *v42; // rax
int v43; // ebx
struct cocos2d::CCObject *v44; // rdi
__int64 v45; // rax
__int64 v46; // rbx
__int64 v47; // rax
bool GameVariable; // [rsp+80h] [rbp-80h]
unsigned int v49; // [rsp+84h] [rbp-7Ch]
float v50[2]; // [rsp+88h] [rbp-78h] BYREF
__int128 *v51; // [rsp+90h] [rbp-70h] BYREF
_BYTE v52[4]; // [rsp+98h] [rbp-68h] BYREF
float v53; // [rsp+9Ch] [rbp-64h]
_BYTE v54[4]; // [rsp+A0h] [rbp-60h] BYREF
float v55; // [rsp+A4h] [rbp-5Ch]
__int128 v56; // [rsp+A8h] [rbp-58h] BYREF
__int64 v57; // [rsp+B8h] [rbp-48h]
__int64 v58; // [rsp+C0h] [rbp-40h]
_BYTE v59[8]; // [rsp+C8h] [rbp-38h] BYREF
void *Block[2]; // [rsp+D0h] [rbp-30h] BYREF
__int64 v61; // [rsp+E0h] [rbp-20h]
unsigned __int64 v62; // [rsp+E8h] [rbp-18h]
void *v63[2]; // [rsp+F0h] [rbp-10h] BYREF
__int64 v64; // [rsp+100h] [rbp+0h]
unsigned __int64 v65; // [rsp+108h] [rbp+8h]
v8 = *(_DWORD *)(a1 + 668);
*(_DWORD *)(a1 + 668) = v8 + 1;
v9 = (int)fmaxf(0.0, floorf((float)(v8 / 10)));
v10 = *(_DWORD *)(a1 + 672);
if ( v10 <= (int)v9 )
v10 = v9;
*(_DWORD *)(a1 + 672) = v10;
v49 = atoi(a3);
v11 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v51 = (__int128 *)operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v51);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v11 = qword_14090BFD0;
}
GameVariable = GameManager::getGameVariable(v11, a3);
*(_OWORD *)Block = 0;
v61 = 0;
v62 = 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, (int)v49);
if ( v62 > 0xF )
{
v17 = Block[0];
if ( v62 + 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, v50);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v54, (float)(v50[0] * 0.5) - 135.0, (float)(v50[1] * 0.5) + 60.0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51, (float)(v50[0] * 0.5) + 35.0, v55);
v19 = MoreVideoOptionsLayer::countForPage(a1, v9);
v20 = (const struct cocos2d::CCPoint *)v54;
if ( (((_BYTE)v19 + 1) & 1) == 0 )
v20 = (const struct cocos2d::CCPoint *)&v51;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v52, v20);
if ( v19 + 1 > 2 )
{
v21 = floorf((float)v19 * 0.5);
v53 = v53 - (float)(48 * (int)v21);
}
v22 = MoreVideoOptionsLayer::layerForPage(a1, v9);
v51 = &v56;
v56 = 0;
v57 = 0;
v58 = 0;
v23 = -1;
do
++v23;
while ( a2[v23] );
sub_14003D230(&v56, a2, v23);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v54, 8.0, 0.0);
v25 = v24;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const struct cocos2d::CCPoint *)v52);
ToggleButton = GameToolbox::createToggleButton(
(const char *)&v56,
(__int64)MoreVideoOptionsLayer::onToggle,
GameVariable,
*(_QWORD *)(a1 + 552),
v26,
a1,
v22,
0.80000001,
0.5,
110.0,
v25,
(const char *)&qword_140704F78,
0,
0,
nullptr);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)ToggleButton + 64LL))(ToggleButton, v49);
*(_DWORD *)(*((_QWORD *)ToggleButton + 47) + 372LL) = 1065353216;
*(_DWORD *)(*((_QWORD *)ToggleButton + 48) + 372LL) = 1065353216;
CCMenuItemToggler::toggle((__int64)ToggleButton, *((unsigned __int8 *)ToggleButton + 392));
LODWORD(v50[0]) = MoreVideoOptionsLayer::countForPage(a1, v9) + 1;
v28 = cocos2d::CCString::createWithFormat("page_%i", v9);
CString = cocos2d::CCString::getCString(v28);
*(_OWORD *)Block = 0;
v61 = 0;
v62 = 0;
v30 = -1;
do
++v30;
while ( CString[v30] );
sub_14003D230(Block, CString, v30);
v31 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, v50[0]);
cocos2d::CCDictionary::setObject(*(_QWORD *)(a1 + 680), v31, Block);
if ( v62 > 0xF )
{
v32 = Block[0];
if ( v62 + 1 >= 0x1000 )
{
v32 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v32 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v32);
}
v33 = (cocos2d::CCArray *)MoreVideoOptionsLayer::objectsForPage(a1, v9);
cocos2d::CCArray::addObject(v33, ToggleButton);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)ToggleButton + 336LL))(ToggleButton, 0);
result = (*(__int64 (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v22 + 336LL))(v22, 0);
if ( a4 )
{
v35 = cocos2d::CCString::createWithFormat("info_%i", v49);
v36 = cocos2d::CCString::getCString(v35);
*(_OWORD *)v63 = 0;
v64 = 0;
v65 = 0;
v37 = -1;
do
++v37;
while ( v36[v37] );
sub_14003D230(v63, v36, v37);
*(_OWORD *)Block = 0;
v61 = 0;
v62 = 0;
do
++v12;
while ( a4[v12] );
sub_14003D230(Block, a4, v12);
v38 = *(_QWORD *)(a1 + 680);
v39 = cocos2d::CCString::create(Block);
cocos2d::CCDictionary::setObject(v38, v39, v63);
if ( v62 > 0xF )
{
v40 = Block[0];
if ( v62 + 1 >= 0x1000 )
{
v40 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v40 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v40);
}
v61 = 0;
v62 = 15;
LOBYTE(Block[0]) = 0;
if ( v65 > 0xF )
{
v41 = v63[0];
if ( v65 + 1 >= 0x1000 )
{
v41 = *((void **)v63[0] - 1);
if ( (unsigned __int64)((char *)v63[0] - (char *)v41 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v41);
}
v42 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
v43 = (int)v42;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v42 + 160LL))(v42);
v44 = CCMenuItemSpriteExtra::create(v43, 0, a1, (__int64)MoreVideoOptionsLayer::onInfo);
*((_DWORD *)v44 + 93) = 0x40000000;
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v44 + 64LL))(v44, v49);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v44);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v50, -18.0, 16.0);
v46 = v45;
v47 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)ToggleButton + 200LL))(ToggleButton);
cocos2d::CCPoint::operator+(v47, &v51, v46);
(*(void (__fastcall **)(struct cocos2d::CCObject *, __int128 **))(*(_QWORD *)v44 + 184LL))(v44, &v51);
cocos2d::CCArray::addObject(v33, v44);
return (*(__int64 (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v44 + 336LL))(v44, 0);
}
return result;
}