//
// MoreOptionsLayer::addToggle from 0x7ca0dc to 0x7ca65c (1408 bytes)
//
// 52 xrefs:
// > MoreOptionsLayer::init @ 0x7cb098
// > MoreOptionsLayer::init @ 0x7cb0b8
// > MoreOptionsLayer::init @ 0x7cb0d8
// > MoreOptionsLayer::init @ 0x7cb0f8
// > MoreOptionsLayer::init @ 0x7cb118
// > MoreOptionsLayer::init @ 0x7cb138
// > MoreOptionsLayer::init @ 0x7cb15c
// > MoreOptionsLayer::init @ 0x7cb17c
// > MoreOptionsLayer::init @ 0x7cb19c
// > MoreOptionsLayer::init @ 0x7cb1bc
// > MoreOptionsLayer::init @ 0x7cb1dc
// > MoreOptionsLayer::init @ 0x7cb1fc
// > MoreOptionsLayer::init @ 0x7cb21c
// > MoreOptionsLayer::init @ 0x7cb23c
// > MoreOptionsLayer::init @ 0x7cb25c
// > MoreOptionsLayer::init @ 0x7cb27c
// > MoreOptionsLayer::init @ 0x7cb29c
// > MoreOptionsLayer::init @ 0x7cb2bc
// > MoreOptionsLayer::init @ 0x7cb2dc
// > MoreOptionsLayer::init @ 0x7cb2fc
// > MoreOptionsLayer::init @ 0x7cb31c
// > MoreOptionsLayer::init @ 0x7cb340
// > MoreOptionsLayer::init @ 0x7cb360
// > MoreOptionsLayer::init @ 0x7cb380
// > MoreOptionsLayer::init @ 0x7cb3a0
// > MoreOptionsLayer::init @ 0x7cb3c0
// > MoreOptionsLayer::init @ 0x7cb3e0
// > MoreOptionsLayer::init @ 0x7cb400
// > MoreOptionsLayer::init @ 0x7cb428
// > MoreOptionsLayer::init @ 0x7cb448
// > MoreOptionsLayer::init @ 0x7cb468
// > MoreOptionsLayer::init @ 0x7cb488
// > MoreOptionsLayer::init @ 0x7cb4a8
// > MoreOptionsLayer::init @ 0x7cb4c8
// > MoreOptionsLayer::init @ 0x7cb4e8
// > MoreOptionsLayer::init @ 0x7cb508
// > MoreOptionsLayer::init @ 0x7cb528
// > MoreOptionsLayer::init @ 0x7cb550
// > MoreOptionsLayer::init @ 0x7cb570
// > MoreOptionsLayer::init @ 0x7cb590
// > MoreOptionsLayer::init @ 0x7cb5b0
// > MoreOptionsLayer::init @ 0x7cb5d8
// > MoreOptionsLayer::init @ 0x7cb5f8
// > MoreOptionsLayer::init @ 0x7cb618
// > MoreOptionsLayer::init @ 0x7cb638
// > MoreOptionsLayer::init @ 0x7cb658
// > MoreOptionsLayer::init @ 0x7cb678
// > MoreOptionsLayer::init @ 0x7cb698
// > MoreOptionsLayer::init @ 0x7cb6b8
// > MoreOptionsLayer::init @ 0x7cb6d8
// > MoreOptionsLayer::init @ 0x7cb6f4
// > ??> @ 0x53e80
//
// 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 MoreOptionsLayer::addToggle(MoreOptionsLayer *a1, const char *a2, const char *a3, const char *a4)
{
int m_toggleCount; // w0
float v9; // s0
int v10; // w19
int m_pageCount; // w1
unsigned int v12; // w24
GameManager *v13; // x0
char *v14; // x1
cocos2d::CCDictionary *m_objects; // x22
const std::string *v16; // x1
cocos2d::CCObject *v17; // x0
void *v18; // x0
cocos2d::CCLayer *v19; // x25
CCMenuItemToggler *v20; // x26
char *v21; // x0
cocos2d::CCArray *v22; // x19
cocos2d::CCDictionary *m_variables; // x25
const std::string *v24; // x1
cocos2d::CCObject *v25; // x28
char *v26; // x0
void *v27; // x0
char *v28; // x0
cocos2d::CCSprite *v29; // x23
CCMenuItemSpriteExtra *v30; // x23
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x20
__int64 v32; // x24
unsigned int *v33; // x1
int v34; // w2
unsigned int *v35; // x1
int v36; // w2
unsigned int *v37; // x1
int v38; // w2
unsigned int *v39; // x1
int v40; // w2
bool GameVariable; // [xsp+9Fh] [xbp+6Fh]
cocos2d::CCMenu *m_buttonMenu; // [xsp+A0h] [xbp+70h]
cocos2d::CCPoint v43; // [xsp+C8h] [xbp+98h] BYREF
cocos2d::CCPoint v44; // [xsp+D0h] [xbp+A0h] BYREF
char *v45; // [xsp+D8h] [xbp+A8h] BYREF
cocos2d::CCPoint v46; // [xsp+E0h] [xbp+B0h] BYREF
cocos2d::SEL_MenuHandler v47; // 0:x2.16
m_toggleCount = a1->m_toggleCount;
a1->m_toggleCount = m_toggleCount + 1;
v9 = floorf((float)(m_toggleCount / 10));
if ( v9 <= 0.0 )
v10 = 0;
else
v10 = (int)v9;
m_pageCount = a1->m_pageCount;
if ( v10 >= m_pageCount )
m_pageCount = v10;
a1->m_pageCount = m_pageCount;
v12 = atoi(a3);
v13 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v13, a3);
v14 = (char *)a3;
m_objects = a1->m_objects;
sub_D153B8((int)&v46, v14);
v17 = (cocos2d::CCObject *)cocos2d::CCString::create((cocos2d::CCString *)&v46, v16);
cocos2d::CCDictionary::setObject(m_objects, v17, (int)v12);
v18 = (void *)(*(_QWORD *)&v46 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v46 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v35 = (unsigned int *)(*(_QWORD *)&v46 - 8LL);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *(_DWORD *)(*(_QWORD *)&v46 - 8LL);
*(_DWORD *)(*(_QWORD *)&v46 - 8LL) = v36 - 1;
}
if ( v36 <= 0 )
operator delete(v18);
}
MoreOptionsLayer::nextPosition(a1, v10);
v19 = MoreOptionsLayer::layerForPage(a1, v10);
sub_D153B8((int)&v45, (char *)a2);
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v46, &v43);
cocos2d::CCPoint::CCPoint(&v44, 8.0, 0.0);
v20 = GameToolbox::createToggleButton(
0.8,
0.4,
130.0,
(__int64)&v45,
(void (__cdecl *)(cocos2d::CCObject *))MoreOptionsLayer::onToggle,
0,
GameVariable,
m_buttonMenu,
&v46,
a1,
v19,
(float *)&v44,
(__int64)"bigFont.fnt",
0,
0,
nullptr);
v21 = v45 - 24;
if ( v45 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)(v45 - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *((_DWORD *)v45 - 2);
*((_DWORD *)v45 - 2) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v21);
}
v20->setTag(v20, v12);
CCMenuItemToggler::setSizeMult(v20, 1.0);
MoreOptionsLayer::incrementCountForPage(a1, v10);
v22 = MoreOptionsLayer::objectsForPage(a1, v10);
cocos2d::CCArray::addObject(v22, v20);
v20->setVisible(v20, 0);
v19->setVisible(v19, 0);
if ( a4 )
{
m_variables = a1->m_variables;
sub_D153B8((int)&v45, (char *)a4);
v25 = (cocos2d::CCObject *)cocos2d::CCString::create((cocos2d::CCString *)&v45, v24);
v26 = (char *)MoreOptionsLayer::infoKey(a1, v12);
sub_D153B8((int)&v46, v26);
cocos2d::CCDictionary::setObject((int)m_variables, v25);
v27 = (void *)(*(_QWORD *)&v46 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v46 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v39 = (unsigned int *)(*(_QWORD *)&v46 - 8LL);
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *(_DWORD *)(*(_QWORD *)&v46 - 8LL);
*(_DWORD *)(*(_QWORD *)&v46 - 8LL) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v27);
}
v28 = v45 - 24;
if ( v45 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v37 = (unsigned int *)(v45 - 8);
do
v38 = __ldaxr(v37);
while ( __stlxr(v38 - 1, v37) );
}
else
{
v38 = *((_DWORD *)v45 - 2);
*((_DWORD *)v45 - 2) = v38 - 1;
}
if ( v38 <= 0 )
operator delete(v28);
}
v29 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
v29->setScale(v29, 0.5);
v47.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v47.adj = (size_t)MoreOptionsLayer::onInfo;
v30 = CCMenuItemSpriteExtra::create(v29, nullptr, v47);
CCMenuItemSpriteExtra::setSizeMult(v30, 2.0);
v30->setTag(v30, v12);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v30);
setPosition = v30->setPosition;
v32 = (__int64)v20->getPosition(v20);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v45, -18.0, 16.0);
cocos2d::CCPoint::operator+(&v46, v32, &v45);
setPosition(v30, &v46);
cocos2d::CCArray::addObject(v22, v30);
v30->setVisible(v30, 0);
}
}