//
// EditButtonBar::loadFromItems from 0x140177060 to 0x140177a93 (2611 bytes)
//
// 5 xrefs:
// > EditButtonBar::create @ 0x140177018
// > EditorUI::reloadCustomItems @ 0x1401f69a9
// > EditorUI::recreateButtonTabs @ 0x1401f6c49
// > EditorUI::recreateButtonTabs @ 0x1401f6d52
// > ??> @ 0x1409185f0
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:27:33 +0000
//
// Hidden C++ exception states: #wind=3
void __fastcall EditButtonBar::loadFromItems(__int64 a1, cocos2d::CCObject *a2, int a3, int a4, char a5)
{
__int64 v9; // rax
unsigned int v10; // r15d
cocos2d::CCArray *v11; // rcx
unsigned int v12; // ebx
struct cocos2d::CCObject *v13; // rax
__int64 v14; // rax
struct cocos2d::CCObject *v15; // rbx
cocos2d::CCTouchDispatcher *v16; // rax
__int64 v17; // rcx
__int64 v18; // rax
__int64 v19; // rcx
cocos2d::CCArray *v20; // r12
__int64 v21; // rcx
struct cocos2d::CCObject *v22; // rax
int v23; // eax
float v24; // xmm6_4
float v25; // xmm7_4
float v26; // xmm7_4
float v27; // xmm13_4
float v28; // xmm8_4
float v29; // xmm6_4
unsigned int i; // r14d
float *v31; // rdi
cocos2d::CCArray *v32; // rbx
unsigned int v33; // eax
__int64 v34; // rcx
struct cocos2d::CCObject *v35; // rdx
cocos2d::CCArray *v36; // rcx
cocos2d::CCArray *v37; // rbx
float v38; // xmm0_4
float v39; // xmm9_4
unsigned int v40; // edi
unsigned int v41; // r14d
struct cocos2d::CCObject *v42; // rbx
__int64 v43; // rax
struct cocos2d::CCObject *v44; // rax
unsigned int v45; // eax
__int64 v46; // rdx
char *v47; // rax
unsigned int v48; // ebx
__int64 v49; // rdi
struct cocos2d::CCObject *v50; // rax
__int64 v51; // rbx
__int64 v52; // rax
__int64 v53; // r15
__int64 *v54; // rbx
cocos2d::CCObject *v55; // r14
float v56; // xmm7_4
__int64 v57; // rbx
__int64 v58; // rax
__int64 v59; // rax
cocos2d::CCSprite *v60; // rbx
__int64 v61; // rdi
__int64 v62; // rbx
__int64 v63; // rax
__int64 v64; // rax
__int64 v65; // rdi
cocos2d::CCArray *v66; // rcx
unsigned int v67; // ebx
struct cocos2d::CCObject *v68; // rax
__int64 *v69; // rdi
__int64 v70; // rbx
__int64 v71; // rax
int v72; // eax
int v73; // r15d
int v74; // r14d
float v75; // xmm7_4
__int64 *v76; // rbx
__int64 *v77; // rax
__int64 *v78; // rdi
__int64 v79; // rbx
__int64 v80; // rax
__int64 v81; // rcx
int v82; // r15d
cocos2d::CCArray *v83; // rcx
signed int v84; // ecx
_QWORD *v85; // r14
__int64 v86; // rbx
unsigned __int64 j; // rsi
__int64 v88; // rdi
__int64 v89; // rbx
int v90; // eax
void (__fastcall *v91)(__int64, void **); // r8
void **v92; // rdx
float v93; // [rsp+38h] [rbp-91h] BYREF
char v94[8]; // [rsp+40h] [rbp-89h] BYREF
char v95[8]; // [rsp+48h] [rbp-81h] BYREF
int v96; // [rsp+128h] [rbp+5Fh]
void *v97; // [rsp+130h] [rbp+67h] BYREF
int v98; // [rsp+138h] [rbp+6Fh]
__int16 v99; // [rsp+140h] [rbp+77h] BYREF
char v100; // [rsp+142h] [rbp+79h]
v98 = a3;
v9 = *(_QWORD *)(a1 + 344);
v10 = 0;
if ( v9 )
v96 = *(_DWORD *)(v9 + 588);
else
v96 = 0;
cocos2d::CCObject::retain(a2);
v11 = *(cocos2d::CCArray **)(a1 + 336);
if ( v11 )
{
v12 = 0;
if ( cocos2d::CCArray::count(v11) )
{
do
{
v13 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 336), v12);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v13 + 520LL))(v13, 0);
++v12;
}
while ( v12 < cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 336)) );
}
cocos2d::CCObject::release(*(cocos2d::CCObject **)(a1 + 336));
}
*(_QWORD *)(a1 + 336) = a2;
if ( *(_QWORD *)(a1 + 344) )
{
v14 = cocos2d::CCDirector::sharedDirector(v11);
v15 = *(struct cocos2d::CCObject **)(a1 + 344);
v16 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v14 + 144LL))(v14);
cocos2d::CCTouchDispatcher::unregisterForcePrio(v16, v15);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 344) + 528LL))(*(_QWORD *)(a1 + 344));
*(_QWORD *)(a1 + 344) = 0;
}
cocos2d::CCArray::removeAllObjects(*(cocos2d::CCArray **)(a1 + 352));
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 568LL))(a1);
*(_QWORD *)(a1 + 344) = 0;
*(_QWORD *)(a1 + 360) = 0;
v18 = cocos2d::CCDirector::sharedDirector(v17);
cocos2d::CCDirector::getWinSize(v18, &v93);
v20 = (cocos2d::CCArray *)cocos2d::CCArray::create(v19);
v22 = (struct cocos2d::CCObject *)cocos2d::CCArray::create(v21);
cocos2d::CCArray::addObject(v20, v22);
LODWORD(v97) = a4 * a3;
v23 = (int)(a4 * a3 + cocos2d::CCArray::count(a2) - 1) / (a4 * a3);
if ( v23 < 1 )
{
LOBYTE(v99) = 1;
LABEL_13:
v24 = 84.0;
v25 = v93 - 200.0;
goto LABEL_15;
}
LOBYTE(v99) = v23 <= 1;
if ( v23 <= 1 )
goto LABEL_13;
v24 = 78.0;
v25 = v93 - 256.0;
LOBYTE(v99) = v23 <= 1;
LABEL_15:
v26 = v25 - 0.0;
v27 = (float)(4 * a4 - 4);
v28 = (float)a4;
v29 = fminf(
(float)((float)(v24 - v27) / (float)a4) / 40.0,
(float)((float)(v26 - (float)(4 * a3 - 4)) / (float)a3) / 40.0);
for ( i = 0; i < cocos2d::CCArray::count(a2); ++i )
{
v31 = (float *)cocos2d::CCArray::objectAtIndex(a2, i);
v32 = cocos2d::CCArray::objectAtIndex(v20, v10);
(*(void (__fastcall **)(float *))(*(_QWORD *)v31 + 160LL))(v31);
v31[101] = v29;
v33 = cocos2d::CCArray::count(v32);
if ( v33 >= (unsigned int)v97 )
{
v37 = (cocos2d::CCArray *)cocos2d::CCArray::create(v34);
cocos2d::CCArray::addObject(v37, (struct cocos2d::CCObject *)v31);
++v10;
v35 = v37;
v36 = v20;
}
else
{
v35 = (struct cocos2d::CCObject *)v31;
v36 = v32;
}
cocos2d::CCArray::addObject(v36, v35);
if ( *(_BYTE *)(a1 + 332) )
{
*((_DWORD *)v31 + 139) = v10;
v31[140] = *(float *)(a1 + 328);
}
}
if ( (_BYTE)v99 )
v38 = 0.0;
else
v38 = 8.0;
v39 = (float)((float)(*(float *)(a1 + 324) + 6.0) + v38) * 0.5;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v94,
*(float *)(a1 + 320),
(float)((float)((float)(v28 * (float)(v29 * 40.0)) + v27) * 0.5) + v39);
v40 = 0;
if ( cocos2d::CCArray::count(v20) )
{
v41 = v98;
do
{
v42 = cocos2d::CCArray::objectAtIndex(v20, v40);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v97, (const struct cocos2d::CCPoint *)v94);
v44 = (struct cocos2d::CCObject *)ButtonPage::create(v42, v43, v41);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 352), v44);
++v40;
}
while ( v40 < cocos2d::CCArray::count(v20) );
}
v45 = cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 352));
v47 = BoomScrollLayer::create(*(_QWORD *)(a1 + 352), v46, v45 >= 2, 0, 0);
*(_QWORD *)(a1 + 344) = v47;
v47[553] = 1;
v48 = 0;
v49 = *(_QWORD *)(a1 + 344);
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(v49 + 416)) )
{
do
{
v50 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(v49 + 416), v48);
(*(void (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v50 + 160LL))(v50);
++v48;
}
while ( v48 < cocos2d::CCArray::count(*(cocos2d::CCArray **)(v49 + 416)) );
}
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 464LL))(a1, *(_QWORD *)(a1 + 344));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v97, v93 * 0.5, 2.0);
v51 = *(_QWORD *)(a1 + 344);
cocos2d::CCPoint::operator=(v51 + 572, v52);
BoomScrollLayer::updateDots(v51);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 344) + 920LL))(*(_QWORD *)(a1 + 344), 0);
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 352)) <= 1 )
goto LABEL_52;
v53 = cocos2d::CCMenu::create();
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v53);
v54 = (__int64 *)cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png");
(*(void (__fastcall **)(__int64 *))(*v54 + 160))(v54);
v97 = operator new(0x208u);
v55 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v97);
if ( v55 )
{
if ( CCMenuItemSpriteExtra::init((__int64 *)v55, v54, 0, a1, (__int64)EditButtonBar::onLeft) )
{
cocos2d::CCObject::autorelease(v55);
goto LABEL_36;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v55 + 8LL))(v55, 1);
}
v55 = nullptr;
LABEL_36:
(*(void (__fastcall **)(__int64, cocos2d::CCObject *))(*(_QWORD *)v53 + 464LL))(v53, v55);
v56 = (float)(v26 * 0.5) + 16.0;
v57 = *(_QWORD *)v55;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v97, *(float *)(a1 + 320) - v56, v39);
cocos2d::CCNode::convertToNodeSpace(v53, v95, v58);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v57 + 184))(v55, v59);
v60 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png");
(*(void (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)v60 + 160LL))(v60);
cocos2d::CCSprite::setFlipX(v60, 1);
v97 = operator new(0x208u);
v61 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v97);
if ( !v61 )
{
LABEL_40:
v61 = 0;
goto LABEL_41;
}
if ( !CCMenuItemSpriteExtra::init((__int64 *)v61, (__int64 *)v60, 0, a1, (__int64)EditButtonBar::onRight) )
{
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v61 + 8LL))(v61, 1);
goto LABEL_40;
}
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v61);
LABEL_41:
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v53 + 464LL))(v53, v61);
v62 = *(_QWORD *)v61;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v97, v56 + *(float *)(a1 + 320), v39);
cocos2d::CCNode::convertToNodeSpace(v53, v95, v63);
(*(void (__fastcall **)(__int64, __int64))(v62 + 184))(v61, v64);
*((_DWORD *)v55 + 93) = 1066192077;
*(_DWORD *)(v61 + 372) = 1066192077;
*(_BYTE *)(*(_QWORD *)(a1 + 344) + 569LL) = 0;
v65 = *(_QWORD *)(a1 + 344);
v66 = *(cocos2d::CCArray **)(v65 + 416);
if ( v66 )
{
v67 = 0;
if ( cocos2d::CCArray::count(v66) )
{
do
{
v68 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(v65 + 416), v67);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v68 + 336LL))(v68, 0);
++v67;
}
while ( v67 < cocos2d::CCArray::count(*(cocos2d::CCArray **)(v65 + 416)) );
}
}
v69 = (__int64 *)cocos2d::CCMenu::create();
*(_QWORD *)(a1 + 360) = v69;
v70 = *v69;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v97, v93 * 0.5, 2.0);
(*(void (__fastcall **)(__int64 *, __int64))(v70 + 184))(v69, v71);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 464LL))(a1, *(_QWORD *)(a1 + 360));
v72 = cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 352));
v73 = v72;
v74 = 0;
if ( v72 > 0 )
{
v75 = (float)(v72 - 1) * 0.5;
while ( 1 )
{
v76 = (__int64 *)cocos2d::CCSprite::create("smallDot.png");
(*(void (__fastcall **)(__int64 *))(*v76 + 160))(v76);
v97 = operator new(0x208u);
v77 = (__int64 *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v97);
v78 = v77;
if ( !v77 )
goto LABEL_50;
if ( !CCMenuItemSpriteExtra::init(v77, v76, 0, a1, (__int64)EditButtonBar::onDotClicked) )
break;
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v78);
LABEL_51:
(*(void (__fastcall **)(__int64 *, _QWORD))(*v78 + 64))(v78, (unsigned int)v74);
*((_DWORD *)v78 + 93) = 1075838976;
v79 = *v78;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v95, (float)((float)v74 - v75) * 16.0, 0.0);
(*(void (__fastcall **)(__int64 *, __int64))(v79 + 184))(v78, v80);
(*(void (__fastcall **)(_QWORD, __int64 *))(**(_QWORD **)(a1 + 360) + 464LL))(*(_QWORD *)(a1 + 360), v78);
if ( ++v74 >= v73 )
goto LABEL_52;
}
(*(void (__fastcall **)(__int64 *, __int64))(*v78 + 8))(v78, 1);
LABEL_50:
v78 = nullptr;
goto LABEL_51;
}
LABEL_52:
if ( v96 > 0 && a5 )
{
BoomScrollLayer::instantMoveToPage(*(_QWORD *)(a1 + 344), v96 - 1);
BoomScrollLayer::instantMoveToPage(*(_QWORD *)(a1 + 344), v96);
}
if ( *(_QWORD *)(a1 + 360) )
{
v81 = *(_QWORD *)(a1 + 344);
if ( v81 )
{
v82 = *(_DWORD *)(v81 + 588);
if ( *(_BYTE *)(v81 + 456) )
v83 = *(cocos2d::CCArray **)(v81 + 448);
else
v83 = *(cocos2d::CCArray **)(v81 + 480);
v84 = cocos2d::CCArray::count(v83);
if ( v82 <= 0 )
{
for ( ; v82 < 0; v82 += v84 )
;
}
else
{
v82 %= v84;
}
if ( (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 360) + 480LL))(*(_QWORD *)(a1 + 360)) )
{
if ( **(_DWORD **)((*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 360) + 480LL))(*(_QWORD *)(a1 + 360))
+ 56) )
{
v85 = *(_QWORD **)(*(_QWORD *)((*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 360) + 480LL))(*(_QWORD *)(a1 + 360))
+ 56)
+ 16LL);
v86 = **(unsigned int **)((*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 360) + 480LL))(*(_QWORD *)(a1 + 360))
+ 56);
for ( j = *(_QWORD *)(*(_QWORD *)((*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 360) + 480LL))(*(_QWORD *)(a1 + 360))
+ 56)
+ 16LL)
+ 8 * (v86 - 1); (unsigned __int64)v85 <= j; ++v85 )
{
v88 = *v85;
if ( !*v85 )
break;
v89 = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)v88 + 952LL))(*v85);
v90 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v88 + 56LL))(v88);
v91 = **(void (__fastcall ***)(__int64, void **))(v89 + 320);
if ( v90 == v82 )
{
LOWORD(v98) = -1;
v99 = -1;
v100 = -1;
v92 = (void **)&v99;
}
else
{
LOWORD(v97) = -26986;
BYTE2(v97) = -106;
v92 = &v97;
}
v91(v89 + 320, v92);
}
}
}
}
}
}