//
// SetupKeyframePopup::onCustomButton from 0x1002019e0 to 0x100201d6e (910 bytes)
//
// 1 xrefs:
// > ??> @ 0x1008dafe8
//
// 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 SetupKeyframePopup::onCustomButton(SetupKeyframePopup *a1, cocos2d::CCObject *a2)
{
double v2; // xmm1_8
double v3; // xmm2_8
EffectGameObject *m_gameObject; // rdi
cocos2d::CCArray *m_gameObjects; // r15
cocos2d::ccArray *data; // rax
unsigned __int64 arr; // r12
unsigned __int64 v9; // r13
_DWORD *v10; // r14
_DWORD *v11; // r14
cocos2d::CCArray *v12; // rax
_QWORD *v13; // rdi
_QWORD *v14; // rbx
void *v15; // rdi
_QWORD *v16; // r15
EffectGameObject *v17; // rdi
cocos2d::CCArray *v18; // r14
cocos2d::ccArray *v19; // rax
unsigned __int64 v20; // r14
__int64 v21; // rax
int v22; // r13d
_QWORD *v23; // r12
int v24; // eax
_DWORD *v25; // rax
_OWORD *v26; // r14
cocos2d::CCArray *v27; // rax
_QWORD *v28; // rcx
_OWORD *v29; // rax
bool v30; // zf
unsigned __int64 v31; // [rsp+8h] [rbp-78h]
void *v32[2]; // [rsp+10h] [rbp-70h] BYREF
void *__p[2]; // [rsp+20h] [rbp-60h]
int v34; // [rsp+30h] [rbp-50h]
_OWORD *v35; // [rsp+40h] [rbp-40h] BYREF
_OWORD v36[3]; // [rsp+48h] [rbp-38h] BYREF
*(_OWORD *)__p = 0;
*(_OWORD *)v32 = 0;
v34 = 1065353216;
m_gameObject = a1->m_gameObject;
if ( m_gameObject )
{
m_gameObjects = (cocos2d::CCArray *)sub_10071FA80(m_gameObject);
if ( !m_gameObjects )
goto LABEL_10;
}
else
{
m_gameObjects = a1->m_gameObjects;
if ( !m_gameObjects )
goto LABEL_10;
}
if ( (unsigned int)sub_100720070(m_gameObjects) )
{
data = m_gameObjects->data;
if ( data->num )
{
arr = (unsigned __int64)data->arr;
v9 = arr + 8LL * data->num - 8;
do
{
if ( !*(_QWORD *)arr )
break;
sub_100054F50(
(float *)v32,
(int *)(*(_QWORD *)arr + 1856LL),
(_DWORD *)(*(_QWORD *)arr + 1856LL),
(__m128)0LL,
v2,
v3);
arr += 8LL;
}
while ( arr <= v9 );
}
}
LABEL_10:
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2) == 2 )
{
SetupKeyframePopup::refreshPreviewArt(a1);
goto LABEL_20;
}
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2) == 4 )
{
v10 = __p[0];
if ( a1->m_editorLayer != nullptr && __p[0] != nullptr )
{
do
{
LevelEditorLayer::reverseKeyframeAnimationOrder(a1->m_editorLayer, v10[4]);
v10 = *(_DWORD **)v10;
}
while ( v10 );
}
LABEL_19:
((void (__fastcall *)(SetupKeyframePopup *, _QWORD))a1->onClose)(a1, 0);
goto LABEL_20;
}
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2) == 3 )
{
EditorUI::deselectAll(a1->m_editorLayer->m_editorUI);
v11 = __p[0];
if ( a1->m_editorLayer != nullptr && __p[0] != nullptr )
{
do
{
v12 = LevelEditorLayer::duplicateKeyframeAnimation(a1->m_editorLayer, v11[4]);
EditorUI::selectObjects(a1->m_editorLayer->m_editorUI, v12, 0);
v11 = *(_DWORD **)v11;
}
while ( v11 );
}
goto LABEL_19;
}
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2) == 1 && a1->m_editorLayer )
{
v16 = v36;
v36[0] = 0;
v35 = v36;
v17 = a1->m_gameObject;
if ( v17 )
{
v18 = (cocos2d::CCArray *)sub_10071FA80(v17);
if ( !v18 )
goto LABEL_46;
}
else
{
v18 = a1->m_gameObjects;
if ( !v18 )
{
LABEL_46:
EditorUI::deselectAll(a1->m_editorLayer->m_editorUI);
v26 = v35;
if ( v35 != v36 )
{
do
{
v27 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(
a1->m_editorLayer->m_keyframeGroups,
*((int *)v26 + 7));
EditorUI::selectObjects(a1->m_editorLayer->m_editorUI, v27, 0);
v28 = *((_QWORD **)v26 + 1);
if ( v28 )
{
do
{
v29 = v28;
v28 = (_QWORD *)*v28;
}
while ( v28 );
}
else
{
do
{
v29 = *((_OWORD **)v26 + 2);
v30 = *(_QWORD *)v29 == (_QWORD)v26;
v26 = v29;
}
while ( !v30 );
}
v26 = v29;
}
while ( v29 != v36 );
}
((void (__fastcall *)(SetupKeyframePopup *, _QWORD))a1->onClose)(a1, 0);
sub_100054D90((__int64)&v35, *(_QWORD **)&v36[0]);
goto LABEL_20;
}
}
if ( (unsigned int)sub_100720070(v18) )
{
v19 = v18->data;
if ( v19->num )
{
v20 = (unsigned __int64)v19->arr;
v31 = v20 + 8LL * v19->num - 8;
do
{
if ( !*(_QWORD *)v20 )
break;
v21 = *(_QWORD *)&v36[0];
v22 = *(_DWORD *)(*(_QWORD *)v20 + 1856LL);
LABEL_39:
v23 = v16;
if ( v21 )
{
do
{
v16 = (_QWORD *)v21;
v24 = *(_DWORD *)(v21 + 28);
if ( v22 < v24 )
{
v21 = *v16;
goto LABEL_39;
}
if ( v22 <= v24 )
goto LABEL_35;
v21 = v16[1];
}
while ( v21 );
v23 = v16 + 1;
}
v25 = operator new(0x20u);
v25[7] = v22;
*(_OWORD *)v25 = 0;
*((_QWORD *)v25 + 2) = v16;
*v23 = v25;
if ( *(_QWORD *)v35 )
v35 = *(_OWORD **)v35;
sub_100054DD0(*(__int64 **)&v36[0], (__int64 *)v25);
++*((_QWORD *)&v36[0] + 1);
LABEL_35:
v20 += 8LL;
v16 = v36;
}
while ( v20 <= v31 );
}
}
goto LABEL_46;
}
LABEL_20:
v13 = __p[0];
if ( __p[0] )
{
do
{
v14 = (_QWORD *)*v13;
operator delete(v13);
v13 = v14;
}
while ( v14 );
}
v15 = v32[0];
v32[0] = nullptr;
if ( v15 )
operator delete(v15);
}