//
// SelectEventLayer::addToggle from 0x140467760 to 0x140467b9a (1082 bytes)
//
// 79 xrefs:
// > SelectEventLayer::init @ 0x1404668a8
// > SelectEventLayer::init @ 0x140466918
// > SelectEventLayer::init @ 0x140466990
// > SelectEventLayer::init @ 0x140466a02
// > SelectEventLayer::init @ 0x140466a66
// > SelectEventLayer::init @ 0x140466ade
// > SelectEventLayer::init @ 0x140466b04
// > SelectEventLayer::init @ 0x140466b2a
// > SelectEventLayer::init @ 0x140466b50
// > SelectEventLayer::init @ 0x140466b76
// > SelectEventLayer::init @ 0x140466b9c
// > SelectEventLayer::init @ 0x140466bc2
// > SelectEventLayer::init @ 0x140466be8
// > SelectEventLayer::init @ 0x140466c0e
// > SelectEventLayer::init @ 0x140466c34
// > SelectEventLayer::init @ 0x140466c5a
// > SelectEventLayer::init @ 0x140466c80
// > SelectEventLayer::init @ 0x140466ca6
// > SelectEventLayer::init @ 0x140466ccc
// > SelectEventLayer::init @ 0x140466cf2
// > SelectEventLayer::init @ 0x140466d18
// > SelectEventLayer::init @ 0x140466d3e
// > SelectEventLayer::init @ 0x140466d64
// > SelectEventLayer::init @ 0x140466d8a
// > SelectEventLayer::init @ 0x140466db0
// > SelectEventLayer::init @ 0x140466dd6
// > SelectEventLayer::init @ 0x140466dfc
// > SelectEventLayer::init @ 0x140466e22
// > SelectEventLayer::init @ 0x140466e48
// > SelectEventLayer::init @ 0x140466e6e
// > SelectEventLayer::init @ 0x140466e94
// > SelectEventLayer::init @ 0x140466eba
// > SelectEventLayer::init @ 0x140466ee0
// > SelectEventLayer::init @ 0x140466f06
// > SelectEventLayer::init @ 0x140466f2c
// > SelectEventLayer::init @ 0x140466f52
// > SelectEventLayer::init @ 0x140466f78
// > SelectEventLayer::init @ 0x140466f9e
// > SelectEventLayer::init @ 0x140466fc4
// > SelectEventLayer::init @ 0x140466fea
// > SelectEventLayer::init @ 0x140467010
// > SelectEventLayer::init @ 0x140467036
// > SelectEventLayer::init @ 0x14046705c
// > SelectEventLayer::init @ 0x140467082
// > SelectEventLayer::init @ 0x1404670a8
// > SelectEventLayer::init @ 0x1404670ce
// > SelectEventLayer::init @ 0x1404670f4
// > SelectEventLayer::init @ 0x14046711a
// > SelectEventLayer::init @ 0x140467140
// > SelectEventLayer::init @ 0x140467166
// > SelectEventLayer::init @ 0x14046718c
// > SelectEventLayer::init @ 0x1404671b2
// > SelectEventLayer::init @ 0x1404671d8
// > SelectEventLayer::init @ 0x140467211
// > SelectEventLayer::init @ 0x14046722f
// > SelectEventLayer::init @ 0x14046724d
// > SelectEventLayer::init @ 0x14046726b
// > SelectEventLayer::init @ 0x140467289
// > SelectEventLayer::init @ 0x1404672a7
// > SelectEventLayer::init @ 0x1404672c5
// > SelectEventLayer::init @ 0x1404672e3
// > SelectEventLayer::init @ 0x140467301
// > SelectEventLayer::init @ 0x14046731f
// > SelectEventLayer::init @ 0x14046733d
// > SelectEventLayer::init @ 0x14046735b
// > SelectEventLayer::init @ 0x140467379
// > SelectEventLayer::init @ 0x140467397
// > SelectEventLayer::init @ 0x1404673b5
// > SelectEventLayer::init @ 0x1404673d3
// > SelectEventLayer::init @ 0x1404673f1
// > SelectEventLayer::init @ 0x14046740f
// > SelectEventLayer::init @ 0x14046742d
// > SelectEventLayer::init @ 0x14046744b
// > SelectEventLayer::init @ 0x140467469
// > SelectEventLayer::init @ 0x140467487
// > SelectEventLayer::init @ 0x1404674a5
// > SelectEventLayer::init @ 0x1404674c3
// > SelectEventLayer::init @ 0x1404674e1
// > ??> @ 0x1406db108
//
// 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 __fastcall SelectEventLayer::addToggle(__int64 a1, int a2, void **a3)
{
int v5; // ecx
__int64 v6; // rcx
float v7; // xmm0_4
int v8; // r15d
int v9; // eax
cocos2d::CCDirector *v10; // rax
double v11; // xmm0_8
int v12; // ebx
_QWORD *v13; // rax
size_t v14; // r8
__int64 *v15; // rcx
__int64 *v16; // rax
bool v17; // bl
__int64 v18; // rax
int v19; // r9d
const char *v20; // rax
struct cocos2d::CCLabelBMFont *v21; // rdi
float v22; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v23; // rbx
const cocos2d::CCPoint *v24; // rax
__int64 v25; // rdx
float v26; // xmm0_4
void **v27; // rax
void *v28; // rdx
struct cocos2d::CCSprite *v29; // rbx
CCMenuItemSpriteExtra *v30; // rdi
float v31; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v32; // rbx
struct cocos2d::CCPoint v33; // rax
int v34; // [rsp+50h] [rbp-59h] BYREF
__int128 *v35; // [rsp+58h] [rbp-51h] BYREF
cocos2d::CCPoint v36; // [rsp+60h] [rbp-49h] BYREF
cocos2d::CCPoint v37; // [rsp+68h] [rbp-41h] BYREF
struct cocos2d::CCPoint v38; // [rsp+70h] [rbp-39h] BYREF
__int128 v39; // [rsp+78h] [rbp-31h] BYREF
__int64 v40; // [rsp+88h] [rbp-21h]
__int64 v41; // [rsp+90h] [rbp-19h]
void **v42; // [rsp+98h] [rbp-11h]
_QWORD v43[4]; // [rsp+A0h] [rbp-9h] BYREF
v34 = a2;
v42 = a3;
v5 = *(_DWORD *)(a1 + 952);
*(_DWORD *)(a1 + 952) = v5 + 1;
v7 = floorf((float)(v5 / 12));
v8 = (int)fmaxf(0.0, v7);
v9 = *(_DWORD *)(a1 + 956);
if ( v9 <= v8 )
v9 = v8;
*(_DWORD *)(a1 + 956) = v9;
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v6);
cocos2d::CCDirector::getWinSize(v10);
v11 = cocos2d::CCPoint::CCPoint(v7, (float)(v38.x * 0.5) - 140.0);
cocos2d::CCPoint::CCPoint(*(float *)&v11, (float)(v38.x * 0.5) + 40.0);
v12 = (*(_DWORD *)(a1 + 952) - 1) % 12;
cocos2d::CCPoint::CCPoint(&v36);
v36.y = v36.y - (float)(34 * (v12 % 6));
v35 = &v39;
v13 = (_QWORD *)GJBaseGameLayer::gameEventToString((__int64)v43, v34);
if ( v13[3] > 0xFu )
v13 = (_QWORD *)*v13;
v39 = 0;
v40 = 0;
v41 = 0;
v14 = -1;
do
++v14;
while ( *((_BYTE *)v13 + v14) );
sub_14003A930(&v39, v13, v14);
v15 = *(__int64 **)(a1 + 976);
v16 = (__int64 *)v15[1];
while ( !*((_BYTE *)v16 + 25) )
{
if ( *((_DWORD *)v16 + 7) >= v34 )
{
v15 = v16;
v16 = (__int64 *)*v16;
}
else
{
v16 = (__int64 *)v16[2];
}
}
v17 = !*((_BYTE *)v15 + 25) && v34 >= *((_DWORD *)v15 + 7);
cocos2d::CCPoint::CCPoint(&v37);
SetupTriggerPopup::createCustomToggleValueControl(a1, v34, v17, v19, (__int64)&v39, v18, 0, v8, 0);
sub_14003A830((__int64)v43);
v20 = (const char *)GameToolbox::intToString(v43, v34);
if ( *((_QWORD *)v20 + 3) > 0xFu )
v20 = *(const char **)v20;
v21 = cocos2d::CCLabelBMFont::create(v20, "chatFont.fnt");
sub_14003A830((__int64)v43);
v22 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *))v21->setScale_0)(v21);
v23 = v21->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v22, 0.5);
v23->setAnchorPoint(v21, v24);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *, __int64))(**(_QWORD **)(a1 + 576) + 440LL))(
*(_QWORD *)(a1 + 576),
v21,
10);
v21->setColor(&v21->cocos2d::CCRGBAProtocol, &stru_140529C5C);
LOBYTE(v25) = -106;
v26 = ((float (__fastcall *)(cocos2d::CCRGBAProtocol *, __int64))v21->setOpacity)(&v21->cocos2d::CCRGBAProtocol, v25);
cocos2d::CCPoint::CCPoint(v26, 0.0);
cocos2d::CCPoint::operator+(&v36, &v35);
v21->setPosition_0(v21, (const cocos2d::CCPoint *)&v35);
SetupTriggerPopup::addObjectToPage((SetupTriggerPopup *)a1, v21, v8);
if ( a3[2] )
{
v27 = (void **)sub_1401D0660((__int64 *)(a1 + 960), &v34);
if ( v27 != a3 )
{
v28 = a3;
if ( (unsigned __int64)a3[3] > 0xF )
v28 = *a3;
sub_14003CCE0(v27, v28, (size_t)a3[2]);
}
v29 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v29->setScale_0)(v29);
v30 = CCMenuItemSpriteExtra::create(
v29,
nullptr,
(cocos2d::CCObject *)a1,
(cocos2d::SEL_MenuHandler *)SelectEventLayer::onInfo);
HIDWORD(v30->m_pfnSelector.adj) = 0x40000000;
v30->setTag(v30, v34);
v31 = (*(float (__fastcall **)(_QWORD, CCMenuItemSpriteExtra *))(**(_QWORD **)(a1 + 544) + 448LL))(
*(_QWORD *)(a1 + 544),
v30);
cocos2d::CCPoint::CCPoint(v31, -26.0);
cocos2d::CCPoint::operator+(&v36, &v35);
v32 = v30->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v33 = cocos2d::CCNode::convertToNodeSpace(*(cocos2d::CCNode **)(a1 + 544), &v38);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v32->setPosition_0)(v30, v33);
SetupTriggerPopup::addObjectToPage((SetupTriggerPopup *)a1, v30, v8);
}
sub_14003A830((__int64)a3);
}