//
// SetFolderPopup::init from 0x8d2e08 to 0x8d3140 (824 bytes)
//
// 2 xrefs:
// > SetFolderPopup::create @ 0x8d327c
// > ??> @ 0x3f150
//
// 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
//
__int64 __fastcall SetFolderPopup::init(__int64 a1, int a2, char a3)
{
unsigned int v6; // w26
void *v7; // x0
unsigned int v8; // w24
void *v9; // x0
cocos2d::CCDirector *v10; // x0
cocos2d::CCLabelBMFont *v11; // x0
cocos2d::CCLabelBMFont_vtbl *v12; // x1
__int64 v13; // x20
void (__fastcall *v14)(__int64, cocos2d::CCPoint *); // x25
cocos2d::CCSprite *v15; // x20
CCMenuItemSpriteExtra *v16; // x20
cocos2d::CCNode *v17; // x26
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x25
unsigned int *v20; // x1
int v21; // w2
unsigned int *v22; // x1
int v23; // w2
float v24; // [xsp+80h] [xbp+70h]
float v25; // [xsp+84h] [xbp+74h]
cocos2d::CCPoint v26; // [xsp+88h] [xbp+78h] BYREF
cocos2d::CCPoint v27; // [xsp+90h] [xbp+80h] BYREF
cocos2d::CCPoint v28; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v29; // 0:x2.16
sub_D18D28(&v26);
sub_D153B8((int)&v27, "OK");
v6 = (unsigned __int8)SetIDPopup::init(
(SetIDPopup *)a1,
a2,
0,
999,
60.0,
(__int64)&v26,
(ButtonSprite **)&v27,
1u,
0,
0,
0);
v7 = (void *)(*(_QWORD *)&v27 - 24LL);
v8 = v6;
if ( (__int64 *)(*(_QWORD *)&v27 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(*(_QWORD *)&v27 - 8LL);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(_DWORD *)(*(_QWORD *)&v27 - 8LL);
*(_DWORD *)(*(_QWORD *)&v27 - 8LL) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v7);
}
v9 = (void *)(*(_QWORD *)&v26 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v26 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(*(_QWORD *)&v26 - 8LL);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *(_DWORD *)(*(_QWORD *)&v26 - 8LL);
*(_DWORD *)(*(_QWORD *)&v26 - 8LL) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v9);
}
if ( v6 )
{
v10 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v10);
*(_BYTE *)(a1 + 688) = a3;
v11 = cocos2d::CCLabelBMFont::create();
v12 = v11->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
*(_QWORD *)(a1 + 696) = v11;
((void (__fastcall *)(float))v12->setScale)(0.4);
(*(void (__fastcall **)(_QWORD, _QWORD, __int64))(**(_QWORD **)(a1 + 576) + 448LL))(
*(_QWORD *)(a1 + 576),
*(_QWORD *)(a1 + 696),
1);
v13 = *(_QWORD *)(a1 + 696);
v14 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v13 + 184LL);
cocos2d::CCPoint::CCPoint(&v27, v24 * 0.5, (float)((float)(v25 * 0.5) + 35.0) + 60.0);
v14(v13, &v27);
v15 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_optionsBtn_001.png");
v15->setScale(v15, 0.5);
v29.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v29.adj = (size_t)SetFolderPopup::onSetFolderName;
v16 = CCMenuItemSpriteExtra::create(v15, nullptr, v29);
CCMenuItemSpriteExtra::setSizeMult(v16, 1.1);
(*(void (__fastcall **)(_QWORD, CCMenuItemSpriteExtra *))(**(_QWORD **)(a1 + 544) + 440LL))(
*(_QWORD *)(a1 + 544),
v16);
v17 = *(cocos2d::CCNode **)(a1 + 544);
setPosition = v16->setPosition;
cocos2d::CCPoint::CCPoint(&v26, (float)(v24 * 0.5) + 90.0, (float)((float)(v25 * 0.5) + 20.0) + 60.0);
v28 = cocos2d::CCNode::convertToNodeSpace(v17, &v26);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))setPosition)(
v16,
&v27,
v28.x,
v28.y);
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1312LL))(a1);
}
return v8;
}