//
// GJSmartBlockPreview::addTemplateGuide_1 from 0x100008c9c to 0x1000090b8 (1052 bytes)
//
// 2 xrefs:
// > GJSmartBlockPreview::addTemplateGuide @ 0x100008ab0
// > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x100071de4
//
// 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
//
cocos2d::CCArray *__fastcall GJSmartBlockPreview::addTemplateGuide_1(
GJSmartBlockPreview *a1,
SmartPrefabResult *a2,
float a3)
{
cocos2d::CCArray *v6; // x19
float v7; // s9
__n128 v8; // q1
__n128 v9; // q0
__int16 v10; // w8
GJSmartBlockPreviewSprite *v11; // x22
SmartBlockType v12; // w23
ObjectToolbox *v13; // x0
int v14; // w1
char *v15; // x0
std::string *v16; // x0
cocos2d::CCSprite *v17; // x24
__int64 v18; // x25
unsigned int v19; // w27
SmartBlockType v20; // w28
const std::string::value_type *v21; // x1
std::string *v22; // x0
cocos2d::CCSprite *v23; // x26
std::string::reference v24; // x0
void (__cdecl *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x8
__int64 v26; // x1
float x; // s0
__int64 v30; // [xsp+8h] [xbp-A8h] BYREF
__int64 v31; // [xsp+10h] [xbp-A0h] BYREF
std::string v32; // [xsp+18h] [xbp-98h] BYREF
__int16 v33; // [xsp+34h] [xbp-7Ch] BYREF
char v34; // [xsp+36h] [xbp-7Ah]
_BYTE v35[8]; // [xsp+38h] [xbp-78h] BYREF
cocos2d::CCPoint v36; // 0:kr08_8.8
cocos2d::CCPoint v37; // 0:kr10_8.8
v6 = (cocos2d::CCArray *)sub_10024A15C();
v7 = *(float *)((__int64 (__fastcall *)(GJSmartBlockPreview *))a1->getContentSize)(a1) * 0.5;
v8.n128_f32[0] = *(float *)(((__int64 (__fastcall *)(GJSmartBlockPreview *))a1->getContentSize)(a1) + 4) * 0.5;
v9.n128_f32[0] = v7;
sub_100022980(v9, v8);
v34 = -1;
v33 = -1;
if ( !a2->m_prefabCount )
{
if ( a2->m_smartPrefab )
{
v34 = 0;
v10 = -256;
}
else
{
v34 = 0;
v10 = 255;
}
v33 = v10;
}
v11 = GJSmartBlockPreviewSprite::create();
((void (__fastcall *)(GJSmartBlockPreview *, GJSmartBlockPreviewSprite *))a1->addChild)(a1, v11);
v12 = *std::string::at((std::string *)&a2->m_binaryKey, 0);
v13 = ObjectToolbox::sharedState();
if ( (unsigned int)(v12 - 50) > 0x1A )
v14 = 2895;
else
v14 = *(_DWORD *)&aP_3[4 * (unsigned __int8)(v12 - 50)];
v15 = (char *)ObjectToolbox::intKeyToFrame(v13, v14);
sub_100009900((int)&v32, v15);
if ( (v32.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v16 = &v32;
else
v16 = (std::string *)v32.__r_.__value_.__r.__words[0];
v17 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v16);
GJSmartTemplate::applyTransformationsForType(v12, v17);
((void (__fastcall *)(cocos2d::CCSprite *, __int16 *))v17->setColor)(v17, &v33);
v36 = GJSmartTemplate::offsetForType(v12);
sub_1000229DC(&v31, v35, &v30, v36.x, v36.y);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v17->setPosition)(v17, &v31);
((void (__fastcall *)(GJSmartBlockPreviewSprite *, cocos2d::CCSprite *, _QWORD))v11->addChild_0)(v11, v17, 0);
((void (__fastcall *)(cocos2d::CCSprite *))v17->setOpacity)(v17);
sub_10024A2D0(v6, v17);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v17->setTag)(v17, 0);
v18 = -8;
do
{
v19 = v18 + 9;
v20 = *std::string::at((std::string *)&a2->m_binaryKey, v18 + 9);
if ( !GJSmartTemplate::shouldDiscardObject(v20, (GJSmartDirection)(v18 + 9)) )
{
v21 = "smartBlock01b_001.png";
if ( (unsigned int)(v20 - 50) < 0x1B )
v21 = off_100762430[(unsigned __int8)(v20 - 50)];
std::string::assign(&v32, v21);
if ( (v32.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v22 = &v32;
else
v22 = (std::string *)v32.__r_.__value_.__r.__words[0];
v23 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v22);
GJSmartTemplate::applyTransformationsForType(v20, v23);
((void (__fastcall *)(GJSmartBlockPreviewSprite *, cocos2d::CCSprite *, _QWORD))v11->addChild_0)(v11, v23, 0);
v37 = GJSmartTemplate::offsetForType(v20);
x = v37.x;
if ( v19 <= 6 && ((1 << v19) & 0x62) != 0 )
{
x = *((float *)&v31 + 1) + 30.0;
*((float *)&v31 + 1) = *((float *)&v31 + 1) + 30.0;
}
if ( v19 <= 8 && ((1 << v19) & 0x184) != 0 )
{
x = *((float *)&v31 + 1) + -30.0;
*((float *)&v31 + 1) = *((float *)&v31 + 1) + -30.0;
}
if ( v18 == -4 || (v19 & 0xB) == 3 )
{
x = *(float *)&v31 + -30.0;
*(float *)&v31 = *(float *)&v31 + -30.0;
}
if ( v18 == -1 || (v19 & 0xD) == 4 )
{
x = *(float *)&v31 + 30.0;
*(float *)&v31 = *(float *)&v31 + 30.0;
}
sub_1000229DC(&v30, v35, &v31, x, v37.y);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v23->setPosition)(v23, &v30);
v24 = std::string::at((std::string *)&a1->m_prefabKey, v18 + 9);
setColor = v23->setColor;
if ( *v24 == 48 )
{
((void (__fastcall *)(cocos2d::CCSprite *, void *))setColor)(v23, &unk_100635117);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v23->setOpacity)(v23, (unsigned int)(int)(float)(a3 * 150.0));
v26 = 2;
}
else
{
((void (__fastcall *)(cocos2d::CCSprite *, __int16 *))setColor)(v23, &v33);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v23->setOpacity)(v23, (unsigned int)(int)(float)(a3 * 255.0));
v26 = 1;
}
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v23->setTag)(v23, v26);
sub_10024A2D0(v6, v23);
}
}
while ( !__CFADD__(v18++, 1) );
if ( SHIBYTE(v32.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v32.__r_.__value_.__l.__data_);
return v6;
}