//
// GJOptionsLayer::onToggle from 0x10029ceb0 to 0x10029cfde (302 bytes)
//
// 2 xrefs:
// > GJOptionsLayer::addToggleInternal @ 0x10029c848
// > GameOptionsLayer::setupOptions @ 0x1002b15c0
//
// 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 __fastcall GJOptionsLayer::onToggle(GJOptionsLayer *a1, cocos2d::CCObject *a2)
{
double v2; // xmm0_8
cocos2d::CCDictionary *m_variables; // r15
intptr_t v5; // rsi
cocos2d::CCObject *v6; // rax
cocos2d::CCString *v7; // r15
GameManager *v8; // r14
const char *CString; // rax
const char *v10; // r15
size_t v11; // rax
size_t v12; // r14
char *v13; // r12
unsigned int v14; // eax
size_t v15; // r13
_QWORD __dst[2]; // [rsp+0h] [rbp-40h] BYREF
void *__p; // [rsp+10h] [rbp-30h]
m_variables = a1->m_variables;
v5 = ((int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2);
v6 = cocos2d::CCDictionary::objectForKey(m_variables, v5);
if ( !v6 )
{
v14 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2);
((void (__fastcall *)(GJOptionsLayer *, _QWORD))a1->didToggle)(a1, v14);
return;
}
v7 = (cocos2d::CCString *)v6;
v8 = GameManager::sharedState();
CString = cocos2d::CCString::getCString(v7);
GameManager::toggleGameVariable(v8, CString);
v10 = cocos2d::CCString::getCString(v7);
v11 = strlen(v10);
if ( v11 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v12 = v11;
if ( v11 >= 0x17 )
{
v15 = 26;
if ( (v11 | 7) != 0x17 )
v15 = (v11 | 7) + 1;
v13 = (char *)operator new(v15);
__p = v13;
__dst[0] = v15 + 1;
__dst[1] = v12;
goto LABEL_10;
}
LOBYTE(__dst[0]) = 2 * v11;
v13 = (char *)__dst + 1;
if ( v11 )
LABEL_10:
memmove(v13, v10, v12);
v13[v12] = 0;
((void (__fastcall *)(GJOptionsLayer *, _QWORD *))a1->didToggleGV)(a1, __dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
}