//
// BrowseSmartKeyLayer::init from 0x1405f0f90 to 0x1405f198f (2559 bytes)
//
// 2 xrefs:
// > BrowseSmartTemplateLayer::onTemplateObject @ 0x1405f0d81
// > ??> @ 0x14092f288
//
// 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=9
char __fastcall BrowseSmartKeyLayer::init(__int64 a1, cocos2d::CCObject *a2, void **a3)
{
void **v3; // r12
void *v7; // rdx
__int64 v8; // rcx
__int64 v9; // rax
char *v10; // rsi
__int64 v11; // rdi
__int64 v12; // rbx
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rbx
__int64 v16; // rax
__int64 v17; // rbx
cocos2d::CCArray *v18; // rsi
__int64 v19; // rax
unsigned int v20; // eax
signed int v21; // r13d
int v22; // r12d
__int64 v23; // rax
void **v24; // rbx
unsigned int v25; // edi
struct cocos2d::CCObject *v26; // rdi
__int128 *v27; // rax
__int64 v28; // rsi
_QWORD *v29; // rax
__int64 v30; // r9
unsigned int v31; // eax
__int128 *v32; // rax
struct cocos2d::CCObject *v33; // rsi
unsigned int v34; // edi
signed int v35; // ebx
float v36; // xmm0_4
__int64 v37; // rax
cocos2d::CCObject *v38; // rbx
cocos2d::CCObject *v39; // r13
cocos2d::CCObject *v40; // rbx
cocos2d::CCObject *v41; // r15
cocos2d::CCObject *v42; // rbx
cocos2d::CCObject *v43; // rsi
cocos2d::CCObject *v44; // rbx
cocos2d::CCObject *v45; // rdi
__int64 v46; // rbx
__int64 v47; // rax
__int64 v48; // rax
__int64 v49; // rax
__int64 v50; // rax
__int64 v51; // rax
void **v52; // [rsp+58h] [rbp-B0h] BYREF
void *v53; // [rsp+60h] [rbp-A8h] BYREF
_QWORD *v54; // [rsp+68h] [rbp-A0h]
cocos2d::CCArray *v55; // [rsp+70h] [rbp-98h] BYREF
float v56; // [rsp+78h] [rbp-90h] BYREF
float v57; // [rsp+7Ch] [rbp-8Ch]
char v58[8]; // [rsp+80h] [rbp-88h] BYREF
signed int v59; // [rsp+88h] [rbp-80h]
char v60[8]; // [rsp+90h] [rbp-78h] BYREF
__int128 v61; // [rsp+98h] [rbp-70h] BYREF
__int64 v62; // [rsp+A8h] [rbp-60h]
__int64 v63; // [rsp+B0h] [rbp-58h]
__int128 v64; // [rsp+B8h] [rbp-50h] BYREF
__int64 v65; // [rsp+C8h] [rbp-40h]
__int64 v66; // [rsp+D0h] [rbp-38h]
char v67[8]; // [rsp+D8h] [rbp-30h] BYREF
_BYTE *v68; // [rsp+E0h] [rbp-28h]
_BYTE *v69; // [rsp+E8h] [rbp-20h]
void *v70; // [rsp+F0h] [rbp-18h]
_BYTE v71[32]; // [rsp+F8h] [rbp-10h] BYREF
_BYTE v72[32]; // [rsp+118h] [rbp+10h] BYREF
void **v73; // [rsp+138h] [rbp+30h]
v3 = a3;
v52 = a3;
v73 = a3;
if ( FLAlertLayer::init_1(a1, 150) )
{
if ( (void **)(a1 + 712) != v3 )
{
v7 = v3;
if ( (unsigned __int64)v3[3] > 0xF )
v7 = *v3;
sub_1400405A0((void **)(a1 + 712), v7, (size_t)v3[2]);
}
BrowseSmartTemplateLayer::baseSetup(a1);
v9 = cocos2d::CCDirector::sharedDirector(v8);
cocos2d::CCDirector::getWinSize(v9, &v56);
if ( a2 )
{
*(_QWORD *)(a1 + 664) = a2;
cocos2d::CCObject::retain(a2);
}
v55 = (cocos2d::CCArray *)&v61;
v61 = 0;
v62 = 0;
v63 = 0;
*(_QWORD *)&v61 = sub_14003D460(0xA0u);
v62 = 151;
v63 = 159;
strcpy(
(char *)v61,
"Use Add to give chance to the selected variation(s).\n"
"Click Zero to reset the chance.\n"
"Use Create to create a specific variation.");
v64 = 0;
v65 = 4;
v66 = 15;
strcpy((char *)&v64, "Help");
v10 = InfoAlertButton::create((__int64)&v64, (__int64)&v61);
(*(void (__fastcall **)(_QWORD, char *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v10);
v11 = *(_QWORD *)v10;
v12 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v55,
(float)((float)(v56 * 0.5) + 225.0) - 18.0,
(float)((float)(v57 * 0.5) + 140.0) - 18.0);
cocos2d::CCNode::convertToNodeSpace(v12, v60, v13);
(*(void (__fastcall **)(char *, __int64))(v11 + 184))(v10, v14);
if ( *(_QWORD *)(a1 + 664) )
{
v15 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v55, v56 * 0.5, (float)((float)(v57 * 0.5) + 140.0) - 50.0);
cocos2d::CCNode::convertToNodeSpace(v15, v67, v16);
v17 = sub_14003F4F0((__int64)&v64, a1 + 712);
v55 = (cocos2d::CCArray *)v17;
v18 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(*(_QWORD *)(a1 + 664) + 56LL), v17);
v55 = v18;
sub_14003D310(v17);
v19 = sub_14003F4F0((__int64)&v61, a1 + 712);
LODWORD(v54) = GJSmartTemplate::getTotalChanceForPrefab(*(_QWORD *)(a1 + 664), v19);
v20 = 0;
if ( v18 )
v20 = cocos2d::CCArray::count(v18);
v21 = 0;
v59 = v20 + 1;
if ( (int)(v20 + 1) > 0 )
{
v22 = (int)v54;
do
{
v23 = sub_14003F4F0((__int64)&v61, a1 + 712);
v24 = GJSmartBlockPreview::create(v23);
v25 = 0;
if ( v21 )
{
v26 = cocos2d::CCArray::objectAtIndex(v18, v21 - 1);
v27 = (__int128 *)sub_14003F4F0((__int64)v71, a1 + 712);
GJSmartBlockPreview::addTemplateGuide((__int64)v24, v27, 1);
v69 = v71;
v68 = v72;
v28 = sub_14003F4F0((__int64)v71, (__int64)v26 + 88);
v29 = (_QWORD *)sub_14003F4F0((__int64)v72, a1 + 712);
v54 = v29;
v30 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v70 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v70);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v30 = qword_14090BFD0;
v29 = v54;
}
GJSmartBlockPreview::addPreview((__int64)v24, v29, v28, *(_QWORD *)(v30 + 568));
v31 = *((_DWORD *)v26 + 30);
LODWORD(v54) = v31;
if ( v22 <= 0 )
{
v25 = v31;
}
else
{
GJSmartBlockPreview::addChance((cocos2d::CCLabelBMFont **)v24, *((_DWORD *)v26 + 31), v22);
v25 = (unsigned int)v54;
}
}
else
{
v32 = (__int128 *)sub_14003F4F0((__int64)v72, a1 + 712);
GJSmartBlockPreview::addTemplateGuide((__int64)v24, v32, 2);
}
(*((void (__fastcall **)(void **))*v24 + 20))(v24);
v33 = CCMenuItemSpriteExtra::create((int)v24, 0, a1, (__int64)BrowseSmartKeyLayer::onPrefabObject);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v33);
(*((void (__fastcall **)(void **, _QWORD))*v24 + 8))(v24, v25);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v33 + 64LL))(v33, v25);
v34 = (int)floorf((float)(v21 / 0x1Cu));
v35 = v21 - 28 * v34;
v36 = floorf((float)(v35 / 7)) * -60.0;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v53,
(float)((float)((float)(v35 % 7) * 60.0) - 210.0) + 30.0,
v36);
cocos2d::CCPoint::operator+(v67, v60, v37);
(*(void (__fastcall **)(struct cocos2d::CCObject *, char *))(*(_QWORD *)v33 + 184LL))(v33, v60);
BrowseSmartTemplateLayer::addObjectToPage(a1, v33, v34);
++v21;
v18 = v55;
}
while ( v21 < v59 );
v3 = v52;
}
BrowseSmartTemplateLayer::goToPage(a1, 0);
v53 = operator new(0x2C8u);
v38 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v53);
if ( v38 )
{
if ( ButtonSprite::init_1(
(__int64)v38,
(__int64)&dword_14072428C,
25,
0,
1056964608,
1,
"goldFont.fnt",
(__int64)"GJ_button_01.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v38);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v38 + 8LL))(v38, 1);
LODWORD(v38) = 0;
}
}
v39 = CCMenuItemSpriteExtra::create((int)v38, 0, a1, (__int64)BrowseSmartKeyLayer::onButton);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v39 + 64LL))(v39, 1);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v39);
v53 = operator new(0x2C8u);
v40 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v53);
if ( v40 )
{
if ( ButtonSprite::init_1(
(__int64)v40,
(__int64)"Delete",
25,
0,
1056964608,
1,
"goldFont.fnt",
(__int64)"GJ_button_05.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v40);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v40 + 8LL))(v40, 1);
LODWORD(v40) = 0;
}
}
v41 = CCMenuItemSpriteExtra::create((int)v40, 0, a1, (__int64)BrowseSmartKeyLayer::onButton);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v41 + 64LL))(v41, 2);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v41);
v53 = operator new(0x2C8u);
v42 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v53);
if ( v42 )
{
if ( ButtonSprite::init_1(
(__int64)v42,
(__int64)"Zero",
25,
0,
1056964608,
1,
"goldFont.fnt",
(__int64)"GJ_button_02.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v42);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v42 + 8LL))(v42, 1);
LODWORD(v42) = 0;
}
}
v43 = CCMenuItemSpriteExtra::create((int)v42, 0, a1, (__int64)BrowseSmartKeyLayer::onButton);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v43 + 64LL))(v43, 3);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v43);
v53 = operator new(0x2C8u);
v44 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v53);
if ( v44 )
{
if ( ButtonSprite::init_1(
(__int64)v44,
(__int64)"Add",
25,
0,
1056964608,
1,
"goldFont.fnt",
(__int64)"GJ_button_02.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v44);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v44 + 8LL))(v44, 1);
LODWORD(v44) = 0;
}
}
v45 = CCMenuItemSpriteExtra::create((int)v44, 0, a1, (__int64)BrowseSmartKeyLayer::onButton);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v45 + 64LL))(v45, 4);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v45);
v46 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v53, v56 * 0.5, (float)((float)(v57 * 0.5) - 140.0) + 24.0);
cocos2d::CCNode::convertToNodeSpace(v46, v58, v47);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v53, -100.0, 0.0);
cocos2d::CCPoint::operator+(v58, &v52, v48);
(*(void (__fastcall **)(cocos2d::CCObject *, void ***))(*(_QWORD *)v39 + 184LL))(v39, &v52);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v53, -50.0, 0.0);
cocos2d::CCPoint::operator+(v58, &v52, v49);
(*(void (__fastcall **)(cocos2d::CCObject *, void ***))(*(_QWORD *)v41 + 184LL))(v41, &v52);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v53, 50.0, 0.0);
cocos2d::CCPoint::operator+(v58, &v52, v50);
(*(void (__fastcall **)(cocos2d::CCObject *, void ***))(*(_QWORD *)v43 + 184LL))(v43, &v52);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v53, 100.0, 0.0);
cocos2d::CCPoint::operator+(v58, &v52, v51);
(*(void (__fastcall **)(cocos2d::CCObject *, void ***))(*(_QWORD *)v45 + 184LL))(v45, &v52);
}
sub_14003D310((__int64)v3);
return 1;
}
else
{
sub_14003D310((__int64)v3);
return 0;
}
}