//
// SetupSmartBlockLayer::init from 0x140456a10 to 0x1404579dd (4045 bytes)
//
// 2 xrefs:
// > SetupSmartBlockLayer::create @ 0x1404569ca
// > ??> @ 0x1406da9ac
//
// 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
//
// Hidden C++ exception states: #wind=12
bool SetupSmartBlockLayer::init(SetupSmartBlockLayer *a1, SmartGameObject *a2, cocos2d::CCArray *a3)
{
bool result; // al
cocos2d::CCObject *v7; // rcx
__int64 v8; // rcx
bool *v9; // rcx
GameManager *v10; // rcx
GameManager *v11; // rcx
__int64 v12; // rcx
SmartGameObject *m_gameObject; // rax
unsigned int i; // ebx
cocos2d::CCDirector *v15; // rax
struct cocos2d::CCRect *v16; // rax
struct cocos2d::extension::CCScale9Sprite *v17; // rdi
cocos2d::extension::CCScale9Sprite_vtbl *v18; // rbx
const cocos2d::CCSize *v19; // rax
float v20; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v21; // rbx
const cocos2d::CCPoint *v22; // rax
struct cocos2d::CCLabelBMFont *v23; // rdi
float v24; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v25; // rbx
double v26; // xmm0_8
const cocos2d::CCPoint *v27; // rax
ButtonSprite *v28; // rbx
ButtonSprite *v29; // rax
cocos2d::CCNode *v30; // rbx
CCMenuItemSpriteExtra *v31; // r13
ButtonSprite *v32; // rax
cocos2d::CCNode *v33; // rbx
CCMenuItemSpriteExtra *v34; // r12
ButtonSprite *v35; // rax
cocos2d::CCNode *v36; // rbx
CCMenuItemSpriteExtra *v37; // r15
ButtonSprite *v38; // rax
cocos2d::CCNode *v39; // rbx
CCMenuItemSpriteExtra *v40; // r14
ButtonSprite *v41; // rbx
CCMenuItemSpriteExtra *v42; // rdi
ButtonSprite *v43; // rbx
CCMenuItemSpriteExtra *v44; // rax
cocos2d::CCMenu *v45; // rax
cocos2d::CCMenu_vtbl *v46; // rbx
const cocos2d::CCPoint *v47; // rax
_QWORD *v48; // rax
_QWORD *v49; // rcx
const char *v50; // rdx
__int64 v51; // r8
char *v52; // rdi
float v53; // xmm0_4
__int64 v54; // rbx
struct cocos2d::CCPoint v55; // rax
float v56; // xmm0_4
double v57; // xmm0_8
float *v58; // rax
double v59; // xmm0_8
float *v60; // rax
double v61; // xmm0_8
float *v62; // rax
CCMenuItemToggler *ToggleButton; // rax
double v64; // xmm0_8
float *v65; // rax
CCMenuItemToggler *v66; // rax
double v67; // xmm0_8
float *v68; // rax
double v69; // xmm0_8
float *v70; // rax
double v71; // xmm0_8
float *v72; // rax
CCMenuItemSpriteExtra *v73; // [rsp+88h] [rbp-80h] BYREF
ButtonSprite *v74; // [rsp+90h] [rbp-78h]
__int128 v75; // [rsp+98h] [rbp-70h] BYREF
__int64 v76; // [rsp+A8h] [rbp-60h]
__int64 v77; // [rsp+B0h] [rbp-58h]
char v78[8]; // [rsp+B8h] [rbp-50h] BYREF
cocos2d::CCRect v79; // [rsp+C8h] [rbp-40h] BYREF
__int64 v80; // [rsp+D8h] [rbp-30h]
__int64 v81; // [rsp+E0h] [rbp-28h]
float v82; // [rsp+170h] [rbp+68h]
result = FLAlertLayer::init_1(a1, 150);
if ( !result )
return result;
if ( a2 )
{
a1->m_gameObject = a2;
v7 = a2;
LABEL_6:
cocos2d::CCObject::retain(v7);
goto LABEL_7;
}
if ( a3 )
{
a1->m_gameObjects = a3;
v7 = a3;
goto LABEL_6;
}
LABEL_7:
v8 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v73 = (CCMenuItemSpriteExtra *)operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v73);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v8 = qword_1406C2EC0;
}
v9 = *(bool **)(v8 + 960);
if ( v9 )
{
a1->m_allowRotation = v9[130];
a1->m_allowFlipX = v9[128];
a1->m_allowFlipY = v9[129];
a1->m_ignoreCorners = v9[131];
}
v10 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v73 = (CCMenuItemSpriteExtra *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v73);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v10 = (GameManager *)qword_1406C2ED8;
}
a1->m_useNearby = GameManager::getGameVariable(v10, "0131");
v11 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v73 = (CCMenuItemSpriteExtra *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v73);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v11 = (GameManager *)qword_1406C2ED8;
}
a1->m_dontDelete = GameManager::getGameVariable(v11, "0132");
m_gameObject = a1->m_gameObject;
if ( m_gameObject )
{
a1->m_referenceOnly = m_gameObject->m_referenceOnly;
}
else
{
a1->m_referenceOnly = 1;
for ( i = 0; i < cocos2d::CCArray::count(a1->m_gameObjects); ++i )
{
if ( !LOBYTE(cocos2d::CCArray::objectAtIndex(a1->m_gameObjects, i)[24].m_nTag) )
a1->m_referenceOnly = 0;
}
}
a1->m_noElasticity = 1;
v15 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v12);
cocos2d::CCDirector::getWinSize(v15);
cocos2d::CCRect::CCRect(&v79, 0.0, 0.0, 80.0, 80.0);
v17 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v16);
v18 = v17->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v73, 300.0, 240.0);
v18->setContentSize(v17, v19);
v20 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v17,
4294967294LL);
v21 = v17->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v20, v82 * 0.5);
v21->setPosition_0(v17, v22);
v23 = cocos2d::CCLabelBMFont::create("Create blocks", "goldFont.fnt");
a1->addChild_1(a1, v23);
v24 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *))v23->setScale_0)(v23);
v25 = v23->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v26 = cocos2d::CCPoint::CCPoint(v24, v82 * 0.5);
v25->setPosition_0(v23, v27);
v73 = (CCMenuItemSpriteExtra *)operator new(0x2C0u);
v28 = ButtonSprite::ButtonSprite((ButtonSprite *)v73);
if ( v28 )
{
if ( ButtonSprite::init_1(v28, "Back", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_05.png", 30.0) )
{
cocos2d::CCObject::autorelease(v28);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v28->~ButtonSprite)(v28, 1);
v28 = nullptr;
}
}
v73 = CCMenuItemSpriteExtra::create(v28, nullptr, a1, (cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onClose);
v74 = (ButtonSprite *)operator new(0x2C0u);
v29 = ButtonSprite::ButtonSprite(v74);
v30 = v29;
if ( v29 )
{
if ( ButtonSprite::init_1(v29, "Create", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v30);
}
else
{
((void (__fastcall *)(cocos2d::CCNode *, __int64))v30->~CCNode)(v30, 1);
v30 = nullptr;
}
}
v31 = CCMenuItemSpriteExtra::create(v30, nullptr, a1, (cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onCreate);
v74 = (ButtonSprite *)operator new(0x2C0u);
v32 = ButtonSprite::ButtonSprite(v74);
v33 = v32;
if ( v32 )
{
if ( ButtonSprite::init_1(v32, "Template", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_02.png", 30.0) )
{
cocos2d::CCObject::autorelease(v33);
}
else
{
((void (__fastcall *)(cocos2d::CCNode *, __int64))v33->~CCNode)(v33, 1);
v33 = nullptr;
}
}
v34 = CCMenuItemSpriteExtra::create(
v33,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onCreateTemplate);
v74 = (ButtonSprite *)operator new(0x2C0u);
v35 = ButtonSprite::ButtonSprite(v74);
v36 = v35;
if ( v35 )
{
if ( ButtonSprite::init_1(v35, "Special", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_02.png", 30.0) )
{
cocos2d::CCObject::autorelease(v36);
}
else
{
((void (__fastcall *)(cocos2d::CCNode *, __int64))v36->~CCNode)(v36, 1);
v36 = nullptr;
}
}
v37 = CCMenuItemSpriteExtra::create(
v36,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onSelectPremade);
v74 = (ButtonSprite *)operator new(0x2C0u);
v38 = ButtonSprite::ButtonSprite(v74);
v39 = v38;
if ( v38 )
{
if ( ButtonSprite::init_1(v38, "Browser", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v39);
}
else
{
((void (__fastcall *)(cocos2d::CCNode *, __int64))v39->~CCNode)(v39, 1);
v39 = nullptr;
}
}
v40 = CCMenuItemSpriteExtra::create(
v39,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onSelectTemplate);
v74 = (ButtonSprite *)operator new(0x2C0u);
v41 = ButtonSprite::ButtonSprite(v74);
if ( v41 )
{
if ( ButtonSprite::init_1(v41, "Paste\nTemplate", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v41);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v41->~ButtonSprite)(v41, 1);
v41 = nullptr;
}
}
v42 = CCMenuItemSpriteExtra::create(
v41,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onPasteTemplate);
v74 = (ButtonSprite *)operator new(0x2C0u);
v43 = ButtonSprite::ButtonSprite(v74);
if ( v43 )
{
if ( ButtonSprite::init_1(v43, "Create\nAll", 25, 0, 0.5, 1, "goldFont.fnt", "GJ_button_01.png", 30.0) )
{
cocos2d::CCObject::autorelease(v43);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v43->~ButtonSprite)(v43, 1);
v43 = nullptr;
}
}
v44 = CCMenuItemSpriteExtra::create(v43, nullptr, a1, (cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onCreateAll);
v45 = cocos2d::CCMenu::create(v73, v31, v34, v37, v40, v44, v42, 0);
a1->m_buttonMenu = v45;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v45, 10);
cocos2d::CCMenu::alignItemsHorizontally(a1->m_buttonMenu);
v46 = a1->m_buttonMenu->FLAlertLayer::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v26, v82 * 0.5);
v46->setPosition_0(a1->m_buttonMenu, v47);
v74 = (ButtonSprite *)&v75;
v75 = 0;
v76 = 0;
v77 = 15;
v48 = sub_14003AA10(0x210u);
*(_QWORD *)&v75 = v48;
v76 = 517;
v77 = 527;
v49 = v48;
v50 = "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.";
v51 = 4;
do
{
*(_OWORD *)v49 = *(_OWORD *)v50;
*((_OWORD *)v49 + 1) = *((_OWORD *)v50 + 1);
*((_OWORD *)v49 + 2) = *((_OWORD *)v50 + 2);
*((_OWORD *)v49 + 3) = *((_OWORD *)v50 + 3);
*((_OWORD *)v49 + 4) = *((_OWORD *)v50 + 4);
*((_OWORD *)v49 + 5) = *((_OWORD *)v50 + 5);
*((_OWORD *)v49 + 6) = *((_OWORD *)v50 + 6);
v49 += 16;
*((_OWORD *)v49 - 1) = *((_OWORD *)v50 + 7);
v50 += 128;
--v51;
}
while ( v51 );
*(_DWORD *)v49 = *(_DWORD *)v50;
*((_BYTE *)v49 + 4) = v50[4];
*((_BYTE *)v48 + 517) = 0;
v79 = 0;
v80 = 4;
v81 = 15;
strcpy((char *)&v79, "Help");
v52 = InfoAlertButton::create((__int64)&v79, (__int64)&v75);
v53 = ((float (__fastcall *)(cocos2d::CCMenu *, char *))a1->m_buttonMenu->addChild_1)(a1->m_buttonMenu, v52);
v54 = *(_QWORD *)v52;
cocos2d::CCPoint::CCPoint(v53, (float)((float)(v82 * 0.5) - 150.0) + 18.0);
v55 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v73);
v56 = (*(float (__fastcall **)(char *, struct cocos2d::CCPoint))(v54 + 184))(v52, v55);
cocos2d::CCPoint::CCPoint(v56, (float)(v82 * 0.5) - 60.0);
v74 = (ButtonSprite *)&v75;
v76 = 14;
v77 = 15;
strcpy((char *)&v75, "Reference Only");
HIBYTE(v75) = 0;
cocos2d::CCPoint::CCPoint(6.8000833e22, 0.0);
v57 = cocos2d::CCPoint::operator+(v78, &v73);
cocos2d::CCPoint::CCPoint(*(float *)&v57, 8.0);
GameToolbox::createToggleButton(
(const char *)&v75,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onReferenceOnly,
a1->m_referenceOnly,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v73,
a1,
a1->m_mainLayer,
0.60000002,
0.34999999,
0.0,
v58,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v79.origin = (cocos2d::CCPoint)&v75;
v76 = 14;
v77 = 15;
strcpy((char *)&v75, "Allow Rotation");
HIBYTE(v75) = 0;
cocos2d::CCPoint::CCPoint(7.3169333e28, 0.0);
v59 = cocos2d::CCPoint::operator+(v78, &v73);
cocos2d::CCPoint::CCPoint(*(float *)&v59, 8.0);
GameToolbox::createToggleButton(
(const char *)&v75,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onAllowRotation,
a1->m_allowRotation,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v73,
a1,
a1->m_mainLayer,
0.60000002,
0.34999999,
0.0,
v60,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v79.origin = (cocos2d::CCPoint)&v75;
v76 = 12;
v77 = 15;
strcpy((char *)&v75, "Allow Flip X");
BYTE13(v75) = 0;
HIWORD(v75) = 0;
cocos2d::CCPoint::CCPoint(7.3169333e28, 0.0);
v61 = cocos2d::CCPoint::operator+(v78, &v73);
cocos2d::CCPoint::CCPoint(*(float *)&v61, 8.0);
ToggleButton = GameToolbox::createToggleButton(
(const char *)&v75,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onAllowFlipping,
a1->m_allowFlipX,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v73,
a1,
a1->m_mainLayer,
0.60000002,
0.34999999,
0.0,
v62,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
ToggleButton->setTag(ToggleButton, 3);
v79.origin = (cocos2d::CCPoint)&v75;
v76 = 12;
v77 = 15;
strcpy((char *)&v75, "Allow Flip Y");
BYTE13(v75) = 0;
HIWORD(v75) = 0;
cocos2d::CCPoint::CCPoint(7.3169333e28, 0.0);
v64 = cocos2d::CCPoint::operator+(v78, &v73);
cocos2d::CCPoint::CCPoint(*(float *)&v64, 8.0);
v66 = GameToolbox::createToggleButton(
(const char *)&v75,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onAllowFlipping,
a1->m_allowFlipY,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v73,
a1,
a1->m_mainLayer,
0.60000002,
0.34999999,
0.0,
v65,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v66->setTag(v66, 4);
v79.origin = (cocos2d::CCPoint)&v75;
v76 = 14;
v77 = 15;
strcpy((char *)&v75, "Ignore Corners");
HIBYTE(v75) = 0;
cocos2d::CCPoint::CCPoint(7.3782296e28, 0.0);
v67 = cocos2d::CCPoint::operator+(v78, &v73);
cocos2d::CCPoint::CCPoint(*(float *)&v67, 8.0);
GameToolbox::createToggleButton(
(const char *)&v75,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onIgnoreCorners,
a1->m_ignoreCorners,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v73,
a1,
a1->m_mainLayer,
0.60000002,
0.34999999,
0.0,
v68,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v79.origin = (cocos2d::CCPoint)&v75;
v75 = 0;
v76 = 0;
v77 = 15;
*(_QWORD *)&v75 = sub_14003AA10(0x20u);
v76 = 23;
v77 = 31;
strcpy((char *)v75, "Use nearby as reference");
cocos2d::CCPoint::CCPoint(1.9435215e-19, 0.0);
v69 = cocos2d::CCPoint::operator+(v78, &v73);
cocos2d::CCPoint::CCPoint(*(float *)&v69, 8.0);
GameToolbox::createToggleButton(
(const char *)&v75,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onNearbyReference,
a1->m_useNearby,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v73,
a1,
a1->m_mainLayer,
0.60000002,
0.34999999,
0.0,
v70,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
v79.origin = (cocos2d::CCPoint)&v75;
v76 = 11;
v77 = 15;
*(_QWORD *)&v75 = 0x6C656420746E6F44LL;
*((_QWORD *)&v75 + 1) = 6648933;
cocos2d::CCPoint::CCPoint(7.5562951e31, 0.0);
v71 = cocos2d::CCPoint::operator+(v78, &v73);
cocos2d::CCPoint::CCPoint(*(float *)&v71, 8.0);
GameToolbox::createToggleButton(
(const char *)&v75,
(cocos2d::SEL_MenuHandler *)SetupSmartBlockLayer::onDontDelete,
a1->m_dontDelete,
a1->m_buttonMenu,
(struct cocos2d::CCPoint)&v73,
a1,
a1->m_mainLayer,
0.60000002,
0.34999999,
0.0,
v72,
(const char *)&qword_14052A4D8,
0,
0,
nullptr);
a1->m_joystickConnected = -1;
return 1;
}