//
// SetupSmartBlockLayer::init from 0x10006f110 to 0x10006fb1c (2572 bytes)
//
// 1 xrefs:
// > SetupSmartBlockLayer::create @ 0x10006f0c0
//
// 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)
{
_BOOL4 inited; // w20
__int64 v7; // x8
cocos2d::CCDirector *v8; // x0
cocos2d::extension::CCScale9Sprite *v9; // x21
__n128 v10; // q0
__n128 v11; // q1
cocos2d::CCLabelBMFont *v12; // x22
__n128 v13; // q0
__n128 v14; // q1
ButtonSprite *v15; // x0
CCMenuItemSpriteExtra *v16; // x22
ButtonSprite *v17; // x0
ButtonSprite *v18; // x0
ButtonSprite *v19; // x0
ButtonSprite *v20; // x0
ButtonSprite *v21; // x0
ButtonSprite *v22; // x0
cocos2d::CCMenu *v23; // x0
cocos2d::CCMenu *m_buttonMenu; // x21
__n128 v25; // q0
__n128 v26; // q1
__int64 v27; // x21
__n128 v28; // q0
cocos2d::CCMenu *v29; // x22
__n128 v30; // q1
__n128 v31; // q0
__n128 v32; // q1
bool m_referenceOnly; // w21
cocos2d::CCMenu *v34; // x22
__n128 v35; // q0
__n128 v36; // q1
__n128 v37; // q0
cocos2d::CCLayer *m_mainLayer; // x23
__n128 v39; // q1
bool m_allowRotation; // w21
cocos2d::CCMenu *v41; // x22
__n128 v42; // q0
__n128 v43; // q1
__n128 v44; // q0
cocos2d::CCLayer *v45; // x23
__n128 v46; // q1
bool m_allowFlipX; // w21
cocos2d::CCMenu *v48; // x22
__n128 v49; // q1
__n128 v50; // q0
__n128 v51; // q0
cocos2d::CCLayer *v52; // x23
__n128 v53; // q1
CCMenuItemToggler *v54; // x21
bool m_allowFlipY; // w21
cocos2d::CCMenu *v56; // x22
__n128 v57; // q1
__n128 v58; // q0
__n128 v59; // q0
cocos2d::CCLayer *v60; // x23
__n128 v61; // q1
CCMenuItemToggler *v62; // x21
bool m_ignoreCorners; // w21
cocos2d::CCMenu *v64; // x22
__n128 v65; // q1
__n128 v66; // q0
__n128 v67; // q0
cocos2d::CCLayer *v68; // x23
__n128 v69; // q1
bool m_useNearby; // w21
cocos2d::CCMenu *v71; // x22
__n128 v72; // q1
__n128 v73; // q0
__n128 v74; // q0
cocos2d::CCLayer *v75; // x23
__n128 v76; // q1
bool m_dontDelete; // w21
cocos2d::CCMenu *v78; // x22
__n128 v79; // q1
__n128 v80; // q0
__n128 v81; // q0
cocos2d::CCLayer *v82; // x23
__n128 v83; // q1
void *v85[2]; // [xsp+40h] [xbp-170h] BYREF
char v86; // [xsp+57h] [xbp-159h]
void *v87[2]; // [xsp+58h] [xbp-158h] BYREF
char v88; // [xsp+6Fh] [xbp-141h]
void *v89[2]; // [xsp+70h] [xbp-140h] BYREF
char v90; // [xsp+87h] [xbp-129h]
void *v91[2]; // [xsp+88h] [xbp-128h] BYREF
char v92; // [xsp+9Fh] [xbp-111h]
void *v93[2]; // [xsp+A0h] [xbp-110h] BYREF
char v94; // [xsp+B7h] [xbp-F9h]
void *__p[2]; // [xsp+B8h] [xbp-F8h] BYREF
char v96; // [xsp+CFh] [xbp-E1h]
int v97; // [xsp+D0h] [xbp-E0h] BYREF
float32x2_t v98; // [xsp+D8h] [xbp-D8h] BYREF
void *v99[2]; // [xsp+E0h] [xbp-D0h] BYREF
char v100; // [xsp+F7h] [xbp-B9h]
cocos2d::CCPoint v101; // [xsp+F8h] [xbp-B8h] BYREF
void *v102[2]; // [xsp+100h] [xbp-B0h] BYREF
char v103; // [xsp+117h] [xbp-99h]
void *v104[2]; // [xsp+118h] [xbp-98h] BYREF
char v105; // [xsp+12Fh] [xbp-81h]
float32x2_t v106[2]; // [xsp+130h] [xbp-80h] BYREF
float v107; // [xsp+140h] [xbp-70h]
float v108; // [xsp+144h] [xbp-6Ch]
cocos2d::CCPoint v109; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v110; // 0:x3.16
cocos2d::SEL_MenuHandler v111; // 0:x3.16
cocos2d::SEL_MenuHandler v112; // 0:x3.16
cocos2d::SEL_MenuHandler v113; // 0:x3.16
cocos2d::SEL_MenuHandler v114; // 0:x3.16
cocos2d::SEL_MenuHandler v115; // 0:x3.16
cocos2d::SEL_MenuHandler v116; // 0:x3.16
cocos2d::CCRect v117; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
inited = FLAlertLayer::init_1(a1, 150);
if ( !inited )
return inited;
if ( a2 )
{
v7 = 664;
LABEL_6:
*(SetupSmartBlockLayer_vtbl **)((char *)&a1->FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v7) = (SetupSmartBlockLayer_vtbl *)a2;
cocos2d::CCObject::retain(a2);
goto LABEL_7;
}
if ( a3 )
{
v7 = 672;
a2 = (SmartGameObject *)a3;
goto LABEL_6;
}
LABEL_7:
SetupSmartBlockLayer::determineStartValues(a1);
a1->m_noElasticity = 1;
v8 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v8);
sub_100022990((float *)v106, 0.0, 0.0, 80.0, 80.0);
v9 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v117);
sub_100022988((float *)v106, 300.0, 240.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v9->setContentSize)(v9, v106);
v10 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v9,
4294967294LL);
v10.n128_f32[0] = v107 * 0.5;
v11.n128_f32[0] = v108 * 0.5;
sub_100022980(v10, v11, v106);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v9->setPosition)(v9, v106);
v12 = cocos2d::CCLabelBMFont::create_1("Create blocks", "goldFont.fnt");
((void (__fastcall *)(SetupSmartBlockLayer *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v12);
v13 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float))v12->setScale)(v12, 0.7);
v13.n128_f32[0] = v107 * 0.5;
v14.n128_f32[0] = (float)((float)(v108 * 0.5) + 120.0) + -18.0;
sub_100022980(v13, v14, v106);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *))v12->setPosition)(v12, v106);
v15 = ButtonSprite::create_1("Back", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_05.png", 30.0);
v110.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onClose;
v110.adj = 0;
v16 = CCMenuItemSpriteExtra::create(v15, nullptr, a1, v110);
v17 = ButtonSprite::create_1("Create", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v111.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onCreate;
v111.adj = 0;
CCMenuItemSpriteExtra::create(v17, nullptr, a1, v111);
v18 = ButtonSprite::create_1("Template", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_02.png", 30.0);
v112.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onCreateTemplate;
v112.adj = 0;
CCMenuItemSpriteExtra::create(v18, nullptr, a1, v112);
v19 = ButtonSprite::create_1("Special", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_02.png", 30.0);
v113.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onSelectPremade;
v113.adj = 0;
CCMenuItemSpriteExtra::create(v19, nullptr, a1, v113);
v20 = ButtonSprite::create_1("Browser", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v114.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onSelectTemplate;
v114.adj = 0;
CCMenuItemSpriteExtra::create(v20, nullptr, a1, v114);
v21 = ButtonSprite::create_1("Paste\nTemplate", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v115.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onPasteTemplate;
v115.adj = 0;
CCMenuItemSpriteExtra::create(v21, nullptr, a1, v115);
v22 = ButtonSprite::create_1("Create\nAll", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0);
v116.ptr = (void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onCreateAll;
v116.adj = 0;
CCMenuItemSpriteExtra::create(v22, nullptr, a1, v116);
v23 = (cocos2d::CCMenu *)sub_1001D7ED0(v16);
a1->m_buttonMenu = v23;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v23,
10);
cocos2d::CCMenu::alignItemsHorizontally(a1->m_buttonMenu);
m_buttonMenu = a1->m_buttonMenu;
v25.n128_f32[0] = v107 * 0.5;
v26.n128_f32[0] = (float)((float)(v108 * 0.5) + -120.0) + 24.0;
sub_100022980(v25, v26, v106);
((void (__fastcall *)(cocos2d::CCMenu *, float32x2_t *))m_buttonMenu->setPosition)(m_buttonMenu, v106);
sub_100009900(v104, "Help");
sub_100009900(
v102,
"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.");
v27 = InfoAlertButton::create(v104, v102, 1.0);
if ( v103 < 0 )
operator delete(v102[0]);
if ( v105 < 0 )
operator delete(v104[0]);
v28 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, __int64))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v27);
v29 = a1->m_buttonMenu;
v28.n128_f32[0] = (float)((float)(v107 * 0.5) + -150.0) + 18.0;
v30.n128_f32[0] = (float)((float)(v108 * 0.5) + 120.0) + -18.0;
sub_100022980(v28, v30, &v101);
v109 = cocos2d::CCNode::convertToNodeSpace(v29, &v101);
v31 = ((__n128 (__fastcall *)(__int64, float32x2_t *, float, float))*(_QWORD *)(*(_QWORD *)v27 + 184LL))(
v27,
v106,
v109.x,
v109.y);
v31.n128_f32[0] = (float)(v107 * 0.5) + -60.0;
v32.n128_f32[0] = (float)(v108 * 0.5) + 70.0;
sub_100022980(v31, v32, v106);
sub_100009900(v99, "Reference Only");
m_referenceOnly = a1->m_referenceOnly;
v34 = a1->m_buttonMenu;
v35.n128_u32[0] = 0;
v36.n128_u64[0] = 0x8000000080000000LL;
sub_100022980(v35, v36, &v98);
v37.n128_f32[1] = sub_1000229DC(v106, &v98, (float32x2_t *)&v101).f32[1];
m_mainLayer = a1->m_mainLayer;
v37.n128_u32[0] = 8.0;
v39.n128_u32[0] = 0;
sub_100022980(v37, v39, &v97);
GameToolbox::createToggleButton(
(const char *)v99,
(void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onReferenceOnly,
0,
m_referenceOnly,
v34,
&v101,
a1,
m_mainLayer,
0.6,
0.35,
0.0,
(float *)&v97,
"bigFont.fnt",
0,
0,
0);
if ( v100 < 0 )
operator delete(v99[0]);
sub_100009900(__p, "Allow Rotation");
m_allowRotation = a1->m_allowRotation;
v41 = a1->m_buttonMenu;
v42.n128_u32[0] = 0;
v43.n128_u32[0] = -22.0;
sub_100022980(v42, v43, &v98);
v44.n128_f32[1] = sub_1000229DC(v106, &v98, (float32x2_t *)&v101).f32[1];
v45 = a1->m_mainLayer;
v44.n128_u32[0] = 8.0;
v46.n128_u32[0] = 0;
sub_100022980(v44, v46, &v97);
GameToolbox::createToggleButton(
(const char *)__p,
(void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onAllowRotation,
0,
m_allowRotation,
v41,
&v101,
a1,
v45,
0.6,
0.35,
0.0,
(float *)&v97,
"bigFont.fnt",
0,
0,
0);
if ( v96 < 0 )
operator delete(__p[0]);
sub_100009900(v93, "Allow Flip X");
m_allowFlipX = a1->m_allowFlipX;
v48 = a1->m_buttonMenu;
v49.n128_u32[0] = -1037041664;
v50.n128_u32[0] = 0;
sub_100022980(v50, v49, &v98);
v51.n128_f32[1] = sub_1000229DC(v106, &v98, (float32x2_t *)&v101).f32[1];
v52 = a1->m_mainLayer;
v51.n128_u32[0] = 8.0;
v53.n128_u32[0] = 0;
sub_100022980(v51, v53, &v97);
v54 = GameToolbox::createToggleButton(
(const char *)v93,
(void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onAllowFlipping,
0,
m_allowFlipX,
v48,
&v101,
a1,
v52,
0.6,
0.35,
0.0,
(float *)&v97,
"bigFont.fnt",
0,
0,
0);
if ( v94 < 0 )
operator delete(v93[0]);
((void (__fastcall *)(CCMenuItemToggler *, __int64))v54->setTag)(v54, 3);
sub_100009900(v91, "Allow Flip Y");
m_allowFlipY = a1->m_allowFlipY;
v56 = a1->m_buttonMenu;
v57.n128_u32[0] = -1031536640;
v58.n128_u32[0] = 0;
sub_100022980(v58, v57, &v98);
v59.n128_f32[1] = sub_1000229DC(v106, &v98, (float32x2_t *)&v101).f32[1];
v60 = a1->m_mainLayer;
v59.n128_u32[0] = 8.0;
v61.n128_u32[0] = 0;
sub_100022980(v59, v61, &v97);
v62 = GameToolbox::createToggleButton(
(const char *)v91,
(void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onAllowFlipping,
0,
m_allowFlipY,
v56,
&v101,
a1,
v60,
0.6,
0.35,
0.0,
(float *)&v97,
"bigFont.fnt",
0,
0,
0);
if ( v92 < 0 )
operator delete(v91[0]);
((void (__fastcall *)(CCMenuItemToggler *, __int64))v62->setTag)(v62, 4);
sub_100009900(v89, "Ignore Corners");
m_ignoreCorners = a1->m_ignoreCorners;
v64 = a1->m_buttonMenu;
v65.n128_u32[0] = -1028653056;
v66.n128_u32[0] = 0;
sub_100022980(v66, v65, &v98);
v67.n128_f32[1] = sub_1000229DC(v106, &v98, (float32x2_t *)&v101).f32[1];
v68 = a1->m_mainLayer;
v67.n128_u32[0] = 8.0;
v69.n128_u32[0] = 0;
sub_100022980(v67, v69, &v97);
GameToolbox::createToggleButton(
(const char *)v89,
(void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onIgnoreCorners,
0,
m_ignoreCorners,
v64,
&v101,
a1,
v68,
0.6,
0.35,
0.0,
(float *)&v97,
"bigFont.fnt",
0,
0,
0);
if ( v90 < 0 )
operator delete(v89[0]);
sub_100009900(v87, "Use nearby as reference");
m_useNearby = a1->m_useNearby;
v71 = a1->m_buttonMenu;
v72.n128_u32[0] = -1025769472;
v73.n128_u32[0] = 0;
sub_100022980(v73, v72, &v98);
v74.n128_f32[1] = sub_1000229DC(v106, &v98, (float32x2_t *)&v101).f32[1];
v75 = a1->m_mainLayer;
v74.n128_u32[0] = 8.0;
v76.n128_u32[0] = 0;
sub_100022980(v74, v76, &v97);
GameToolbox::createToggleButton(
(const char *)v87,
(void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onNearbyReference,
0,
m_useNearby,
v71,
&v101,
a1,
v75,
0.6,
0.35,
0.0,
(float *)&v97,
"bigFont.fnt",
0,
0,
0);
if ( v88 < 0 )
operator delete(v87[0]);
sub_100009900(v85, "Dont delete");
m_dontDelete = a1->m_dontDelete;
v78 = a1->m_buttonMenu;
v79.n128_u32[0] = -1023148032;
v80.n128_u32[0] = 0;
sub_100022980(v80, v79, &v98);
v81.n128_f32[1] = sub_1000229DC(v106, &v98, (float32x2_t *)&v101).f32[1];
v82 = a1->m_mainLayer;
v81.n128_u32[0] = 8.0;
v83.n128_u32[0] = 0;
sub_100022980(v81, v83, &v97);
GameToolbox::createToggleButton(
(const char *)v85,
(void (__cdecl *)(cocos2d::CCObject *))SetupSmartBlockLayer::onDontDelete,
0,
m_dontDelete,
v78,
&v101,
a1,
v82,
0.6,
0.35,
0.0,
(float *)&v97,
"bigFont.fnt",
0,
0,
0);
if ( v86 < 0 )
operator delete(v85[0]);
a1->m_joystickConnected = -1;
return inited;
}