//
// CharacterColorPage::updateColorMode from 0xa24820 to 0xa24b9c (892 bytes)
//
// 3 xrefs:
// > CharacterColorPage::onMode @ 0xa24be8
// > CharacterColorPage::init @ 0xa25fa0
// > ??> @ 0x88ba8
//
// 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)
{
cocos2d::CCPoint v2; // x2
cocos2d::CCDictionary *m_colorButtons; // x0
cocos2d::CCDictElement *m_pElements; // x0
cocos2d::CCDictElement *i; // x22
cocos2d::CCObject *m_pObject; // x28
__int64 v8; // x0
int v9; // w20
cocos2d::CCLayer *m_mainLayer; // x24
cocos2d::CCMenu *m_buttonMenu; // x26
__int64 v12; // x0
const cocos2d::CCPoint *v13; // x0
GameManager *v14; // x0
UnlockType v15; // w2
_BOOL4 isColorUnlocked; // w24
__int64 v17; // x28
void (__fastcall *v18)(__int64, cocos2d::CCPoint *); // x2
GameStatsManager *v19; // x0
UnlockType v20; // w2
void (__fastcall *v21)(__int64, cocos2d::CCPoint *); // x2
unsigned int j; // w20
__int64 v23; // x22
ButtonSprite *v24; // x24
void (__fastcall *v25)(__int64, cocos2d::CCPoint *); // x3
__int64 v26; // x0
__int64 v27; // x0
__int64 v28; // x0
__int64 v29; // x0
void (__fastcall *v30)(__int64, cocos2d::CCPoint *); // x2
__int64 v31; // x0
int v32; // [xsp+64h] [xbp+64h]
int v33; // [xsp+68h] [xbp+68h]
int active; // [xsp+6Ch] [xbp+6Ch]
char v35[8]; // [xsp+78h] [xbp+78h] BYREF
cocos2d::CCPoint v36[2]; // [xsp+80h] [xbp+80h] BYREF
v2 = (cocos2d::CCPoint)_stack_chk_guard;
a1->m_colorMode = a2;
v36[1] = v2;
active = CharacterColorPage::activeColorForMode(a1, 0);
v33 = CharacterColorPage::activeColorForMode(a1, 1);
v32 = CharacterColorPage::activeColorForMode(a1, 2);
m_colorButtons = a1->m_colorButtons;
if ( m_colorButtons )
{
m_pElements = m_colorButtons->m_pElements;
if ( m_pElements )
{
for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next )
{
m_pObject = m_pElements->m_pObject;
v8 = ((__int64 (__fastcall *)(cocos2d::CCObject *))m_pObject->__vftable[6].~CCObject_0)(m_pObject);
v9 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v8 + 64LL))(v8);
m_mainLayer = a1->m_mainLayer;
m_buttonMenu = a1->m_buttonMenu;
v12 = ((__int64 (__fastcall *)(cocos2d::CCObject *))m_pObject->__vftable[6].~CCObject_0)(m_pObject);
v13 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v12 + 192LL))(v12);
cocos2d::CCNode::convertToWorldSpace(m_buttonMenu, v13);
cocos2d::CCNode::convertToNodeSpace(m_mainLayer, v36);
if ( active == v9 )
{
v29 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 0);
(*(void (__fastcall **)(__int64, char *))(*(_QWORD *)v29 + 184LL))(v29, v35);
}
if ( v33 == v9 )
{
v28 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 1u);
(*(void (__fastcall **)(__int64, char *))(*(_QWORD *)v28 + 184LL))(v28, v35);
}
if ( v32 == v9 )
{
v27 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 2u);
(*(void (__fastcall **)(__int64, char *))(*(_QWORD *)v27 + 184LL))(v27, v35);
}
v14 = GameManager::sharedState();
if ( a1->m_colorMode )
v15 = Col2;
else
v15 = Col1;
isColorUnlocked = GameManager::isColorUnlocked(v14, v9, v15);
v17 = ((__int64 (__fastcall *)(cocos2d::CCObject *, __int64))m_pObject->__vftable[5].getTag)(m_pObject, 100);
(*(void (__fastcall **)(__int64, bool))(*(_QWORD *)v17 + 328LL))(v17, !isColorUnlocked);
if ( isColorUnlocked
|| ((v19 = GameStatsManager::sharedState(), a1->m_colorMode) ? (v20 = Col2) : (v20 = Col1),
GameStatsManager::getItemUnlockState(v19, v9, v20)) )
{
v18 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v17 + 944LL);
LOWORD(v36[0].x) = -1;
BYTE2(v36[0].x) = -1;
v18(v17, v36);
if ( !i )
break;
}
else
{
v21 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v17 + 944LL);
LOBYTE(v36[0].x) = 0;
*(_WORD *)((char *)&v36[0].x + 1) = 255;
v21(v17, v36);
if ( !i )
break;
}
m_pElements = i;
}
}
}
for ( j = 0; j != 3; ++j )
{
v23 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, j);
v24 = (ButtonSprite *)cocos2d::CCArray::objectAtIndex(a1->m_modeButtons, j);
if ( a1->m_colorMode == j )
{
v30 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v23 + 944LL);
LOWORD(v36[0].x) = -1;
BYTE2(v36[0].x) = -1;
v30(v23, v36);
v31 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v23 + 496LL))(v23);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v31 + 576LL))(v31, v23, 11);
ButtonSprite::updateBGImage(v24, "GJ_button_01.png");
}
else
{
v25 = *(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v23 + 944LL);
memset(v36, 50, 3);
v25(v23, v36);
v26 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v23 + 496LL))(v23);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v26 + 576LL))(v26, v23, 1);
ButtonSprite::updateBGImage(v24, "GJ_button_04.png");
}
}
CharacterColorPage::toggleGlowItems(a1, a1->m_colorMode == 2);
}