//
// GJOptionsLayer::onToggle from 0x8c5c90 to 0x8c5e0c (380 bytes)
//
// 4 xrefs:
// > ??> @ 0x9af80
// > GJOptionsLayer::addToggleInternal @ 0x8dad3c
// > GameOptionsLayer::setupOptions @ 0x8dc1ec
// > ??> @ 0x122d4a0
//
// 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 GJOptionsLayer::onToggle(GJOptionsLayer *a1, cocos2d::CCObject *a2)
{
cocos2d::CCDictionary *m_variables; // x22
int v5; // w0
cocos2d::CCString *v6; // x22
GameManager *v7; // x23
const char *CString; // x0
cocos2d::CCString *v9; // x0
void (__fastcall *didToggleGV)(GJOptionsLayer *__hidden, std::string); // x22
char *v11; // x0
void *v12; // x0
cocos2d::CCObject *v13; // x0
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // x1
void (__fastcall *didToggle)(GJOptionsLayer *__hidden, int); // x20
int v16; // w0
unsigned int *v17; // x2
int v18; // w1
__int64 v19; // [xsp+50h] [xbp+50h] BYREF
m_variables = a1->m_variables;
v5 = a2->getTag(a2);
v6 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(m_variables, v5);
if ( v6 )
{
v7 = GameManager::sharedState();
CString = cocos2d::CCString::getCString(v6);
GameManager::toggleGameVariable(v7, CString);
v9 = v6;
didToggleGV = a1->didToggleGV;
v11 = (char *)cocos2d::CCString::getCString(v9);
sub_D153B8((int)&v19, v11);
((void (__fastcall *)(GJOptionsLayer *, __int64 *))didToggleGV)(a1, &v19);
v12 = (void *)(v19 - 24);
if ( (__int64 *)(v19 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(v19 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *(_DWORD *)(v19 - 8);
*(_DWORD *)(v19 - 8) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v12);
}
}
else
{
v13 = a2;
getTag = a2->getTag;
didToggle = a1->didToggle;
v16 = getTag(v13);
didToggle(a1, v16);
}
}