//
// CharacterColorPage::updateColorMode from 0x564d44 to 0x564f80 (572 bytes)
//
// 2 xrefs:
// > CharacterColorPage::onMode @ 0x564fbe
// > CharacterColorPage::init @ 0x565df6
//
// 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 CharacterColorPage::updateColorMode(CharacterColorPage *a1, int a2)
{
int v3; // r0
cocos2d::CCDictionary *m_colorButtons; // r3
int v5; // r11
unsigned int i; // r6
cocos2d::CCDictElement *m_pElements; // r3
cocos2d::CCDictElement *next; // r5
cocos2d::CCObject *m_pObject; // r6
int v10; // r0
int v11; // r0
cocos2d::CCLayer *m_mainLayer; // r10
int v13; // r7
int v14; // r0
const cocos2d::CCPoint *v15; // r0
int v16; // r0
int v17; // r0
int v18; // r0
GameManager *v19; // r0
UnlockType v20; // r2
_BOOL4 isColorUnlocked; // r10
int v22; // r6
GameStatsManager *v23; // r0
UnlockType v24; // r2
int v25; // r0
ButtonSprite *v26; // r0
const char *v27; // r1
int v28; // r5
ButtonSprite *v29; // r0
void (__fastcall *v30)(int, cocos2d::CCPoint *); // r2
ButtonSprite *v31; // r8
int v32; // r0
void (__fastcall *v33)(int, cocos2d::CCPoint *); // r2
cocos2d::CCDictElement *v34; // r2
void (__fastcall *v35)(int, cocos2d::CCPoint *); // r3
int active; // [sp+0h] [bp-2Ch]
int v37; // [sp+4h] [bp-28h]
cocos2d::CCMenu *m_buttonMenu; // [sp+Ch] [bp-20h]
cocos2d::CCPoint v39; // [sp+14h] [bp-18h] BYREF
cocos2d::CCPoint v40; // [sp+1Ch] [bp-10h] BYREF
a1->m_colorMode = a2;
active = CharacterColorPage::activeColorForMode(a1, 0);
v37 = CharacterColorPage::activeColorForMode(a1, 1);
v3 = CharacterColorPage::activeColorForMode(a1, 2);
m_colorButtons = a1->m_colorButtons;
v5 = v3;
if ( m_colorButtons )
{
m_pElements = m_colorButtons->m_pElements;
if ( m_pElements )
next = (cocos2d::CCDictElement *)m_pElements->hh.next;
else
next = nullptr;
while ( m_pElements )
{
m_pObject = m_pElements->m_pObject;
v10 = ((int (__fastcall *)(cocos2d::CCObject *))m_pObject->__vftable[6].~CCObject_0)(m_pObject);
v11 = (*(int (__fastcall **)(int))(*(_DWORD *)v10 + 32))(v10);
m_mainLayer = a1->m_mainLayer;
m_buttonMenu = a1->m_buttonMenu;
v13 = v11;
v14 = ((int (__fastcall *)(cocos2d::CCObject *))m_pObject->__vftable[6].~CCObject_0)(m_pObject);
v15 = (const cocos2d::CCPoint *)(*(int (__fastcall **)(int))(*(_DWORD *)v14 + 96))(v14);
cocos2d::CCNode::convertToWorldSpace(&v40, m_buttonMenu, v15);
cocos2d::CCNode::convertToNodeSpace(&v39, m_mainLayer, &v40);
if ( v13 == active )
{
v16 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 0);
(*(void (__fastcall **)(int, cocos2d::CCPoint *))(*(_DWORD *)v16 + 92))(v16, &v39);
}
if ( v13 == v37 )
{
v17 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 1u);
(*(void (__fastcall **)(int, cocos2d::CCPoint *))(*(_DWORD *)v17 + 92))(v17, &v39);
}
if ( v13 == v5 )
{
v18 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 2u);
(*(void (__fastcall **)(int, cocos2d::CCPoint *))(*(_DWORD *)v18 + 92))(v18, &v39);
}
v19 = GameManager::sharedState();
if ( a1->m_colorMode )
v20 = Col2;
else
v20 = Col1;
isColorUnlocked = GameManager::isColorUnlocked(v19, v13, v20);
v22 = ((int (__fastcall *)(cocos2d::CCObject *, int))m_pObject->__vftable[5].getTag)(m_pObject, 100);
(*(void (__fastcall **)(int, bool))(*(_DWORD *)v22 + 164))(v22, !isColorUnlocked);
if ( isColorUnlocked
|| ((v23 = GameStatsManager::sharedState(), a1->m_colorMode) ? (v24 = Col2) : (v24 = Col1),
GameStatsManager::getItemUnlockState(v23, v13, v24)) )
{
v33 = *(void (__fastcall **)(int, cocos2d::CCPoint *))(*(_DWORD *)v22 + 472);
LOWORD(v40.x) = -1;
BYTE2(v40.x) = -1;
v33(v22, &v40);
}
else
{
v35 = *(void (__fastcall **)(int, cocos2d::CCPoint *))(*(_DWORD *)v22 + 472);
LOBYTE(v40.x) = 0;
*(_WORD *)((char *)&v40.x + 1) = 255;
v35(v22, &v40);
}
if ( next )
v34 = (cocos2d::CCDictElement *)next->hh.next;
else
v34 = nullptr;
m_pElements = next;
next = v34;
}
}
for ( i = 0; i != 3; ++i )
{
v28 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, i);
v29 = (ButtonSprite *)cocos2d::CCArray::objectAtIndex(a1->m_modeButtons, i);
v30 = *(void (__fastcall **)(int, cocos2d::CCPoint *))(*(_DWORD *)v28 + 472);
v31 = v29;
if ( i == a1->m_colorMode )
{
LOWORD(v40.x) = -1;
BYTE2(v40.x) = -1;
v30(v28, &v40);
v25 = (*(int (__fastcall **)(int))(*(_DWORD *)v28 + 248))(v28);
(*(void (__fastcall **)(int, int, int))(*(_DWORD *)v25 + 288))(v25, v28, 11);
v26 = v31;
v27 = "GJ_button_01.png";
}
else
{
memset(&v40, 50, 3);
v30(v28, &v40);
v32 = (*(int (__fastcall **)(int))(*(_DWORD *)v28 + 248))(v28);
(*(void (__fastcall **)(int, int, int))(*(_DWORD *)v32 + 288))(v32, v28, 1);
v26 = v31;
v27 = "GJ_button_04.png";
}
ButtonSprite::updateBGImage(v26, v27);
}
CharacterColorPage::toggleGlowItems(a1, a1->m_colorMode == 2);
}