//
// CharacterColorPage::updateColorMode from 0x100129d68 to 0x10012a088 (800 bytes)
//
// 2 xrefs:
// > CharacterColorPage::init @ 0x1001295a4
// > CharacterColorPage::onMode @ 0x100129770
//
// 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 __fastcall CharacterColorPage::updateColorMode(CharacterColorPage *a1, int a2)
{
GameManager *v3; // x0
int random; // w20
int seed; // w21
GameManager *v6; // x0
int v7; // w22
int v8; // w23
GameManager *v9; // x0
cocos2d::CCDictionary *m_colorButtons; // x8
cocos2d::CCDictElement *m_pElements; // x24
int v12; // w25
int v13; // w26
int v14; // w27
cocos2d::CCObject *m_pObject; // x21
__int64 v16; // x0
int v17; // w20
cocos2d::CCLayer *m_mainLayer; // x22
cocos2d::CCMenu *m_buttonMenu; // x23
__int64 v20; // x0
const cocos2d::CCPoint *v21; // x0
__int64 v22; // x0
__int64 v23; // x0
__int64 v24; // x0
GameManager *v25; // x0
UnlockType v26; // w2
_BOOL4 isColorUnlocked; // w22
__int64 v28; // x21
GameStatsManager *v29; // x0
UnlockType v30; // w2
__int16 v31; // w8
__int64 v32; // x20
__int64 v33; // x21
ButtonSprite *v34; // x22
__int64 v35; // x23
const char *v36; // x24
__int64 v37; // x0
_BOOL8 v38; // x20
cocos2d::CCPoint v39; // [xsp+0h] [xbp-60h] BYREF
_WORD v40[4]; // [xsp+8h] [xbp-58h] BYREF
a1->m_colorMode = a2;
v3 = GameManager::sharedState();
random = v3->m_playerColor.random;
seed = v3->m_playerColor.seed;
v6 = GameManager::sharedState();
v7 = v6->m_playerColor2.random;
v8 = v6->m_playerColor2.seed;
v9 = GameManager::sharedState();
m_colorButtons = a1->m_colorButtons;
if ( m_colorButtons )
{
m_pElements = m_colorButtons->m_pElements;
if ( m_pElements )
{
v12 = random - seed;
v13 = v7 - v8;
v14 = v9->m_playerGlowColor.random - v9->m_playerGlowColor.seed;
do
{
m_pObject = m_pElements->m_pObject;
m_pElements = (cocos2d::CCDictElement *)m_pElements->hh.next;
v16 = ((__int64 (__fastcall *)(cocos2d::CCObject *))m_pObject->__vftable[6].~CCObject_0)(m_pObject);
v17 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v16 + 64LL))(v16);
m_mainLayer = a1->m_mainLayer;
m_buttonMenu = a1->m_buttonMenu;
v20 = ((__int64 (__fastcall *)(cocos2d::CCObject *))m_pObject->__vftable[6].~CCObject_0)(m_pObject);
v21 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v20 + 192LL))(v20);
cocos2d::CCNode::convertToWorldSpace(m_buttonMenu, v21);
cocos2d::CCNode::convertToNodeSpace(m_mainLayer, &v39);
if ( v17 == v12 )
{
v22 = sub_10024A388(a1->m_cursors, 0);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v22 + 184LL))(v22, v40);
}
if ( v17 == v13 )
{
v23 = sub_10024A388(a1->m_cursors, 1);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v23 + 184LL))(v23, v40);
}
if ( v17 == v14 )
{
v24 = sub_10024A388(a1->m_cursors, 2);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v24 + 184LL))(v24, v40);
}
v25 = GameManager::sharedState();
if ( a1->m_colorMode )
v26 = Col2;
else
v26 = Col1;
isColorUnlocked = GameManager::isColorUnlocked(v25, v17, v26);
v28 = ((__int64 (__fastcall *)(cocos2d::CCObject *, __int64))m_pObject->__vftable[5].getTag)(m_pObject, 100);
(*(void (__fastcall **)(__int64, bool))(*(_QWORD *)v28 + 328LL))(v28, !isColorUnlocked);
if ( isColorUnlocked
|| ((v29 = GameStatsManager::sharedState(), !a1->m_colorMode) ? (v30 = Col1) : (v30 = Col2),
GameStatsManager::getItemUnlockState(v29, v17, v30)) )
{
BYTE2(v39.x) = -1;
v31 = -1;
}
else
{
BYTE2(v39.x) = 0;
v31 = -256;
}
LOWORD(v39.x) = v31;
(*(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v28 + 944LL))(v28, &v39);
}
while ( m_pElements );
}
}
v32 = 0;
do
{
v33 = sub_10024A388(a1->m_cursors, v32);
v34 = (ButtonSprite *)sub_10024A388(a1->m_modeButtons, v32);
if ( (_DWORD)v32 == a1->m_colorMode )
{
LOBYTE(v40[1]) = -1;
v40[0] = -1;
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v33 + 944LL))(v33, v40);
v35 = 11;
v36 = "GJ_button_01.png";
}
else
{
memset(v40, 50, 3);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v33 + 944LL))(v33, v40);
v35 = 1;
v36 = "GJ_button_04.png";
}
v37 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v33 + 496LL))(v33);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v37 + 576LL))(v37, v33, v35);
ButtonSprite::updateBGImage(v34, v36);
v32 = (unsigned int)(v32 + 1);
}
while ( (_DWORD)v32 != 3 );
v38 = a1->m_colorMode == 2;
((void (__fastcall *)(CCMenuItemToggler *, _BOOL8))a1->m_glowToggler->setEnabled)(a1->m_glowToggler, v38);
((void (__fastcall *)(CCMenuItemToggler *, _BOOL8))a1->m_glowToggler->setVisible)(a1->m_glowToggler, v38);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _BOOL8))a1->m_glowLabel->setVisible)(a1->m_glowLabel, v38);
}