//
// cocos2d::extension::CCControlButton::needsLayout from 0x1003549c0 to 0x100354ed4 (1300 bytes)
//
// 2 xrefs:
// > ??> @ 0x100916128
// > ??> @ 0x100947870
//
// 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
//
void __fastcall cocos2d::extension::CCControlButton::needsLayout(cocos2d::extension::CCControlButton *a1)
{
__int64 v2; // rdi
__int64 v3; // rdi
double v4; // xmm0_8
cocos2d::CCObject *v5; // rdi
cocos2d::extension::CCControlButton_vtbl *v6; // rax
__int64 v7; // rax
cocos2d::CCObject *v8; // rax
cocos2d::CCObject *v9; // rdi
cocos2d::CCObject *v10; // r14
void (__fastcall ***v11)(_QWORD, const char *); // rax
cocos2d::CCString *v12; // rdi
void (__fastcall ***v13)(_QWORD, const char *); // r15
const char *CString; // rax
void (__fastcall ***v15)(void *, unsigned int *); // rax
__int64 v16; // rax
cocos2d::CCObject *v17; // rax
cocos2d::CCObject *v18; // rdi
cocos2d::CCObject *v19; // r14
__int64 v20; // rax
__int64 *v21; // r14
__int64 v22; // rax
__int64 *v23; // rdi
__int64 v24; // r14
__int64 v25; // rax
__int64 v26; // r14
__int64 v27; // rax
__m128 v28; // [rsp-64h] [rbp-64h] BYREF
cocos2d::CCRect v29; // [rsp-54h] [rbp-54h] BYREF
float v30; // [rsp-44h] [rbp-44h] BYREF
__int64 v31; // [rsp-3Ch] [rbp-3Ch] BYREF
__m128 v32; // [rsp-34h] [rbp-34h] BYREF
float v33; // [rsp-24h] [rbp-24h]
if ( BYTE1(a1[1].m_unknown5) != 1 )
return;
v2 = *(_QWORD *)&a1[1].m_nTag;
if ( v2 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v2 + 328LL))(v2, 0);
v3 = *(_QWORD *)&a1[1].m_uAutoReleaseCount;
if ( v3 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v3 + 328LL))(v3, 0);
v4 = sub_10028CC60(&v32, (double *)&a1[1].m_nZOrder);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, __m128 *, double))a1->setLabelAnchorPoint)(a1, &v32, v4);
v5 = (cocos2d::CCObject *)a1[1].cocos2d::extension::CCControl::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( v5 )
cocos2d::CCObject::release(v5);
v6 = (cocos2d::extension::CCControlButton_vtbl *)((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD))a1->getTitleForState)(
a1,
a1->m_eState);
a1[1].cocos2d::extension::CCControl::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable = v6;
if ( v6 )
cocos2d::CCObject::retain((cocos2d::CCObject *)v6);
v7 = ((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD))a1->getTitleColorForState)(
a1,
a1->m_eState);
LOWORD(a1[1].m_uID) = v7;
BYTE2(a1[1].m_uID) = BYTE2(v7);
v8 = (cocos2d::CCObject *)((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD))a1->getTitleLabelForState)(
a1,
a1->m_eState);
v9 = *(cocos2d::CCObject **)&a1[1].m_nTag;
if ( v9 == v8 )
{
v10 = *(cocos2d::CCObject **)&a1[1].m_nTag;
if ( !v9 )
goto LABEL_24;
goto LABEL_18;
}
v10 = v8;
if ( v8 )
{
cocos2d::CCObject::retain(v8);
v9 = *(cocos2d::CCObject **)&a1[1].m_nTag;
}
if ( v9 )
cocos2d::CCObject::release(v9);
*(_QWORD *)&a1[1].m_nTag = v10;
if ( v10 )
{
LABEL_18:
v11 = (void (__fastcall ***)(_QWORD, const char *))__dynamic_cast(
v10,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCLabelProtocol,
-2);
if ( !v11
|| (v12 = (cocos2d::CCString *)a1[1].cocos2d::extension::CCControl::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable) == nullptr
|| (v13 = v11,
CString = cocos2d::CCString::getCString(v12),
(**v13)(v13, CString),
(v10 = *(cocos2d::CCObject **)&a1[1].m_nTag) != nullptr) )
{
v15 = (void (__fastcall ***)(void *, unsigned int *))__dynamic_cast(
v10,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCRGBAProtocol,
-2);
if ( !v15 || ((**v15)(v15, &a1[1].m_uID), (v10 = *(cocos2d::CCObject **)&a1[1].m_nTag) != nullptr) )
{
v33 = *(float *)((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *))a1->getContentSize)(a1) * 0.5;
v16 = ((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *))a1->getContentSize)(a1);
sub_10028CBE0(v32.f32, v33, 0.5 * *(float *)(v16 + 4));
((void (__fastcall *)(cocos2d::CCObject *, __m128 *))v10->__vftable[2].isEqual)(v10, &v32);
}
}
}
LABEL_24:
v17 = (cocos2d::CCObject *)((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *, _QWORD))a1->getBackgroundSpriteForState)(
a1,
a1->m_eState);
v18 = *(cocos2d::CCObject **)&a1[1].m_uAutoReleaseCount;
if ( v18 == v17 )
{
v19 = *(cocos2d::CCObject **)&a1[1].m_uAutoReleaseCount;
if ( v18 )
{
LABEL_30:
v33 = *(float *)((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *))a1->getContentSize)(a1) * 0.5;
v20 = ((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *))a1->getContentSize)(a1);
sub_10028CBE0(v32.f32, v33, 0.5 * *(float *)(v20 + 4));
((void (__fastcall *)(cocos2d::CCObject *, __m128 *))v19->__vftable[2].isEqual)(v19, &v32);
}
}
else
{
v19 = v17;
if ( v17 )
{
cocos2d::CCObject::retain(v17);
v18 = *(cocos2d::CCObject **)&a1[1].m_uAutoReleaseCount;
}
if ( v18 )
cocos2d::CCObject::release(v18);
*(_QWORD *)&a1[1].m_uAutoReleaseCount = v19;
if ( v19 )
goto LABEL_30;
}
sub_10028CF90(&v31);
if ( *(_QWORD *)&a1[1].m_nTag )
{
cocos2d::CCNode::boundingBox((cocos2d::CCNode *)&v32);
sub_10028CFF0(&v31, &v32.i64[1]);
}
v21 = *(__int64 **)&a1[1].m_uAutoReleaseCount;
if ( HIBYTE(a1[1].m_uID) == 1 )
{
if ( v21 )
{
sub_10028CBF0(
v32.f32,
(float)(2 * LODWORD(a1[1].m_obAnchorPointInPoints.x)) + *(float *)&v31,
(float)(2 * LODWORD(a1[1].m_fSkewY)) + *((float *)&v31 + 1));
v22 = *v21;
v23 = v21;
LABEL_42:
(*(void (__fastcall **)(__int64 *, __m128 *))(v22 + 304))(v23, &v32);
}
}
else if ( v21 )
{
(*(void (__fastcall **)(__m128 *, _QWORD))(*v21 + 992))(&v32, *(_QWORD *)&a1[1].m_uAutoReleaseCount);
if ( v32.f32[0] <= 0.0 )
v32.i32[0] = v31;
if ( v32.f32[1] <= 0.0 )
v32.i32[1] = HIDWORD(v31);
v23 = *(__int64 **)&a1[1].m_uAutoReleaseCount;
v22 = *v23;
goto LABEL_42;
}
sub_10028D130(&v32);
if ( *(_QWORD *)&a1[1].m_nTag )
{
cocos2d::CCNode::boundingBox((cocos2d::CCNode *)&v28);
sub_10028D1A0(&v32, (unsigned __int64 *)&v28);
}
sub_10028D130(&v28);
if ( *(_QWORD *)&a1[1].m_uAutoReleaseCount )
{
cocos2d::CCNode::boundingBox((cocos2d::CCNode *)&v29);
sub_10028D1A0(&v28, (unsigned __int64 *)&v29);
}
cocos2d::extension::CCControlUtils::CCRectUnion(&v29, (const cocos2d::CCRect *)&v32);
sub_10028CBF0(&v30, v29.size.width, v29.size.height);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, float *))a1->setContentSize)(a1, &v30);
v24 = *(_QWORD *)&a1[1].m_nTag;
if ( v24 )
{
v33 = *(float *)((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *))a1->getContentSize)(a1) * 0.5;
v25 = ((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *))a1->getContentSize)(a1);
sub_10028CBE0(&v30, v33, 0.5 * *(float *)(v25 + 4));
(*(void (__fastcall **)(__int64, float *))(*(_QWORD *)v24 + 184LL))(v24, &v30);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)&a1[1].m_nTag + 328LL))(*(_QWORD *)&a1[1].m_nTag, 1);
}
v26 = *(_QWORD *)&a1[1].m_uAutoReleaseCount;
if ( v26 )
{
v33 = *(float *)((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *))a1->getContentSize)(a1) * 0.5;
v27 = ((__int64 (__fastcall *)(cocos2d::extension::CCControlButton *))a1->getContentSize)(a1);
sub_10028CBE0(&v30, v33, 0.5 * *(float *)(v27 + 4));
(*(void (__fastcall **)(__int64, float *))(*(_QWORD *)v26 + 184LL))(v26, &v30);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)&a1[1].m_uAutoReleaseCount + 328LL))(
*(_QWORD *)&a1[1].m_uAutoReleaseCount,
1);
}
}