//
// EditorUI::getEditColorTargets from 0x14011eb00 to 0x14011ed85 (645 bytes)
//
// 3 xrefs:
// > EditorUI::updateEditColorButton @ 0x14011e9de
// > EditorUI::editColor @ 0x14011edbb
// > ??> @ 0x1406c94ec
//
// 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=2
void EditorUI::getEditColorTargets(EditorUI *a1, ColorAction **a2, ColorAction **a3, EffectGameObject **a4)
{
int v7; // edi
int v8; // ebx
GameObject *m_selectedObject; // rax
int *p_m_colorID; // rdx
int v11; // ecx
int *v12; // rcx
char v13; // r9
cocos2d::CCArray *m_selectedObjects; // rax
cocos2d::ccArray *data; // r8
__int64 num; // rax
cocos2d::CCObject **arr; // r8
cocos2d::CCObject **v18; // r10
cocos2d::CCObject *v19; // rcx
int *v20; // rax
int v21; // edx
int *v22; // rax
int v23; // eax
int v24; // ecx
__int64 v25; // rax
__int64 v26; // rax
void *v27; // [rsp+40h] [rbp+8h]
void *v28; // [rsp+40h] [rbp+8h]
v7 = -1;
v8 = -1;
m_selectedObject = a1->m_selectedObject;
if ( !m_selectedObject )
{
if ( !cocos2d::CCArray::count(a1->m_selectedObjects) )
goto LABEL_49;
v7 = -2;
v8 = -2;
v13 = 0;
m_selectedObjects = a1->m_selectedObjects;
if ( !m_selectedObjects )
goto LABEL_49;
data = m_selectedObjects->data;
num = data->num;
if ( !(_DWORD)num )
goto LABEL_49;
arr = data->arr;
v18 = &arr[num - 1];
if ( arr > v18 )
goto LABEL_49;
while ( 1 )
{
v19 = *arr;
if ( !*arr )
goto LABEL_41;
v20 = *(int **)&v19[19].m_unknown2;
v21 = v20[1];
if ( !v21 )
break;
v23 = *v20;
if ( v21 == v23 || !v23 )
v23 = v21;
if ( v7 == -2 )
{
v7 = v23;
}
else if ( v7 != v23 )
{
v13 = 1;
}
v22 = *(int **)&v19[19].m_uOrderOfArrival;
if ( v22 )
goto LABEL_32;
LABEL_39:
if ( v13 )
goto LABEL_49;
if ( ++arr > v18 )
goto LABEL_41;
}
v22 = *(int **)&v19[19].m_uOrderOfArrival;
if ( !v22 || !v22[1] )
goto LABEL_49;
LABEL_32:
if ( v22[1] )
{
v24 = v22[1];
if ( v24 != *v22 && *v22 )
v24 = *v22;
if ( v8 == -2 )
{
v8 = v24;
}
else if ( v8 != v24 )
{
goto LABEL_49;
}
}
goto LABEL_39;
}
if ( m_selectedObject->m_classType == Effect
&& (m_selectedObject->m_isColorTrigger || m_selectedObject->m_objectID == 1006) )
{
*a4 = (EffectGameObject *)m_selectedObject;
}
else
{
p_m_colorID = &m_selectedObject->m_baseColor->m_colorID;
v11 = p_m_colorID[1];
if ( v11 )
{
v7 = *p_m_colorID;
if ( v11 == *p_m_colorID || !v7 )
v7 = p_m_colorID[1];
}
v12 = &m_selectedObject->m_detailColor->m_colorID;
if ( v12 )
{
if ( v12[1] )
{
v8 = *v12;
if ( v12[1] == *v12 || !v8 )
v8 = v12[1];
}
}
LABEL_41:
if ( v7 >= 0 )
{
v25 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v27 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v25 = qword_1406C2ED8;
}
*a2 = GJEffectManager::getColorAction(
*(GJEffectManager **)(*(_QWORD *)(*(_QWORD *)(v25 + 528) + 3504LL) + 320LL),
v7);
}
if ( v8 >= 0 )
{
v26 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v28 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v26 = qword_1406C2ED8;
}
*a3 = GJEffectManager::getColorAction(
*(GJEffectManager **)(*(_QWORD *)(*(_QWORD *)(v26 + 528) + 3504LL) + 320LL),
v8);
}
}
LABEL_49:
if ( !*a2 )
{
if ( *a3 )
{
*a2 = *a3;
*a3 = nullptr;
}
}
}