//
// EditButtonBar::loadFromItems from 0x73ae50 to 0x73b380 (1328 bytes)
//
// 4 xrefs:
// > EditorUI::reloadCustomItems @ 0x69794c
// > EditButtonBar::init @ 0x73b428
// > EditButtonBar::reloadItems @ 0x73b590
// > ??> @ 0x50358
//
// 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 EditButtonBar::loadFromItems(EditButtonBar *a1, cocos2d::CCArray *a2, int a3, int a4, bool a5)
{
BoomScrollLayer *m_scrollLayer; // x20
cocos2d::CCArray *m_buttonArray; // x0
unsigned int v11; // w22
unsigned int v12; // w1
__int64 v13; // x0
bool v14; // cf
cocos2d::CCArray *v15; // x0
BoomScrollLayer *v16; // x0
cocos2d::CCDirector *v17; // x0
cocos2d::CCTouchDispatcher *v18; // x0
cocos2d::CCDirector *v19; // x0
cocos2d::CCArray *v20; // x0
cocos2d::CCArray *v21; // x21
cocos2d::CCObject *v22; // x0
int v23; // w3
float v24; // s10
float v25; // s12
float v26; // s8
unsigned int v27; // w20
unsigned int v28; // w22
unsigned int v29; // w25
cocos2d::CCObject *v30; // x28
cocos2d::CCArray *v31; // x23
_BOOL4 m_hasCreateItems; // w0
cocos2d::CCArray *v33; // x0
unsigned int v34; // w20
unsigned int v35; // w1
cocos2d::CCArray *v36; // x23
float v37; // s2
ButtonPage *v38; // x0
cocos2d::CCArray *m_pagesArray; // x21
bool v40; // w2
BoomScrollLayer *v41; // x0
BoomScrollLayer *v42; // x21
cocos2d::CCMenu *v43; // x25
cocos2d::CCSprite *v44; // x22
CCMenuItemSpriteExtra *v45; // x22
float v46; // s11
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
float v48; // s10
cocos2d::CCSprite *v49; // x23
CCMenuItemSpriteExtra *v50; // x20
void (__fastcall *v51)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
cocos2d::CCArray *v52; // x23
int m_page; // [xsp+98h] [xbp+98h]
_BOOL4 v54; // [xsp+9Ch] [xbp+9Ch]
float v55; // [xsp+A0h] [xbp+A0h]
cocos2d::CCPoint v56; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCPoint v57; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCPoint v58; // 0:kr08_8.8
cocos2d::CCPoint v59; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v60; // 0:x2.16
cocos2d::SEL_MenuHandler v61; // 0:x2.16
cocos2d::CCPoint v62; // 0:s0.4,4:s1.4
cocos2d::CCPoint v63; // 0:s0.4,4:s1.4
m_scrollLayer = a1->m_scrollLayer;
if ( m_scrollLayer )
{
m_page = m_scrollLayer->m_page;
v54 = a5 && m_page > 0;
}
else
{
v54 = 0;
m_page = 0;
}
cocos2d::CCObject::retain(a2);
m_buttonArray = a1->m_buttonArray;
if ( m_buttonArray )
{
v11 = 0;
while ( 1 )
{
v14 = v11 >= (unsigned int)cocos2d::CCArray::count(m_buttonArray);
v15 = a1->m_buttonArray;
if ( v14 )
break;
v12 = v11++;
v13 = cocos2d::CCArray::objectAtIndex(v15, v12);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v13 + 512LL))(v13, 0);
m_buttonArray = a1->m_buttonArray;
}
cocos2d::CCObject::release(v15);
}
v16 = a1->m_scrollLayer;
a1->m_buttonArray = a2;
if ( v16 )
{
v17 = cocos2d::CCDirector::sharedDirector();
v18 = v17->getTouchDispatcher(v17);
cocos2d::CCTouchDispatcher::unregisterForcePrio(v18, a1->m_scrollLayer);
a1->m_scrollLayer->removeMeAndCleanup(a1->m_scrollLayer);
a1->m_scrollLayer = nullptr;
}
cocos2d::CCArray::removeAllObjects(a1->m_pagesArray);
a1->removeAllChildren(a1);
a1->m_scrollLayer = nullptr;
v19 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v19);
v21 = (cocos2d::CCArray *)cocos2d::CCArray::create(v20);
v22 = (cocos2d::CCObject *)cocos2d::CCArray::create(v21);
cocos2d::CCArray::addObject(v21, v22);
v23 = 4 * (a4 - 1);
v24 = (float)v23;
v25 = (float)a4;
v26 = (float)((float)((float)(v55 - 240.0) - (float)(4 * (a3 - 1))) / (float)a3) / 40.0;
if ( v26 >= (float)((float)((float)(78.0 - (float)v23) / (float)a4) / 40.0) )
v26 = (float)((float)(78.0 - (float)v23) / (float)a4) / 40.0;
v27 = 0;
v28 = 0;
v29 = a3 * a4;
while ( v27 < (unsigned int)cocos2d::CCArray::count(a2) )
{
v30 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(a2, v27);
v31 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v21, v28);
((void (__fastcall *)(cocos2d::CCObject *, float))v30->__vftable[2].copyWithZone)(v30, v26);
m_hasCreateItems = a1->m_hasCreateItems;
*(float *)&v30[7].m_nLuaID = v26;
if ( m_hasCreateItems )
{
v30[8].m_uUnknown = v28;
v30[8].m_unknown2 = a1->m_tabIndex;
}
v33 = (cocos2d::CCArray *)cocos2d::CCArray::count(v31);
if ( (unsigned int)v33 >= v29 )
{
v52 = (cocos2d::CCArray *)cocos2d::CCArray::create(v33);
++v28;
++v27;
cocos2d::CCArray::addObject(v52, v30);
cocos2d::CCArray::addObject(v21, v52);
}
else
{
++v27;
cocos2d::CCArray::addObject(v31, v30);
}
}
v34 = 0;
while ( v34 < (unsigned int)cocos2d::CCArray::count(v21) )
{
v35 = v34++;
v36 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v21, v35);
cocos2d::CCPoint::CCPoint(&v57, &a1->m_position);
v62.x = v26 * 40.0;
v38 = ButtonPage::create(v36, v62, (int)&v57, v37);
cocos2d::CCArray::addObject(a1->m_pagesArray, v38);
}
m_pagesArray = a1->m_pagesArray;
v40 = (unsigned int)cocos2d::CCArray::count(m_pagesArray) > 1;
v41 = BoomScrollLayer::create(m_pagesArray, 0, v40);
a1->m_scrollLayer = v41;
v41->m_pagesInvisible = 1;
BoomScrollLayer::setDotScale(v41, 0.4);
a1->addChild(a1, a1->m_scrollLayer);
v42 = a1->m_scrollLayer;
cocos2d::CCPoint::CCPoint(&v57, v55 * 0.5, 2.0);
BoomScrollLayer::setPagesIndicatorPosition(v42, v63);
a1->m_scrollLayer->setTouchEnabled(a1->m_scrollLayer, 0);
if ( (unsigned int)cocos2d::CCArray::count(a1->m_pagesArray) > 1 )
{
v43 = cocos2d::CCMenu::create();
a1->addChild(a1, v43);
v44 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png");
v44->setScale(v44, 0.6);
v60.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v60.adj = (size_t)EditButtonBar::onLeft;
v45 = CCMenuItemSpriteExtra::create(v44, nullptr, v60);
v43->addChild(v43, v45);
v46 = (float)((float)(v55 - 240.0) * 0.5) + 16.0;
setPosition = v45->setPosition;
v48 = a1->m_position.y - (float)((float)(v24 + (float)(v25 * (float)(v26 * 40.0))) * 0.5);
cocos2d::CCPoint::CCPoint(&v56, a1->m_position.x - v46, v48);
v58 = cocos2d::CCNode::convertToNodeSpace(v43, &v56);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))setPosition)(
v45,
&v57,
v58.x,
v58.y);
v49 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png");
v49->setScale(v49, 0.6);
cocos2d::CCSprite::setFlipX(v49, 1);
v61.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v61.adj = (size_t)EditButtonBar::onRight;
v50 = CCMenuItemSpriteExtra::create(v49, nullptr, v61);
v43->addChild(v43, v50);
v51 = v50->setPosition;
cocos2d::CCPoint::CCPoint(&v56, v46 + a1->m_position.x, v48);
v59 = cocos2d::CCNode::convertToNodeSpace(v43, &v56);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))v51)(v50, &v57, v59.x, v59.y);
CCMenuItemSpriteExtra::setSizeMult(v45, 1.1);
CCMenuItemSpriteExtra::setSizeMult(v50, 1.1);
}
if ( v54 )
{
BoomScrollLayer::instantMoveToPage(a1->m_scrollLayer, m_page - 1);
BoomScrollLayer::instantMoveToPage(a1->m_scrollLayer, m_page);
}
}