//
// ButtonSprite::updateSpriteBGSize from 0x10005eedc to 0x10005f294 (952 bytes)
//
// 3 xrefs:
// > ButtonSprite::init @ 0x10005eeb4
// > ButtonSprite::updateBGImage @ 0x10005fa84
// > ButtonSprite::updateSpriteOffset @ 0x10005fabc
//
// 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 ButtonSprite::updateSpriteBGSize(ButtonSprite *a1)
{
float m_width; // s8
float m_minWidth; // s8
float v4; // s9
float v5; // s8
__n128 v6; // q0
cocos2d::extension::CCScale9Sprite *m_BGSprite; // x20
float v8; // s8
float v9; // s10
float v10; // s11
float v11; // s10
float v12; // s1
cocos2d::CCSprite *m_subBGSprite; // x0
double *v14; // x1
float v15; // s8
__int64 v16; // x0
cocos2d::CCSprite *m_subSprite; // x20
float v18; // s8
__n128 v19; // q0
__n128 v20; // q1
float v21; // s8
float v22; // s10
__n128 v23; // q0
__n128 v24; // q1
__n128 v25; // q1
__n128 v26; // q0
void *v27; // x20
float v28; // s8
__n128 v29; // q1
__n128 v30; // q0
const void *v31; // x0
__int64 v32; // x20
__int64 v33; // x0
float v34; // s8
__n128 v35; // q1
__n128 v36; // q0
float v37[4]; // [xsp+0h] [xbp-60h] BYREF
float v38[4]; // [xsp+10h] [xbp-50h] BYREF
float v39[2]; // [xsp+20h] [xbp-40h] BYREF
__int64 v40; // [xsp+28h] [xbp-38h] BYREF
if ( a1->m_absolute )
{
m_width = a1->m_width;
}
else
{
m_minWidth = a1->m_minWidth;
v4 = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite);
if ( m_minWidth >= (float)(v4
* ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite)) )
{
m_width = a1->m_minWidth;
}
else
{
v5 = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite);
m_width = v5 * ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite);
}
}
sub_100022AF4(&v40);
m_BGSprite = a1->m_BGSprite;
if ( m_BGSprite )
{
v8 = m_width + 8.0;
sub_100022990(v38, 0.0, 0.0, 40.0, 40.0);
v9 = v38[3];
v10 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite) + 4);
if ( v9 >= (float)((float)(v10
* ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite))
+ 8.0) )
{
sub_100022990(v37, 0.0, 0.0, 40.0, 40.0);
v12 = v37[3];
}
else
{
v11 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite)
+ 4);
v12 = (float)(v11 * ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite)) + 8.0;
}
sub_100022988(v39, v8, v12);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))m_BGSprite->setContentSize)(m_BGSprite, v39);
v15 = *(float *)((__int64 (__fastcall *)(cocos2d::extension::CCScale9Sprite *))a1->m_BGSprite->getContentSize)(a1->m_BGSprite);
v16 = ((__int64 (__fastcall *)(cocos2d::extension::CCScale9Sprite *))a1->m_BGSprite->getContentSize)(a1->m_BGSprite);
sub_100022988(v38, v15, *(float *)(v16 + 4));
v14 = (double *)v38;
goto LABEL_13;
}
m_subBGSprite = a1->m_subBGSprite;
if ( m_subBGSprite )
{
v14 = (double *)((__int64 (__fastcall *)(cocos2d::CCSprite *))m_subBGSprite->getContentSize)(m_subBGSprite);
LABEL_13:
v6.n128_f64[0] = sub_100022B14(&v40, v14);
}
((void (__fastcall *)(ButtonSprite *, __int64 *, __n128))a1->setContentSize)(a1, &v40, v6);
m_subSprite = a1->m_subSprite;
v18 = *(float *)((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) * 0.5;
v19.n128_u32[0] = 0;
v20.n128_u32[0] = 2.0;
sub_100022980(v19, v20, v37);
v21 = (float)(v18 + v37[0]) + a1->m_spritePosition.x;
v22 = *(float *)(((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) + 4) * 0.5;
v23.n128_u32[0] = 0;
v24.n128_u32[0] = 2.0;
sub_100022980(v23, v24, v39);
v25.n128_f32[0] = (float)(v22 + v39[1]) + a1->m_spritePosition.y;
v26.n128_f32[0] = v21;
sub_100022980(v26, v25, v38);
((void (__fastcall *)(cocos2d::CCSprite *, float *))m_subSprite->setPosition)(m_subSprite, v38);
v27 = a1->m_BGSprite;
if ( v27 || (v27 = a1->m_subBGSprite) != nullptr )
{
v28 = *(float *)((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) * 0.5;
v29.n128_f32[0] = *(float *)(((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) + 4) * 0.5;
v30.n128_f32[0] = v28;
sub_100022980(v30, v29, v38);
(*(void (__fastcall **)(void *, float *))(*(_QWORD *)v27 + 184LL))(v27, v38);
}
if ( ((__int64 (__fastcall *)(ButtonSprite *))a1->getParent)(a1) )
{
v31 = (const void *)((__int64 (__fastcall *)(ButtonSprite *))a1->getParent)(a1);
if ( v31 )
{
if ( __dynamic_cast(
v31,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
(const struct __class_type_info *)&`typeinfo for'CCMenuItemSpriteExtra,
0) )
{
v32 = ((__int64 (__fastcall *)(ButtonSprite *))a1->getParent)(a1);
v33 = ((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v32 + 304LL))(v32, v33);
v34 = *(float *)((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) * 0.5;
v35.n128_f32[0] = *(float *)(((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) + 4) * 0.5;
v36.n128_f32[0] = v34;
sub_100022980(v36, v35, v38);
((void (__fastcall *)(ButtonSprite *, float *))a1->setPosition)(a1, v38);
}
}
}
}