//
// EditorUI::getEditColorTargets from 0x1000195f0 to 0x10001989f (687 bytes)
//
// 3 xrefs:
// > EditorUI::updateEditColorButton @ 0x100018cdb
// > EditorUI::editHSV @ 0x100019925
// > EditorUI::editColor @ 0x100019a36
//
// 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 12:18:55 +0000
//
_QWORD *__fastcall EditorUI::getEditColorTargets(__int64 a1, unsigned __int64 a2, _QWORD *a3, _QWORD *a4)
{
__int64 v5; // rdi
int v6; // r15d
int v7; // r12d
int *v8; // rax
__int64 v9; // rdi
__int64 v10; // rdx
int *v11; // rax
__int64 v12; // rax
unsigned int *v13; // rax
__int64 v14; // r14
unsigned __int64 v15; // r14
char v16; // bl
__int64 v17; // r13
bool v18; // cc
int *MainColor; // rax
int v20; // ecx
int *SecondaryColor; // rax
int v22; // ecx
__int64 v23; // rax
_QWORD *result; // rax
unsigned __int64 v25; // [rsp+0h] [rbp-40h]
_QWORD *v26; // [rsp+8h] [rbp-38h]
v26 = (_QWORD *)a2;
v5 = *(_QWORD *)(a1 + 1496);
if ( !v5 )
{
v9 = *(_QWORD *)(a1 + 896);
if ( !(unsigned int)sub_1007FEF90(v9) )
goto LABEL_45;
v12 = *(_QWORD *)(a1 + 896);
if ( !v12 )
goto LABEL_45;
v13 = *(unsigned int **)(v12 + 56);
if ( !*v13 )
goto LABEL_45;
v14 = *((_QWORD *)v13 + 2);
v25 = v14 + 8LL * *v13 - 8;
v15 = v14 + 8;
v7 = -2;
v16 = 0;
v6 = -2;
while ( 1 )
{
v17 = *(_QWORD *)(v15 - 8);
if ( !v17 )
{
LABEL_40:
if ( (v16 & 1) == 0 )
goto LABEL_41;
goto LABEL_45;
}
if ( !(unsigned __int8)GameObject::canChangeCustomColor(*(_QWORD *)(v15 - 8)) )
goto LABEL_45;
if ( (unsigned __int8)GameObject::canChangeMainColor(v17) )
{
MainColor = (int *)GameObject::getMainColor(v17);
v20 = *MainColor;
if ( !*MainColor )
v20 = MainColor[1];
if ( v7 == -2 )
{
v7 = v20;
v9 = v17;
if ( !(unsigned __int8)GameObject::canChangeSecondaryColor(v17) )
goto LABEL_20;
}
else if ( v7 == v20 )
{
v9 = v17;
if ( !(unsigned __int8)GameObject::canChangeSecondaryColor(v17) )
{
LABEL_20:
if ( (v16 & 1) != 0 )
goto LABEL_40;
goto LABEL_21;
}
}
else
{
v16 = 1;
v9 = v17;
if ( !(unsigned __int8)GameObject::canChangeSecondaryColor(v17) )
goto LABEL_20;
}
}
else
{
v9 = v17;
if ( !(unsigned __int8)GameObject::canChangeSecondaryColor(v17) )
goto LABEL_20;
}
v9 = v17;
SecondaryColor = (int *)GameObject::getSecondaryColor(v17);
v22 = *SecondaryColor;
if ( !*SecondaryColor )
v22 = SecondaryColor[1];
if ( v6 == -2 )
{
v6 = v22;
if ( (v16 & 1) != 0 )
goto LABEL_40;
}
else
{
if ( v6 != v22 )
v16 = 1;
if ( (v16 & 1) != 0 )
goto LABEL_40;
}
LABEL_21:
v18 = v15 <= v25;
v15 += 8LL;
if ( !v18 )
goto LABEL_40;
}
}
if ( *(_DWORD *)(v5 + 1248) == 1 && (*(_BYTE *)(v5 + 1254) || *(_DWORD *)(v5 + 1028) == 1006) )
{
*a4 = v5;
}
else
{
v6 = -1;
v7 = -1;
if ( (unsigned __int8)GameObject::canChangeMainColor(v5) )
{
v8 = (int *)GameObject::getMainColor(*(_QWORD *)(a1 + 1496));
v7 = *v8;
if ( !*v8 )
v7 = v8[1];
}
v9 = *(_QWORD *)(a1 + 1496);
if ( (unsigned __int8)GameObject::canChangeSecondaryColor(v9) )
{
v9 = *(_QWORD *)(a1 + 1496);
v11 = (int *)GameObject::getSecondaryColor(v9);
v6 = *v11;
if ( !*v11 )
v6 = v11[1];
}
LABEL_41:
if ( v7 >= 0 )
{
v9 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(GameManager::sharedState(v9, a2, v10) + 552) + 3272LL) + 320LL);
a2 = (unsigned int)v7;
*v26 = GJEffectManager::getColorAction(v9, (unsigned int)v7);
}
if ( v6 >= 0 )
{
v23 = GameManager::sharedState(v9, a2, v10);
*a3 = GJEffectManager::getColorAction(
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v23 + 552) + 3272LL) + 320LL),
(unsigned int)v6);
}
}
LABEL_45:
result = v26;
if ( !*v26 )
{
result = (_QWORD *)*a3;
if ( *a3 )
{
*v26 = result;
*a3 = 0;
return a3;
}
}
return result;
}