//
// EditButtonBar::loadFromItems from 0x100420ebc to 0x1004213ec (1328 bytes)
//
// 3 xrefs:
// > EditorUI::reloadCustomItems @ 0x1003e8b18
// > EditButtonBar::init @ 0x100420e9c
// > EditButtonBar::reloadItems @ 0x100421400
//
// 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 EditButtonBar::loadFromItems(EditButtonBar *a1, cocos2d::CCArray *a2, int a3, int a4, bool a5)
{
BoomScrollLayer *m_scrollLayer; // x8
int m_page; // w21
cocos2d::CCArray *m_buttonArray; // x0
unsigned int v12; // w24
__int64 v13; // x0
cocos2d::CCDirector *v14; // x0
cocos2d::CCTouchDispatcher *v15; // x0
cocos2d::CCDirector *v16; // x0
cocos2d::CCObject *v17; // x24
AppDelegate *v18; // x0
__n128 v19; // q3
float v20; // s0
float v21; // s2
float32x2_t v22; // d0
float32x2_t v23; // d1
float32x2_t v24; // d0
float v25; // s8
unsigned int v26; // w26
unsigned int v27; // w27
unsigned int v28; // w20
__int64 v29; // x25
__int64 v30; // x28
__int64 v31; // x0
cocos2d::CCObject *v32; // x28
float v33; // s8
unsigned int v34; // w23
cocos2d::CCArray *v35; // x25
float v36; // s2
cocos2d::CCArray *m_pagesArray; // x22
bool v38; // w2
BoomScrollLayer *v39; // x0
__n128 v40; // q0
BoomScrollLayer *v41; // x22
__n128 v42; // q1
cocos2d::CCMenu *v43; // x22
cocos2d::CCSprite *v44; // x23
CCMenuItemSpriteExtra *v45; // x23
__n128 v46; // q0
float v47; // s11
__n128 v48; // q1
float v49; // s8
cocos2d::CCSprite *v50; // x24
CCMenuItemSpriteExtra *v51; // x24
__n128 v52; // q0
__n128 v53; // q1
float v54; // [xsp+0h] [xbp-C0h]
__n128 v55; // [xsp+10h] [xbp-B0h]
float v56; // [xsp+20h] [xbp-A0h]
_BOOL4 v57; // [xsp+34h] [xbp-8Ch]
cocos2d::CCPoint v58; // [xsp+38h] [xbp-88h] BYREF
__int64 v59; // [xsp+40h] [xbp-80h] BYREF
float v60; // [xsp+48h] [xbp-78h]
cocos2d::CCPoint v61; // 0:kr08_8.8
cocos2d::CCPoint v62; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v63; // 0:x3.16
cocos2d::SEL_MenuHandler v64; // 0:x3.16
cocos2d::CCPoint v65; // 0:s0.4,4:s1.4
cocos2d::CCPoint v66; // 0:s0.4,4:s1.4
v57 = a5;
m_scrollLayer = a1->m_scrollLayer;
if ( m_scrollLayer )
m_page = m_scrollLayer->m_page;
else
m_page = 0;
cocos2d::CCObject::retain(a2);
m_buttonArray = a1->m_buttonArray;
if ( m_buttonArray )
{
if ( (unsigned int)sub_10024A36C((__int64)m_buttonArray) )
{
v12 = 0;
do
{
v13 = sub_10024A388((__int64)a1->m_buttonArray, v12);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v13 + 512LL))(v13, 0);
++v12;
}
while ( v12 < (unsigned int)sub_10024A36C((__int64)a1->m_buttonArray) );
}
cocos2d::CCObject::release(a1->m_buttonArray);
}
a1->m_buttonArray = a2;
if ( a1->m_scrollLayer )
{
v14 = cocos2d::CCDirector::sharedDirector();
v15 = (cocos2d::CCTouchDispatcher *)((__int64 (__fastcall *)(cocos2d::CCDirector *))v14->getTouchDispatcher)(v14);
cocos2d::CCTouchDispatcher::unregisterForcePrio(v15, a1->m_scrollLayer);
((void (__fastcall *)(BoomScrollLayer *))a1->m_scrollLayer->removeMeAndCleanup)(a1->m_scrollLayer);
a1->m_scrollLayer = nullptr;
}
sub_10024A45C((__int64)a1->m_pagesArray);
((void (__fastcall *)(EditButtonBar *))a1->removeAllChildren)(a1);
a1->m_scrollLayer = nullptr;
v16 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v16);
v17 = sub_10024A15C();
sub_10024A15C();
sub_10024A2D0((__int64)v17);
v18 = AppDelegate::get();
v20 = 50.0;
if ( !v18->m_startupScriptFilename.m_data.m_short.shortStorage.__elems_[4] )
v20 = 0.0;
v21 = (float)(v60 + -240.0) - v20;
v19.n128_u64[0] = (unsigned __int64)vcvt_f32_s32((int32x2_t)__PAIR64__(a3, a4));
v22 = (float32x2_t)vadd_s32(vshl_n_s32((int32x2_t)__PAIR64__(a3, a4), 2u), (int32x2_t)0x300000003LL);
v23 = vcvt_f32_s32((int32x2_t)v22);
v22.i32[0] = 1117519872;
v22.i32[0] = vdup_lane_s32((int32x2_t)v22, 0).u32[0];
v55 = v19;
v56 = v21;
v22.f32[1] = v21;
v54 = v23.f32[0];
v24 = vdiv_f32(vdiv_f32(vsub_f32(v22, v23), (float32x2_t)v19.n128_u64[0]), (float32x2_t)vdup_n_s32(0x42200000u));
if ( v24.f32[0] <= v24.f32[1] )
v25 = v24.f32[0];
else
v25 = v24.f32[1];
if ( (unsigned int)sub_10024A36C((__int64)a2) )
{
v26 = 0;
v27 = 0;
v28 = a4 * a3;
do
{
v29 = sub_10024A388((__int64)a2, v27);
v30 = sub_10024A388((__int64)v17, v26);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v29 + 160LL))(v29, v25);
*(float *)(v29 + 404) = v25;
if ( a1->m_hasCreateItems )
{
*(_DWORD *)(v29 + 532) = v26;
*(_DWORD *)(v29 + 536) = a1->m_tabIndex;
}
if ( (unsigned int)sub_10024A36C(v30) >= v28 )
{
v32 = sub_10024A15C();
sub_10024A2D0((__int64)v32);
++v26;
v31 = (__int64)v17;
}
else
{
v31 = v30;
}
sub_10024A2D0(v31);
++v27;
}
while ( v27 < (unsigned int)sub_10024A36C((__int64)a2) );
}
v33 = v25 * 40.0;
if ( (unsigned int)sub_10024A36C((__int64)v17) )
{
v34 = 0;
do
{
v35 = (cocos2d::CCArray *)sub_10024A388((__int64)v17, v34);
sub_1000229B8(&v59, (__int64 *)&a1->m_position);
v65.x = v33;
ButtonPage::create(v35, v65, (int)&v59, v36);
sub_10024A2D0((__int64)a1->m_pagesArray);
++v34;
}
while ( v34 < (unsigned int)sub_10024A36C((__int64)v17) );
}
m_pagesArray = a1->m_pagesArray;
v38 = (unsigned int)sub_10024A36C((__int64)m_pagesArray) > 1;
v39 = BoomScrollLayer::create_1(m_pagesArray, 0, v38);
a1->m_scrollLayer = v39;
v39->m_pagesInvisible = 1;
BoomScrollLayer::setDotScale(v39, 0.4);
v40 = ((__n128 (__fastcall *)(EditButtonBar *, BoomScrollLayer *))a1->addChild)(a1, a1->m_scrollLayer);
v41 = a1->m_scrollLayer;
v40.n128_f32[0] = v60 * 0.5;
v42.n128_u32[0] = 2.0;
sub_100022980(v40, v42, &v59);
BoomScrollLayer::setPagesIndicatorPosition(v41, v66);
((void (__fastcall *)(BoomScrollLayer *, _QWORD))a1->m_scrollLayer->setTouchEnabled)(a1->m_scrollLayer, 0);
if ( (unsigned int)sub_10024A36C((__int64)a1->m_pagesArray) > 1 )
{
v43 = cocos2d::CCMenu::create();
((void (__fastcall *)(EditButtonBar *, cocos2d::CCMenu *))a1->addChild)(a1, v43);
v44 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v44->setScale)(v44, 0.6);
v63.ptr = (void (__cdecl *)(cocos2d::CCObject *))EditButtonBar::onLeft;
v63.adj = 0;
v45 = CCMenuItemSpriteExtra::create(v44, nullptr, a1, v63);
v46 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v43->addChild)(v43, v45);
v47 = (float)(v56 * 0.5) + 16.0;
v48 = v55;
v49 = a1->m_position.y - (float)((float)(v54 + (float)(v55.n128_f32[0] * v33)) * 0.5);
v46.n128_f32[0] = a1->m_position.x - v47;
v48.n128_f32[0] = v49;
sub_100022980(v46, v48, &v58);
v61 = cocos2d::CCNode::convertToNodeSpace(v43, &v58);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))v45->setPosition)(v45, &v59, v61.x, v61.y);
v50 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v50->setScale)(v50, 0.6);
cocos2d::CCSprite::setFlipX(v50, 1);
v64.ptr = (void (__cdecl *)(cocos2d::CCObject *))EditButtonBar::onRight;
v64.adj = 0;
v51 = CCMenuItemSpriteExtra::create(v50, nullptr, a1, v64);
v52 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v43->addChild)(v43, v51);
v52.n128_f32[0] = v47 + a1->m_position.x;
v53.n128_f32[0] = v49;
sub_100022980(v52, v53, &v58);
v62 = cocos2d::CCNode::convertToNodeSpace(v43, &v58);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))v51->setPosition)(v51, &v59, v62.x, v62.y);
CCMenuItemSpriteExtra::setSizeMult(v45, 1.1);
CCMenuItemSpriteExtra::setSizeMult(v51, 1.1);
}
if ( m_page >= 1 && v57 )
{
BoomScrollLayer::instantMoveToPage(a1->m_scrollLayer, m_page - 1);
BoomScrollLayer::instantMoveToPage(a1->m_scrollLayer, m_page);
}
}