//
// SetupKeyframePopup::onCustomButton from 0x1001b5a58 to 0x1001b5d0c (692 bytes)
//
// 1 xrefs:
// > ??> @ 0x1007b1d08
//
// 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)
{
EffectGameObject *m_gameObject; // x0
__int64 m_gameObjects; // x21
unsigned int *v6; // x9
__int64 v7; // x8
unsigned __int64 v8; // x21
unsigned __int64 v9; // x22
__int64 *i; // x20
__int64 *j; // x20
cocos2d::CCArray *v12; // x0
EffectGameObject *v13; // x0
__int64 v14; // x20
unsigned int *v15; // x9
__int64 v16; // x8
unsigned __int64 v17; // x20
unsigned __int64 v18; // x22
_QWORD **v19; // x20
cocos2d::CCArray *v20; // x0
_QWORD *v21; // x9
_QWORD **v22; // x8
bool v23; // zf
_QWORD **v24; // [xsp+8h] [xbp-68h] BYREF
_QWORD *v25[2]; // [xsp+10h] [xbp-60h] BYREF
__int128 v26; // [xsp+20h] [xbp-50h] BYREF
__int128 v27; // [xsp+30h] [xbp-40h]
int v28; // [xsp+40h] [xbp-30h]
v26 = 0u;
v27 = 0u;
v28 = 1065353216;
m_gameObject = a1->m_gameObject;
if ( m_gameObject )
{
m_gameObjects = sub_10024A1B8(m_gameObject);
if ( !m_gameObjects )
goto LABEL_10;
}
else
{
m_gameObjects = (__int64)a1->m_gameObjects;
if ( !m_gameObjects )
goto LABEL_10;
}
if ( (unsigned int)sub_10024A36C(m_gameObjects) )
{
v6 = *(unsigned int **)(m_gameObjects + 56);
v7 = *v6;
if ( (_DWORD)v7 )
{
v8 = *((_QWORD *)v6 + 2);
v9 = v8 + 8 * v7 - 8;
do
{
if ( !*(_QWORD *)v8 )
break;
sub_10001C1B0((unsigned __int64)&v26, (int *)(*(_QWORD *)v8 + 1856LL), (_DWORD *)(*(_QWORD *)v8 + 1856LL));
v8 += 8LL;
}
while ( v8 <= v9 );
}
}
LABEL_10:
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2) == 2 )
{
SetupKeyframePopup::refreshPreviewArt(a1);
goto LABEL_22;
}
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2) == 4 )
{
if ( a1->m_editorLayer )
{
for ( i = (__int64 *)v27; i; i = (__int64 *)*i )
LevelEditorLayer::reverseKeyframeAnimationOrder(a1->m_editorLayer, *((_DWORD *)i + 4));
}
LABEL_21:
((void (__fastcall *)(SetupKeyframePopup *, _QWORD))a1->onClose)(a1, 0);
goto LABEL_22;
}
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2) == 3 )
{
EditorUI::deselectAll(a1->m_editorLayer->m_editorUI);
if ( a1->m_editorLayer )
{
for ( j = (__int64 *)v27; j; j = (__int64 *)*j )
{
v12 = LevelEditorLayer::duplicateKeyframeAnimation(a1->m_editorLayer, *((_DWORD *)j + 4));
EditorUI::selectObjects(a1->m_editorLayer->m_editorUI, v12, 0);
}
}
goto LABEL_21;
}
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2) == 1 && a1->m_editorLayer )
{
v25[0] = nullptr;
v25[1] = nullptr;
v24 = v25;
v13 = a1->m_gameObject;
if ( v13 )
{
v14 = sub_10024A1B8(v13);
if ( !v14 )
goto LABEL_34;
}
else
{
v14 = (__int64)a1->m_gameObjects;
if ( !v14 )
{
LABEL_34:
EditorUI::deselectAll(a1->m_editorLayer->m_editorUI);
v19 = v24;
if ( v24 != v25 )
{
do
{
v20 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(
a1->m_editorLayer->m_keyframeGroups,
*((int *)v19 + 7));
EditorUI::selectObjects(a1->m_editorLayer->m_editorUI, v20, 0);
v21 = v19[1];
if ( v21 )
{
do
{
v22 = (_QWORD **)v21;
v21 = (_QWORD *)*v21;
}
while ( v21 );
}
else
{
do
{
v22 = (_QWORD **)v19[2];
v23 = *v22 == v19;
v19 = v22;
}
while ( !v23 );
}
v19 = v22;
}
while ( v22 != v25 );
}
((void (__fastcall *)(SetupKeyframePopup *, _QWORD))a1->onClose)(a1, 0);
sub_100017D70((__int64)&v24, v25[0]);
goto LABEL_22;
}
}
if ( (unsigned int)sub_10024A36C(v14) )
{
v15 = *(unsigned int **)(v14 + 56);
v16 = *v15;
if ( (_DWORD)v16 )
{
v17 = *((_QWORD *)v15 + 2);
v18 = v17 + 8 * v16 - 8;
do
{
if ( !*(_QWORD *)v17 )
break;
sub_1000B4D20((__int64)&v24, (int *)(*(_QWORD *)v17 + 1856LL), (_DWORD *)(*(_QWORD *)v17 + 1856LL));
v17 += 8LL;
}
while ( v17 <= v18 );
}
}
goto LABEL_34;
}
LABEL_22:
sub_100017A98((__int64)&v26);
}