//
// SetupSmartTemplateLayer::init from 0x1405ee530 to 0x1405eef87 (2647 bytes)
//
// 2 xrefs:
// > SetupSmartTemplateLayer::create @ 0x1405ee4e6
// > ??> @ 0x14092f12c
//
// 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=7
bool __fastcall SetupSmartTemplateLayer::init(__int64 a1, cocos2d::CCObject *a2)
{
bool result; // al
__int64 v5; // rcx
__int64 v6; // rax
__int64 v7; // rax
__int64 *v8; // rdi
__int64 v9; // rbx
__int64 v10; // rax
__int64 v11; // rbx
__int64 v12; // rax
__int64 v13; // rcx
__int64 v14; // rax
struct cocos2d::CCSprite *v15; // rax
cocos2d::CCObject *v16; // rsi
__int64 v17; // rdi
__int64 v18; // rbx
__int64 v19; // rax
__int64 v20; // rax
char *v21; // rsi
__int64 v22; // rdi
__int64 v23; // rbx
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rdx
void **v27; // rax
int v28; // esi
__int128 v29; // xmm8
__m128i v30; // xmm6
void *v31; // rcx
__int64 v32; // rax
_QWORD *v33; // rdi
__int64 v34; // rdx
size_t v35; // r15
__int64 v36; // rdx
__int64 v37; // rcx
char *v38; // rax
void **v39; // rdx
__int64 v40; // rcx
__int64 v41; // rcx
__int64 v42; // rcx
__int16 *v43; // rax
struct cocos2d::CCLabelBMFont *v44; // rax
cocos2d::CCLabelBMFont *v45; // rbx
__int64 v46; // rax
__int64 v47; // rax
cocos2d::CCObject *v48; // rbx
cocos2d::CCObject *v49; // rsi
__int64 v50; // rdi
__int64 v51; // rbx
__int64 v52; // rax
__int64 v53; // rax
__int64 v54; // rax
cocos2d::CCObject *v55; // rbx
cocos2d::CCObject *v56; // rsi
__int64 v57; // rdi
__int64 v58; // rbx
__int64 v59; // rax
__int64 v60; // rax
void *v61; // rcx
__int16 v62; // [rsp+58h] [rbp-B0h] BYREF
char v63; // [rsp+5Ah] [rbp-AEh]
_DWORD v64[3]; // [rsp+5Ch] [rbp-ACh] BYREF
float v65; // [rsp+68h] [rbp-A0h] BYREF
float v66; // [rsp+6Ch] [rbp-9Ch]
void *Block[3]; // [rsp+70h] [rbp-98h] BYREF
unsigned __int64 v68; // [rsp+88h] [rbp-80h]
_BYTE v69[8]; // [rsp+90h] [rbp-78h] BYREF
void *v70[2]; // [rsp+98h] [rbp-70h] BYREF
__m128i v71; // [rsp+A8h] [rbp-60h]
_BYTE v72[8]; // [rsp+B8h] [rbp-50h] BYREF
__int128 v73; // [rsp+C0h] [rbp-48h] BYREF
__int64 v74; // [rsp+D0h] [rbp-38h]
__int64 v75; // [rsp+D8h] [rbp-30h]
v64[0] = 0;
result = FLAlertLayer::init_1(a1, 150);
if ( !result )
return result;
if ( a2 )
{
*(_QWORD *)(a1 + 672) = a2;
cocos2d::CCObject::retain(a2);
}
*(_BYTE *)(a1 + 596) = 1;
v6 = cocos2d::CCDirector::sharedDirector(v5);
cocos2d::CCDirector::getWinSize(v6, &v65);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)Block, 0.0, 0.0, 80.0, 80.0);
v8 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v7);
v9 = *v8;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v64, 450.0, 280.0);
(*(void (__fastcall **)(__int64 *, __int64))(v9 + 312))(v8, v10);
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v8,
4294967294LL);
v11 = *v8;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v64, v65 * 0.5, v66 * 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v11 + 184))(v8, v12);
v14 = cocos2d::CCMenu::create(v13);
*(_QWORD *)(a1 + 552) = v14;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v14, 10);
v15 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
LODWORD(v11) = (_DWORD)v15;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v15 + 160LL))(v15);
v16 = CCMenuItemSpriteExtra::create(v11, 0, a1, (__int64)SetupSmartTemplateLayer::onBack);
*((_DWORD *)v16 + 93) = 1070386381;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v16);
v17 = *(_QWORD *)v16;
v18 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v64,
(float)((float)(v65 * 0.5) - 225.0) + 6.0,
(float)((float)(v66 * 0.5) + 140.0) - 6.0);
cocos2d::CCNode::convertToNodeSpace(v18, Block, v19);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v17 + 184))(v16, v20);
Block[0] = v70;
*(_OWORD *)v70 = 0;
v71 = 0u;
v70[0] = sub_14003D460(0x90u);
v71.m128i_i64[0] = 135;
v71.m128i_i64[1] = 143;
strcpy(
(char *)v70[0],
"Defined tells you how many variations you have in the template.\n"
"Click Browse to see your template's defined variations.");
v73 = 0;
v74 = 4;
v75 = 15;
strcpy((char *)&v73, "Help");
v21 = InfoAlertButton::create((__int64)&v73, (__int64)v70);
(*(void (__fastcall **)(_QWORD, char *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v21);
v22 = *(_QWORD *)v21;
v23 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)Block,
(float)((float)(v65 * 0.5) + 225.0) - 18.0,
(float)((float)(v66 * 0.5) + 140.0) - 18.0);
cocos2d::CCNode::convertToNodeSpace(v23, v64, v24);
(*(void (__fastcall **)(char *, __int64))(v22 + 184))(v21, v25);
v26 = *(_QWORD *)(a1 + 672);
if ( v26 )
{
sub_14003F4F0((__int64)&v73, v26 + 136);
v27 = (void **)&v73;
v28 = 9;
}
else
{
Block[1] = nullptr;
Block[2] = (void *)7;
v68 = 15;
Block[0] = (void *)0x64656D616E6E55LL;
v27 = Block;
v28 = 2;
}
v64[0] = v28;
v29 = *(_OWORD *)v27;
*(_OWORD *)v70 = *(_OWORD *)v27;
v30 = *((__m128i *)v27 + 1);
v71 = v30;
v27[2] = nullptr;
v27[3] = (void *)15;
*(_BYTE *)v27 = 0;
if ( (v28 & 2) != 0 )
{
v28 &= ~2u;
v64[0] = v28;
if ( v68 > 0xF )
{
v31 = Block[0];
if ( v68 + 1 >= 0x1000 )
{
v31 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v31 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v31);
}
}
if ( (v28 & 1) != 0 )
{
v28 &= ~1u;
v64[0] = v28;
sub_14003D310((__int64)&v73);
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v69, v65 * 0.5, (float)((float)(v66 * 0.5) + 140.0) - 40.0);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)Block, 0.0, 0.0, 80.0, 80.0);
v33 = (_QWORD *)cocos2d::extension::CCScale9Sprite::create("square02b_001.png", v32);
LOBYTE(v34) = 75;
(*(void (__fastcall **)(_QWORD *, __int64))(v33[40] + 40LL))(v33 + 40, v34);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v72, 600.0, 80.0);
(*(void (__fastcall **)(_QWORD *, _BYTE *))(*v33 + 312LL))(v33, v72);
v35 = -1;
(*(void (__fastcall **)(_QWORD, _QWORD *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v33,
0xFFFFFFFFLL);
(*(void (__fastcall **)(_QWORD *, _BYTE *))(*v33 + 184LL))(v33, v69);
v62 = 0;
v63 = 0;
(*(void (__fastcall **)(_QWORD *, __int16 *))v33[40])(v33 + 40, &v62);
(*(void (__fastcall **)(_QWORD *))(*v33 + 160LL))(v33);
v38 = CCTextInputNode::create(v37, v36, (__int64)"Template Name");
*(_QWORD *)(a1 + 680) = v38;
(*(void (__fastcall **)(_QWORD, char *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v38, 18);
*(_QWORD *)(*(_QWORD *)(a1 + 680) + 600LL) = a1 + 544;
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 680) + 64LL))(*(_QWORD *)(a1 + 680), 0);
(*(void (__fastcall **)(_QWORD, _BYTE *))(**(_QWORD **)(a1 + 680) + 184LL))(*(_QWORD *)(a1 + 680), v69);
*(_DWORD *)(*(_QWORD *)(a1 + 680) + 608LL) = 20;
*(_BYTE *)(*(_QWORD *)(a1 + 680) + 624LL) = 1;
v39 = v70;
if ( _mm_srli_si128(v30, 8).m128i_u64[0] > 0xF )
v39 = (void **)v29;
v73 = 0;
v74 = 0;
v75 = 0;
do
++v35;
while ( *((_BYTE *)v39 + v35) );
sub_14003D230(&v73, v39, v35);
CCTextInputNode::setString(*(_QWORD **)(a1 + 680), &v73);
v62 = -21896;
v40 = *(_QWORD *)(a1 + 680);
*(_WORD *)(v40 + 572) = -21896;
*(_BYTE *)(v40 + 574) = -16;
CCTextInputNode::refreshLabel(v40);
v41 = *(_QWORD *)(a1 + 680);
*(_DWORD *)(v41 + 568) = 1060320051;
CCTextInputNode::refreshLabel(v41);
v42 = *(_QWORD *)(a1 + 672);
if ( !v42 )
{
v43 = &word_14070E1CC;
goto LABEL_23;
}
v43 = (__int16 *)GJSmartTemplate::logTemplateStatus(v42, &v73);
v28 |= 4u;
v64[0] = v28;
if ( *((_QWORD *)v43 + 3) <= 0xFu )
{
LABEL_23:
v44 = cocos2d::CCLabelBMFont::create((const char *)v43, "chatFont.fnt");
goto LABEL_24;
}
v44 = cocos2d::CCLabelBMFont::create(*(const char **)v43, "chatFont.fnt");
LABEL_24:
v45 = v44;
if ( (v28 & 4) != 0 )
sub_14003D310((__int64)&v73);
(*(void (__fastcall **)(_QWORD, cocos2d::CCLabelBMFont *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v45,
18);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)Block, 0.0, -40.0);
cocos2d::CCPoint::operator+(v69, v64, v46);
(*(void (__fastcall **)(cocos2d::CCLabelBMFont *, _DWORD *))(*(_QWORD *)v45 + 184LL))(v45, v64);
cocos2d::CCLabelBMFont::limitLabelWidth(v45, 300.0, 0.60000002, 0.0);
Block[0] = operator new(0x2C8u);
v47 = ButtonSprite::ButtonSprite((__int64)Block[0]);
v48 = (cocos2d::CCObject *)v47;
if ( v47 )
{
if ( ButtonSprite::init_1(
v47,
(__int64)"Browse",
40,
0,
1061997773,
1,
"goldFont.fnt",
(__int64)"GJ_button_01.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v48);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v48 + 8LL))(v48, 1);
LODWORD(v48) = 0;
}
}
v49 = CCMenuItemSpriteExtra::create((int)v48, 0, a1, (__int64)SetupSmartTemplateLayer::onClick);
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v49 + 64LL))(v49, 0);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v49);
v50 = *(_QWORD *)v49;
v51 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)Block, v65 * 0.5, v66 * 0.5);
cocos2d::CCNode::convertToNodeSpace(v51, v64, v52);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v50 + 184))(v49, v53);
Block[0] = operator new(0x2C8u);
v54 = ButtonSprite::ButtonSprite((__int64)Block[0]);
v55 = (cocos2d::CCObject *)v54;
if ( v54 )
{
if ( ButtonSprite::init_1(
v54,
(__int64)"Delete",
40,
0,
1061997773,
1,
"goldFont.fnt",
(__int64)"GJ_button_01.png",
1106247680) )
{
cocos2d::CCObject::autorelease(v55);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v55 + 8LL))(v55, 1);
LODWORD(v55) = 0;
}
}
v56 = CCMenuItemSpriteExtra::create((int)v55, 0, a1, (__int64)SetupSmartTemplateLayer::onClick);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v56 + 64LL))(v56, 5);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v56);
v57 = *(_QWORD *)v56;
v58 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)Block, (float)(v65 * 0.5) + 100.0, v66 * 0.5);
cocos2d::CCNode::convertToNodeSpace(v58, v64, v59);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v57 + 184))(v56, v60);
if ( v71.m128i_i64[1] > 0xFuLL )
{
v61 = v70[0];
if ( (unsigned __int64)(v71.m128i_i64[1] + 1) >= 0x1000 )
{
v61 = *((void **)v70[0] - 1);
if ( (unsigned __int64)((char *)v70[0] - (char *)v61 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v61);
}
return 1;
}