//
// SetupSmartBlockLayer::init from 0x1004e5da0 to 0x1004e6a59 (3257 bytes)
//
// 1 xrefs:
// > SetupSmartBlockLayer::create @ 0x1004e5d5e
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
bool __fastcall SetupSmartBlockLayer::init(SetupSmartBlockLayer *a1, SmartGameObject *a2, cocos2d::CCArray *a3)
{
SetupSmartBlockLayer_vtbl *v4; // r14
__int64 v5; // rax
cocos2d::extension::CCScale9Sprite *v6; // r14
cocos2d::CCLabelBMFont *v7; // r14
ButtonSprite *v8; // rax
ButtonSprite *v9; // rax
ButtonSprite *v10; // rax
ButtonSprite *v11; // rax
ButtonSprite *v12; // rax
unsigned int v13; // r12d
ButtonSprite *v14; // rax
ButtonSprite *v15; // rax
unsigned int v16; // eax
cocos2d::CCMenu *v17; // rax
cocos2d::CCMenu *m_buttonMenu; // r14
__int64 v19; // r14
cocos2d::CCMenu *v20; // r15
bool m_referenceOnly; // r13
cocos2d::CCMenu *v22; // r14
cocos2d::CCLayer *m_mainLayer; // r12
bool m_allowRotation; // r13
cocos2d::CCMenu *v25; // r14
cocos2d::CCLayer *v26; // r12
bool m_allowFlipX; // r12
cocos2d::CCMenu *v28; // r14
cocos2d::CCLayer *v29; // r13
__int64 ToggleButton; // r14
bool m_allowFlipY; // r12
cocos2d::CCMenu *v32; // r14
cocos2d::CCLayer *v33; // r13
__int64 v34; // r14
bool m_ignoreCorners; // r12
cocos2d::CCMenu *v36; // r14
cocos2d::CCLayer *v37; // r13
void *v38; // rax
bool m_useNearby; // r12
cocos2d::CCMenu *v40; // r14
cocos2d::CCLayer *v41; // r13
bool m_dontDelete; // r12
cocos2d::CCMenu *v43; // r14
cocos2d::CCLayer *v44; // r13
unsigned int v46; // [rsp+38h] [rbp-158h]
unsigned int v47; // [rsp+40h] [rbp-150h]
unsigned int v48; // [rsp+48h] [rbp-148h]
char v49; // [rsp+50h] [rbp-140h] BYREF
char v50[15]; // [rsp+51h] [rbp-13Fh] BYREF
void *v51; // [rsp+60h] [rbp-130h]
_QWORD v52[2]; // [rsp+68h] [rbp-128h] BYREF
void *__p; // [rsp+78h] [rbp-118h]
_QWORD v54[2]; // [rsp+80h] [rbp-110h] BYREF
void *v55; // [rsp+90h] [rbp-100h] BYREF
char v56; // [rsp+98h] [rbp-F8h] BYREF
_BYTE v57[23]; // [rsp+99h] [rbp-F7h] BYREF
char v58; // [rsp+B0h] [rbp-E0h] BYREF
_BYTE v59[23]; // [rsp+B1h] [rbp-DFh] BYREF
char v60; // [rsp+C8h] [rbp-C8h] BYREF
_BYTE v61[23]; // [rsp+C9h] [rbp-C7h] BYREF
char v62; // [rsp+E0h] [rbp-B0h] BYREF
_BYTE v63[23]; // [rsp+E1h] [rbp-AFh] BYREF
char v64; // [rsp+F8h] [rbp-98h] BYREF
_BYTE v65[23]; // [rsp+F9h] [rbp-97h] BYREF
char v66; // [rsp+110h] [rbp-80h] BYREF
_BYTE v67[23]; // [rsp+111h] [rbp-7Fh] BYREF
unsigned __int64 v68[2]; // [rsp+128h] [rbp-68h] BYREF
float v69; // [rsp+138h] [rbp-58h] BYREF
CCMenuItemSpriteExtra *v70; // [rsp+140h] [rbp-50h]
float v71; // [rsp+14Ch] [rbp-44h] BYREF
float v72; // [rsp+150h] [rbp-40h]
unsigned __int64 v73; // [rsp+154h] [rbp-3Ch] BYREF
double v74; // [rsp+15Ch] [rbp-34h] BYREF
bool inited; // [rsp+167h] [rbp-29h]
double v76; // 0:xmm0_8.8
cocos2d::CCRect v77; // 0:xmm0_8.8,8:xmm1_8.8
v4 = (SetupSmartBlockLayer_vtbl *)a2;
inited = FLAlertLayer::init_1(a1, 150);
if ( inited )
{
v5 = 664;
if ( a2 || (v5 = 672, (v4 = (SetupSmartBlockLayer_vtbl *)a3) != nullptr) )
{
*(SetupSmartBlockLayer_vtbl **)((char *)&a1->FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v5) = v4;
cocos2d::CCObject::retain((cocos2d::CCObject *)v4);
}
SetupSmartBlockLayer::determineStartValues(a1);
a1->m_noElasticity = 1;
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v71);
v77.origin = 0;
v77.size = 0;
sub_10028CC00((__int64)v68, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v6 = cocos2d::extension::CCScale9Sprite::create_2("GJ_square01.png", v77);
sub_10028CBF0((float *)v68, 300.0, 240.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, unsigned __int64 *))v6->setContentSize)(v6, v68);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v6,
4294967294LL);
sub_10028CBE0((float *)v68, v71 * 0.5, v72 * 0.5);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, unsigned __int64 *))v6->setPosition)(v6, v68);
v7 = cocos2d::CCLabelBMFont::create_3("Create blocks", "goldFont.fnt");
((void (__fastcall *)(SetupSmartBlockLayer *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v7);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v7->setScale)(v7, 0.69999999);
sub_10028CBE0((float *)v68, v71 * 0.5, (float)((float)(v72 * 0.5) + 120.0) + -18.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))v7->setPosition)(v7, v68);
v8 = ButtonSprite::create_1("Back", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_05.png", 30.0);
v70 = CCMenuItemSpriteExtra::create(
v8,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetupSmartBlockLayer::onClose);
v9 = ButtonSprite::create_1("Create", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v46 = (unsigned int)CCMenuItemSpriteExtra::create(
v9,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetupSmartBlockLayer::onCreate);
v10 = ButtonSprite::create_1("Template", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_02.png", 30.0);
v47 = (unsigned int)CCMenuItemSpriteExtra::create(
v10,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetupSmartBlockLayer::onCreateTemplate);
v11 = ButtonSprite::create_1("Special", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_02.png", 30.0);
v48 = (unsigned int)CCMenuItemSpriteExtra::create(
v11,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetupSmartBlockLayer::onSelectPremade);
v12 = ButtonSprite::create_1("Browser", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v13 = (unsigned int)CCMenuItemSpriteExtra::create(
v12,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetupSmartBlockLayer::onSelectTemplate);
v14 = ButtonSprite::create_1("Paste\nTemplate", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
CCMenuItemSpriteExtra::create(
v14,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetupSmartBlockLayer::onPasteTemplate);
v15 = ButtonSprite::create_1("Create\nAll", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v16 = (unsigned int)CCMenuItemSpriteExtra::create(
v15,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)SetupSmartBlockLayer::onCreateAll);
v17 = (cocos2d::CCMenu *)sub_100792C50((_DWORD)v70, v46, v47, v48, v13, v16);
a1->m_buttonMenu = v17;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v17,
10);
cocos2d::CCMenu::alignItemsHorizontally(a1->m_buttonMenu);
m_buttonMenu = a1->m_buttonMenu;
sub_10028CBE0((float *)v68, v71 * 0.5, (float)((float)(v72 * 0.5) + -120.0) + 24.0);
((void (__fastcall *)(cocos2d::CCMenu *, unsigned __int64 *))m_buttonMenu->setPosition)(m_buttonMenu, v68);
v49 = 8;
strcpy(v50, "Help");
__p = operator new(0x208u);
v52[0] = 521;
v52[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.");
v19 = InfoAlertButton::create(&v49, v52, 1.0);
if ( (v52[0] & 1) != 0 )
operator delete(__p);
if ( (v49 & 1) != 0 )
operator delete(v51);
((void (__fastcall *)(cocos2d::CCMenu *, __int64))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v19);
v20 = a1->m_buttonMenu;
sub_10028CBE0(
(float *)&v74,
(float)((float)(v71 * 0.5) + -150.0) + 18.0,
(float)((float)(v72 * 0.5) + 120.0) + -18.0);
*(cocos2d::CCPoint *)&v76 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)v68,
(const cocos2d::CCPoint *)v20);
(*(void (__fastcall **)(__int64, unsigned __int64 *, double))(*(_QWORD *)v19 + 184LL))(v19, v68, v76);
sub_10028CBE0((float *)v68, (float)(v71 * 0.5) + -60.0, (float)(0.5 * v72) + 70.0);
v56 = 28;
strcpy(v57, "Reference Only");
m_referenceOnly = a1->m_referenceOnly;
v22 = a1->m_buttonMenu;
sub_10028CBE0((float *)&v73, 0.0, -0.0);
sub_10028CCE0(&v74, v68, &v73);
m_mainLayer = a1->m_mainLayer;
sub_10028CBE0(&v69, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)&v56,
(unsigned int)SetupSmartBlockLayer::onReferenceOnly,
0,
m_referenceOnly,
(_DWORD)v22,
(unsigned int)&v74,
(__int64)a1,
(__int64)m_mainLayer,
(__int64)&v69,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v56 & 1) != 0 )
operator delete(*(void **)&v57[15]);
v58 = 28;
strcpy(v59, "Allow Rotation");
m_allowRotation = a1->m_allowRotation;
v25 = a1->m_buttonMenu;
sub_10028CBE0((float *)&v73, 0.0, -22.0);
sub_10028CCE0(&v74, v68, &v73);
v26 = a1->m_mainLayer;
sub_10028CBE0(&v69, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)&v58,
(unsigned int)SetupSmartBlockLayer::onAllowRotation,
0,
m_allowRotation,
(_DWORD)v25,
(unsigned int)&v74,
(__int64)a1,
(__int64)v26,
(__int64)&v69,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v58 & 1) != 0 )
operator delete(*(void **)&v59[15]);
v60 = 24;
strcpy(v61, "Allow Flip X");
m_allowFlipX = a1->m_allowFlipX;
v28 = a1->m_buttonMenu;
sub_10028CBE0((float *)&v73, 0.0, -44.0);
sub_10028CCE0(&v74, v68, &v73);
v29 = a1->m_mainLayer;
sub_10028CBE0(&v69, 8.0, 0.0);
ToggleButton = GameToolbox::createToggleButton(
(unsigned int)&v60,
(unsigned int)SetupSmartBlockLayer::onAllowFlipping,
0,
m_allowFlipX,
(_DWORD)v28,
(unsigned int)&v74,
(__int64)a1,
(__int64)v29,
(__int64)&v69,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v60 & 1) != 0 )
operator delete(*(void **)&v61[15]);
(*(void (__fastcall **)(__int64, __int64, double, double, double))(*(_QWORD *)ToggleButton + 72LL))(
ToggleButton,
3,
COERCE_DOUBLE(1058642330),
COERCE_DOUBLE(1051931443),
0.0);
v62 = 24;
strcpy(v63, "Allow Flip Y");
m_allowFlipY = a1->m_allowFlipY;
v32 = a1->m_buttonMenu;
sub_10028CBE0((float *)&v73, 0.0, -66.0);
sub_10028CCE0(&v74, v68, &v73);
v33 = a1->m_mainLayer;
sub_10028CBE0(&v69, 8.0, 0.0);
v34 = GameToolbox::createToggleButton(
(unsigned int)&v62,
(unsigned int)SetupSmartBlockLayer::onAllowFlipping,
0,
m_allowFlipY,
(_DWORD)v32,
(unsigned int)&v74,
(__int64)a1,
(__int64)v33,
(__int64)&v69,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v62 & 1) != 0 )
operator delete(*(void **)&v63[15]);
(*(void (__fastcall **)(__int64, __int64, double, double, double))(*(_QWORD *)v34 + 72LL))(
v34,
4,
COERCE_DOUBLE(1058642330),
COERCE_DOUBLE(1051931443),
0.0);
v64 = 28;
strcpy(v65, "Ignore Corners");
m_ignoreCorners = a1->m_ignoreCorners;
v36 = a1->m_buttonMenu;
sub_10028CBE0((float *)&v73, 0.0, -88.0);
sub_10028CCE0(&v74, v68, &v73);
v37 = a1->m_mainLayer;
sub_10028CBE0(&v69, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)&v64,
(unsigned int)SetupSmartBlockLayer::onIgnoreCorners,
0,
m_ignoreCorners,
(_DWORD)v36,
(unsigned int)&v74,
(__int64)a1,
(__int64)v37,
(__int64)&v69,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v64 & 1) != 0 )
operator delete(*(void **)&v65[15]);
v38 = operator new(0x1Au);
v70 = (CCMenuItemSpriteExtra *)&v55;
v55 = v38;
v54[0] = 27;
v54[1] = 23;
strcpy((char *)v38, "Use nearby as reference");
m_useNearby = a1->m_useNearby;
v40 = a1->m_buttonMenu;
sub_10028CBE0((float *)&v73, 0.0, -110.0);
sub_10028CCE0(&v74, v68, &v73);
v41 = a1->m_mainLayer;
sub_10028CBE0(&v69, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)v54,
(unsigned int)SetupSmartBlockLayer::onNearbyReference,
0,
m_useNearby,
(_DWORD)v40,
(unsigned int)&v74,
(__int64)a1,
(__int64)v41,
(__int64)&v69,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v54[0] & 1) != 0 )
operator delete(v55);
v66 = 22;
strcpy(v67, "Dont delete");
m_dontDelete = a1->m_dontDelete;
v43 = a1->m_buttonMenu;
sub_10028CBE0((float *)&v73, 0.0, -132.0);
sub_10028CCE0(&v74, v68, &v73);
v44 = a1->m_mainLayer;
sub_10028CBE0(&v69, 8.0, 0.0);
GameToolbox::createToggleButton(
(unsigned int)&v66,
(unsigned int)SetupSmartBlockLayer::onDontDelete,
0,
m_dontDelete,
(_DWORD)v43,
(unsigned int)&v74,
(__int64)a1,
(__int64)v44,
(__int64)&v69,
(__int64)"bigFont.fnt",
0,
0,
0);
if ( (v66 & 1) != 0 )
operator delete(*(void **)&v67[15]);
a1->m_joystickConnected = -1;
}
return inited;
}