//
// CharacterColorPage::updateColorMode from 0x140089840 to 0x140089da7 (1383 bytes)
//
// 4 xrefs:
// > CharacterColorPage::init @ 0x140088c49
// > CharacterColorPage::onMode @ 0x140089817
// > ??> @ 0x1406c6d08
// > ??> @ 0x1406c6d14
//
// 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=11
void CharacterColorPage::updateColorMode(CharacterColorPage *a1, int a2)
{
_DWORD *v3; // rax
int v4; // ebx
int v5; // r13d
int v6; // r12d
cocos2d::CCDictionary *m_colorButtons; // rax
cocos2d::CCDictElement *m_pElements; // rax
cocos2d::CCDictElement *next; // rsi
cocos2d::CCObject *m_pObject; // r15
__int64 v11; // rax
int v12; // r14d
__int64 v13; // rax
struct cocos2d::CCObject *v14; // rax
struct cocos2d::CCObject *v15; // rax
struct cocos2d::CCObject *v16; // rax
GameManager *v17; // rcx
bool isColorUnlocked; // bl
void (__fastcall ***v19)(_QWORD, _QWORD); // r15
GameStatsManager *v20; // rcx
__int16 *v21; // rdx
struct cocos2d::CCObject *v22; // rbx
ButtonSprite *v23; // rsi
void (__fastcall *v24)(int *, void **); // r9
const char *v25; // r14
int *p_m_unknown2; // rcx
__int64 v27; // rax
const char *v28; // rdx
__int64 v29; // rax
struct cocos2d::CCObject *v30; // rbx
ButtonSprite *v31; // rsi
int *v32; // rcx
void (__fastcall *v33)(int *, __int16 *); // r8
__int64 v34; // rax
const char *v35; // rdx
__int64 v36; // rax
struct cocos2d::CCObject *v37; // rbx
ButtonSprite *v38; // rsi
int *v39; // rcx
void (__fastcall *v40)(int *, __int16 *); // r9
__int64 v41; // rax
__int64 v42; // rax
bool v43; // bl
int v44; // [rsp+20h] [rbp-38h]
struct cocos2d::CCPoint v45; // [rsp+28h] [rbp-30h] BYREF
struct cocos2d::CCPoint v46; // [rsp+30h] [rbp-28h] BYREF
void *v47; // [rsp+38h] [rbp-20h]
void *v48; // [rsp+40h] [rbp-18h]
void *v49; // [rsp+A0h] [rbp+48h] BYREF
__int16 v50; // [rsp+A8h] [rbp+50h]
__int16 v51; // [rsp+B0h] [rbp+58h]
__int16 v52; // [rsp+B8h] [rbp+60h] BYREF
char v53; // [rsp+BAh] [rbp+62h]
a1->m_colorMode = a2;
v3 = (_DWORD *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v49 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v49);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v3 = (_DWORD *)qword_1406C2ED8;
}
v4 = v3[201] - v3[202];
v44 = v4;
v5 = v3[204] - v3[205];
v6 = v3[207] - v3[208];
m_colorButtons = a1->m_colorButtons;
if ( m_colorButtons )
{
m_pElements = m_colorButtons->m_pElements;
if ( m_pElements )
{
next = (cocos2d::CCDictElement *)m_pElements->hh.next;
while ( 1 )
{
m_pObject = m_pElements->m_pObject;
v11 = ((__int64 (__fastcall *)(cocos2d::CCObject *))m_pObject->__vftable[6].getTag)(m_pObject);
v12 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v11 + 56LL))(v11);
v13 = ((__int64 (__fastcall *)(cocos2d::CCObject *))m_pObject->__vftable[6].getTag)(m_pObject);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v13 + 200LL))(v13);
cocos2d::CCNode::convertToWorldSpace(a1->m_buttonMenu, &v46);
cocos2d::CCNode::convertToNodeSpace(a1->m_mainLayer, &v45);
if ( v12 == v4 )
{
v14 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 0);
v14->__vftable[2].encodeWithCoder(v14, (DS_Dictionary *)&v45);
}
if ( v12 == v5 )
{
v15 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 1u);
v15->__vftable[2].encodeWithCoder(v15, (DS_Dictionary *)&v45);
}
if ( v12 == v6 )
{
v16 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 2u);
v16->__vftable[2].encodeWithCoder(v16, (DS_Dictionary *)&v45);
}
v17 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v47 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v47);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v17 = (GameManager *)qword_1406C2ED8;
}
isColorUnlocked = GameManager::isColorUnlocked(v17, v12, (UnlockType)((a1->m_colorMode != 0) + 2));
v19 = (void (__fastcall ***)(_QWORD, _QWORD))((__int64 (__fastcall *)(cocos2d::CCObject *, __int64))m_pObject->__vftable[6].acceptVisitor)(
m_pObject,
100);
((void (__fastcall **)(_QWORD, bool))*v19)[40](v19, !isColorUnlocked);
if ( isColorUnlocked )
goto LABEL_19;
v20 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v48 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0(v48);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v20 = (GameStatsManager *)qword_1406C2EE8;
}
if ( GameStatsManager::getItemUnlockState(v20, v12, (UnlockType)((a1->m_colorMode != 0) + 2)) )
{
LABEL_19:
v51 = -1;
v52 = -1;
v53 = -1;
v21 = &v52;
}
else
{
v50 = -256;
LOWORD(v49) = -256;
BYTE2(v49) = 0;
v21 = (__int16 *)&v49;
}
(*v19[40])(v19 + 40, v21);
m_pElements = next;
if ( !next )
break;
next = (cocos2d::CCDictElement *)next->hh.next;
v4 = v44;
}
}
}
v22 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 0);
v23 = (ButtonSprite *)cocos2d::CCArray::objectAtIndex(a1->m_modeButtons, 0);
v24 = **(void (__fastcall ***)(int *, void **))&v22[5].m_unknown2;
v25 = "GJ_button_04.png";
p_m_unknown2 = &v22[5].m_unknown2;
if ( a1->m_colorMode )
{
v50 = 12850;
memset(&v49, 50, 3);
v24(p_m_unknown2, &v49);
v27 = ((__int64 (__fastcall *)(struct cocos2d::CCObject *))v22->__vftable[6].getTag)(v22);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v27 + 568LL))(v27, v22, 1);
v28 = "GJ_button_04.png";
}
else
{
v51 = -1;
v52 = -1;
v53 = -1;
v24(p_m_unknown2, (void **)&v52);
v29 = ((__int64 (__fastcall *)(struct cocos2d::CCObject *))v22->__vftable[6].getTag)(v22);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v29 + 568LL))(v29, v22, 11);
v28 = "GJ_button_01.png";
}
ButtonSprite::updateBGImage(v23, v28);
v30 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 1u);
v31 = (ButtonSprite *)cocos2d::CCArray::objectAtIndex(a1->m_modeButtons, 1u);
v32 = &v30[5].m_unknown2;
v33 = **(void (__fastcall ***)(int *, __int16 *))&v30[5].m_unknown2;
if ( a1->m_colorMode == 1 )
{
v51 = -1;
v52 = -1;
v53 = -1;
v33(v32, &v52);
v36 = ((__int64 (__fastcall *)(struct cocos2d::CCObject *))v30->__vftable[6].getTag)(v30);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v36 + 568LL))(v36, v30, 11);
v35 = "GJ_button_01.png";
}
else
{
v50 = 12850;
memset(&v49, 50, 3);
v33(v32, (__int16 *)&v49);
v34 = ((__int64 (__fastcall *)(struct cocos2d::CCObject *))v30->__vftable[6].getTag)(v30);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v34 + 568LL))(v34, v30, 1);
v35 = "GJ_button_04.png";
}
ButtonSprite::updateBGImage(v31, v35);
v37 = cocos2d::CCArray::objectAtIndex(a1->m_cursors, 2u);
v38 = (ButtonSprite *)cocos2d::CCArray::objectAtIndex(a1->m_modeButtons, 2u);
v39 = &v37[5].m_unknown2;
v40 = **(void (__fastcall ***)(int *, __int16 *))&v37[5].m_unknown2;
if ( a1->m_colorMode == 2 )
{
v51 = -1;
v52 = -1;
v53 = -1;
v40(v39, &v52);
v42 = ((__int64 (__fastcall *)(struct cocos2d::CCObject *))v37->__vftable[6].getTag)(v37);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v42 + 568LL))(v42, v37, 11);
v25 = "GJ_button_01.png";
}
else
{
v50 = 12850;
memset(&v49, 50, 3);
v40(v39, (__int16 *)&v49);
v41 = ((__int64 (__fastcall *)(struct cocos2d::CCObject *))v37->__vftable[6].getTag)(v37);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v41 + 568LL))(v41, v37, 1);
}
ButtonSprite::updateBGImage(v38, v25);
v43 = a1->m_colorMode == 2;
a1->m_glowToggler->setEnabled(a1->m_glowToggler, v43);
a1->m_glowToggler->setVisible(a1->m_glowToggler, v43);
a1->m_glowLabel->setVisible(a1->m_glowLabel, v43);
}