//
// EditButtonBar::loadFromItems from 0x1400d45d0 to 0x1400d4eee (2334 bytes)
//
// 5 xrefs:
// > EditButtonBar::create @ 0x1400d4584
// > EditorPauseLayer::onResume @ 0x1400dd7e9
// > EditorPauseLayer::onResume @ 0x1400dd81f
// > EditorUI::reloadCustomItems @ 0x1400e4d51
// > ??> @ 0x1406c8700
//
// 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
//
// Hidden C++ exception states: #wind=3
void EditButtonBar::loadFromItems(EditButtonBar *a1, cocos2d::CCArray *a2, int a3, int a4, bool a5)
{
int v6; // ebx
EditButtonBar *v8; // r14
BoomScrollLayer *m_scrollLayer; // rax
unsigned int v10; // esi
cocos2d::CCArray *m_buttonArray; // rcx
unsigned int v12; // ebx
struct cocos2d::CCObject *v13; // rax
__int64 v14; // rax
cocos2d::CCTouchDispatcher *v15; // rax
__int64 v16; // rcx
cocos2d::CCDirector *v17; // rax
__int64 v18; // rcx
cocos2d::CCArray *v19; // r12
__int64 v20; // rcx
struct cocos2d::CCObject *v21; // rax
unsigned int v22; // ebp
float v23; // xmm14_4
float v24; // xmm8_4
float v25; // xmm13_4
float v26; // xmm15_4
float v27; // xmm6_4
float v28; // xmm12_4
unsigned int v29; // r13d
struct cocos2d::CCObject *v30; // rdi
cocos2d::CCArray *v31; // rbx
__int64 v32; // rcx
struct cocos2d::CCObject *v33; // rdx
cocos2d::CCArray *v34; // rcx
cocos2d::CCArray *v35; // rbx
unsigned int v36; // r13d
const struct cocos2d::CCPoint *p_m_position; // rbx
int v38; // esi
cocos2d::CCArray *v39; // rdi
const struct cocos2d::CCPoint *v40; // rax
const struct cocos2d::CCPoint *v41; // rbx
cocos2d::CCLayer *v42; // r15
float *v43; // rax
float *v44; // rbx
__int64 v45; // rcx
float v46; // xmm9_4
float v47; // xmm7_4
signed int v48; // ebp
cocos2d::CCNode *v49; // r14
cocos2d::CCArray *v50; // r12
int v51; // r13d
int v52; // ebx
struct cocos2d::CCObject *v53; // rsi
cocos2d::CCObject_vtbl *v54; // rbx
struct cocos2d::CCPoint v55; // rax
unsigned int v56; // eax
int v57; // edx
BoomScrollLayer *v58; // rax
BoomScrollLayer *v59; // rdi
unsigned int i; // ebx
struct cocos2d::CCObject *v61; // rax
BoomScrollLayer *v62; // rbx
__int64 v63; // rax
__int64 v64; // rcx
cocos2d::CCNode *v65; // r15
struct cocos2d::CCSprite *v66; // rbx
CCMenuItemSpriteExtra *v67; // rsi
float v68; // xmm14_4
float v69; // xmm6_4
CCMenuItemSpriteExtra_vtbl *v70; // rbx
struct cocos2d::CCPoint v71; // rax
cocos2d::CCSprite *v72; // rbx
CCMenuItemSpriteExtra *v73; // rdi
CCMenuItemSpriteExtra_vtbl *v74; // rbx
struct cocos2d::CCPoint v75; // rax
int v76; // ebx
float v77; // [rsp+38h] [rbp-130h]
struct cocos2d::CCPoint v78; // [rsp+40h] [rbp-128h] BYREF
__int64 v79; // [rsp+48h] [rbp-120h]
cocos2d::CCArray *v80; // [rsp+50h] [rbp-118h]
cocos2d::CCPoint v81; // [rsp+58h] [rbp-110h] BYREF
cocos2d::CCArray *v82; // [rsp+60h] [rbp-108h]
cocos2d::CCPoint v83[2]; // [rsp+68h] [rbp-100h] BYREF
cocos2d::CCPoint v84; // [rsp+78h] [rbp-F0h] BYREF
CCMenuItemSpriteExtra *v85; // [rsp+170h] [rbp+8h] BYREF
int m_page; // [rsp+178h] [rbp+10h]
int v87; // [rsp+180h] [rbp+18h]
unsigned int v88; // [rsp+188h] [rbp+20h]
v87 = a3;
v85 = (CCMenuItemSpriteExtra *)a1;
v6 = a3;
v8 = a1;
m_scrollLayer = a1->m_scrollLayer;
v10 = 0;
if ( m_scrollLayer )
m_page = m_scrollLayer->m_page;
else
m_page = 0;
cocos2d::CCObject::retain(a2);
m_buttonArray = v8->m_buttonArray;
if ( m_buttonArray )
{
v12 = 0;
if ( cocos2d::CCArray::count(m_buttonArray) )
{
do
{
v13 = cocos2d::CCArray::objectAtIndex(v8->m_buttonArray, v12);
v13->__vftable[7].copyWithZone(v13, nullptr);
++v12;
}
while ( v12 < cocos2d::CCArray::count(v8->m_buttonArray) );
}
cocos2d::CCObject::release(v8->m_buttonArray);
v6 = v87;
}
v8->m_buttonArray = a2;
if ( v8->m_scrollLayer )
{
v14 = cocos2d::CCDirector::sharedDirector(m_buttonArray);
v15 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v14 + 144LL))(v14);
cocos2d::CCTouchDispatcher::unregisterForcePrio(v15, v8->m_scrollLayer);
v8->m_scrollLayer->removeMeAndCleanup(v8->m_scrollLayer);
v8->m_scrollLayer = nullptr;
}
cocos2d::CCArray::removeAllObjects(v8->m_pagesArray);
v8->removeAllChildren(v8);
v8->m_scrollLayer = nullptr;
v17 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v16);
cocos2d::CCDirector::getWinSize(v17);
v19 = (cocos2d::CCArray *)cocos2d::CCArray::create(v18);
v82 = v19;
v21 = (struct cocos2d::CCObject *)cocos2d::CCArray::create(v20);
cocos2d::CCArray::addObject(v19, v21);
v22 = 0;
v23 = (float)(v77 - 240.0) - 0.0;
v24 = (float)(4 * a4 - 4);
v25 = (float)v6;
v26 = (float)a4;
v27 = fminf(
(float)((float)(78.0 - v24) / (float)a4) / 40.0,
(float)((float)(v23 - (float)(4 * v6 - 4)) / (float)v6) / 40.0);
v28 = v27 * 40.0;
v29 = a4 * v6;
if ( cocos2d::CCArray::count(a2) )
{
do
{
v30 = cocos2d::CCArray::objectAtIndex(a2, v10);
v31 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v19, v22);
((void (__fastcall *)(struct cocos2d::CCObject *))v30->__vftable[2].isEqual)(v30);
*(float *)&v30[7].m_nLuaID = v27;
if ( v8->m_hasCreateItems )
{
v30[9].m_unknown5 = v22;
LODWORD(v30[10].__vftable) = v8->m_tabIndex;
}
if ( cocos2d::CCArray::count(v31) >= v29 )
{
v35 = (cocos2d::CCArray *)cocos2d::CCArray::create(v32);
cocos2d::CCArray::addObject(v35, v30);
++v22;
v33 = v35;
v34 = v19;
}
else
{
v33 = v30;
v34 = v31;
}
cocos2d::CCArray::addObject(v34, v33);
++v10;
}
while ( v10 < cocos2d::CCArray::count(a2) );
}
v36 = 0;
v88 = 0;
if ( cocos2d::CCArray::count(v19) )
{
p_m_position = &v8->m_position;
v38 = v87;
do
{
v39 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v19, v36);
v80 = v39;
cocos2d::CCPoint::CCPoint(v83, p_m_position);
v41 = v40;
v42 = (cocos2d::CCLayer *)operator new(0x198u);
v83[1] = (cocos2d::CCPoint)v42;
cocos2d::CCLayer::CCLayer(v42);
v42->cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable = (cocos2d::CCLayer_vtbl *)&ButtonPage::`vftable';
v42->cocos2d::CCTouchDelegate::__vftable = (cocos2d::CCTouchDelegate_vtbl *)&ButtonPage::`vftable';
v42->cocos2d::CCAccelerometerDelegate::__vftable = (cocos2d::CCAccelerometerDelegate_vtbl *)&ButtonPage::`vftable';
v42->cocos2d::CCKeypadDelegate::__vftable = (cocos2d::CCKeypadDelegate_vtbl *)&ButtonPage::`vftable';
v42->cocos2d::CCKeyboardDelegate::__vftable = (cocos2d::CCKeyboardDelegate_vtbl *)&ButtonPage::`vftable';
v42->cocos2d::CCMouseDelegate::__vftable = (cocos2d::CCMouseDelegate_vtbl *)&ButtonPage::`vftable';
cocos2d::CCPoint::CCPoint(&v84, v41);
v44 = v43;
if ( cocos2d::CCLayer::init(v42) )
{
v79 = cocos2d::CCMenu::create(v45);
v42->addChild_1(v42, (cocos2d::CCNode *)v79);
v46 = v44[1] - (float)(v28 * 0.5);
v47 = (float)(*v44 - (float)((float)(v25 * 0.5) * v28)) - (float)((float)((float)(v38 - 1) * 0.5) * 4.0);
v48 = 0;
if ( cocos2d::CCArray::count(v39) )
{
v49 = (cocos2d::CCNode *)v79;
v50 = v80;
v51 = v87;
do
{
v52 = (int)floorf((float)v48 / v25);
v53 = cocos2d::CCArray::objectAtIndex(v50, v48);
v49->addChild_1(v49, (cocos2d::CCNode *)v53);
cocos2d::CCPoint::CCPoint(
&v81,
(float)((float)(v48 % v51) * (float)(v28 + 4.0)) + (float)((float)(v28 * 0.5) + v47),
v46 - (float)((float)v52 * (float)(v28 + 4.0)));
v54 = v53->__vftable;
v55 = cocos2d::CCNode::convertToNodeSpace(v49, &v78);
((void (__fastcall *)(struct cocos2d::CCObject *, struct cocos2d::CCPoint))v54[2].encodeWithCoder)(v53, v55);
++v48;
}
while ( v48 < cocos2d::CCArray::count(v50) );
v8 = (EditButtonBar *)v85;
v19 = v82;
v36 = v88;
v38 = v87;
}
cocos2d::CCObject::autorelease(v42);
}
else
{
((void (__fastcall *)(cocos2d::CCLayer *, __int64))v42->~CCLayer)(v42, 1);
v42 = nullptr;
}
cocos2d::CCArray::addObject(v8->m_pagesArray, v42);
v88 = ++v36;
p_m_position = &v8->m_position;
}
while ( v36 < cocos2d::CCArray::count(v19) );
}
v56 = cocos2d::CCArray::count(v8->m_pagesArray);
v58 = BoomScrollLayer::create(v8->m_pagesArray, v57, v56 >= 2, nullptr, nullptr);
v8->m_scrollLayer = v58;
v58->m_pagesInvisible = 1;
v59 = v8->m_scrollLayer;
for ( i = 0; i < cocos2d::CCArray::count(v59->m_dots); ++i )
{
v61 = cocos2d::CCArray::objectAtIndex(v59->m_dots, i);
((void (__fastcall *)(struct cocos2d::CCObject *))v61->__vftable[2].isEqual)(v61);
}
v8->addChild_1(v8, v8->m_scrollLayer);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v85, v77 * 0.5, 2.0);
v62 = v8->m_scrollLayer;
cocos2d::CCPoint::operator=(&v62->m_dotPosition, v63);
BoomScrollLayer::updateDots(v62, 0.0);
v8->m_scrollLayer->setTouchEnabled(v8->m_scrollLayer, 0);
if ( cocos2d::CCArray::count(v8->m_pagesArray) > 1 )
{
v65 = (cocos2d::CCNode *)cocos2d::CCMenu::create(v64);
v8->addChild_1(v8, v65);
v66 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v66->setScale_0)(v66);
v85 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v67 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v85);
if ( v67 )
{
if ( CCMenuItemSpriteExtra::init(v67, v66, nullptr, v8, (cocos2d::SEL_MenuHandler *)EditButtonBar::onLeft) )
{
cocos2d::CCObject::autorelease(v67);
goto LABEL_35;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v67->~CCMenuItemSpriteExtra)(v67, 1);
}
v67 = nullptr;
LABEL_35:
v65->addChild_1(v65, v67);
v68 = (float)(v23 * 0.5) + 16.0;
v69 = v8->m_position.y - (float)((float)((float)(v26 * v28) + v24) * 0.5);
v70 = v67->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v85, v8->m_position.x - v68, v69);
v71 = cocos2d::CCNode::convertToNodeSpace(v65, &v78);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v70->setPosition_0)(v67, v71);
v72 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png");
((void (__fastcall *)(cocos2d::CCSprite *))v72->setScale_0)(v72);
cocos2d::CCSprite::setFlipX(v72, 1);
v85 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v73 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v85);
if ( v73 )
{
if ( CCMenuItemSpriteExtra::init(v73, v72, nullptr, v8, (cocos2d::SEL_MenuHandler *)EditButtonBar::onRight) )
{
cocos2d::CCObject::autorelease(v73);
LABEL_40:
v65->addChild_1(v65, v73);
v74 = v73->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v85, v68 + v8->m_position.x, v69);
v75 = cocos2d::CCNode::convertToNodeSpace(v65, &v78);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v74->setPosition_0)(v73, v75);
HIDWORD(v67->m_pfnSelector.adj) = 1066192077;
HIDWORD(v73->m_pfnSelector.adj) = 1066192077;
goto LABEL_41;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v73->~CCMenuItemSpriteExtra)(v73, 1);
}
v73 = nullptr;
goto LABEL_40;
}
LABEL_41:
v76 = m_page;
if ( m_page > 0 && a5 )
{
BoomScrollLayer::instantMoveToPage(v8->m_scrollLayer, m_page - 1);
BoomScrollLayer::instantMoveToPage(v8->m_scrollLayer, v76);
}
}