//
// GJColorSetupLayer::init from 0x8a1c08 to 0x8a22d8 (1744 bytes)
//
// 2 xrefs:
// > GJColorSetupLayer::create @ 0x8a23f0
// > ??> @ 0x9dc50
//
// 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
//
bool GJColorSetupLayer::init(GJColorSetupLayer *a1, LevelSettingsObject *a2)
{
cocos2d::CCDirector *v5; // x0
cocos2d::CCNode *v6; // x21
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x22
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
cocos2d::CCDictionary *v9; // x0
cocos2d::CCDictionary *v10; // x0
cocos2d::CCArray *v11; // x0
cocos2d::CCArray *v12; // x0
cocos2d::CCArray *v13; // x0
cocos2d::CCArray *v14; // x0
cocos2d::CCMenu *v15; // x0
cocos2d::CCLabelBMFont *v16; // x21
void (__fastcall *v17)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
float v18; // s0
int v19; // w21
cocos2d::CCLabelBMFont *v20; // x26
ColorChannelSprite *v21; // x25
CCMenuItemSpriteExtra *v22; // x25
cocos2d::CCMenu *m_buttonMenu; // x28
void (__fastcall *v24)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
__int64 v25; // x26
__int64 v26; // x1
cocos2d::CCMenu *v27; // x24
cocos2d::CCSprite *v28; // x25
CCMenuItemSpriteExtra *v29; // x0
CCMenuItemSpriteExtra *m_prevButton; // x25
void (__fastcall *v31)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
cocos2d::CCSprite *v32; // x24
CCMenuItemSpriteExtra *v33; // x0
CCMenuItemSpriteExtra *m_nextButton; // x21
void (__fastcall *v35)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
const char *v36; // x6
cocos2d::CCNode *v37; // x0
CCMenuItemSpriteExtra *v38; // x21
cocos2d::CCMenu *v39; // x24
void (__fastcall *v40)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
int m_colorPage; // w1
char v42; // [xsp+8Fh] [xbp+8Fh]
float v43; // [xsp+B0h] [xbp+B0h]
float v44; // [xsp+B4h] [xbp+B4h]
cocos2d::CCPoint v45; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v46; // [xsp+C0h] [xbp+C0h] BYREF
_BYTE v47[8]; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCPoint v48; // [xsp+D0h] [xbp+D0h] BYREF
cocos2d::CCRect v49; // [xsp+D8h] [xbp+D8h] BYREF
cocos2d::CCPoint v50; // 0:kr08_8.8
cocos2d::CCPoint v51; // 0:kr18_8.8
cocos2d::SEL_MenuHandler v52; // 0:x2.16
cocos2d::SEL_MenuHandler v53; // 0:x2.16
cocos2d::SEL_MenuHandler v54; // 0:x2.16
cocos2d::SEL_MenuHandler v55; // 0:x2.16
cocos2d::CCRect v56; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v42 = FLAlertLayer::init(a1, 0x96u);
if ( v42 )
{
a1->m_settingsObject = a2;
a1->m_noElasticity = 1;
cocos2d::CCObject::retain(a2);
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v5);
cocos2d::CCRect::CCRect(&v49, 0.0, 0.0, 80.0, 80.0);
v6 = (cocos2d::CCNode *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)"GJ_square01.png",
(const char *)&v49,
v56);
((void (__fastcall *)(cocos2d::CCNode *, __int64))v6->__vftable[1].~CCNode_0)(v6, 0xFFFFFFFFLL);
setContentSize = v6->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v49, 450.0, 300.0);
setContentSize(v6, (const cocos2d::CCSize *)&v49);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v6, -2);
setPosition = v6->setPosition;
cocos2d::CCPoint::CCPoint(&v49.origin, v43 * 0.5, v44 * 0.5);
setPosition(v6, &v49.origin);
v9 = cocos2d::CCDictionary::create();
a1->m_unk290 = v9;
cocos2d::CCObject::retain(v9);
v10 = cocos2d::CCDictionary::create();
a1->m_unk298 = v10;
cocos2d::CCObject::retain(v10);
v12 = (cocos2d::CCArray *)cocos2d::CCArray::create(v11);
a1->m_colorLabels = v12;
cocos2d::CCObject::retain(v12);
v14 = (cocos2d::CCArray *)cocos2d::CCArray::create(v13);
a1->m_colorSprites = v14;
cocos2d::CCObject::retain(v14);
a1->m_colorsPerPage = 24;
a1->m_totalPages = (unsigned int)&qword_28 + 2;
v15 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v15;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v15, 10);
v16 = cocos2d::CCLabelBMFont::create();
v16->setScale(v16, 0.8);
a1->m_mainLayer->addChild(a1->m_mainLayer, v16);
v17 = v16->setPosition;
cocos2d::CCPoint::CCPoint(&v49.origin, v43 * 0.5, (float)(v44 * 0.5) + 130.0);
v17(v16, &v49.origin);
v18 = (float)(v43 * 0.5) - 132.5;
cocos2d::CCPoint::CCPoint(&v45, v18, (float)(v44 * 0.5) + 100.0);
if ( a1->m_colorsPerPage > 0 )
{
v19 = 1;
do
{
v20 = cocos2d::CCLabelBMFont::create();
v20->setScale(v20, 0.3);
a1->m_mainLayer->addChild(a1->m_mainLayer, v20);
cocos2d::CCArray::addObject(a1->m_colorLabels, v20);
cocos2d::CCPoint::CCPoint(
&v49.origin,
(float)((v19 - 1) % 6) * 53.0,
(float)-vcvtms_s32_f32((float)((v19 - 1) / 6)) * 53.0);
cocos2d::CCPoint::operator+(&v46, &v45, &v49);
v20->setPosition(v20, (const cocos2d::CCPoint *)&v46);
v21 = ColorChannelSprite::create();
v21->setScale(v21, 0.8);
v21->setColor(v21, (const cocos2d::ccColor3B *)&off_EEDD70);
cocos2d::CCArray::addObject(a1->m_colorSprites, v21);
v52.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v52.adj = (size_t)GJColorSetupLayer::onColor;
v22 = CCMenuItemSpriteExtra::create(v21, nullptr, v52);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v22);
m_buttonMenu = a1->m_buttonMenu;
v24 = v22->setPosition;
v25 = (__int64)v20->getPosition(v20);
cocos2d::CCPoint::CCPoint(&v49.origin, 0.0, -22.0);
cocos2d::CCPoint::operator+(&v48, v25, &v49);
v50 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, &v48);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _BYTE *, float, float))v24)(v22, v47, v50.x, v50.y);
v26 = (unsigned int)v19++;
v22->setTag(v22, v26);
}
while ( v19 <= a1->m_colorsPerPage );
}
GJColorSetupLayer::updateSpriteColors(a1);
v27 = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v49.origin, v43 * 0.5, v44 * 0.5);
cocos2d::CCNode::convertToNodeSpace(v27, &v49.origin);
v28 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v28->setScale(v28, 1.0);
v53.adj = (size_t)GJColorSetupLayer::onPage;
v53.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v29 = CCMenuItemSpriteExtra::create(v28, nullptr, v53);
a1->m_prevButton = v29;
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v29);
m_prevButton = a1->m_prevButton;
v31 = m_prevButton->setPosition;
cocos2d::CCPoint::CCPoint(&v49.origin, -190.0, 0.0);
cocos2d::CCPoint::operator+(&v48, v47, &v49);
v31(m_prevButton, &v48);
CCMenuItemSpriteExtra::setSizeMult(a1->m_prevButton, 2.0);
a1->m_prevButton->setTag(a1->m_prevButton, 1);
v32 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v32->setScale(v32, 1.0);
cocos2d::CCSprite::setFlipX(v32, 1);
v54.adj = (size_t)GJColorSetupLayer::onPage;
v54.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v33 = CCMenuItemSpriteExtra::create(v32, nullptr, v54);
a1->m_nextButton = v33;
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v33);
m_nextButton = a1->m_nextButton;
v35 = m_nextButton->setPosition;
cocos2d::CCPoint::CCPoint(&v49.origin, 190.0, 0.0);
cocos2d::CCPoint::operator+(&v48, v47, &v49);
v35(m_nextButton, &v48);
CCMenuItemSpriteExtra::setSizeMult(a1->m_nextButton, 2.0);
a1->m_nextButton->setTag(a1->m_nextButton, 0);
v37 = (cocos2d::CCNode *)ButtonSprite::create(
(ButtonSprite *)"OK",
(const char *)&qword_28,
0,
1,
0.8,
"goldFont.fnt",
"GJ_button_01.png",
v36,
30.0);
v55.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v55.adj = (size_t)GJColorSetupLayer::onClose;
v38 = CCMenuItemSpriteExtra::create(v37, nullptr, v55);
a1->m_buttonMenu->addChild(a1->m_buttonMenu, v38);
v39 = a1->m_buttonMenu;
v40 = v38->setPosition;
cocos2d::CCPoint::CCPoint(&v49.origin, v43 * 0.5, (float)(v44 * 0.5) + -126.0);
v51 = cocos2d::CCNode::convertToNodeSpace(v39, &v49.origin);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))v40)(v38, &v48, v51.x, v51.y);
m_colorPage = a1->m_settingsObject->m_colorPage;
a1->m_page = m_colorPage;
GJColorSetupLayer::showPage(a1, m_colorPage);
}
return v42;
}