//
// BrowseSmartTemplateLayer::addPrefabMenuItem from 0x673b2c to 0x673d56 (554 bytes)
//
// 2 xrefs:
// > BrowseSmartTemplateLayer::init @ 0x6755d4
// > BrowseSmartTemplateLayer::init @ 0x67563e
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:55:54 +0000
//
int __fastcall BrowseSmartTemplateLayer::addPrefabMenuItem(cocos2d::CCDirector *a1, int *a2, int a3)
{
int v6; // r9
const cocos2d::CCPoint *v7; // r8
unsigned __int8 *v8; // r5
float v9; // r2
int v10; // r8
int *v11; // r0
int v12; // r0
const char *v13; // r2
const char *v14; // r1
cocos2d::CCObject *v15; // r4
unsigned int v16; // r7
int v17; // r10
void (__fastcall *v18)(cocos2d::CCObject *, _BYTE *); // r9
float v19; // s16
int RandomPrefab; // [sp+8h] [bp-14h]
float v22[2]; // [sp+14h] [bp-8h] BYREF
_BYTE v23[8]; // [sp+1Ch] [bp+0h] BYREF
_BYTE v24[8]; // [sp+24h] [bp+8h] BYREF
_BYTE v25[8]; // [sp+2Ch] [bp+10h] BYREF
_DWORD v26[2]; // [sp+34h] [bp+18h] BYREF
int v27[3]; // [sp+3Ch] [bp+20h] BYREF
int v28[11]; // [sp+48h] [bp+2Ch] BYREF
v6 = (int)(a2 + 1);
cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v22);
v7 = *((const cocos2d::CCPoint **)a1 + 111);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v26, v22[0] * 0.5, (float)((float)(v22[1] * 0.5) + 140.0) - 50.0);
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v23, v7);
std::string::basic_string(v28, v6);
v8 = (unsigned __int8 *)GJSmartBlockPreview::create((int)v28);
std::string::~string((int)v28);
SmartPrefabResult::SmartPrefabResult((SmartPrefabResult *)v28, (const SmartPrefabResult *)a2);
if ( a2[7] > 0 )
v9 = 0.5;
else
v9 = 1.0;
GJSmartBlockPreview::addTemplateGuide(v8, (int)v28, v9);
SmartPrefabResult::~SmartPrefabResult((SmartPrefabResult *)v28);
if ( a2[7] > 0 )
{
v10 = *((_DWORD *)a1 + 130);
std::string::basic_string(v28, v6);
RandomPrefab = GJSmartTemplate::getRandomPrefab(v10, (int)v28);
std::string::~string((int)v28);
if ( RandomPrefab )
{
std::string::basic_string(v27, v6);
v11 = std::string::basic_string(v28, RandomPrefab + 64);
v12 = GameManager::sharedState((GameManager *)v11);
GJSmartBlockPreview::addPreview(
(cocos2d::CCArray *)v8,
(unsigned __int8 *)v27,
(unsigned __int8 *)v28,
*(LevelEditorLayer **)(v12 + 408));
std::string::~string((int)v28);
std::string::~string((int)v27);
v14 = (const char *)a2[7];
if ( (int)v14 > 1 )
GJSmartBlockPreview::addCount((GJSmartBlockPreview *)v8, v14, v13);
}
}
(*(void (__fastcall **)(unsigned __int8 *, int))(*(_DWORD *)v8 + 80))(v8, 1056964608);
v26[0] = BrowseSmartTemplateLayer::onTemplateObject;
v26[1] = 0;
v15 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::create(
(int)v8,
0,
(int)a1,
(int)BrowseSmartTemplateLayer::onTemplateObject,
0);
(*(void (__fastcall **)(_DWORD, cocos2d::CCObject *))(**((_DWORD **)a1 + 111) + 228))(*((_DWORD *)a1 + 111), v15);
v16 = (int)floorf((float)(a3 / 28));
v17 = a3 - 28 * v16;
v18 = *(void (__fastcall **)(cocos2d::CCObject *, _BYTE *))(*(_DWORD *)v15 + 92);
v19 = floorf((float)(v17 / 7));
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v24,
(float)((float)((float)(v17 % 7) * 60.0) - 210.0) + 30.0,
v19 * -60.0);
cocos2d::CCPoint::operator+(v25, v23, v24);
v18(v15, v25);
return BrowseSmartTemplateLayer::addObjectToPage((cocos2d::CCArray **)a1, v15, v16);
}