//
// ControlSlotsPopup::init from 0x140456860 to 0x140456e52 (1522 bytes)
//
// 2 xrefs:
// > TouchControlEditLayer::onSlots @ 0x140456495
// > ??> @ 0x140927b3c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:32:29 +0000
//
// Hidden C++ exception states: #wind=5
char __fastcall ControlSlotsPopup::init(__int64 a1, __int64 a2, char a3, int a4)
{
char result; // al
__int64 v8; // rax
__int64 v9; // rcx
__int64 v10; // rax
float v11; // xmm9_4
float v12; // xmm12_4
int i; // r14d
cocos2d::CCString *v14; // rax
const char *CString; // rdi
cocos2d::CCObject *v16; // rbx
__int64 *v17; // rax
cocos2d::CCObject *v18; // rdi
float v19; // xmm7_4
__int64 v20; // rax
__int64 v21; // rbx
__int64 v22; // rax
cocos2d::CCString *v23; // rax
const char *v24; // rdi
cocos2d::CCObject *v25; // rbx
cocos2d::CCObject *v26; // rdi
__int64 v27; // rax
__int64 v28; // rbx
__int64 v29; // rax
__int64 *v30; // rbx
cocos2d::CCObject *v31; // r14
__int64 v32; // rdi
__int64 v33; // rbx
__int64 v34; // rax
__int64 v35; // rax
float v36[2]; // [rsp+50h] [rbp-B0h] BYREF
_BYTE v37[8]; // [rsp+58h] [rbp-A8h] BYREF
_WORD v38[8]; // [rsp+60h] [rbp-A0h] BYREF
__int64 v39; // [rsp+70h] [rbp-90h]
__int64 v40; // [rsp+78h] [rbp-88h]
_BYTE v41[8]; // [rsp+80h] [rbp-80h] BYREF
_BYTE v42[8]; // [rsp+88h] [rbp-78h] BYREF
void *v43; // [rsp+90h] [rbp-70h]
void *v44; // [rsp+98h] [rbp-68h]
_BYTE v45[8]; // [rsp+A0h] [rbp-60h] BYREF
_BYTE v46[8]; // [rsp+A8h] [rbp-58h] BYREF
void *v47; // [rsp+B0h] [rbp-50h]
void *v48; // [rsp+B8h] [rbp-48h]
_BYTE v49[160]; // [rsp+C0h] [rbp-40h] BYREF
void *v50; // [rsp+1A8h] [rbp+A8h] BYREF
result = SetupTriggerPopup::init(a1, 0, 0, a4, 1128792064, 7, 0);
if ( !result )
return result;
*(_BYTE *)(a1 + 744) = 1;
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1096LL))(a1);
qmemcpy(&v50, "PWi", 3);
v8 = (*(__int64 (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 584) + 472LL))(*(_QWORD *)(a1 + 584), 3);
if ( v8 )
(**(void (__fastcall ***)(__int64, void **))(v8 + 320))(v8 + 320, &v50);
*(_QWORD *)(a1 + 1000) = a2;
*(_BYTE *)(a1 + 1008) = a3;
v10 = cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::getWinSize(v10, v36);
v11 = v36[0] * 0.5;
v12 = v36[1] * 0.5;
v38[7] = 0;
v39 = 13;
v40 = 15;
strcpy((char *)v38, "Control Slots");
SetupTriggerPopup::addTitle(a1, v38);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v37, v11, v12 + 25.0);
for ( i = 1; i <= 3; ++i )
{
v14 = cocos2d::CCString::createWithFormat("Save %i", i);
CString = cocos2d::CCString::getCString(v14);
v43 = operator new(0x2C8u);
v16 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v43);
if ( v16 )
{
if ( ButtonSprite::init_1(
(__int64)v16,
(__int64)CString,
50,
0,
1060320051,
1,
"goldFont.fnt",
(__int64)"GJ_button_01.png",
1105199104) )
{
cocos2d::CCObject::autorelease(v16);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v16 + 8LL))(v16, 1);
v16 = nullptr;
}
}
v44 = operator new(0x208u);
v17 = (__int64 *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v44);
v18 = (cocos2d::CCObject *)v17;
if ( v17 )
{
if ( CCMenuItemSpriteExtra::init(v17, (__int64 *)v16, 0, a1, (__int64)ControlSlotsPopup::onSave) )
{
cocos2d::CCObject::autorelease(v18);
goto LABEL_14;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v18 + 8LL))(v18, 1);
}
v18 = nullptr;
LABEL_14:
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v18 + 64LL))(v18, (unsigned int)i);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v18);
v19 = (float)(i - 1) * -42.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v45, -45.0, v19);
cocos2d::CCPoint::operator+(v37, &v50, v20);
v21 = *(_QWORD *)v18;
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), v46, &v50);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v21 + 184))(v18, v22);
v23 = cocos2d::CCString::createWithFormat("Load %i", i);
v24 = cocos2d::CCString::getCString(v23);
v47 = operator new(0x2C8u);
v25 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v47);
if ( v25 )
{
if ( ButtonSprite::init_1(
(__int64)v25,
(__int64)v24,
50,
0,
1060320051,
1,
"goldFont.fnt",
(__int64)"GJ_button_02.png",
1105199104) )
{
cocos2d::CCObject::autorelease(v25);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v25 + 8LL))(v25, 1);
v25 = nullptr;
}
}
v48 = operator new(0x208u);
v26 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v48);
if ( v26 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v26, (__int64 *)v25, 0, a1, (__int64)ControlSlotsPopup::onLoad) )
{
cocos2d::CCObject::autorelease(v26);
goto LABEL_23;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v26 + 8LL))(v26, 1);
}
v26 = nullptr;
LABEL_23:
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v26 + 64LL))(v26, (unsigned int)i);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v26);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v49, 45.0, v19);
cocos2d::CCPoint::operator+(v37, v41, v27);
v28 = *(_QWORD *)v26;
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), v42, v41);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v28 + 184))(v26, v29);
}
v30 = (__int64 *)cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
(*(void (__fastcall **)(__int64 *))(*v30 + 160))(v30);
v50 = operator new(0x208u);
v31 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v50);
if ( v31 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v31, v30, 0, a1, (__int64)sub_14009D628) )
{
cocos2d::CCObject::autorelease(v31);
goto LABEL_29;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v31 + 8LL))(v31, 1);
}
v31 = nullptr;
LABEL_29:
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v31);
v32 = *(_QWORD *)v31;
v33 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v50,
v11 - (float)(*(float *)(a1 + 732) * 0.5),
(float)(*(float *)(a1 + 736) * 0.5) + v12);
cocos2d::CCNode::convertToNodeSpace(v33, v42, v34);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v32 + 184))(v31, v35);
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1136LL))(a1);
*(_BYTE *)(a1 + 744) = 0;
return 1;
}