//
// ButtonSprite::updateSpriteBGSize from 0x100092600 to 0x100092a23 (1059 bytes)
//
// 3 xrefs:
// > ButtonSprite::init @ 0x1000925de
// > ButtonSprite::updateBGImage @ 0x10009336d
// > ButtonSprite::updateSpriteOffset @ 0x1000933ae
//
// 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; // xmm0_4
cocos2d::extension::CCScale9Sprite *m_BGSprite; // r14
float v4; // xmm0_4
double v5; // xmm0_8
float v6; // xmm1_4
cocos2d::CCSprite *m_subBGSprite; // rdi
_BYTE *v8; // rsi
__int64 v9; // rax
cocos2d::CCSprite *m_subSprite; // r14
void *v11; // r14
__int64 v12; // rax
const void *v13; // rax
__int64 v14; // r14
__int64 v15; // rax
__int64 v16; // rax
float v17[4]; // [rsp+Ch] [rbp-54h] BYREF
_BYTE v18[4]; // [rsp+1Ch] [rbp-44h] BYREF
float v19; // [rsp+20h] [rbp-40h]
_BYTE v20[12]; // [rsp+24h] [rbp-3Ch] BYREF
float v21; // [rsp+30h] [rbp-30h]
_BYTE v22[8]; // [rsp+34h] [rbp-2Ch] BYREF
float v23; // [rsp+3Ch] [rbp-24h]
float v24; // [rsp+40h] [rbp-20h]
float m_minWidth; // [rsp+44h] [rbp-1Ch]
if ( a1->m_absolute )
{
m_width = a1->m_width;
}
else
{
m_minWidth = a1->m_minWidth;
v24 = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite);
if ( (float)(((float (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite) * v24) <= m_minWidth )
{
m_width = a1->m_minWidth;
}
else
{
m_minWidth = *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite);
m_width = ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite) * m_minWidth;
}
}
m_minWidth = m_width;
sub_10028CF90(v22);
m_BGSprite = a1->m_BGSprite;
if ( m_BGSprite )
{
m_minWidth = m_minWidth + 8.0;
sub_10028CC00(v20, 0.0, 0.0, 40.0, 40.0);
v24 = v21;
v23 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite) + 4);
v4 = ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite);
if ( (float)((float)(v4 * v23) + 8.0) <= v24 )
{
sub_10028CC00(v17, 0.0, 0.0, 40.0, 40.0);
v6 = v17[3];
}
else
{
v24 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite)
+ 4);
v5 = ((double (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite);
v6 = (float)(*(float *)&v5 * v24) + 8.0;
}
sub_10028CBF0(v18, m_minWidth, v6);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, _BYTE *))m_BGSprite->setContentSize)(m_BGSprite, v18);
m_minWidth = *(float *)((__int64 (__fastcall *)(cocos2d::extension::CCScale9Sprite *))a1->m_BGSprite->getContentSize)(a1->m_BGSprite);
v9 = ((__int64 (__fastcall *)(cocos2d::extension::CCScale9Sprite *))a1->m_BGSprite->getContentSize)(a1->m_BGSprite);
sub_10028CBF0(v20, m_minWidth, *(float *)(v9 + 4));
v8 = v20;
goto LABEL_13;
}
m_subBGSprite = a1->m_subBGSprite;
if ( m_subBGSprite )
{
v8 = (_BYTE *)((__int64 (__fastcall *)(cocos2d::CCSprite *))m_subBGSprite->getContentSize)(m_subBGSprite);
LABEL_13:
sub_10028CFF0(v22, v8);
}
((void (__fastcall *)(ButtonSprite *, _BYTE *))a1->setContentSize)(a1, v22);
m_subSprite = a1->m_subSprite;
m_minWidth = *(float *)((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) * 0.5;
sub_10028CBE0(v17, 0.0, 2.0);
m_minWidth = (float)(m_minWidth + v17[0]) + a1->m_spritePosition.x;
v24 = *(float *)(((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) + 4) * 0.5;
sub_10028CBE0(v18, 0.0, 2.0);
sub_10028CBE0(v20, m_minWidth, (float)(v24 + v19) + a1->m_spritePosition.y);
((void (__fastcall *)(cocos2d::CCSprite *, _BYTE *))m_subSprite->setPosition)(m_subSprite, v20);
v11 = a1->m_BGSprite;
if ( v11 || (v11 = a1->m_subBGSprite) != nullptr )
{
m_minWidth = *(float *)((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) * 0.5;
v12 = ((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1);
sub_10028CBE0(v20, m_minWidth, *(float *)(v12 + 4) * 0.5);
(*(void (__fastcall **)(void *, _BYTE *))(*(_QWORD *)v11 + 184LL))(v11, v20);
}
if ( ((__int64 (__fastcall *)(ButtonSprite *))a1->getParent)(a1) )
{
v13 = (const void *)((__int64 (__fastcall *)(ButtonSprite *))a1->getParent)(a1);
if ( v13 )
{
if ( __dynamic_cast(
v13,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCNode,
(const struct __class_type_info *)&`typeinfo for'CCMenuItemSpriteExtra,
0) )
{
v14 = ((__int64 (__fastcall *)(ButtonSprite *))a1->getParent)(a1);
v15 = ((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v14 + 304LL))(v14, v15);
m_minWidth = *(float *)((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1) * 0.5;
v16 = ((__int64 (__fastcall *)(ButtonSprite *))a1->getContentSize)(a1);
sub_10028CBE0(v20, m_minWidth, 0.5 * *(float *)(v16 + 4));
((void (__fastcall *)(ButtonSprite *, _BYTE *))a1->setPosition)(a1, v20);
}
}
}
}