//
// SetupSmartBlockLayer::init from 0x53d870 to 0x53e16e (2302 bytes)
//
// 1 xrefs:
// > SetupSmartBlockLayer::create @ 0x53e214
//
// 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 SetupSmartBlockLayer::init(SetupSmartBlockLayer *a1, SmartGameObject *a2, cocos2d::CCArray *a3)
{
cocos2d::CCObject *v6; // r0
cocos2d::CCDirector *v7; // r0
cocos2d::CCNode *v8; // r6
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // r8
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r8
cocos2d::CCLabelBMFont *v11; // r8
void (__fastcall *v12)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
ButtonSprite *v13; // r0
ButtonSprite *v14; // r0
ButtonSprite *v15; // r0
ButtonSprite *v16; // r0
CCMenuItemSpriteExtra *v17; // r10
ButtonSprite *v18; // r0
ButtonSprite *v19; // r0
ButtonSprite *v20; // r0
CCMenuItemSpriteExtra *v21; // r0
cocos2d::CCMenu *v22; // r0
cocos2d::CCMenu *m_buttonMenu; // r6
void (__fastcall *v24)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
CCMenuItemSpriteExtra *v25; // r7
cocos2d::CCMenu *v26; // r10
void (__fastcall *v27)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r8
bool m_referenceOnly; // r11
cocos2d::CCLayer *m_mainLayer; // r10
cocos2d::CCMenu *v30; // r11
cocos2d::CCLayer *v31; // r8
cocos2d::CCMenu *v32; // r8
cocos2d::CCLayer *v33; // r11
CCMenuItemToggler *v34; // r8
cocos2d::CCMenu *v35; // r11
CCMenuItemToggler *v36; // r7
cocos2d::CCMenu *v37; // r7
cocos2d::CCLayer *v38; // r8
cocos2d::CCMenu *v39; // r8
cocos2d::CCLayer *v40; // r10
cocos2d::CCMenu *v41; // r8
cocos2d::CCLayer *v42; // r9
float v44; // r2
float v45; // r3
float v46; // [sp+10h] [bp-F4h]
float v47; // [sp+10h] [bp-F4h]
float v48; // [sp+10h] [bp-F4h]
float v49; // [sp+10h] [bp-F4h]
float v50; // [sp+10h] [bp-F4h]
float v51; // [sp+10h] [bp-F4h]
float v52; // [sp+10h] [bp-F4h]
CCMenuItemSpriteExtra *v53; // [sp+34h] [bp-D0h]
int v54; // [sp+38h] [bp-CCh]
CCMenuItemSpriteExtra *v55; // [sp+3Ch] [bp-C8h]
cocos2d::CCMenu *v56; // [sp+3Ch] [bp-C8h]
cocos2d::CCLayer *v57; // [sp+3Ch] [bp-C8h]
CCMenuItemSpriteExtra *v58; // [sp+40h] [bp-C4h]
CCMenuItemSpriteExtra *v59; // [sp+44h] [bp-C0h]
CCMenuItemSpriteExtra *v60; // [sp+48h] [bp-BCh]
_BYTE v61[4]; // [sp+58h] [bp-ACh] BYREF
cocos2d::CCSize v62; // [sp+5Ch] [bp-A8h] BYREF
cocos2d::CCPoint v63; // [sp+64h] [bp-A0h] BYREF
cocos2d::CCPoint v64; // [sp+6Ch] [bp-98h] BYREF
cocos2d::CCPoint v65; // [sp+74h] [bp-90h] BYREF
cocos2d::CCPoint v66; // [sp+7Ch] [bp-88h] BYREF
void (*v67)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+84h] [bp-80h]
int v68; // [sp+88h] [bp-7Ch]
void (*v69)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+8Ch] [bp-78h]
int v70; // [sp+90h] [bp-74h]
void (*v71)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+94h] [bp-70h]
int v72; // [sp+98h] [bp-6Ch]
void (*v73)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+9Ch] [bp-68h]
int v74; // [sp+A0h] [bp-64h]
void (*v75)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+A4h] [bp-60h]
int v76; // [sp+A8h] [bp-5Ch]
void (*v77)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+ACh] [bp-58h]
int v78; // [sp+B0h] [bp-54h]
void (*v79)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+B4h] [bp-50h]
int v80; // [sp+B8h] [bp-4Ch]
void (*v81)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+BCh] [bp-48h]
unsigned int v82; // [sp+C0h] [bp-44h]
void (*v83)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+C4h] [bp-40h]
unsigned int v84; // [sp+C8h] [bp-3Ch]
void (*v85)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+CCh] [bp-38h]
unsigned int v86; // [sp+D0h] [bp-34h]
void (*v87)(SetupSmartBlockLayer *, cocos2d::CCObject *); // [sp+D4h] [bp-30h] BYREF
unsigned int v88; // [sp+D8h] [bp-2Ch]
cocos2d::CCPoint v89; // [sp+DCh] [bp-28h] BYREF
cocos2d::CCPoint v90; // [sp+E4h] [bp-20h] BYREF
cocos2d::CCRect v91; // [sp+ECh] [bp-18h] BYREF
cocos2d::CCSize v92; // 0:^0.8
cocos2d::CCRect v93; // 0:kr00_16.16
v54 = FLAlertLayer::init(a1, (cocos2d::_ccColor4B)150);
if ( v54 )
{
if ( a2 )
{
a1->m_gameObject = a2;
v6 = a2;
}
else
{
if ( !a3 )
{
LABEL_7:
SetupSmartBlockLayer::determineStartValues(a1);
a1->m_noElasticity = 1;
v7 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v62, v7);
cocos2d::CCRect::CCRect(&v91, 0.0, 0.0, 80.0, 80.0);
v93.origin.x = v44;
v93.origin.y = v45;
v93.size = v92;
v8 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square01.png",
(const char *)&v91,
v93);
setContentSize = v8->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v91, 300.0, 240.0);
setContentSize(v8, (const cocos2d::CCSize *)&v91);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v8, -2);
setPosition = v8->setPosition;
cocos2d::CCPoint::CCPoint(&v91.origin, v62.width * 0.5, v62.height * 0.5);
setPosition(v8, &v91.origin);
v11 = cocos2d::CCLabelBMFont::create();
a1->addChild(a1, v11);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v11->setScale)(v11, 1060320051);
v12 = v11->setPosition;
cocos2d::CCPoint::CCPoint(&v91.origin, v62.width * 0.5, (float)((float)(v62.height * 0.5) + 120.0) - 18.0);
v12(v11, &v91.origin);
v13 = ButtonSprite::create(
(ButtonSprite *)"Back",
(const char *)&dword_18 + 1,
0,
0.5,
1,
"goldFont.fnt",
"GJ_button_05.png",
COERCE_CONST_CHAR_(30.0),
v46);
v68 = 0;
v67 = SetupSmartBlockLayer::onClose;
v53 = CCMenuItemSpriteExtra::create(
v13,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetupSmartBlockLayer::onClose, (unsigned int)a1));
v14 = ButtonSprite::create(
(ButtonSprite *)"Create",
(const char *)&dword_18 + 1,
0,
0.5,
1,
"goldFont.fnt",
"GJ_button_01.png",
COERCE_CONST_CHAR_(30.0),
v47);
v70 = 0;
v69 = SetupSmartBlockLayer::onCreate;
v55 = CCMenuItemSpriteExtra::create(
v14,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetupSmartBlockLayer::onCreate, (unsigned int)a1));
v15 = ButtonSprite::create(
(ButtonSprite *)"Template",
(const char *)&dword_18 + 1,
0,
0.5,
1,
"goldFont.fnt",
"GJ_button_02.png",
COERCE_CONST_CHAR_(30.0),
v48);
v72 = 0;
v71 = SetupSmartBlockLayer::onCreateTemplate;
v58 = CCMenuItemSpriteExtra::create(
v15,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetupSmartBlockLayer::onCreateTemplate, (unsigned int)a1));
v16 = ButtonSprite::create(
(ButtonSprite *)"Special",
(const char *)&dword_18 + 1,
0,
0.5,
1,
"goldFont.fnt",
"GJ_button_02.png",
COERCE_CONST_CHAR_(30.0),
v49);
v74 = 0;
v73 = SetupSmartBlockLayer::onSelectPremade;
v17 = CCMenuItemSpriteExtra::create(
v16,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetupSmartBlockLayer::onSelectPremade, (unsigned int)a1));
v18 = ButtonSprite::create(
(ButtonSprite *)"Browser",
(const char *)&dword_18 + 1,
0,
0.5,
1,
"goldFont.fnt",
"GJ_button_01.png",
COERCE_CONST_CHAR_(30.0),
v50);
v76 = 0;
v75 = SetupSmartBlockLayer::onSelectTemplate;
v59 = CCMenuItemSpriteExtra::create(
v18,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetupSmartBlockLayer::onSelectTemplate, (unsigned int)a1));
v19 = ButtonSprite::create(
(ButtonSprite *)"Paste\nTemplate",
(const char *)&dword_18 + 1,
0,
0.5,
1,
"goldFont.fnt",
"GJ_button_01.png",
COERCE_CONST_CHAR_(30.0),
v51);
v78 = 0;
v77 = SetupSmartBlockLayer::onPasteTemplate;
v60 = CCMenuItemSpriteExtra::create(
v19,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetupSmartBlockLayer::onPasteTemplate, (unsigned int)a1));
v20 = ButtonSprite::create(
(ButtonSprite *)"Create\nAll",
(const char *)&dword_18 + 1,
0,
0.5,
1,
"goldFont.fnt",
"GJ_button_01.png",
COERCE_CONST_CHAR_(30.0),
v52);
v80 = 0;
v79 = SetupSmartBlockLayer::onCreateAll;
v21 = CCMenuItemSpriteExtra::create(
v20,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(SetupSmartBlockLayer::onCreateAll, (unsigned int)a1));
v22 = (cocos2d::CCMenu *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v53, v55, v58, v17, v59, v21, v60, 0);
a1->m_buttonMenu = v22;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v22, 10);
cocos2d::CCMenu::alignItemsHorizontally(a1->m_buttonMenu);
m_buttonMenu = a1->m_buttonMenu;
v24 = m_buttonMenu->setPosition;
cocos2d::CCPoint::CCPoint(&v91.origin, v62.width * 0.5, (float)((float)(v62.height * 0.5) - 120.0) + 24.0);
v24(m_buttonMenu, &v91.origin);
sub_776584((int)&v90, "Help");
sub_776584(
(int)&v91,
"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.");
v25 = InfoAlertButton::create((int)&v90, (int)&v91, 1065353216);
sub_774008(&v91);
sub_774008(&v90);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v25);
v26 = a1->m_buttonMenu;
v27 = v25->setPosition;
cocos2d::CCPoint::CCPoint(
&v90,
(float)((float)(v62.width * 0.5) - 150.0) + 18.0,
(float)((float)(v62.height * 0.5) + 120.0) - 18.0);
cocos2d::CCNode::convertToNodeSpace(&v91.origin, v26, &v90);
v27(v25, &v91.origin);
cocos2d::CCPoint::CCPoint(&v63, (float)(v62.width * 0.5) - 60.0, (float)(v62.height * 0.5) + 70.0);
sub_776584((int)&v87, "Reference Only");
v82 = 0;
m_referenceOnly = a1->m_referenceOnly;
v81 = SetupSmartBlockLayer::onReferenceOnly;
v56 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v89, 0.0, -0.0);
cocos2d::CCPoint::operator+(&v90, &v63, &v89);
m_mainLayer = a1->m_mainLayer;
cocos2d::CCPoint::CCPoint(&v91.origin, 8.0, 0.0);
GameToolbox::createToggleButton(
(int)&v87,
(unsigned int)v81,
v82,
m_referenceOnly,
v56,
&v90,
a1,
m_mainLayer,
0.6,
0.35,
0.0,
(int)&v91,
(int)"bigFont.fnt",
0,
0,
nullptr);
sub_774008(&v87);
sub_776584((int)&v87, "Allow Rotation");
LOBYTE(m_mainLayer) = a1->m_allowRotation;
v83 = SetupSmartBlockLayer::onAllowRotation;
v30 = a1->m_buttonMenu;
v84 = 0;
cocos2d::CCPoint::CCPoint(&v89, 0.0, -22.0);
cocos2d::CCPoint::operator+(&v90, &v63, &v89);
v31 = a1->m_mainLayer;
cocos2d::CCPoint::CCPoint(&v91.origin, 8.0, 0.0);
GameToolbox::createToggleButton(
(int)&v87,
(unsigned int)v83,
v84,
(bool)m_mainLayer,
v30,
&v90,
a1,
v31,
0.6,
0.35,
0.0,
(int)&v91,
(int)"bigFont.fnt",
0,
0,
nullptr);
sub_774008(&v87);
sub_776584((int)&v87, "Allow Flip X");
v86 = 0;
v85 = SetupSmartBlockLayer::onAllowFlipping;
LOBYTE(m_mainLayer) = a1->m_allowFlipX;
v32 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v89, 0.0, -44.0);
cocos2d::CCPoint::operator+(&v90, &v63, &v89);
v33 = a1->m_mainLayer;
cocos2d::CCPoint::CCPoint(&v91.origin, 8.0, 0.0);
v34 = GameToolbox::createToggleButton(
(int)&v87,
(unsigned int)v85,
v86,
(bool)m_mainLayer,
v32,
&v90,
a1,
v33,
0.6,
0.35,
0.0,
(int)&v91,
(int)"bigFont.fnt",
0,
0,
nullptr);
sub_774008(&v87);
v34->setTag(v34, 3);
sub_776584((int)&v66, "Allow Flip Y");
v87 = SetupSmartBlockLayer::onAllowFlipping;
LOBYTE(m_mainLayer) = a1->m_allowFlipY;
v88 = 0;
v35 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v89, 0.0, -66.0);
cocos2d::CCPoint::operator+(&v90, &v63, &v89);
v57 = a1->m_mainLayer;
cocos2d::CCPoint::CCPoint(&v91.origin, 8.0, 0.0);
v36 = GameToolbox::createToggleButton(
(int)&v66,
(unsigned int)v87,
v88,
(bool)m_mainLayer,
v35,
&v90,
a1,
v57,
0.6,
0.35,
0.0,
(int)&v91,
(int)"bigFont.fnt",
0,
0,
nullptr);
sub_774008(&v66);
v36->setTag(v36, 4);
sub_776584((int)&v65, "Ignore Corners");
LOBYTE(v35) = a1->m_ignoreCorners;
v37 = a1->m_buttonMenu;
LODWORD(v89.x) = SetupSmartBlockLayer::onIgnoreCorners;
v89.y = 0.0;
cocos2d::CCPoint::CCPoint(&v66, 0.0, -88.0);
cocos2d::CCPoint::operator+(&v90, &v63, &v66);
v38 = a1->m_mainLayer;
cocos2d::CCPoint::CCPoint(&v91.origin, 8.0, 0.0);
GameToolbox::createToggleButton(
(int)&v65,
LODWORD(v89.x),
LODWORD(v89.y),
(bool)v35,
v37,
&v90,
a1,
v38,
0.6,
0.35,
0.0,
(int)&v91,
(int)"bigFont.fnt",
0,
0,
nullptr);
sub_774008(&v65);
sub_776584((int)&v64, "Use nearby as reference");
LOBYTE(v37) = a1->m_useNearby;
v39 = a1->m_buttonMenu;
LODWORD(v90.x) = SetupSmartBlockLayer::onNearbyReference;
v90.y = 0.0;
cocos2d::CCPoint::CCPoint(&v65, 0.0, -110.0);
cocos2d::CCPoint::operator+(&v66, &v63, &v65);
v40 = a1->m_mainLayer;
cocos2d::CCPoint::CCPoint(&v91.origin, 8.0, 0.0);
GameToolbox::createToggleButton(
(int)&v64,
LODWORD(v90.x),
LODWORD(v90.y),
(bool)v37,
v39,
&v66,
a1,
v40,
0.6,
0.35,
0.0,
(int)&v91,
(int)"bigFont.fnt",
0,
0,
nullptr);
sub_774008(&v64);
sub_776584((int)v61, "Dont delete");
LOBYTE(v37) = a1->m_dontDelete;
v41 = a1->m_buttonMenu;
LODWORD(v91.origin.x) = SetupSmartBlockLayer::onDontDelete;
v91.origin.y = 0.0;
cocos2d::CCPoint::CCPoint(&v64, 0.0, -132.0);
cocos2d::CCPoint::operator+(&v65, &v63, &v64);
v42 = a1->m_mainLayer;
cocos2d::CCPoint::CCPoint(&v66, 8.0, 0.0);
GameToolbox::createToggleButton(
(int)v61,
LODWORD(v91.origin.x),
LODWORD(v91.origin.y),
(bool)v37,
v41,
&v65,
a1,
v42,
0.6,
0.35,
0.0,
(int)&v66,
(int)"bigFont.fnt",
0,
0,
nullptr);
sub_774008(v61);
a1->m_joystickConnected = -1;
return v54;
}
v6 = a3;
a1->m_gameObjects = a3;
}
cocos2d::CCObject::retain(v6);
goto LABEL_7;
}
return v54;
}