//
// CharacterColorPage::onPlayerColor from 0x140089db0 to 0x14008a091 (737 bytes)
//
// 2 xrefs:
// > CharacterColorPage::createColorMenu @ 0x1400891a2
// > ??> @ 0x1406c6d20
//
// 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=6
void CharacterColorPage::onPlayerColor(CharacterColorPage *a1, cocos2d::CCObject *a2)
{
UnlockType v4; // edi
unsigned int v5; // ebx
GameManager *v6; // rcx
CharacterColorPage *v7; // rcx
CharacterColorDelegate *m_delegate; // rcx
cocos2d::ccColor3B *v9; // rcx
int m_colorMode; // edx
int v11; // edx
_DWORD *v12; // rdi
float v13; // xmm0_4
_DWORD *v14; // rdi
float v15; // xmm0_4
_DWORD *v16; // rdi
float v17; // xmm0_4
struct cocos2d::CCObject *v18; // rbx
cocos2d::CCObject_vtbl *v19; // rdi
struct cocos2d::CCPoint v20; // rax
char v21; // [rsp+40h] [rbp+8h] BYREF
struct cocos2d::CCPoint v22; // [rsp+48h] [rbp+10h] BYREF
struct cocos2d::CCPoint v23; // [rsp+50h] [rbp+18h] BYREF
v4 = (a1->m_colorMode != 0) + 2;
v5 = a2->getTag(a2);
v6 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v22 = (struct cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v6 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::isColorUnlocked(v6, v5, v4) && CharacterColorPage::activeColorForMode(v7, a1->m_colorMode) != v5 )
{
v9 = (cocos2d::ccColor3B *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v22 = (struct cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v9 = (cocos2d::ccColor3B *)qword_1406C2ED8;
}
v9[216].r = 0;
GameManager::colorForIdx(v9, (GameManager *)&v21, v5);
m_colorMode = a1->m_colorMode;
if ( m_colorMode )
{
v11 = m_colorMode - 1;
if ( v11 )
{
if ( v11 == 1 )
{
v12 = (_DWORD *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v22 = (struct cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v12 = (_DWORD *)qword_1406C2ED8;
}
v12[209] = v5;
v13 = (float)((float)rand() / 32767.0) * 1000.0;
v12[208] = (int)v13;
v12[207] = v5 + (int)v13;
}
}
else
{
v14 = (_DWORD *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v22 = (struct cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v14 = (_DWORD *)qword_1406C2ED8;
}
v14[206] = v5;
v15 = (float)((float)rand() / 32767.0) * 1000.0;
v14[205] = (int)v15;
v14[204] = v5 + (int)v15;
}
}
else
{
v16 = (_DWORD *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v22 = (struct cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v16 = (_DWORD *)qword_1406C2ED8;
}
v16[203] = v5;
v17 = (float)((float)rand() / 32767.0) * 1000.0;
v16[202] = (int)v17;
v16[201] = v5 + (int)v17;
}
v18 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, a1->m_colorMode);
v19 = v18->__vftable;
a2->__vftable[2].getTag(a2);
cocos2d::CCNode::convertToWorldSpace(a1->m_buttonMenu, &v22);
v20 = cocos2d::CCNode::convertToNodeSpace(a1->m_mainLayer, &v23);
((void (__fastcall *)(struct cocos2d::CCObject *, struct cocos2d::CCPoint))v19[2].encodeWithCoder)(v18, v20);
CharacterColorPage::updateIconColors(a1);
}
else
{
m_delegate = a1->m_delegate;
if ( m_delegate )
m_delegate->showUnlockPopup(m_delegate, v5, v4);
}
}