//
// SetupSmartBlockLayer::init from 0x1004e06a0 to 0x1004e1359 (3257 bytes)
//
// 1 xrefs:
// > SetupSmartBlockLayer::create @ 0x1004e063a
//
// 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 12:31:18 +0000
//
__int64 __fastcall SetupSmartBlockLayer::init(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r14
__int64 v5; // rax
__int64 v6; // rax
void *v7; // r14
__int64 v8; // r14
char *v9; // rax
char *v10; // rax
char *v11; // rax
char *v12; // rax
char *v13; // rax
unsigned int v14; // r12d
char *v15; // rax
char *v16; // rax
unsigned int v17; // eax
__int64 v18; // rax
__int64 v19; // r14
__int64 v20; // r14
__int64 v21; // r15
unsigned __int8 v22; // r13
__int64 v23; // r14
__int64 v24; // r12
unsigned __int8 v25; // r13
__int64 v26; // r14
__int64 v27; // r12
unsigned __int8 v28; // r12
__int64 v29; // r14
__int64 v30; // r13
__int64 ToggleButton; // r14
unsigned __int8 v32; // r12
__int64 v33; // r14
__int64 v34; // r13
__int64 v35; // r14
unsigned __int8 v36; // r12
__int64 v37; // r14
__int64 v38; // r13
void *v39; // rax
unsigned __int8 v40; // r12
__int64 v41; // r14
__int64 v42; // r13
unsigned __int8 v43; // r12
__int64 v44; // r14
__int64 v45; // r13
unsigned int v47; // [rsp+38h] [rbp-158h]
unsigned int v48; // [rsp+40h] [rbp-150h]
unsigned int v49; // [rsp+48h] [rbp-148h]
char v50; // [rsp+50h] [rbp-140h] BYREF
char v51[15]; // [rsp+51h] [rbp-13Fh] BYREF
void *v52; // [rsp+60h] [rbp-130h]
_QWORD v53[2]; // [rsp+68h] [rbp-128h] BYREF
void *__p; // [rsp+78h] [rbp-118h]
_QWORD v55[2]; // [rsp+80h] [rbp-110h] BYREF
void *v56; // [rsp+90h] [rbp-100h] BYREF
char v57; // [rsp+98h] [rbp-F8h] BYREF
_BYTE v58[23]; // [rsp+99h] [rbp-F7h] BYREF
char v59; // [rsp+B0h] [rbp-E0h] BYREF
_BYTE v60[23]; // [rsp+B1h] [rbp-DFh] BYREF
char v61; // [rsp+C8h] [rbp-C8h] BYREF
_BYTE v62[23]; // [rsp+C9h] [rbp-C7h] BYREF
char v63; // [rsp+E0h] [rbp-B0h] BYREF
_BYTE v64[23]; // [rsp+E1h] [rbp-AFh] BYREF
char v65; // [rsp+F8h] [rbp-98h] BYREF
_BYTE v66[23]; // [rsp+F9h] [rbp-97h] BYREF
char v67; // [rsp+110h] [rbp-80h] BYREF
_BYTE v68[23]; // [rsp+111h] [rbp-7Fh] BYREF
unsigned __int64 v69[2]; // [rsp+128h] [rbp-68h] BYREF
float v70; // [rsp+138h] [rbp-58h] BYREF
void *v71; // [rsp+140h] [rbp-50h]
__int64 v72; // [rsp+14Ch] [rbp-44h] BYREF
unsigned __int64 v73; // [rsp+154h] [rbp-3Ch] BYREF
double v74; // [rsp+15Ch] [rbp-34h] BYREF
unsigned __int8 inited; // [rsp+167h] [rbp-29h]
v4 = a2;
inited = FLAlertLayer::init_1((_BYTE *)a1, 150);
if ( inited )
{
v5 = 688;
if ( a2 || (v5 = 696, (v4 = a3) != 0) )
{
*(_QWORD *)(a1 + v5) = v4;
cocos2d::CCObject::retain(v4);
}
SetupSmartBlockLayer::determineStartValues(a1);
*(_BYTE *)(a1 + 596) = 1;
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v72, v6);
sub_100278270((__int64)v69, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v7 = cocos2d::extension::CCScale9Sprite::create_2((__int64)"GJ_square01.png", v69);
sub_100278260((float *)v69, 300.0, 240.0);
(*(void (__fastcall **)(void *, unsigned __int64 *))(*(_QWORD *)v7 + 320LL))(v7, v69);
(*(void (__fastcall **)(_QWORD, void *, __int64))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v7,
4294967294LL);
sub_100278250((float *)v69, *(float *)&v72 * 0.5, *((float *)&v72 + 1) * 0.5);
(*(void (__fastcall **)(void *, unsigned __int64 *))(*(_QWORD *)v7 + 184LL))(v7, v69);
v8 = cocos2d::CCLabelBMFont::create_3("Create blocks", "goldFont.fnt");
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 456LL))(a1, v8);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v8 + 160LL))(v8, 0.69999999);
sub_100278250((float *)v69, *(float *)&v72 * 0.5, (float)((float)(*((float *)&v72 + 1) * 0.5) + 120.0) + -18.0);
(*(void (__fastcall **)(__int64, unsigned __int64 *))(*(_QWORD *)v8 + 184LL))(v8, v69);
v9 = ButtonSprite::create_1(
(__int64)"Back",
0x19u,
0,
1u,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_05.png",
0.5,
30.0);
v71 = CCMenuItemSpriteExtra::create((__int64)v9, 0, a1, (__int64)SetupSmartBlockLayer::onClose, 0);
v10 = ButtonSprite::create_1(
(__int64)"Create",
0x19u,
0,
1u,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_01.png",
0.5,
30.0);
v47 = (unsigned int)CCMenuItemSpriteExtra::create((__int64)v10, 0, a1, (__int64)SetupSmartBlockLayer::onCreate, 0);
v11 = ButtonSprite::create_1(
(__int64)"Template",
0x19u,
0,
1u,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_02.png",
0.5,
30.0);
v48 = (unsigned int)CCMenuItemSpriteExtra::create(
(__int64)v11,
0,
a1,
(__int64)SetupSmartBlockLayer::onCreateTemplate,
0);
v12 = ButtonSprite::create_1(
(__int64)"Special",
0x19u,
0,
1u,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_02.png",
0.5,
30.0);
v49 = (unsigned int)CCMenuItemSpriteExtra::create(
(__int64)v12,
0,
a1,
(__int64)SetupSmartBlockLayer::onSelectPremade,
0);
v13 = ButtonSprite::create_1(
(__int64)"Browser",
0x19u,
0,
1u,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_01.png",
0.5,
30.0);
v14 = (unsigned int)CCMenuItemSpriteExtra::create(
(__int64)v13,
0,
a1,
(__int64)SetupSmartBlockLayer::onSelectTemplate,
0);
v15 = ButtonSprite::create_1(
(__int64)"Paste\nTemplate",
0x19u,
0,
1u,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_01.png",
0.5,
30.0);
CCMenuItemSpriteExtra::create((__int64)v15, 0, a1, (__int64)SetupSmartBlockLayer::onPasteTemplate, 0);
v16 = ButtonSprite::create_1(
(__int64)"Create\nAll",
0x19u,
0,
1u,
(__int64)"goldFont.fnt",
(__int64)"GJ_button_01.png",
0.5,
30.0);
v17 = (unsigned int)CCMenuItemSpriteExtra::create(
(__int64)v16,
0,
a1,
(__int64)SetupSmartBlockLayer::onCreateAll,
0);
v18 = sub_1008735E0((_DWORD)v71, v47, v48, v49, v14, v17);
*(_QWORD *)(a1 + 552) = v18;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 464LL))(*(_QWORD *)(a1 + 584), v18, 10);
cocos2d::CCMenu::alignItemsHorizontally(*(_QWORD *)(a1 + 552));
v19 = *(_QWORD *)(a1 + 552);
sub_100278250((float *)v69, *(float *)&v72 * 0.5, (float)((float)(*((float *)&v72 + 1) * 0.5) + -120.0) + 24.0);
(*(void (__fastcall **)(__int64, unsigned __int64 *))(*(_QWORD *)v19 + 184LL))(v19, v69);
v50 = 8;
strcpy(v51, "Help");
__p = operator new(0x208u);
v53[0] = 521;
v53[1] = 517;
strcpy(
(char *)__p,
"Auto-builds structures with given templates.\n"
"Use Browser to start and select templates.\n"
"Click Template with a template made to save it.\n"
"Create structures with these blocks and click Create to paste the selected template.\n"
"Reference Only blocks are used as reference positions.\n"
"Allow Rotation, Flip X, and Flip Y allow rotating the design.\n"
"Dont Delete keeps these blocks when template is pasted.\n"
"The tool is in beta and will be enhanced in future updates.");
v20 = InfoAlertButton::create(&v50, v53, 1.0);
if ( (v53[0] & 1) != 0 )
operator delete(__p);
if ( (v50 & 1) != 0 )
operator delete(v52);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 552) + 456LL))(*(_QWORD *)(a1 + 552), v20);
v21 = *(_QWORD *)(a1 + 552);
sub_100278250(
(float *)&v74,
(float)((float)(*(float *)&v72 * 0.5) + -150.0) + 18.0,
(float)((float)(*((float *)&v72 + 1) * 0.5) + 120.0) + -18.0);
cocos2d::CCNode::convertToNodeSpace((double *)v69, v21, (unsigned int *)&v74);
(*(void (__fastcall **)(__int64, unsigned __int64 *))(*(_QWORD *)v20 + 184LL))(v20, v69);
sub_100278250((float *)v69, (float)(*(float *)&v72 * 0.5) + -60.0, (float)(0.5 * *((float *)&v72 + 1)) + 70.0);
v57 = 28;
strcpy(v58, "Reference Only");
v22 = *(_BYTE *)(a1 + 672);
v23 = *(_QWORD *)(a1 + 552);
sub_100278250((float *)&v73, 0.0, -0.0);
sub_100278350(&v74, v69, &v73);
v24 = *(_QWORD *)(a1 + 584);
sub_100278250(&v70, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)&v57,
(unsigned int)SetupSmartBlockLayer::onReferenceOnly,
0,
v22,
v23,
(unsigned int)&v74,
a1,
v24,
(__int64)&v70,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v57 & 1) != 0 )
operator delete(*(void **)&v58[15]);
v59 = 28;
strcpy(v60, "Allow Rotation");
v25 = *(_BYTE *)(a1 + 673);
v26 = *(_QWORD *)(a1 + 552);
sub_100278250((float *)&v73, 0.0, -22.0);
sub_100278350(&v74, v69, &v73);
v27 = *(_QWORD *)(a1 + 584);
sub_100278250(&v70, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)&v59,
(unsigned int)SetupSmartBlockLayer::onAllowRotation,
0,
v25,
v26,
(unsigned int)&v74,
a1,
v27,
(__int64)&v70,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v59 & 1) != 0 )
operator delete(*(void **)&v60[15]);
v61 = 24;
strcpy(v62, "Allow Flip X");
v28 = *(_BYTE *)(a1 + 674);
v29 = *(_QWORD *)(a1 + 552);
sub_100278250((float *)&v73, 0.0, -44.0);
sub_100278350(&v74, v69, &v73);
v30 = *(_QWORD *)(a1 + 584);
sub_100278250(&v70, 8.0, 0.0);
ToggleButton = GameToolbox::createToggleButton(
(unsigned int)&v61,
(unsigned int)SetupSmartBlockLayer::onAllowFlipping,
0,
v28,
v29,
(unsigned int)&v74,
a1,
v30,
(__int64)&v70,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v61 & 1) != 0 )
operator delete(*(void **)&v62[15]);
(*(void (__fastcall **)(__int64, __int64, double, double, double))(*(_QWORD *)ToggleButton + 72LL))(
ToggleButton,
3,
COERCE_DOUBLE(1058642330),
COERCE_DOUBLE(1051931443),
0.0);
v63 = 24;
strcpy(v64, "Allow Flip Y");
v32 = *(_BYTE *)(a1 + 675);
v33 = *(_QWORD *)(a1 + 552);
sub_100278250((float *)&v73, 0.0, -66.0);
sub_100278350(&v74, v69, &v73);
v34 = *(_QWORD *)(a1 + 584);
sub_100278250(&v70, 8.0, 0.0);
v35 = GameToolbox::createToggleButton(
(unsigned int)&v63,
(unsigned int)SetupSmartBlockLayer::onAllowFlipping,
0,
v32,
v33,
(unsigned int)&v74,
a1,
v34,
(__int64)&v70,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v63 & 1) != 0 )
operator delete(*(void **)&v64[15]);
(*(void (__fastcall **)(__int64, __int64, double, double, double))(*(_QWORD *)v35 + 72LL))(
v35,
4,
COERCE_DOUBLE(1058642330),
COERCE_DOUBLE(1051931443),
0.0);
v65 = 28;
strcpy(v66, "Ignore Corners");
v36 = *(_BYTE *)(a1 + 678);
v37 = *(_QWORD *)(a1 + 552);
sub_100278250((float *)&v73, 0.0, -88.0);
sub_100278350(&v74, v69, &v73);
v38 = *(_QWORD *)(a1 + 584);
sub_100278250(&v70, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)&v65,
(unsigned int)SetupSmartBlockLayer::onIgnoreCorners,
0,
v36,
v37,
(unsigned int)&v74,
a1,
v38,
(__int64)&v70,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v65 & 1) != 0 )
operator delete(*(void **)&v66[15]);
v39 = operator new(0x1Au);
v71 = &v56;
v56 = v39;
v55[0] = 27;
v55[1] = 23;
strcpy((char *)v39, "Use nearby as reference");
v40 = *(_BYTE *)(a1 + 676);
v41 = *(_QWORD *)(a1 + 552);
sub_100278250((float *)&v73, 0.0, -110.0);
sub_100278350(&v74, v69, &v73);
v42 = *(_QWORD *)(a1 + 584);
sub_100278250(&v70, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)v55,
(unsigned int)SetupSmartBlockLayer::onNearbyReference,
0,
v40,
v41,
(unsigned int)&v74,
a1,
v42,
(__int64)&v70,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v55[0] & 1) != 0 )
operator delete(v56);
v67 = 22;
strcpy(v68, "Dont delete");
v43 = *(_BYTE *)(a1 + 677);
v44 = *(_QWORD *)(a1 + 552);
sub_100278250((float *)&v73, 0.0, -132.0);
sub_100278350(&v74, v69, &v73);
v45 = *(_QWORD *)(a1 + 584);
sub_100278250(&v70, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)&v67,
(unsigned int)SetupSmartBlockLayer::onDontDelete,
0,
v43,
v44,
(unsigned int)&v74,
a1,
v45,
(__int64)&v70,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v67 & 1) != 0 )
operator delete(*(void **)&v68[15]);
*(_DWORD *)(a1 + 640) = -1;
}
return inited;
}