//
// GJOptionsLayer::addToggleInternal from 0x14028fee0 to 0x140290306 (1062 bytes)
//
// 35 xrefs:
// > GJOptionsLayer::addGVToggle @ 0x14028fe28
// > GameOptionsLayer::setupOptions @ 0x14029f019
// > GameOptionsLayer::setupOptions @ 0x14029f07d
// > GameOptionsLayer::setupOptions @ 0x14029f0d9
// > GameOptionsLayer::setupOptions @ 0x14029f13d
// > GameOptionsLayer::setupOptions @ 0x14029f1a1
// > GameOptionsLayer::setupOptions @ 0x14029f205
// > GameOptionsLayer::setupOptions @ 0x14029f269
// > GameOptionsLayer::setupOptions @ 0x14029f2cd
// > GameOptionsLayer::setupOptions @ 0x14029f338
// > GameOptionsLayer::setupOptions @ 0x14029f3a3
// > GameLevelOptionsLayer::setupOptions @ 0x1402a0c1b
// > GameLevelOptionsLayer::setupOptions @ 0x1402a0c44
// > LevelOptionsLayer::setupOptions @ 0x1403240cb
// > LevelOptionsLayer::setupOptions @ 0x1403240f4
// > LevelOptionsLayer::setupOptions @ 0x14032412e
// > LevelOptionsLayer::setupOptions @ 0x140324157
// > LevelOptionsLayer::setupOptions @ 0x140324180
// > LevelOptionsLayer::setupOptions @ 0x1403241a9
// > LevelOptionsLayer::setupOptions @ 0x1403241d2
// > LevelOptionsLayer::setupOptions @ 0x140324210
// > LevelOptionsLayer2::setupOptions @ 0x140324a01
// > LevelOptionsLayer2::setupOptions @ 0x140324a31
// > LevelOptionsLayer2::setupOptions @ 0x140324a61
// > LevelOptionsLayer2::setupOptions @ 0x140324a91
// > LevelOptionsLayer2::setupOptions @ 0x140324ac1
// > LevelOptionsLayer2::setupOptions @ 0x140324af1
// > LevelOptionsLayer2::setupOptions @ 0x140324b21
// > LevelOptionsLayer2::setupOptions @ 0x140324b51
// > LevelOptionsLayer2::setupOptions @ 0x140324b81
// > LevelOptionsLayer2::setupOptions @ 0x140324bb1
// > LevelOptionsLayer2::setupOptions @ 0x140324be1
// > LevelOptionsLayer2::setupOptions @ 0x140324c11
// > LevelOptionsLayer2::setupOptions @ 0x140324c43
// > ??> @ 0x1406d1934
//
// 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=3
void GJOptionsLayer::addToggleInternal(GJOptionsLayer *a1, const char *a2, int a3, bool a4, const char *a5)
{
int m_toggleCount; // eax
int v10; // r15d
int m_maxPage; // eax
size_t v12; // rdi
size_t v13; // r8
float *v14; // rax
float *v15; // rbx
cocos2d::CCLayer *v16; // rbx
struct cocos2d::CCPoint v17; // rax
CCMenuItemToggler *ToggleButton; // r13
cocos2d::CCArray *v19; // r15
__int64 v20; // rax
cocos2d::CCString *v21; // rax
const char *CString; // rax
size_t v23; // r8
__int64 v24; // rax
void *v25; // rcx
void *v26; // rcx
struct cocos2d::CCSprite *v27; // rbx
CCMenuItemSpriteExtra *v28; // rdi
float v29; // xmm0_4
__int64 v30; // rax
float *v31; // [rsp+50h] [rbp-B0h]
cocos2d::CCLayer *v32; // [rsp+80h] [rbp-80h] BYREF
char v33[8]; // [rsp+88h] [rbp-78h] BYREF
__int128 *v34; // [rsp+90h] [rbp-70h]
__int128 v35; // [rsp+98h] [rbp-68h] BYREF
__int64 v36; // [rsp+A8h] [rbp-58h]
__int64 v37; // [rsp+B0h] [rbp-50h]
cocos2d::CCPoint v38; // [rsp+C0h] [rbp-40h] BYREF
void *Block[2]; // [rsp+C8h] [rbp-38h] BYREF
__m128i si128; // [rsp+D8h] [rbp-28h]
void *v41[2]; // [rsp+E8h] [rbp-18h] BYREF
__int128 v42; // [rsp+F8h] [rbp-8h]
m_toggleCount = a1->m_toggleCount;
a1->m_toggleCount = m_toggleCount + 1;
v10 = (int)fmaxf(0.0, floorf((float)(m_toggleCount / a1->m_togglesPerPage)));
m_maxPage = a1->m_maxPage;
if ( m_maxPage <= v10 )
m_maxPage = v10;
a1->m_maxPage = m_maxPage;
sub_140290310(a1, v33, (unsigned int)v10);
v32 = GJOptionsLayer::layerForPage(a1, v10);
v34 = &v35;
v35 = 0;
v36 = 0;
v37 = 0;
v12 = -1;
v13 = -1;
do
++v13;
while ( a2[v13] );
sub_14003A930(&v35, a2, v13);
cocos2d::CCPoint::CCPoint(0.0, 8.0);
v15 = v14;
cocos2d::CCPoint::CCPoint(&v38);
v31 = v15;
v16 = v32;
ToggleButton = GameToolbox::createToggleButton(
(const char *)&v35,
(cocos2d::SEL_MenuHandler *)GJOptionsLayer::onToggle,
a4,
a1->m_buttonMenu,
v17,
a1,
v32,
0.80000001,
a1->m_maxLabelScale,
a1->m_maxLabelWidth,
v31,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
ToggleButton->setTag(ToggleButton, a3);
*(_DWORD *)(*(_QWORD *)&ToggleButton->m_nScriptTapHandler + 372LL) = 1065353216;
HIDWORD(ToggleButton->m_offButton->m_pfnSelector.adj) = 1065353216;
CCMenuItemToggler::toggle(ToggleButton, (bool)ToggleButton->m_onButton);
GJOptionsLayer::incrementCountForPage(a1, v10);
v19 = GJOptionsLayer::objectsForPage(a1, v10);
cocos2d::CCArray::addObject(v19, ToggleButton);
ToggleButton->setVisible(ToggleButton, 0);
v16->setVisible(v16, 0);
if ( a5 )
{
v20 = -1;
do
++v20;
while ( a5[v20] );
if ( v20 )
{
v21 = cocos2d::CCString::createWithFormat("info_%i", a3);
CString = cocos2d::CCString::getCString(v21);
*(_OWORD *)v41 = 0;
v42 = 0;
v23 = -1;
do
++v23;
while ( CString[v23] );
sub_14003A930(v41, CString, v23);
*(_OWORD *)Block = 0;
si128 = 0;
do
++v12;
while ( a5[v12] );
sub_14003A930(Block, a5, v12);
v24 = cocos2d::CCString::create(Block);
cocos2d::CCDictionary::setObject(a1->m_values, v24, v41);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v25 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v25 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v25 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v25);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Block[0]) = 0;
if ( *((_QWORD *)&v42 + 1) > 0xFu )
{
v26 = v41[0];
if ( (unsigned __int64)(*((_QWORD *)&v42 + 1) + 1LL) >= 0x1000 )
{
v26 = *((void **)v41[0] - 1);
if ( (unsigned __int64)((char *)v41[0] - (char *)v26 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v26);
}
v27 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v27->setScale_0)(v27);
v28 = CCMenuItemSpriteExtra::create(v27, nullptr, a1, (cocos2d::SEL_MenuHandler *)GJOptionsLayer::onInfo);
HIDWORD(v28->m_pfnSelector.adj) = 0x40000000;
v28->setTag(v28, a3);
v29 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v28);
cocos2d::CCPoint::CCPoint(v29, -18.0);
v30 = (__int64)ToggleButton->getPosition_0(ToggleButton);
cocos2d::CCPoint::operator+(v30, &v32);
v28->setPosition_0(v28, (const cocos2d::CCPoint *)&v32);
cocos2d::CCArray::addObject(v19, v28);
v28->setVisible(v28, 0);
}
}
}