//
// cocos2d::extension::CCControlButton::initWithLabelAndBackgroundSprite from 0x100353610 to 0x100353a0b (1019 bytes)
//
// 2 xrefs:
// > ??> @ 0x100916190
// > ??> @ 0x1009478d8
//
// 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 cocos2d::extension::CCControlButton::initWithLabelAndBackgroundSprite(
cocos2d::extension::CCControlButton *a1,
cocos2d::CCNode *a2,
cocos2d::extension::CCScale9Sprite *a3)
{
bool result; // al
void *v6; // r13
cocos2d::CCDictionary *v7; // rax
cocos2d::CCObject *v8; // rdi
cocos2d::CCDictionary *v9; // r12
cocos2d::CCDictionary *v10; // rax
cocos2d::CCObject *v11; // rdi
cocos2d::CCDictionary *v12; // r12
cocos2d::CCDictionary *v13; // rax
cocos2d::CCObject *v14; // rdi
cocos2d::CCDictionary *v15; // r12
cocos2d::CCDictionary *v16; // rax
cocos2d::CCObject *v17; // rdi
cocos2d::CCDictionary *v18; // r12
cocos2d::CCNode *v19; // rdi
cocos2d::extension::CCScale9Sprite *v20; // rdi
const char *v21; // r12
size_t v22; // rax
size_t v23; // r13
char *v24; // r14
size_t v25; // r15
__int64 v26; // r14
unsigned __int16 *v27; // rax
cocos2d::extension::CCScale9Sprite *v28; // [rsp+0h] [rbp-60h]
void *v29; // [rsp+10h] [rbp-50h]
_QWORD __dst[2]; // [rsp+18h] [rbp-48h] BYREF
void *__p; // [rsp+28h] [rbp-38h]
bool v32; // [rsp+37h] [rbp-29h]
result = cocos2d::extension::CCControl::init(a1);
if ( !result )
return result;
v32 = result;
if ( a2 )
{
v6 = __dynamic_cast(
a2,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCLabelProtocol,
-2);
v29 = __dynamic_cast(
a2,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCRGBAProtocol,
-2);
}
else
{
v6 = nullptr;
v29 = nullptr;
}
BYTE1(a1[1].m_unknown5) = 1;
v7 = cocos2d::CCDictionary::create();
v8 = *(cocos2d::CCObject **)&a1[1].m_fRotationX;
if ( v8 != v7 )
{
v9 = v7;
if ( v7 )
{
cocos2d::CCObject::retain(v7);
v8 = *(cocos2d::CCObject **)&a1[1].m_fRotationX;
}
if ( v8 )
cocos2d::CCObject::release(v8);
*(_QWORD *)&a1[1].m_fRotationX = v9;
}
v10 = cocos2d::CCDictionary::create();
v11 = *(cocos2d::CCObject **)&a1[1].m_fScaleX;
if ( v11 != v10 )
{
v12 = v10;
if ( v10 )
{
cocos2d::CCObject::retain(v10);
v11 = *(cocos2d::CCObject **)&a1[1].m_fScaleX;
}
if ( v11 )
cocos2d::CCObject::release(v11);
*(_QWORD *)&a1[1].m_fScaleX = v12;
}
v13 = cocos2d::CCDictionary::create();
v14 = *(cocos2d::CCObject **)&a1[1].m_fVertexZ;
if ( v14 != v13 )
{
v15 = v13;
if ( v13 )
{
cocos2d::CCObject::retain(v13);
v14 = *(cocos2d::CCObject **)&a1[1].m_fVertexZ;
}
if ( v14 )
cocos2d::CCObject::release(v14);
*(_QWORD *)&a1[1].m_fVertexZ = v15;
}
v16 = cocos2d::CCDictionary::create();
v17 = *(cocos2d::CCObject **)&a1[1].m_obPosition.y;
if ( v17 != v16 )
{
v18 = v16;
if ( v16 )
{
cocos2d::CCObject::retain(v16);
v17 = *(cocos2d::CCObject **)&a1[1].m_obPosition.y;
}
if ( v17 )
cocos2d::CCObject::release(v17);
*(_QWORD *)&a1[1].m_obPosition.y = v18;
}
((void (__fastcall *)(cocos2d::extension::CCControlButton *, __int64))a1->setTouchEnabled)(a1, 1);
LOBYTE(a1[1].m_unknown5) = 0;
LOBYTE(a1[1].m_unknown2) = 1;
a1[1].cocos2d::extension::CCControl::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable = nullptr;
HIBYTE(a1[1].m_uID) = 1;
((void (__fastcall *)(cocos2d::extension::CCControlButton *))a1->needsLayout)(a1);
sub_10028CFC0(__dst, &qword_1009A0AC8);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD *))a1->setPreferredSize)(a1, __dst);
LOBYTE(a1[1].m_unknown2) = 1;
((void (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD))a1->ignoreAnchorPointForPosition)(a1, 0);
sub_10028CBE0((float *)__dst, 0.5, 0.5);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD *))a1->setAnchorPoint)(a1, __dst);
v19 = *(cocos2d::CCNode **)&a1[1].m_nTag;
if ( v19 != a2 )
{
if ( a2 )
{
cocos2d::CCObject::retain(a2);
v19 = *(cocos2d::CCNode **)&a1[1].m_nTag;
}
if ( v19 )
cocos2d::CCObject::release(v19);
*(_QWORD *)&a1[1].m_nTag = a2;
}
v20 = *(cocos2d::extension::CCScale9Sprite **)&a1[1].m_uAutoReleaseCount;
if ( v20 != a3 )
{
if ( a3 )
{
cocos2d::CCObject::retain(a3);
v20 = *(cocos2d::extension::CCScale9Sprite **)&a1[1].m_uAutoReleaseCount;
}
if ( v20 )
cocos2d::CCObject::release(v20);
*(_QWORD *)&a1[1].m_uAutoReleaseCount = a3;
}
BYTE2(__dst[0]) = -1;
LOWORD(__dst[0]) = -1;
((void (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD *))a1->setColor)(a1, __dst);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, __int64))a1->setOpacity)(a1, 255);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, __int64))a1->setOpacityModifyRGB)(a1, 1);
v21 = (const char *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)v6 + 8LL))(v6);
v22 = strlen(v21);
if ( v22 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(COERCE_DOUBLE(1056964608));
v23 = v22;
if ( v22 >= 0x17 )
{
v28 = a3;
v25 = 26;
if ( (v22 | 7) != 0x17 )
v25 = (v22 | 7) + 1;
v24 = (char *)operator new(v25);
__p = v24;
__dst[0] = v25 + 1;
a3 = v28;
__dst[1] = v23;
}
else
{
LOBYTE(__dst[0]) = 2 * v22;
v24 = (char *)__dst + 1;
if ( !v22 )
goto LABEL_49;
}
memmove(v24, v21, v23);
LABEL_49:
v24[v23] = 0;
v26 = sub_1007AB360(__dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, __int64, __int64))a1->setTitleForState)(a1, v26, 1);
v27 = (unsigned __int16 *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)v29 + 8LL))(v29);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD, __int64))a1->setTitleColorForState)(
a1,
*v27 | (*((unsigned __int8 *)v27 + 2) << 16),
1);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, cocos2d::CCNode *, __int64))a1->setTitleLabelForState)(
a1,
a2,
1);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, cocos2d::extension::CCScale9Sprite *, __int64))a1->setBackgroundSpriteForState)(
a1,
a3,
1);
sub_10028CBE0((float *)__dst, 0.5, 0.5);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD *))a1->setLabelAnchorPoint)(a1, __dst);
((void (__fastcall *)(cocos2d::extension::CCControlButton *))a1->needsLayout)(a1);
return v32;
}