//
// SetupKeyframePopup::onCustomButton from 0x1405bbbe0 to 0x1405bc145 (1381 bytes)
//
// 2 xrefs:
// > ??> @ 0x1407f5c78
// > ??> @ 0x14092dee4
//
// 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:34:45 +0000
//
// Hidden C++ exception states: #wind=6
void __fastcall SetupKeyframePopup::onCustomButton(_QWORD *a1, __int64 a2)
{
_QWORD *v4; // rax
struct cocos2d::CCObject *v5; // rcx
struct cocos2d::CCArray *v6; // rbx
unsigned int *v7; // rbx
__int64 v8; // rax
unsigned __int64 v9; // rbx
unsigned __int64 i; // rsi
_DWORD *v11; // r15
_DWORD *j; // rbx
int v13; // edi
__int64 v14; // rsi
cocos2d::CCArray *v15; // rax
__int64 v16; // rcx
void **v17; // r12
void **k; // rbx
__int64 v19; // rdi
__int64 v20; // rsi
struct cocos2d::CCObject *v21; // r15
cocos2d::CCArray *v22; // rax
__int64 v23; // rdi
__int64 v24; // r8
cocos2d::CCArray *v25; // rax
_QWORD *v26; // rax
struct cocos2d::CCObject *v27; // rcx
struct cocos2d::CCArray *v28; // rbx
unsigned int *v29; // rbx
__int64 v30; // rax
__int64 *v31; // rbx
__int64 *v32; // r15
_QWORD *v33; // rsi
__int64 v34; // rdi
_BYTE *v35; // rdx
__int64 v36; // rcx
_QWORD *v37; // r8
__int64 *v38; // rax
_DWORD *v39; // rax
__int64 *v40; // rbx
cocos2d::CCArray *v41; // rax
__int64 **v42; // rcx
__int64 *m; // rax
__int64 *n; // rcx
_QWORD *v45; // [rsp+30h] [rbp-69h] BYREF
__int64 v46; // [rsp+38h] [rbp-61h]
int v47; // [rsp+40h] [rbp-59h] BYREF
void *v48[2]; // [rsp+48h] [rbp-51h] BYREF
__int64 v49; // [rsp+58h] [rbp-41h] BYREF
__int128 v50; // [rsp+60h] [rbp-39h]
__int64 v51; // [rsp+70h] [rbp-29h]
__int64 v52; // [rsp+78h] [rbp-21h]
_QWORD **v53; // [rsp+80h] [rbp-19h]
__int64 v54; // [rsp+88h] [rbp-11h]
const void *v55; // [rsp+90h] [rbp-9h] BYREF
int v56; // [rsp+98h] [rbp-1h]
v48[1] = nullptr;
v4 = operator new(0x18u);
*v4 = v4;
v4[1] = v4;
v48[0] = v4;
v49 = 0;
v50 = 0;
v51 = 7;
v52 = 8;
v47 = 1065353216;
sub_14003F200((__int64)&v49, 0x10u, (unsigned __int64)v4);
v5 = (struct cocos2d::CCObject *)a1[85];
if ( v5 )
v6 = cocos2d::CCArray::createWithObject(v5);
else
v6 = (struct cocos2d::CCArray *)a1[86];
if ( v6 )
{
if ( cocos2d::CCArray::count(v6) )
{
v7 = *((unsigned int **)v6 + 7);
v8 = *v7;
if ( (_DWORD)v8 )
{
v9 = *((_QWORD *)v7 + 2);
for ( i = v9 + 8 * (v8 - 1); v9 <= i; v9 += 8LL )
{
if ( !*(_QWORD *)v9 )
break;
sub_140068190((__int64)&v47, (__int64)&v55, (unsigned __int8 *)(*(_QWORD *)v9 + 1872LL));
}
}
}
}
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2) == 2 )
{
SetupKeyframePopup::refreshPreviewArt(a1);
goto LABEL_57;
}
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2) == 4 )
{
if ( a1[126] )
{
v11 = v48[0];
for ( j = *(_DWORD **)v48[0]; j != v11; j = *(_DWORD **)j )
{
v13 = j[4];
v14 = a1[126];
v15 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v14 + 13872), v13);
cocos2d::CCArray::reverseObjects(v15);
GJBaseGameLayer::updateKeyframeOrder(v14, v13);
}
}
LABEL_16:
(*(void (__fastcall **)(_QWORD *, _QWORD))(*a1 + 1104LL))(a1, 0);
goto LABEL_57;
}
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2) == 3 )
{
EditorUI::deselectAll(*(_QWORD *)(a1[126] + 14904LL));
if ( a1[126] )
{
v17 = (void **)v48[0];
for ( k = *(void ***)v48[0]; k != v17; k = (void **)*k )
{
v19 = *((int *)k + 4);
v20 = a1[126];
v21 = (struct cocos2d::CCObject *)cocos2d::CCArray::create(v16);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v21 + 64LL))(
v21,
*(unsigned int *)(v20 + 13880));
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(v20 + 13872), v21, *(int *)(v20 + 13880));
++*(_DWORD *)(v20 + 13880);
*(_DWORD *)(v20 + 15548) = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v21 + 56LL))(v21);
v22 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v20 + 13872), v19);
v23 = (__int64)v22;
if ( v22 && cocos2d::CCArray::count(v22) )
{
EditorUI::copyObjects(*(_QWORD *)(v20 + 14904), &v55, v23, 0, 1);
*(_BYTE *)(v20 + 14808) = 1;
v25 = LevelEditorLayer::createObjectsFromString(v20, &v55, v24, 1);
GJBaseGameLayer::assignNewStickyGroups(v20, v25);
*(_BYTE *)(v20 + 14808) = 0;
sub_14003D310((__int64)&v55);
}
*(_DWORD *)(v20 + 15548) = 0;
EditorUI::selectObjects(*(_QWORD *)(a1[126] + 14904LL), v21, 0);
}
}
goto LABEL_16;
}
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2) == 1 && a1[126] )
{
v46 = 0;
v26 = operator new(0x20u);
*v26 = v26;
v26[1] = v26;
v26[2] = v26;
*((_WORD *)v26 + 12) = 257;
v45 = v26;
v27 = (struct cocos2d::CCObject *)a1[85];
if ( v27 )
v28 = cocos2d::CCArray::createWithObject(v27);
else
v28 = (struct cocos2d::CCArray *)a1[86];
if ( v28 )
{
if ( cocos2d::CCArray::count(v28) )
{
v29 = *((unsigned int **)v28 + 7);
v30 = *v29;
if ( (_DWORD)v30 )
{
v31 = *((__int64 **)v29 + 2);
v32 = &v31[v30 - 1];
if ( v31 <= v32 )
{
v33 = v45;
do
{
v34 = *v31;
if ( !*v31 )
break;
v35 = (_BYTE *)v33[1];
v36 = 0;
v37 = v33;
if ( !v35[25] )
{
v38 = (__int64 *)v33[1];
do
{
v35 = v38;
if ( *((_DWORD *)v38 + 7) >= *(_DWORD *)(v34 + 1872) )
{
v36 = 1;
v37 = v38;
}
else
{
v36 = 0;
v38 += 2;
}
v38 = (__int64 *)*v38;
}
while ( !*((_BYTE *)v38 + 25) );
}
v55 = v35;
v56 = v36;
if ( *((_BYTE *)v37 + 25) || *(_DWORD *)(v34 + 1872) < *((_DWORD *)v37 + 7) )
{
if ( v46 == 0x7FFFFFFFFFFFFFFLL )
sub_14005BD90(v36, v35, v37);
v53 = &v45;
v54 = 0;
v39 = operator new(0x20u);
v39[7] = *(_DWORD *)(v34 + 1872);
*(_QWORD *)v39 = v33;
*((_QWORD *)v39 + 1) = v33;
*((_QWORD *)v39 + 2) = v33;
*((_WORD *)v39 + 12) = 0;
v54 = 0;
sub_14006A770(&v45, (__int64)&v55, (__int64)v39);
v33 = v45;
}
++v31;
}
while ( v31 <= v32 );
}
}
}
}
EditorUI::deselectAll(*(_QWORD *)(a1[126] + 14904LL));
v40 = (__int64 *)*v45;
if ( !*(_BYTE *)(*v45 + 25LL) )
{
do
{
v41 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1[126] + 13872LL), *((int *)v40 + 7));
EditorUI::selectObjects(*(_QWORD *)(a1[126] + 14904LL), v41, 0);
v42 = (__int64 **)v40[2];
if ( *((_BYTE *)v42 + 25) )
{
for ( m = (__int64 *)v40[1]; !*((_BYTE *)m + 25); m = (__int64 *)m[1] )
{
if ( v40 != (__int64 *)m[2] )
break;
v40 = m;
}
v40 = m;
}
else
{
v40 = (__int64 *)v40[2];
for ( n = *v42; !*((_BYTE *)n + 25); n = (__int64 *)*n )
v40 = n;
}
}
while ( !*((_BYTE *)v40 + 25) );
}
(*(void (__fastcall **)(_QWORD *, _QWORD))(*a1 + 1104LL))(a1, 0);
sub_1400BD560((void **)&v45, (__int64)&v45);
}
LABEL_57:
sub_14003EA90(&v49);
sub_14003EB00(v48);
}