//
// BrowseSmartTemplateLayer::addPrefabMenuItem from 0x1405eff20 to 0x1405f0310 (1008 bytes)
//
// 3 xrefs:
// > BrowseSmartTemplateLayer::init @ 0x1405efca3
// > BrowseSmartTemplateLayer::init @ 0x1405efdfc
// > ??> @ 0x14092f1a4
//
// 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:35:05 +0000
//
// Hidden C++ exception states: #wind=5
void __fastcall BrowseSmartTemplateLayer::addPrefabMenuItem(__int64 a1, int *a2, int a3)
{
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // r14
__int64 v8; // rax
void **v9; // rsi
float v10; // xmm6_4
__int64 v11; // r12
__int64 v12; // rax
struct cocos2d::CCObject *RandomPrefab; // rax
__int64 v14; // rdi
_QWORD *v15; // r15
__int64 v16; // r9
int v17; // r15d
struct cocos2d::CCLabelBMFont *v18; // rax
__int64 v19; // rdi
void *v20; // rbx
__int64 v21; // rax
void (__fastcall **v22)(__int64, const char *); // rdi
void *v23; // rbx
cocos2d::CCString *v24; // rax
const char *CString; // rax
cocos2d::CCObject *v26; // rdi
int v27; // esi
unsigned int v28; // ebx
int v29; // esi
float v30; // xmm0_4
__int64 v31; // rax
__int64 *v32; // [rsp+20h] [rbp-E0h] BYREF
int v33; // [rsp+28h] [rbp-D8h] BYREF
float v34[2]; // [rsp+30h] [rbp-D0h] BYREF
void *v35; // [rsp+38h] [rbp-C8h] BYREF
_BYTE v36[8]; // [rsp+40h] [rbp-C0h] BYREF
_BYTE *v37; // [rsp+48h] [rbp-B8h]
__int64 v38; // [rsp+50h] [rbp-B0h] BYREF
_BYTE v39[32]; // [rsp+58h] [rbp-A8h] BYREF
_BYTE v40[32]; // [rsp+78h] [rbp-88h] BYREF
int v41; // [rsp+98h] [rbp-68h]
char v42; // [rsp+9Ch] [rbp-64h]
int v43; // [rsp+A0h] [rbp-60h]
char v44; // [rsp+A4h] [rbp-5Ch]
char v45; // [rsp+A5h] [rbp-5Bh]
char v46; // [rsp+A6h] [rbp-5Ah]
_BYTE v47[32]; // [rsp+A8h] [rbp-58h] BYREF
_BYTE v48[32]; // [rsp+C8h] [rbp-38h] BYREF
_BYTE v49[32]; // [rsp+E8h] [rbp-18h] BYREF
_BYTE v50[32]; // [rsp+108h] [rbp+8h] BYREF
__int64 *v51; // [rsp+128h] [rbp+28h]
v33 = a3;
v51 = (__int64 *)a2;
v5 = cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v5, v34);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v32, v34[0] * 0.5, (float)((float)(v34[1] * 0.5) + 140.0) - 50.0);
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), v36, v6);
v7 = (__int64)(a2 + 2);
v8 = sub_14003F4F0((__int64)v47, (__int64)(a2 + 2));
v9 = GJSmartBlockPreview::create(v8);
if ( a2[18] <= 0 )
v10 = 1.0;
else
v10 = 0.5;
v32 = &v38;
v38 = *(_QWORD *)a2;
sub_14003F4F0((__int64)v39, (__int64)(a2 + 2));
v11 = (__int64)(a2 + 10);
sub_14003F4F0((__int64)v40, (__int64)(a2 + 10));
v41 = a2[18];
v42 = *((_BYTE *)a2 + 76);
v43 = a2[20];
v44 = *((_BYTE *)a2 + 84);
v45 = *((_BYTE *)a2 + 85);
v46 = *((_BYTE *)a2 + 86);
GJSmartBlockPreview::addTemplateGuide_1(v9, (__int64)&v38, v10);
if ( a2[18] > 0 )
{
v12 = sub_14003F4F0((__int64)v48, (__int64)(a2 + 2));
RandomPrefab = GJSmartTemplate::getRandomPrefab(*(_QWORD *)(a1 + 664), v12);
if ( RandomPrefab )
{
v32 = (__int64 *)v49;
v37 = v50;
v14 = sub_14003F4F0((__int64)v49, (__int64)RandomPrefab + 88);
v15 = (_QWORD *)sub_14003F4F0((__int64)v50, (__int64)(a2 + 2));
v16 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v35 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v35);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v16 = qword_14090BFD0;
}
GJSmartBlockPreview::addPreview((__int64)v9, v15, v14, *(_QWORD *)(v16 + 568));
v17 = a2[18];
if ( v17 > 1 )
{
if ( !v9[44] )
{
v18 = cocos2d::CCLabelBMFont::create(" ", &qword_140704F78);
v9[44] = v18;
(*((void (__fastcall **)(void **, struct cocos2d::CCLabelBMFont *))*v9 + 58))(v9, v18);
}
v19 = *(_QWORD *)v9[44];
v20 = v9[44];
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v35, 90.0, 90.0);
(*(void (__fastcall **)(void *, __int64))(v19 + 184))(v20, v21);
v22 = *((void (__fastcall ***)(__int64, const char *))v9[44] + 45);
v23 = v9[44];
v24 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, (unsigned int)v17);
CString = cocos2d::CCString::getCString(v24);
(*v22)((__int64)v23 + 360, CString);
cocos2d::CCLabelBMFont::limitLabelWidth((cocos2d::CCLabelBMFont *)v9[44], 20.0, 0.60000002, 0.0);
}
}
}
(*((void (__fastcall **)(void **))*v9 + 20))(v9);
v26 = CCMenuItemSpriteExtra::create((int)v9, 0, a1, (__int64)BrowseSmartTemplateLayer::onTemplateObject);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v26);
v27 = v33;
v28 = (int)floorf((float)(v33 / 28));
v29 = v27 - 28 * v28;
v30 = floorf((float)(v29 / 7)) * -60.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v35, (float)((float)((float)(v29 % 7) * 60.0) - 210.0) + 30.0, v30);
cocos2d::CCPoint::operator+(v36, &v33, v31);
(*(void (__fastcall **)(cocos2d::CCObject *, int *))(*(_QWORD *)v26 + 184LL))(v26, &v33);
BrowseSmartTemplateLayer::addObjectToPage(a1, v26, v28);
sub_14003D310(v11);
sub_14003D310(v7);
}