//
// GameSettingsLayer::addToggle from 0x710c50 to 0x710f26 (726 bytes)
//
// 3 xrefs:
// > GameSettingsLayer::addGVToggle @ 0x712070
// > GameSettingsLayer::buildTabContent @ 0x712156
// > GameSettingsLayer::buildTabContent @ 0x712782
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:57:44 +0000
//
CCMenuItemToggler *__fastcall GameSettingsLayer::addToggle(
GameSettingsLayer *this,
const char *a2,
int a3,
const char *a4,
bool a5)
{
int v9; // r2
int v10; // r1
_DWORD *v12; // r6
size_t v13; // r0
int v14; // r4
cocos2d::CCArray *ToggleValueControlAdvanced; // r8
CCMenuItemToggler *v16; // r4
float v17; // s15
int v18; // r3
_DWORD *v19; // r2
int v20; // r3
int *v21; // r2
int *v22; // r11
int v23; // r0
int *v24; // r2
int v25; // t1
size_t v26; // r0
unsigned __int8 *v27; // r3
int v28; // r2
char *v29; // r2
int v30; // r0
size_t v31; // r0
cocos2d::CCObject *v32; // r7
int v33; // r11
int v34; // r5
int v35; // [sp+20h] [bp-54h]
unsigned int v36; // [sp+24h] [bp-50h]
int *v37; // [sp+28h] [bp-4Ch]
void (__fastcall *v38)(cocos2d::CCObject *, _BYTE *); // [sp+28h] [bp-4Ch]
_BYTE v39[8]; // [sp+30h] [bp-44h] BYREF
_BYTE v40[8]; // [sp+38h] [bp-3Ch] BYREF
_BYTE v41[8]; // [sp+40h] [bp-34h] BYREF
int v42; // [sp+48h] [bp-2Ch] BYREF
int v43; // [sp+4Ch] [bp-28h]
unsigned __int8 *v44; // [sp+50h] [bp-24h]
int v45[3]; // [sp+54h] [bp-20h] BYREF
int v46; // [sp+60h] [bp-14h] BYREF
int v47; // [sp+64h] [bp-10h]
int v48; // [sp+68h] [bp-Ch]
v9 = *((_DWORD *)this + 185);
if ( v9 < 0 )
return nullptr;
v10 = *((_DWORD *)this + 178);
if ( v9 >= -1171354717 * ((*((_DWORD *)this + 179) - v10) >> 2) )
return nullptr;
v12 = (_DWORD *)(v10 + 44 * v9);
v35 = TabbedPopupLayer::pageForButtonCount(this, v12[9], 12);
v36 = TabbedPopupLayer::ensurePopupPage(this, *((_DWORD *)this + 185), v35);
GameSettingsLayer::nextPosition((GameSettingsLayer *)v39, (int)this, v12[9] % 12 + 1);
v46 = 0;
v47 = 0;
v48 = 0;
v13 = strlen(a2);
std::string::__init(&v46, a2, v13);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v41, (const cocos2d::CCPoint *)v39);
v14 = v12[6];
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v40, 8.0, 0.0);
ToggleValueControlAdvanced = SetupTriggerPopup::createToggleValueControlAdvanced(
(int)this,
a3,
(int)&v46,
(const cocos2d::CCPoint *)v41,
0,
v36,
v14,
0.7,
0.35,
500.0,
(const cocos2d::CCPoint *)v40);
std::string::~string((int)&v46);
v16 = (CCMenuItemToggler *)cocos2d::CCDictionary::objectForKey(*((cocos2d::CCDictionary **)this + 143), a3);
if ( v16 )
{
v17 = COERCE_FLOAT((*(int (__fastcall **)(GameSettingsLayer *, int))(*(_DWORD *)this + 732))(this, a3));
CCMenuItemToggler::toggle(v16, v17 != 0.0);
}
if ( ToggleValueControlAdvanced )
{
v19 = *((_DWORD **)ToggleValueControlAdvanced + 13);
if ( *v19 )
{
v20 = *v19 + 0x40000000;
v21 = (int *)v19[3];
v22 = &v21[v20 - 1];
while ( v21 <= v22 )
{
v25 = *v21;
v24 = v21 + 1;
v23 = v25;
if ( !v25 )
break;
v37 = v24;
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v23 + 172))(v23, 0);
v21 = v37;
}
}
}
if ( a4 && *a4 && v16 )
{
v42 = 0;
v43 = 0;
v44 = nullptr;
v26 = strlen(a2);
std::string::__init(&v42, a2, v26);
if ( (v42 & 1) != 0 )
{
v27 = v44;
v28 = v43;
}
else
{
v28 = (int)(unsigned __int8)v42 >> 1;
v27 = (unsigned __int8 *)&v42 + 1;
}
v29 = (char *)&v27[v28];
while ( v27 != (unsigned __int8 *)v29 )
{
v30 = *v27++;
if ( v30 == 10 )
*(v27 - 1) = 32;
}
std::string::basic_string(v45, (int)&v42);
v46 = 0;
v47 = 0;
v48 = 0;
v31 = strlen(a4);
std::string::__init(&v46, a4, v31);
v32 = (cocos2d::CCObject *)InfoAlertButton::create((char *)v45, (int)&v46, 1056964608);
std::string::~string((int)&v46);
std::string::~string((int)v45);
(*(void (__fastcall **)(_DWORD, cocos2d::CCObject *))(**((_DWORD **)this + 111) + 228))(
*((_DWORD *)this + 111),
v32);
v38 = *(void (__fastcall **)(cocos2d::CCObject *, _BYTE *))(*(_DWORD *)v32 + 92);
v33 = (*(int (__fastcall **)(CCMenuItemToggler *))(*(_DWORD *)v16 + 96))(v16);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v40, -17.0, 15.0);
cocos2d::CCPoint::operator+(v41, v33, v40);
v38(v32, v41);
(*(void (__fastcall **)(cocos2d::CCObject *, _DWORD))(*(_DWORD *)v32 + 172))(v32, 0);
SetupTriggerPopup::addObjectToPage((cocos2d::CCArray **)this, v32, v36);
SetupTriggerPopup::addObjectToGroup((cocos2d::CCArray **)this, v32, v12[6]);
std::string::~string((int)&v42);
}
++v12[9];
v18 = v12[8];
if ( v35 >= v18 )
v18 = v35 + 1;
v12[8] = v18;
if ( a5 )
{
if ( cocos2d::CCArray::count(ToggleValueControlAdvanced) <= 1u )
v34 = 0;
else
v34 = cocos2d::CCArray::objectAtIndex(ToggleValueControlAdvanced, 1u);
memset(v41, 150, 3);
*((_BYTE *)v16 + 309) = 1;
CCMenuItemToggler::setSpriteColor((int)v16, (int)v41);
if ( v34 )
(*(void (__fastcall **)(int, _BYTE *))(*(_DWORD *)v34 + 536))(v34, v41);
}
return v16;
}