//
// ParentalOptionsLayer::addToggle from 0x426a28 to 0x426caa (642 bytes)
//
// 3 xrefs:
// > ParentalOptionsLayer::init @ 0x427060
// > ParentalOptionsLayer::init @ 0x427070
// > ParentalOptionsLayer::init @ 0x427080
//
// 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
//
void ParentalOptionsLayer::addToggle(ParentalOptionsLayer *a1, const char *a2, const char *a3, const char *a4)
{
int v4; // r10
int m_toggleCount; // r0
float v9; // r0
int m_maxPage; // r3
int v11; // s15
GameManager *v12; // r0
bool GameVariable; // r0
cocos2d::CCDictionary *m_variables; // r7
bool v15; // r6
const std::string *v16; // r1
cocos2d::CCObject *v17; // r0
cocos2d::CCLayer *v18; // r9
cocos2d::CCMenu *m_buttonMenu; // r8
CCMenuItemToggler *v20; // r6
cocos2d::CCArray *v21; // r11
const std::string *v22; // r1
cocos2d::CCObject *v23; // r10
char *v24; // r0
cocos2d::CCSprite *v25; // r5
CCMenuItemSpriteExtra *v26; // r5
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r4
int v28; // r6
intptr_t v29; // [sp+34h] [bp-48h]
cocos2d::CCDictionary *m_values; // [sp+40h] [bp-3Ch]
cocos2d::CCPoint v32; // [sp+4Ch] [bp-30h] BYREF
cocos2d::CCPoint v33; // [sp+54h] [bp-28h] BYREF
cocos2d::CCPoint v34; // [sp+5Ch] [bp-20h] BYREF
void (*v35)(ParentalOptionsLayer *, cocos2d::CCObject *); // [sp+64h] [bp-18h]
unsigned int v36; // [sp+68h] [bp-14h]
cocos2d::CCPoint v37; // [sp+6Ch] [bp-10h] BYREF
m_toggleCount = a1->m_toggleCount;
a1->m_toggleCount = m_toggleCount + 1;
v9 = floorf((float)(m_toggleCount / 10));
m_maxPage = a1->m_maxPage;
v11 = LODWORD(v9);
if ( v9 <= 0.0 )
v4 = 0;
else
v11 = (int)v9;
if ( v9 > 0.0 )
v4 = v11;
if ( m_maxPage < v4 )
a1->m_maxPage = v4;
else
a1->m_maxPage = m_maxPage;
v29 = atoi(a3);
v12 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v12, a3);
m_variables = a1->m_variables;
v15 = GameVariable;
sub_776584((int)&v37, (char *)a3);
v17 = (cocos2d::CCObject *)cocos2d::CCString::create((cocos2d::CCString *)&v37, v16);
cocos2d::CCDictionary::setObject(m_variables, v17, v29);
sub_774008(&v37);
ParentalOptionsLayer::nextPosition(&v32, a1, v4);
v18 = ParentalOptionsLayer::layerForPage(a1, v4);
sub_776584((int)&v33, (char *)a2);
m_buttonMenu = a1->m_buttonMenu;
v35 = ParentalOptionsLayer::onToggle;
v36 = 0;
cocos2d::CCPoint::CCPoint(&v37, &v32);
cocos2d::CCPoint::CCPoint(&v34, 8.0, 0.0);
v20 = GameToolbox::createToggleButton(
(int)&v33,
(unsigned int)v35,
v36,
v15,
m_buttonMenu,
&v37,
a1,
v18,
0.8,
0.5,
110.0,
(int)&v34,
(int)"bigFont.fnt",
0,
0,
nullptr);
sub_774008(&v33);
v20->setTag(v20, v29);
CCMenuItemToggler::setSizeMult(v20, 1.0);
ParentalOptionsLayer::incrementCountForPage(a1, v4);
v21 = ParentalOptionsLayer::objectsForPage(a1, v4);
cocos2d::CCArray::addObject(v21, v20);
v20->setVisible(v20, 0);
v18->setVisible(v18, 0);
if ( a4 )
{
m_values = a1->m_values;
sub_776584((int)&v34, (char *)a4);
v23 = (cocos2d::CCObject *)cocos2d::CCString::create((cocos2d::CCString *)&v34, v22);
v24 = (char *)ParentalOptionsLayer::infoKey(a1, v29);
sub_776584((int)&v37, v24);
cocos2d::CCDictionary::setObject((int)m_values, v23);
sub_774008(&v37);
sub_774008(&v34);
v25 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, int))v25->setScale)(v25, 1056964608);
LODWORD(v37.x) = ParentalOptionsLayer::onInfo;
v37.y = 0.0;
v26 = CCMenuItemSpriteExtra::create(
v25,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(ParentalOptionsLayer::onInfo, (unsigned int)a1));
CCMenuItemSpriteExtra::setSizeMult(v26, 2.0);
v26->setTag(v26, v29);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v26);
setPosition = v26->setPosition;
v28 = (int)v20->getPosition(v20);
cocos2d::CCPoint::CCPoint(&v33, -18.0, 16.0);
cocos2d::CCPoint::operator+(&v34, v28, &v33);
setPosition(v26, &v34);
cocos2d::CCArray::addObject(v21, v26);
v26->setVisible(v26, 0);
}
}