//
// MoreVideoOptionsLayer::addToggle from 0x140379720 to 0x140379d71 (1617 bytes)
//
// 5 xrefs:
// > MoreVideoOptionsLayer::init @ 0x140378efd
// > MoreVideoOptionsLayer::init @ 0x140378f1a
// > MoreVideoOptionsLayer::init @ 0x140378f37
// > MoreVideoOptionsLayer::init @ 0x140378f54
// > ??> @ 0x1406d5c6c
//
// 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
//
// Hidden C++ exception states: #wind=5
void MoreVideoOptionsLayer::addToggle(MoreVideoOptionsLayer *a1, const char *a2, const char *a3, const char *a4)
{
int m_toggleCount; // ecx
int v9; // r12d
int m_pageCount; // eax
int v11; // eax
__int64 v12; // r13
GameManager *v13; // rcx
size_t v14; // rdi
size_t v15; // r8
struct cocos2d::CCObject *v16; // rax
__int64 v17; // rcx
void *v18; // rcx
cocos2d::CCDirector *v19; // rax
double v20; // xmm0_8
int v21; // r13d
float v22; // xmm0_4
cocos2d::CCLayer *v23; // r13
size_t v24; // r8
float *v25; // rax
float *v26; // rbx
struct cocos2d::CCPoint v27; // rax
CCMenuItemToggler *ToggleButton; // r15
cocos2d::CCString *v29; // rax
const char *CString; // rax
size_t v31; // r8
struct cocos2d::CCString *v32; // rax
void *v33; // rcx
cocos2d::CCArray *v34; // r12
cocos2d::CCString *v35; // rax
const char *v36; // rax
size_t v37; // r8
__int64 v38; // rax
void *v39; // rcx
void *v40; // rcx
struct cocos2d::CCSprite *v41; // rbx
CCMenuItemSpriteExtra *v42; // rdi
float v43; // xmm0_4
__int64 v44; // rax
bool GameVariable; // [rsp+80h] [rbp-80h]
float v46; // [rsp+88h] [rbp-78h]
int v47; // [rsp+88h] [rbp-78h]
int v48; // [rsp+90h] [rbp-70h]
__int128 *v49; // [rsp+98h] [rbp-68h] BYREF
cocos2d::CCPoint v50; // [rsp+A0h] [rbp-60h] BYREF
__int128 v51; // [rsp+B0h] [rbp-50h] BYREF
__int64 v52; // [rsp+C0h] [rbp-40h]
__int64 v53; // [rsp+C8h] [rbp-38h]
cocos2d::CCPoint v54; // [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]
m_toggleCount = a1->m_toggleCount;
a1->m_toggleCount = m_toggleCount + 1;
v9 = (int)fmaxf(0.0, floorf((float)(m_toggleCount / 10)));
m_pageCount = a1->m_pageCount;
if ( m_pageCount <= v9 )
m_pageCount = v9;
a1->m_pageCount = m_pageCount;
v11 = atoi(a3);
v12 = v11;
v48 = v11;
v13 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v49 = (__int128 *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v49);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v13 = (GameManager *)qword_1406C2ED8;
}
GameVariable = GameManager::getGameVariable(v13, a3);
*(_OWORD *)Block = 0;
v56 = 0;
v57 = 0;
v14 = -1;
v15 = -1;
do
++v15;
while ( a3[v15] );
sub_14003A930(Block, a3, v15);
v16 = (struct cocos2d::CCObject *)cocos2d::CCString::create(Block);
cocos2d::CCDictionary::setObject(a1->m_variables, v16, v12);
if ( v57 > 0xF )
{
v18 = Block[0];
if ( v57 + 1 >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v18);
}
v19 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v17);
cocos2d::CCDirector::getWinSize(v19);
v20 = cocos2d::CCPoint::CCPoint(0.0, (float)(v46 * 0.5) - 135.0);
cocos2d::CCPoint::CCPoint(*(float *)&v20, (float)(v46 * 0.5) + 35.0);
v21 = MoreVideoOptionsLayer::countForPage(a1, v9);
cocos2d::CCPoint::CCPoint(&v50);
if ( v21 + 1 > 2 )
{
v22 = floorf((float)v21 * 0.5);
v50.y = v50.y - (float)(48 * (int)v22);
}
v23 = MoreVideoOptionsLayer::layerForPage(a1, v9);
v49 = &v51;
v51 = 0;
v52 = 0;
v53 = 0;
v24 = -1;
do
++v24;
while ( a2[v24] );
sub_14003A930(&v51, a2, v24);
cocos2d::CCPoint::CCPoint(0.0, 8.0);
v26 = v25;
cocos2d::CCPoint::CCPoint(&v54);
ToggleButton = GameToolbox::createToggleButton(
(const char *)&v51,
(cocos2d::SEL_MenuHandler *)MoreVideoOptionsLayer::onToggle,
GameVariable,
a1->m_buttonMenu,
v27,
a1,
v23,
0.80000001,
0.5,
110.0,
v26,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
ToggleButton->setTag(ToggleButton, v48);
*(_DWORD *)(*(_QWORD *)&ToggleButton->m_nScriptTapHandler + 372LL) = 1065353216;
HIDWORD(ToggleButton->m_offButton->m_pfnSelector.adj) = 1065353216;
CCMenuItemToggler::toggle(ToggleButton, (bool)ToggleButton->m_onButton);
v47 = MoreVideoOptionsLayer::countForPage(a1, v9) + 1;
v29 = cocos2d::CCString::createWithFormat("page_%i", v9);
CString = cocos2d::CCString::getCString(v29);
*(_OWORD *)Block = 0;
v56 = 0;
v57 = 0;
v31 = -1;
do
++v31;
while ( CString[v31] );
sub_14003A930(Block, CString, v31);
v32 = cocos2d::CCString::createWithFormat("%i", v47);
cocos2d::CCDictionary::setObject(a1->m_values, v32, Block);
if ( v57 > 0xF )
{
v33 = Block[0];
if ( v57 + 1 >= 0x1000 )
{
v33 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v33 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v33);
}
v34 = MoreVideoOptionsLayer::objectsForPage(a1, v9);
cocos2d::CCArray::addObject(v34, ToggleButton);
ToggleButton->setVisible(ToggleButton, 0);
v23->setVisible(v23, 0);
if ( a4 )
{
v35 = cocos2d::CCString::createWithFormat("info_%i", v48);
v36 = cocos2d::CCString::getCString(v35);
*(_OWORD *)v58 = 0;
v59 = 0;
v60 = 0;
v37 = -1;
do
++v37;
while ( v36[v37] );
sub_14003A930(v58, v36, v37);
*(_OWORD *)Block = 0;
v56 = 0;
v57 = 0;
do
++v14;
while ( a4[v14] );
sub_14003A930(Block, a4, v14);
v38 = cocos2d::CCString::create(Block);
cocos2d::CCDictionary::setObject(a1->m_values, v38, v58);
if ( v57 > 0xF )
{
v39 = Block[0];
if ( v57 + 1 >= 0x1000 )
{
v39 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v39 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v39);
}
v56 = 0;
v57 = 15;
LOBYTE(Block[0]) = 0;
if ( v60 > 0xF )
{
v40 = v58[0];
if ( v60 + 1 >= 0x1000 )
{
v40 = *((void **)v58[0] - 1);
if ( (unsigned __int64)((char *)v58[0] - (char *)v40 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v40);
}
v41 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v41->setScale_0)(v41);
v42 = CCMenuItemSpriteExtra::create(v41, nullptr, a1, (cocos2d::SEL_MenuHandler *)MoreVideoOptionsLayer::onInfo);
HIDWORD(v42->m_pfnSelector.adj) = 0x40000000;
v42->setTag(v42, v48);
v43 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v42);
cocos2d::CCPoint::CCPoint(v43, -18.0);
v44 = (__int64)ToggleButton->getPosition_0(ToggleButton);
cocos2d::CCPoint::operator+(v44, &v49);
v42->setPosition_0(v42, (const cocos2d::CCPoint *)&v49);
cocos2d::CCArray::addObject(v34, v42);
v42->setVisible(v42, 0);
}
}