//
// ButtonSprite::init from 0x10005ec88 to 0x10005eedc (596 bytes)
//
// 1 xrefs:
// > ButtonSprite::create @ 0x10005ec2c
//
// 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 ButtonSprite::init(
ButtonSprite *a1,
cocos2d::CCSprite *a2,
int a3,
int a4,
float a5,
float a6,
bool a7,
const char *a8,
bool a9)
{
_BOOL4 v18; // w20
cocos2d::CCSprite *m_BGSprite; // x1
cocos2d::extension::CCScale9Sprite *v20; // x21
__n128 v21; // q0
float m_width; // s9
cocos2d::CCSprite *m_subSprite; // x21
float *v24; // x0
float v25; // s9
cocos2d::CCSprite *v26; // x21
__int64 v27; // x0
cocos2d::CCSprite *v28; // x21
float v30[4]; // [xsp+0h] [xbp-60h] BYREF
cocos2d::CCRect v31; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v18 = cocos2d::CCSprite::init(a1);
if ( v18 )
{
a1->m_mode = 0;
a1->m_width = (float)a3;
a1->m_minWidth = (float)a4;
a1->m_scale = a6;
a1->m_absolute = a7;
a1->m_subSprite = a2;
((void (__fastcall *)(ButtonSprite *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, a2, 1);
if ( a9 )
{
m_BGSprite = cocos2d::CCSprite::create(a8);
a1->m_subBGSprite = m_BGSprite;
}
else
{
sub_100022990(v30, 0.0, 0.0, 40.0, 40.0);
v20 = cocos2d::extension::CCScale9Sprite::create(a8, v31);
a1->m_BGSprite = v20;
sub_100022988(v30, 16.0, 16.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v20->setContentSize)(v20, v30);
m_BGSprite = (cocos2d::CCSprite *)a1->m_BGSprite;
}
((void (__fastcall *)(ButtonSprite *, cocos2d::CCSprite *, _QWORD))a1->addChild_0)(a1, m_BGSprite, 0);
v21.n128_u32[0] = LODWORD(a1->m_width);
if ( v21.n128_f32[0] > 0.0 )
{
v21.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite);
m_width = a1->m_width;
if ( v21.n128_f32[0] > m_width )
{
m_subSprite = a1->m_subSprite;
v24 = (float *)((__int64 (__fastcall *)(cocos2d::CCSprite *, float))m_subSprite->getContentSize)(
m_subSprite,
v21.n128_f32[0]);
((void (__fastcall *)(cocos2d::CCSprite *, float))m_subSprite->setScale)(m_subSprite, m_width / *v24);
}
}
if ( a5 > 0.0
&& *(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *, __n128))a1->m_subSprite->getContentSize)(
a1->m_subSprite,
v21)
+ 4) > a5 )
{
v25 = a5
/ *(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getContentSize)(a1->m_subSprite)
+ 4);
if ( v25 < ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite) )
{
v26 = a1->m_subSprite;
v27 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v26->getContentSize)(v26);
((void (__fastcall *)(cocos2d::CCSprite *, float))v26->setScale)(v26, a5 / *(float *)(v27 + 4));
}
}
v28 = a1->m_subSprite;
if ( ((float (__fastcall *)(cocos2d::CCSprite *))v28->getScale)(v28) <= a1->m_scale )
((void (__fastcall *)(cocos2d::CCSprite *))a1->m_subSprite->getScale)(a1->m_subSprite);
((void (__fastcall *)(cocos2d::CCSprite *))v28->setScale)(v28);
ButtonSprite::updateSpriteBGSize(a1);
}
return v18;
}