//
// cocos2d::extension::CCControlButton::needsLayout from 0xa9b4ac to 0xa9b9e0 (1332 bytes)
//
// 3 xrefs:
// > ??> @ 0x67b60
// > ??> @ 0x11f51e0
// > ??> @ 0x11fa7f0
//
// 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 cocos2d::extension::CCControlButton::needsLayout(cocos2d::extension::CCControlButton *a1)
{
__int64 v2; // x0
__int64 v3; // x0
void (__fastcall *setLabelAnchorPoint)(cocos2d::extension::CCControlButton *__hidden, cocos2d::CCPoint); // x22
cocos2d::CCObject *v5; // x0
cocos2d::extension::CCControlButton_vtbl *v6; // x0
__int64 v7; // x0
cocos2d::extension::CCControlButton_vtbl *v8; // x2
cocos2d::CCObject *v9; // x0
cocos2d::CCObject *v10; // x22
cocos2d::CCObject *v11; // x1
void (__fastcall ***v12)(void *, const char *); // x24
cocos2d::CCString *v13; // x0
void (__fastcall *v14)(void *, const char *); // x22
const char *CString; // x0
void (__fastcall ***v16)(void *, unsigned int *); // x0
__int64 v17; // x22
void (__fastcall *v18)(__int64, cocos2d::CCPoint *); // x23
const cocos2d::CCSize *v19; // x0
cocos2d::extension::CCScale9Sprite *v20; // x0
cocos2d::extension::CCScale9Sprite *v21; // x22
cocos2d::CCObject *v22; // x1
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
const cocos2d::CCSize *v24; // x0
long double v25; // q0
cocos2d::CCNode *v26; // x0
__int64 v27; // x22
void (__fastcall *v28)(__int64, cocos2d::CCPoint *); // x23
cocos2d::CCNode *v29; // x0
cocos2d::CCNode *v30; // x0
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x22
__int64 v32; // x22
void (__fastcall *v33)(__int64, cocos2d::CCPoint *); // x23
const cocos2d::CCSize *v34; // x0
__int64 v35; // x22
void (__fastcall *v36)(__int64, cocos2d::CCPoint *); // x23
const cocos2d::CCSize *v37; // x0
__int64 v38; // x0
float v39; // [xsp+50h] [xbp+50h]
float v40; // [xsp+50h] [xbp+50h]
float v41; // [xsp+50h] [xbp+50h]
float v42; // [xsp+50h] [xbp+50h]
cocos2d::CCSize v43; // [xsp+68h] [xbp+68h] BYREF
cocos2d::CCPoint v44; // [xsp+70h] [xbp+70h] BYREF
cocos2d::CCRect v45; // [xsp+78h] [xbp+78h] BYREF
cocos2d::CCRect v46; // [xsp+88h] [xbp+88h] BYREF
cocos2d::CCPoint v47; // [xsp+98h] [xbp+98h] BYREF
float v48[2]; // [xsp+A0h] [xbp+A0h] BYREF
if ( !BYTE1(a1[1].m_unknown5) )
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);
setLabelAnchorPoint = a1->setLabelAnchorPoint;
cocos2d::CCPoint::CCPoint(&v47, (const cocos2d::CCPoint *)&a1[1].m_nZOrder);
((void (__fastcall *)(cocos2d::extension::CCControlButton *, cocos2d::CCPoint *))setLabelAnchorPoint)(a1, &v47);
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 *)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);
v8 = a1->cocos2d::extension::CCControl::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
LOWORD(a1[1].m_uID) = v7;
BYTE2(a1[1].m_uID) = BYTE2(v7);
v9 = v8->getTitleLabelForState(a1, a1->m_eState);
v10 = v9;
v11 = *(cocos2d::CCObject **)&a1[1].m_nTag;
if ( v11 != v9 )
{
if ( v9 )
{
cocos2d::CCObject::retain(v9);
v11 = *(cocos2d::CCObject **)&a1[1].m_nTag;
}
if ( v11 )
cocos2d::CCObject::release(v11);
*(_QWORD *)&a1[1].m_nTag = v10;
}
if ( v10 )
{
v12 = (void (__fastcall ***)(void *, 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 ( !v12
|| (v13 = (cocos2d::CCString *)a1[1].cocos2d::extension::CCControl::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable) == nullptr
|| (v14 = **v12,
CString = cocos2d::CCString::getCString(v13),
v14(v12, CString),
(v10 = *(cocos2d::CCObject **)&a1[1].m_nTag) != nullptr) )
{
v16 = (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 ( !v16 )
{
v17 = *(_QWORD *)&a1[1].m_nTag;
goto LABEL_22;
}
(**v16)(v16, &a1[1].m_uID);
v17 = *(_QWORD *)&a1[1].m_nTag;
if ( v17 )
{
LABEL_22:
v18 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v17 + 184LL);
v39 = a1->getContentSize(a1)->width * 0.5;
v19 = a1->getContentSize(a1);
cocos2d::CCPoint::CCPoint(&v47, v39, v19->height * 0.5);
v18(v17, &v47);
}
}
}
v20 = a1->getBackgroundSpriteForState(a1, a1->m_eState);
v21 = v20;
v22 = *(cocos2d::CCObject **)&a1[1].m_uAutoReleaseCount;
if ( v20 != v22 )
{
if ( v20 )
{
cocos2d::CCObject::retain(v20);
v22 = *(cocos2d::CCObject **)&a1[1].m_uAutoReleaseCount;
}
if ( v22 )
cocos2d::CCObject::release(v22);
*(_QWORD *)&a1[1].m_uAutoReleaseCount = v21;
}
if ( v21 )
{
setPosition = v21->setPosition;
v40 = a1->getContentSize(a1)->width * 0.5;
v24 = a1->getContentSize(a1);
cocos2d::CCPoint::CCPoint(&v47, v40, v24->height * 0.5);
setPosition(v21, &v47);
}
cocos2d::CCSize::CCSize(&v43);
v26 = *(cocos2d::CCNode **)&a1[1].m_nTag;
if ( v26 )
{
cocos2d::CCNode::boundingBox(v26);
*(__n128 *)&v25 = cocos2d::CCSize::operator=(&v43, v48);
}
if ( HIBYTE(a1[1].m_uID) )
{
v27 = *(_QWORD *)&a1[1].m_uAutoReleaseCount;
if ( v27 )
{
v28 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v27 + 304LL);
cocos2d::CCSize::CCSize(
(cocos2d::CCSize *)&v47,
(float)(2 * LODWORD(a1[1].m_obAnchorPointInPoints.x)) + v43.width,
(float)(2 * LODWORD(a1[1].m_fSkewY)) + v43.height);
v28(v27, &v47);
}
}
else
{
v38 = *(_QWORD *)&a1[1].m_uAutoReleaseCount;
if ( v38 )
{
(*(void (__fastcall **)(cocos2d::CCPoint *__return_ptr, long double))(*(_QWORD *)v38 + 992LL))(&v47, v25);
if ( v47.x <= 0.0 )
v47.x = v43.width;
if ( v47.y <= 0.0 )
v47.y = v43.height;
(*(void (__fastcall **)(_QWORD, cocos2d::CCPoint *))(**(_QWORD **)&a1[1].m_uAutoReleaseCount + 304LL))(
*(_QWORD *)&a1[1].m_uAutoReleaseCount,
&v47);
}
}
cocos2d::CCRect::CCRect(&v45);
v29 = *(cocos2d::CCNode **)&a1[1].m_nTag;
if ( v29 )
{
cocos2d::CCNode::boundingBox(v29);
cocos2d::CCRect::operator=(&v45, &v47);
}
cocos2d::CCRect::CCRect(&v46);
v30 = *(cocos2d::CCNode **)&a1[1].m_uAutoReleaseCount;
if ( v30 )
{
cocos2d::CCNode::boundingBox(v30);
cocos2d::CCRect::operator=(&v46, &v47);
}
cocos2d::extension::CCControlUtils::CCRectUnion(&v45, &v46);
setContentSize = a1->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v44, v48[0], v48[1]);
setContentSize(a1, (const cocos2d::CCSize *)&v44);
v32 = *(_QWORD *)&a1[1].m_nTag;
if ( v32 )
{
v33 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v32 + 184LL);
v41 = a1->getContentSize(a1)->width * 0.5;
v34 = a1->getContentSize(a1);
cocos2d::CCPoint::CCPoint(&v44, v41, v34->height * 0.5);
v33(v32, &v44);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)&a1[1].m_nTag + 328LL))(*(_QWORD *)&a1[1].m_nTag, 1);
}
v35 = *(_QWORD *)&a1[1].m_uAutoReleaseCount;
if ( v35 )
{
v36 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v35 + 184LL);
v42 = a1->getContentSize(a1)->width * 0.5;
v37 = a1->getContentSize(a1);
cocos2d::CCPoint::CCPoint(&v44, v42, v37->height * 0.5);
v36(v35, &v44);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)&a1[1].m_uAutoReleaseCount + 328LL))(
*(_QWORD *)&a1[1].m_uAutoReleaseCount,
1);
}
}